mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix navigating back to tab in catalog from hotbar
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
a311355784
commit
c5b22c8cbe
@ -42,7 +42,7 @@ import hotbarStoreInjectable from "../../../common/hotbar-store.injectable";
|
|||||||
import type { HotbarStore } from "../../../common/hotbar-store";
|
import type { HotbarStore } from "../../../common/hotbar-store";
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
catalogPreviousActiveTabStorage: { set: (value: string ) => void };
|
catalogPreviousActiveTabStorage: { set: (value: string ) => void; get: () => string };
|
||||||
catalogEntityStore: CatalogEntityStore;
|
catalogEntityStore: CatalogEntityStore;
|
||||||
getCategoryColumns: (params: GetCategoryColumnsParams) => CategoryColumns;
|
getCategoryColumns: (params: GetCategoryColumnsParams) => CategoryColumns;
|
||||||
customCategoryViews: IComputedValue<Map<string, Map<string, RegisteredCustomCategoryViewDecl>>>;
|
customCategoryViews: IComputedValue<Map<string, Map<string, RegisteredCustomCategoryViewDecl>>>;
|
||||||
@ -78,6 +78,12 @@ class NonInjectedCatalog extends React.Component<Dependencies> {
|
|||||||
return `${dereferencedGroup}/${dereferencedKind}`;
|
return `${dereferencedGroup}/${dereferencedKind}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const previousTab = this.props.catalogPreviousActiveTabStorage.get();
|
||||||
|
|
||||||
|
if (previousTab) {
|
||||||
|
return previousTab;
|
||||||
|
}
|
||||||
|
|
||||||
return browseCatalogTab;
|
return browseCatalogTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +95,6 @@ class NonInjectedCatalog extends React.Component<Dependencies> {
|
|||||||
disposeOnUnmount(this, [
|
disposeOnUnmount(this, [
|
||||||
this.props.catalogEntityStore.watch(),
|
this.props.catalogEntityStore.watch(),
|
||||||
reaction(() => this.routeActiveTab, async (routeTab) => {
|
reaction(() => this.routeActiveTab, async (routeTab) => {
|
||||||
this.props.catalogPreviousActiveTabStorage.set(this.routeActiveTab);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await when(() => (routeTab === browseCatalogTab || !!catalogCategoryRegistry.filteredItems.find(i => i.getId() === routeTab)), { timeout: 5_000 }); // we need to wait because extensions might take a while to load
|
await when(() => (routeTab === browseCatalogTab || !!catalogCategoryRegistry.filteredItems.find(i => i.getId() === routeTab)), { timeout: 5_000 }); // we need to wait because extensions might take a while to load
|
||||||
const item = catalogCategoryRegistry.filteredItems.find(i => i.getId() === routeTab);
|
const item = catalogCategoryRegistry.filteredItems.find(i => i.getId() === routeTab);
|
||||||
@ -175,9 +179,10 @@ class NonInjectedCatalog extends React.Component<Dependencies> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (activeCategory) {
|
if (activeCategory) {
|
||||||
|
this.props.catalogPreviousActiveTabStorage.set(`${activeCategory.spec.group}/${activeCategory.spec.names.kind}`);
|
||||||
this.props.navigateToCatalog({ group: activeCategory.spec.group, kind: activeCategory.spec.names.kind });
|
this.props.navigateToCatalog({ group: activeCategory.spec.group, kind: activeCategory.spec.names.kind });
|
||||||
} else {
|
} else {
|
||||||
|
this.props.catalogPreviousActiveTabStorage.set(null);
|
||||||
this.props.navigateToCatalog({ group: browseCatalogTab });
|
this.props.navigateToCatalog({ group: browseCatalogTab });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user