Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Central Dashboard - Add statefulness to generated links #2913

Merged
merged 4 commits into from
Apr 4, 2019

Conversation

prodonjs
Copy link
Contributor

@prodonjs prodonjs commented Apr 2, 2019

Ensures that all links on the Central Dashboard are namespace-aware in order to preserve state and allow it to be passed down to child components.

/area front-end
/area centraldashboard
/assign @avdaredevil


This change is Reviewable

@prodonjs
Copy link
Contributor Author

prodonjs commented Apr 2, 2019

addresses #2845

Copy link
Contributor

@avdaredevil avdaredevil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments. Can we also have:

  • The change that defaults the namespace to the first namespace that comes back from the API
  • The generated route, just be a relative path, not an absolute one

*/
_buildHref(href) {
const current = new URL(window.location.href);
const url = new URL(href, window.location.origin);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this, isn't that implicit?

Suggested change
const url = new URL(href, window.location.origin);
const url = new URL(href);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to MDN, If url is a relative URL, base is required, and will be used as the base URL. If url is an absolute URL, a given base will be ignored. If we were getting the href from the anchor element's href property it would already be absolute, but since we are passing in a relative string we need to provide the base. The suggested change failed when I tried it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, perhaps I misunderstood what this was doing. Thanks for following through!

const url = new URL(e.currentTarget.href);
window.history.pushState({}, null, `_${url.pathname}`);
// e.currentTarget is an anchor element
const url = e.currentTarget.href.substr(e.currentTarget.origin.length);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think slice is the recommended js-onic way of substringing:

Suggested change
const url = e.currentTarget.href.substr(e.currentTarget.origin.length);
const url = e.currentTarget.href.slice(e.currentTarget.origin.length);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

paper-tab(page='activity', link)
a.link(tabindex='-1', href='/activity') Activity
aside#NamespaceSelector(hidden$='[[!equals(page, "activity")]]')
a.link(tabindex='-1', href$='[[_buildHref("/activity")]]') Activity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't these be static links?? All the _buildHref?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that depends. I was thinking that namespace would behave similar to how projectId behaves in the GCP console. It's propagated along with every link even if the page being displayed doesn't use it to change its behavior.

@prodonjs prodonjs changed the title [WIP] Central Dashboard - Add statefulness to generated links Central Dashboard - Add statefulness to generated links Apr 3, 2019
@prodonjs
Copy link
Contributor Author

prodonjs commented Apr 3, 2019

/remove do-not-merge/work-in-progress

@prodonjs
Copy link
Contributor Author

prodonjs commented Apr 3, 2019

@avdaredevil PTAL when you have the chance. I think this addresses things correctly. If we find that other pages are often introducing links that need to be namespace aware, we should consider moving this to a mixin along with some of the other utility methods you created.

@avdaredevil
Copy link
Contributor

I agree I can make a PR next week to refactor a few of these changes.
/hold cancel
/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: avdaredevil

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 48edfe4 into kubeflow:master Apr 4, 2019
@prodonjs prodonjs deleted the link-statefulness branch May 3, 2019 13:31
saffaalvi pushed a commit to StatCan/kubeflow that referenced this pull request Feb 11, 2021
* Add statefulness to generated links

* Ensure that _buildHref uses a computed dependency when queryParams changes

* Final implementation including tests

* Add logic to hide namespace selector only when viewing Pipelines
saffaalvi pushed a commit to StatCan/kubeflow that referenced this pull request Feb 12, 2021
* Add statefulness to generated links

* Ensure that _buildHref uses a computed dependency when queryParams changes

* Final implementation including tests

* Add logic to hide namespace selector only when viewing Pipelines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/centraldashboard UI/UX improvements for Kubeflow central dashboard / landing page area/front-end cla: yes lgtm size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants