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

cdb(front): Fetch left sidebar links #6953

Merged

Conversation

orfeas-k
Copy link
Contributor

This PR is part of the Rewrite the Central Dashboard in Angular effort and implements the following two functionalities:

  • Fetch the left sidebar links

Here, we also had to handle the until now unhandled fragment/hash in links. For that, we decided to always split links to its sub-parts (path, queryParams, fragment) and use the fragment option in router.navigate.

  • Automatically change selected link from the sidebar

We couldn't go only with routerLinkActive for this and used a custom implementation instead since we need the path + fragment combination to be a subset of the browser's URL. In this implementation, we also added an explicit condition for checking when the user is in Recurring Runs WA since the KFP removes the 's' from its path when navigating inside a Recurring Run's details page ( /_/pipeline/#/recurringruns in contrast to /_/pipeline/#/recurringrun/details/).

Copy link
Contributor

@tasos-ale tasos-ale left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @orfeas-k. Please take a look at my comments.

) {}

ngOnInit() {
this.envInfoSub = this.backend.getEnvInfo().subscribe((res: envInfo) => {
this.handleEnvInfo(res);
});

this.dashboardLinksSub = this.backend
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need the dashboardLinksSub since we are not polling.

Comment on lines 113 to 123
/**
* We need this condition because Pipelines Web App removes
* the 's' from its path when navigating inside a Recurring
* Run's details page
*/
if (
browserUrl.includes('pipeline/#/recurringrun') &&
url.includes('/pipeline/#/recurringruns')
) {
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It is ok for now, but we may need to do something better here. I would prefer not to have hardcoded values. Maybe we can have pipeline/#/recurringrun inside menuLinks and compare it with startsWith().

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at this again I don't think we should have specific code for pipelines or any other app. We could tackle this problem with another solution, but for now, let's remove this if statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ACK I agree that this is not something we should tackle in the Dashboard's logic and having ifs for different WAs isn't a good practice.
cc @kimwnasptd for awareness

return true;
}

return browserUrl.includes(url);
Copy link
Contributor

Choose a reason for hiding this comment

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

It works, but it will be safer to use startsWith() in case we end up with a url inside the browserUrl that we don't want to match

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I removed the prefix from browser's URL and changed that to startsWith().

const urlParams = urlObject.search;
/**
* We need an empty string as a default value because in case
* of undefined strings, Typescript will go ahead and append the
Copy link
Contributor

Choose a reason for hiding this comment

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

Blame JavaScript not TypeScript for this 😃

Comment on lines 40 to 41
public externalLinks: any[];
public quickLinks: quickLink[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we don't render externalLinks and quickLinks anywhere? If we will have them in a following PR, fine by me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the old dashboard, quickLinks and documentationItems are part of the Home page and this page will be a separate effort/PR. @kimwnasptd What about externalLinks?

Copy link
Contributor

Choose a reason for hiding this comment

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

@orfeas-k There is no need to wait. If we want the externalLinks we can add them in the next PR.

Comment on lines 15 to 19
export interface quickLink {
text: string;
desc: string;
link: string;
}

export interface documentationItem {
text: string;
desc: string;
link: string;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can use the same type here. I don't see a need for two different interfaces.

 - Fetch left sidebar links from 'api/dashboard-links' endpoint
 - Handle links with fragment/hash in Router navigation and URLs
   comparison/syncing

Signed-off-by: Orfeas Kourkakis <orfeas@arrikto.com>
Signed-off-by: Orfeas Kourkakis <orfeas@arrikto.com>
Update UI tests to mock requests at 'api/workgroup/env-info' and
'/api/dashboard-links'.

Signed-off-by: Orfeas Kourkakis <orfeas@arrikto.com>
@orfeas-k orfeas-k force-pushed the feature-orfeas-cdb-left-sidebar-links branch from c93bab8 to 4b9f50e Compare February 28, 2023 16:05
@tasos-ale
Copy link
Contributor

/lgtm
/approve

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tasos-ale

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

@google-oss-prow google-oss-prow bot merged commit 6e8e2a6 into kubeflow:master Feb 28, 2023
@tasos-ale tasos-ale deleted the feature-orfeas-cdb-left-sidebar-links branch February 28, 2023 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants