1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

refactoring + fix subPages routePath

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-11-13 10:26:49 +02:00
parent 97068f4c07
commit ac9adfbbb8
5 changed files with 18 additions and 15 deletions

View File

@ -44,13 +44,9 @@ export class LensExtension {
return this.manifest.description return this.manifest.description
} }
getPageUrl(baseUrl = "") { getPageRoute(suffixPathOrUrl = "") {
const validUrlName = this.name.replace("@", "").replace("/", "-"); const validUrlName = this.name.replace("@", "").replace("/", "-");
return compile(this.routePrefix)({ name: validUrlName }) + baseUrl; return compile(this.routePrefix)({ name: validUrlName }) + suffixPathOrUrl;
}
getPageRoute(baseRoute = "") {
return this.getPageUrl() + baseRoute;
} }
@action @action

View File

@ -8,7 +8,7 @@ export class LensMainExtension extends LensExtension {
async navigate(location?: string, frameId?: number) { async navigate(location?: string, frameId?: number) {
const windowManager = WindowManager.getInstance<WindowManager>(); const windowManager = WindowManager.getInstance<WindowManager>();
const url = this.getPageUrl(location); // get full path to extension's page const url = this.getPageRoute(location); // get full path to extension's page
await windowManager.navigate(url, frameId); await windowManager.navigate(url, frameId);
} }
} }

View File

@ -16,6 +16,6 @@ export class LensRendererExtension extends LensExtension {
async navigate(location?: string) { async navigate(location?: string) {
const { navigate } = await import("../renderer/navigation"); const { navigate } = await import("../renderer/navigation");
navigate(this.getPageUrl(location)); navigate(this.getPageRoute(location));
} }
} }

View File

@ -23,10 +23,10 @@ export interface PageMenuComponents {
export class PageMenuRegistry<T extends PageMenuRegistration> extends BaseRegistry<T> { export class PageMenuRegistry<T extends PageMenuRegistration> extends BaseRegistry<T> {
getItems() { getItems() {
return super.getItems().map(item => { return super.getItems().map(menuItem => ({
item.url = item.extension.getPageUrl(item.url) ...menuItem,
return item url: menuItem.extension.getPageRoute(menuItem.url),
}); }));
} }
} }

View File

@ -22,9 +22,16 @@ export interface PageComponents {
export class PageRegistry<T extends PageRegistration> extends BaseRegistry<T> { export class PageRegistry<T extends PageRegistration> extends BaseRegistry<T> {
getItems() { getItems() {
return super.getItems().map(item => { return super.getItems().map(page => {
item.routePath = item.extension.getPageRoute(item.routePath) const pageRoute = page.extension.getPageRoute(page.routePath);
return item return {
...page,
routePath: pageRoute,
subPages: page?.subPages?.map(subPage => ({
...subPage,
routePath: pageRoute + subPage.routePath
}))
}
}); });
} }
} }