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

Cleaning up

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-07-21 11:35:34 +03:00
parent 286beb4b26
commit 1443074632
4 changed files with 17 additions and 10 deletions

View File

@ -44,6 +44,7 @@ import { CatalogMenu } from "./catalog-menu";
import { HotbarIcon } from "../hotbar/hotbar-icon";
import { RenderDelay } from "../render-delay/render-delay";
import { CatalogTopbar } from "../cluster-manager/catalog-topbar";
import type { TableSortCallback } from "../table";
export const previousActiveTab = createAppStorage("catalog-previous-active-tab", "");
@ -194,8 +195,17 @@ export class Catalog extends React.Component<Props> {
renderList() {
const { activeCategory } = this.catalogEntityStore;
const tableId = activeCategory ? `catalog-items-${activeCategory.metadata.name.replace(" ", "")}` : "catalog-items";
let sortingCallbacks: { [sortBy: string]: TableSortCallback } = {
[sortBy.name]: (item: CatalogEntityItem<CatalogEntity>) => item.name,
[sortBy.source]: (item: CatalogEntityItem<CatalogEntity>) => item.source,
[sortBy.status]: (item: CatalogEntityItem<CatalogEntity>) => item.phase,
};
const tableId = activeCategory ? `catalog-items-${activeCategory?.metadata.name.replace(" ", "")}` : "catalog-items";
sortingCallbacks = activeCategory ? sortingCallbacks : {
...sortingCallbacks,
[sortBy.kind]: (item: CatalogEntityItem<CatalogEntity>) => item.kind,
};
if (this.activeTab === undefined) {
return null;
@ -209,12 +219,7 @@ export class Catalog extends React.Component<Props> {
isConfigurable={true}
className="CatalogItemList"
store={this.catalogEntityStore}
sortingCallbacks={{
[sortBy.name]: (item: CatalogEntityItem<CatalogEntity>) => item.name,
[sortBy.kind]: (item: CatalogEntityItem<CatalogEntity>) => item.kind,
[sortBy.source]: (item: CatalogEntityItem<CatalogEntity>) => item.source,
[sortBy.status]: (item: CatalogEntityItem<CatalogEntity>) => item.phase,
}}
sortingCallbacks={sortingCallbacks}
searchFilters={[
(entity: CatalogEntityItem<CatalogEntity>) => entity.searchFields,
]}

View File

@ -260,7 +260,7 @@ export class Menu extends React.Component<MenuProps, State> {
}
onBlur() {
if (!this.isOpen) return;
if (!this.isOpen) return; // Prevents triggering document.activeElement for each <Menu/> instance
if (document.activeElement?.tagName == "IFRAME") {
this.close();

View File

@ -39,7 +39,9 @@ export class RenderDelay extends React.Component<Props> {
}
componentDidMount() {
window.requestIdleCallback(this.showContents);
const guaranteedFireTime = 1000;
window.requestIdleCallback(this.showContents, { timeout: guaranteedFireTime });
}
componentWillUnmount() {

2
types/dom.d.ts vendored
View File

@ -26,7 +26,7 @@ declare global {
}
interface Window {
requestIdleCallback(callback: () => void);
requestIdleCallback(callback: () => void, options: { timeout: number });
cancelIdleCallback(callback: () => void);
}
}