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

Fix: navigating to extension page #1361

Closed
wants to merge 4 commits into from
Closed

Fix: navigating to extension page #1361

wants to merge 4 commits into from

Conversation

ixrock
Copy link
Contributor

@ixrock ixrock commented Nov 12, 2020

Proper handling extension page base route.

Fixes:

  • extension page route matches to actual extension name, e.g. /extension/lens-hello-world
  • extension name updated in accordance to be supported in URL (@ removed, / => -)

Signed-off-by: Roman ixrock@gmail.com

Signed-off-by: Roman <ixrock@gmail.com>
@ixrock ixrock added bug Something isn't working area/extension Something to related to the extension api labels Nov 12, 2020
@ixrock ixrock requested a review from a team November 12, 2020 20:54
Signed-off-by: Roman <ixrock@gmail.com>
@@ -45,11 +45,12 @@ export class LensExtension {
}

getPageUrl(baseUrl = "") {
return compile(this.routePrefix)({ name: this.name }) + baseUrl;
const validUrlName = this.name.replace("@", "").replace("/", "-");
Copy link
Contributor

@jim-docker jim-docker Nov 12, 2020

Choose a reason for hiding this comment

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

Is there a uniqueness requirement for the name? This would have to be part of that because @foo would clash with one already named foo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't clash since when package name with @ the format is @org/package-name, not just @some-name

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 we should be OK because I don't think @fred is a valid package name on NPM (and hopefully not on other registries like GH). You'd have to have a package name too, like @fred/fred, which would become fred-fred here, and wouldn't conflict with a package published as just fred (without a scope).

Copy link
Contributor

Choose a reason for hiding this comment

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

I can see it is unlikely but it's theoretically possible to have mirantis-foo and @mirantis/foo

Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference now between getPageUrl and getPageRoute? To me they look identical 🤔

Copy link
Contributor Author

@ixrock ixrock Nov 13, 2020

Choose a reason for hiding this comment

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

They are the same when no additional (suffix) route provided for the page:

export class PageRegistry<T extends PageRegistration> extends BaseRegistry<T> {
  getItems() {
    return super.getItems().map(item => {
      item.routePath = item.extension.getPageRoute(item.routePath)
      return item
    });
  }
}

Copy link
Contributor Author

@ixrock ixrock Nov 13, 2020

Choose a reason for hiding this comment

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

This is baseRoute of page-item, not baseRoute of extension.

Copy link
Contributor

Choose a reason for hiding this comment

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

to me it looks like this.getPageUrl('foo') returns the same as this.getPageRoute('foo')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, now I see what you mean.. Both functions are similar but for different purposes..
Will refactor..

Copy link
Contributor Author

@ixrock ixrock Nov 13, 2020

Choose a reason for hiding this comment

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

@jakolehm PTAL, also fixed proper sub-pages route-paths and sub-menus urls.

Copy link
Contributor

@jim-docker jim-docker left a comment

Choose a reason for hiding this comment

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

tried it out with lens-extension-cc repo, LGTM

@stefcameron
Copy link
Contributor

tried it out with lens-extension-cc repo, LGTM

Thanks for doing that, @jim-docker ! Glad to know it will work. 😄

Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
@ixrock
Copy link
Contributor Author

ixrock commented Nov 13, 2020

Closing in favour #1364

@ixrock ixrock closed this Nov 13, 2020
@ixrock ixrock deleted the page_navigation_fix branch November 13, 2020 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/extension Something to related to the extension api bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants