mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
update catalog url params on category change (#3102)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
e9a89f396f
commit
d812e28639
@ -40,7 +40,7 @@ import { MainLayout } from "../layout/main-layout";
|
|||||||
import { cssNames } from "../../utils";
|
import { cssNames } from "../../utils";
|
||||||
import { makeCss } from "../../../common/utils/makeCss";
|
import { makeCss } from "../../../common/utils/makeCss";
|
||||||
import { CatalogEntityDetails } from "./catalog-entity-details";
|
import { CatalogEntityDetails } from "./catalog-entity-details";
|
||||||
import type { CatalogViewRouteParam } from "../../../common/routes";
|
import { catalogURL, CatalogViewRouteParam } from "../../../common/routes";
|
||||||
import { CatalogMenu } from "./catalog-menu";
|
import { CatalogMenu } from "./catalog-menu";
|
||||||
import { HotbarIcon } from "../hotbar/hotbar-icon";
|
import { HotbarIcon } from "../hotbar/hotbar-icon";
|
||||||
|
|
||||||
@ -83,22 +83,17 @@ export class Catalog extends React.Component<Props> {
|
|||||||
this.catalogEntityStore = new CatalogEntityStore();
|
this.catalogEntityStore = new CatalogEntityStore();
|
||||||
disposeOnUnmount(this, [
|
disposeOnUnmount(this, [
|
||||||
this.catalogEntityStore.watch(),
|
this.catalogEntityStore.watch(),
|
||||||
when(() => catalogCategoryRegistry.items.length > 0, () => {
|
reaction(() => this.routeActiveTab, async (routeTab) => {
|
||||||
const item = catalogCategoryRegistry.items.find(i => i.getId() === this.routeActiveTab);
|
await when(() => catalogCategoryRegistry.items.length > 0);
|
||||||
|
const item = catalogCategoryRegistry.items.find(i => i.getId() === routeTab);
|
||||||
|
|
||||||
if (item || this.routeActiveTab === undefined) {
|
if (item || routeTab === undefined) {
|
||||||
this.activeTab = this.routeActiveTab;
|
this.activeTab = routeTab;
|
||||||
this.catalogEntityStore.activeCategory = item;
|
this.catalogEntityStore.activeCategory = item;
|
||||||
} else {
|
} else {
|
||||||
Notifications.error(<p>Unknown category: {this.routeActiveTab}</p>);
|
Notifications.error(<p>Unknown category: {routeTab}</p>);
|
||||||
}
|
}
|
||||||
}),
|
}, {fireImmediately: true}),
|
||||||
reaction(() => catalogCategoryRegistry.items, (items) => {
|
|
||||||
if (!this.activeTab && items.length > 0) {
|
|
||||||
this.activeTab = items[0].getId();
|
|
||||||
this.catalogEntityStore.activeCategory = items[0];
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,8 +130,11 @@ export class Catalog extends React.Component<Props> {
|
|||||||
onTabChange = (tabId: string | null) => {
|
onTabChange = (tabId: string | null) => {
|
||||||
const activeCategory = this.categories.find(category => category.getId() === tabId);
|
const activeCategory = this.categories.find(category => category.getId() === tabId);
|
||||||
|
|
||||||
this.catalogEntityStore.activeCategory = activeCategory;
|
if (activeCategory) {
|
||||||
this.activeTab = activeCategory?.getId();
|
navigate(catalogURL({ params: {group: activeCategory.spec.group, kind: activeCategory.spec.names.kind }}));
|
||||||
|
} else {
|
||||||
|
navigate(catalogURL());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
renderNavigation() {
|
renderNavigation() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user