-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
PageRegistration & BaseRegistry refactoring #1334
Conversation
Signed-off-by: Roman <ixrock@gmail.com>
…_1258 # Conflicts: # src/extensions/lens-renderer-extension.ts
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
package.json
Outdated
@@ -241,6 +241,7 @@ | |||
"openid-client": "^3.15.2", | |||
"path-to-regexp": "^6.1.0", | |||
"proper-lockfile": "^4.1.1", | |||
"react-router": "^5.2.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is moved to normal dependencies since required in runtime (matchPath
is used in page-registry.ts
and page-menu-registry.ts
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
react
apparently also required internally in react-router
when used in runtime
Signed-off-by: Roman <ixrock@gmail.com>
db77f8e
to
e671d07
Compare
extensions/support-page/main.ts
Outdated
click() { | ||
windowManager.navigate(supportPageURL()); | ||
click: () => { | ||
windowManager.navigate(this.getPageUrl(pageUrl)); // todo: simplify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you see my comment here? Maybe this is similar to what you are already planning...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Page registration doesn't have ID
- Registered page exists only in
LensRendererExtension
but access to URL might need fromLensMainExtension
as well (like from top-menu support item) - If even this possible should be done in another PR
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
extensions/support-page/renderer.tsx
Outdated
@@ -20,9 +18,9 @@ export default class SupportPageRendererExtension extends LensRendererExtension | |||
item: ( | |||
<div | |||
className="flex align-center gaps hover-highlight" | |||
onClick={() => Navigation.navigate(supportPageURL())} | |||
onClick={() => Navigation.navigate(this.getPageUrl(pageUrl))} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you instead have a navigate()
method on LensRendererExtension
(or LensExtension
?) then this could be
onClick={() => Navigation.navigate(this.getPageUrl(pageUrl))} | |
onClick={() => this.navigate(pageUrl)} |
(the navigate()
method would call this.getPageUrl()
, no need to expose it. This aligns with what @jakolehm did in #1323
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guess that didn't work out. Would be nice if it were possible ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #1345
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked in dev/local build :/
…_1258 # Conflicts: # extensions/support-page/main.ts # src/extensions/renderer-api/navigation.ts
@@ -100,13 +100,22 @@ import { ExamplePage } from "./src/example-page" | |||
export default class ExampleRendererExtension extends LensRendererExtension { | |||
globalPages = [ | |||
{ | |||
path: "/example-route", | |||
hideInMenu: true, | |||
routePath: "/items/:id?", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems cumbersome if the extension developer has to specify this. Can it default to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just an example. Now could be optional since we have route-prefix for all extensions.
path: "/extension-example", | ||
title: "Example Extension", | ||
routePath: "/extension-example", | ||
exact: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can default be true
? So developer doesn't have to set it unless they want it false
(which assumes they know what they are doing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is optional. Could be default whatever we want :)
extensions/support-page/renderer.tsx
Outdated
@@ -20,9 +18,9 @@ export default class SupportPageRendererExtension extends LensRendererExtension | |||
item: ( | |||
<div | |||
className="flex align-center gaps hover-highlight" | |||
onClick={() => Navigation.navigate(supportPageURL())} | |||
onClick={() => Navigation.navigate(this.getPageUrl(pageUrl))} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guess that didn't work out. Would be nice if it were possible ...
async navigate(location: string, frameId?: number) { | ||
await WindowManager.getInstance<WindowManager>().navigate(location, frameId) | ||
const windowManager = WindowManager.getInstance<WindowManager>(); | ||
const url = this.getPageUrl(location); | ||
await windowManager.navigate(url, frameId) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this a lot but @jakolehm couldn't get it to work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this a lot but @jakolehm couldn't get it to work?
It works on main extension.
@@ -98,108 +97,100 @@ export class Sidebar extends React.Component<Props> { | |||
</div> | |||
<div className="sidebar-nav flex column box grow-fixed"> | |||
<SidebarNavItem | |||
id="cluster" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the integration tests rely on these ids
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ixrock pls revert removal of ids.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it's bad, but let's fix that in separate PR
@@ -98,108 +97,100 @@ export class Sidebar extends React.Component<Props> { | |||
</div> | |||
<div className="sidebar-nav flex column box grow-fixed"> | |||
<SidebarNavItem | |||
id="cluster" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ixrock pls revert removal of ids.
}) | ||
remove(items: T[], key: LensExtension = null) { | ||
const storedItems = this.items.get(key); | ||
if (storedItems) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be also be
if (!storedItems) return;
…_1258 # Conflicts: # src/extensions/lens-renderer-extension.ts
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
…_1258 # Conflicts: # extensions/support-page/renderer.tsx
subPages?: (PageRegistration & TabRoute)[]; | ||
export interface PageRegistration extends BaseRegistryItem { | ||
routePath?: string; // additional (suffix) route path to base extension's route: "/extension/:name" | ||
exact?: boolean; // route matching flag, see: https://reactrouter.com/web/api/NavLink/exact-bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit mystery flag ... when does it needs to be set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping provided url from comment will explain this.. but.. it's about strict matching route:
e.g. if you have route like /page
with exact: true
it will match only this, but not /page/sub-page
Signed-off-by: Roman <ixrock@gmail.com>
Changes:
PageRegistry
BaseRegistry
so now all extension pages registered under/extension/:name
route prefixTabLayout
close #1258
Fix for hello-world example: https://github.com/lensapp/hello-world-extension