From ec65b1ff7f9738b07361a552959fd9f763bbceed Mon Sep 17 00:00:00 2001 From: testA113 Date: Tue, 8 Oct 2024 18:01:22 +1300 Subject: [PATCH] fix(apps): persist table settings [r8s-120] --- .../react/components/applications.ts | 2 -- app/kubernetes/react/components/index.ts | 2 -- .../views/applications/applications.html | 4 --- .../applications/applicationsController.js | 8 ----- .../ApplicationsDatatable.tsx | 19 ++---------- .../ApplicationsStacksDatatable.tsx | 29 ++++++----------- .../StacksSettingsMenu.tsx | 31 ------------------- .../datatables/DefaultDatatableSettings.tsx | 3 -- 8 files changed, 12 insertions(+), 86 deletions(-) delete mode 100644 app/react/kubernetes/applications/ListView/ApplicationsStacksDatatable/StacksSettingsMenu.tsx diff --git a/app/kubernetes/react/components/applications.ts b/app/kubernetes/react/components/applications.ts index aa5092c4c..844ab6a92 100644 --- a/app/kubernetes/react/components/applications.ts +++ b/app/kubernetes/react/components/applications.ts @@ -15,8 +15,6 @@ export const applicationsModule = angular 'namespaces', 'onNamespaceChange', 'onRefresh', - 'showSystem', - 'onShowSystemChange', 'onRemove', 'hideStacks', ]) diff --git a/app/kubernetes/react/components/index.ts b/app/kubernetes/react/components/index.ts index 38bb2a23a..081b5fbce 100644 --- a/app/kubernetes/react/components/index.ts +++ b/app/kubernetes/react/components/index.ts @@ -215,8 +215,6 @@ export const ngModule = angular 'namespace', 'namespaces', 'onNamespaceChange', - 'showSystem', - 'setSystemResources', ]) ) .component( diff --git a/app/kubernetes/views/applications/applications.html b/app/kubernetes/views/applications/applications.html index 9b076efb0..44fc20be8 100644 --- a/app/kubernetes/views/applications/applications.html +++ b/app/kubernetes/views/applications/applications.html @@ -18,8 +18,6 @@ namespace="ctrl.state.namespaceName" on-namespace-change="(ctrl.onChangeNamespaceDropdown)" is-loading="ctrl.state.isAppsLoading" - show-system="ctrl.state.isSystemResources" - on-show-system-change="(ctrl.setSystemResources)" on-remove="(ctrl.removeAction)" hide-stacks="ctrl.deploymentOptions.hideStacksFunctionality" > @@ -50,8 +48,6 @@ namespace="ctrl.state.namespaceName" on-namespace-change="(ctrl.onChangeNamespaceDropdown)" is-loading="ctrl.state.isAppsLoading" - show-system="ctrl.state.isSystemResources" - on-show-system-change="(ctrl.setSystemResources)" on-remove="(ctrl.removeAction)" hide-stacks="ctrl.deploymentOptions.hideStacksFunctionality" > diff --git a/app/kubernetes/views/applications/applicationsController.js b/app/kubernetes/views/applications/applicationsController.js index c48836e0e..e7fb8d431 100644 --- a/app/kubernetes/views/applications/applicationsController.js +++ b/app/kubernetes/views/applications/applicationsController.js @@ -42,7 +42,6 @@ class KubernetesApplicationsController { this.removeStacksActionAsync = this.removeStacksActionAsync.bind(this); this.onPublishingModeClick = this.onPublishingModeClick.bind(this); this.onChangeNamespaceDropdown = this.onChangeNamespaceDropdown.bind(this); - this.setSystemResources = this.setSystemResources.bind(this); } selectTab(index) { @@ -133,12 +132,6 @@ class KubernetesApplicationsController { }); } - setSystemResources(flag) { - return this.$scope.$applyAsync(() => { - this.state.isSystemResources = flag; - }); - } - async onInit() { this.state = { activeTab: this.LocalStorage.getActiveTab('applications'), @@ -150,7 +143,6 @@ class KubernetesApplicationsController { ports: [], namespaces: [], namespaceName: '', - isSystemResources: undefined, }; this.deploymentOptions = await getDeploymentOptions(); diff --git a/app/react/kubernetes/applications/ListView/ApplicationsDatatable/ApplicationsDatatable.tsx b/app/react/kubernetes/applications/ListView/ApplicationsDatatable/ApplicationsDatatable.tsx index bedcadc38..d8b82f15b 100644 --- a/app/react/kubernetes/applications/ListView/ApplicationsDatatable/ApplicationsDatatable.tsx +++ b/app/react/kubernetes/applications/ListView/ApplicationsDatatable/ApplicationsDatatable.tsx @@ -1,4 +1,3 @@ -import { useEffect } from 'react'; import { BoxIcon } from 'lucide-react'; import { useKubeStore } from '@/react/kubernetes/datatables/default-kube-datatable-store'; @@ -33,8 +32,6 @@ export function ApplicationsDatatable({ namespace = '', namespaces, onNamespaceChange, - showSystem, - onShowSystemChange, hideStacks, }: { onRefresh: () => void; @@ -42,8 +39,6 @@ export function ApplicationsDatatable({ namespace?: string; namespaces: Array; onNamespaceChange(namespace: string): void; - showSystem?: boolean; - onShowSystemChange(showSystem: boolean): void; hideStacks: boolean; }) { const envId = useEnvironmentId(); @@ -58,20 +53,13 @@ export function ApplicationsDatatable({ undefined, false ); - - const { setShowSystemResources } = tableState; - - useEffect(() => { - setShowSystemResources(showSystem || false); - }, [showSystem, setShowSystemResources]); - const applicationsQuery = useApplications(envId, { refetchInterval: tableState.autoRefreshRate * 1000, namespace, withDependencies: true, }); const applications = applicationsQuery.data ?? []; - const filteredApplications = showSystem + const filteredApplications = tableState.showSystemResources ? applications : applications.filter( (application) => @@ -124,10 +112,7 @@ export function ApplicationsDatatable({ } renderTableSettings={() => ( - + )} description={ diff --git a/app/react/kubernetes/applications/ListView/ApplicationsStacksDatatable/ApplicationsStacksDatatable.tsx b/app/react/kubernetes/applications/ListView/ApplicationsStacksDatatable/ApplicationsStacksDatatable.tsx index c4db89c5b..123e2c54d 100644 --- a/app/react/kubernetes/applications/ListView/ApplicationsStacksDatatable/ApplicationsStacksDatatable.tsx +++ b/app/react/kubernetes/applications/ListView/ApplicationsStacksDatatable/ApplicationsStacksDatatable.tsx @@ -1,5 +1,4 @@ import { List } from 'lucide-react'; -import { useEffect } from 'react'; import { useAuthorizations } from '@/react/hooks/useUser'; import { SystemResourceDescription } from '@/react/kubernetes/datatables/SystemResourceDescription'; @@ -7,16 +6,17 @@ import { createStore } from '@/react/kubernetes/datatables/default-kube-datatabl import { useEnvironmentId } from '@/react/hooks/useEnvironmentId'; import { isSystemNamespace } from '@/react/kubernetes/namespaces/queries/useIsSystemNamespace'; import { useNamespacesQuery } from '@/react/kubernetes/namespaces/queries/useNamespacesQuery'; +import { DefaultDatatableSettings } from '@/react/kubernetes/datatables/DefaultDatatableSettings'; import { ExpandableDatatable } from '@@/datatables/ExpandableDatatable'; import { useTableState } from '@@/datatables/useTableState'; +import { TableSettingsMenu } from '@@/datatables'; import { useApplications } from '../../application.queries'; import { columns } from './columns'; import { SubRows } from './SubRows'; import { Namespace, Stack } from './types'; -import { StacksSettingsMenu } from './StacksSettingsMenu'; import { NamespaceFilter } from './NamespaceFilter'; import { TableActions } from './TableActions'; import { getStacksFromApplications } from './getStacksFromApplications'; @@ -30,8 +30,6 @@ interface Props { namespace?: string; namespaces: Array; onNamespaceChange(namespace: string): void; - showSystem?: boolean; - setSystemResources(showSystem: boolean): void; } export function ApplicationsStacksDatatable({ @@ -39,17 +37,9 @@ export function ApplicationsStacksDatatable({ namespace = '', namespaces, onNamespaceChange, - showSystem, - setSystemResources, }: Props) { const tableState = useTableState(settingsStore, storageKey); - const { setShowSystemResources } = tableState; - - useEffect(() => { - setShowSystemResources(showSystem || false); - }, [showSystem, setShowSystemResources]); - const envId = useEnvironmentId(); const applicationsQuery = useApplications(envId, { refetchInterval: tableState.autoRefreshRate * 1000, @@ -58,7 +48,7 @@ export function ApplicationsStacksDatatable({ }); const namespaceListQuery = useNamespacesQuery(envId); const applications = applicationsQuery.data ?? []; - const filteredApplications = showSystem + const filteredApplications = tableState.showSystemResources ? applications : applications.filter( (item) => @@ -90,12 +80,14 @@ export function ApplicationsStacksDatatable({ namespaces={namespaces} value={namespace} onChange={onNamespaceChange} - showSystem={showSystem} + showSystem={tableState.showSystemResources} />
- +
} @@ -103,10 +95,9 @@ export function ApplicationsStacksDatatable({ )} renderTableSettings={() => ( - + + + )} getRowId={(row) => `${row.Name}-${row.ResourcePool}`} data-cy="applications-stacks-datatable" diff --git a/app/react/kubernetes/applications/ListView/ApplicationsStacksDatatable/StacksSettingsMenu.tsx b/app/react/kubernetes/applications/ListView/ApplicationsStacksDatatable/StacksSettingsMenu.tsx deleted file mode 100644 index f33ea2815..000000000 --- a/app/react/kubernetes/applications/ListView/ApplicationsStacksDatatable/StacksSettingsMenu.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { SystemResourcesSettings } from '@/react/kubernetes/datatables/SystemResourcesSettings'; - -import { TableSettingsMenu } from '@@/datatables'; -import { TableSettingsMenuAutoRefresh } from '@@/datatables/TableSettingsMenuAutoRefresh'; - -import { type TableSettings } from './types'; - -export function StacksSettingsMenu({ - settings, - setSystemResources, -}: { - settings: TableSettings; - setSystemResources(showSystem: boolean): void; -}) { - return ( - - { - setSystemResources(value); - settings.setShowSystemResources(value); - }} - /> - - - - ); -} diff --git a/app/react/kubernetes/datatables/DefaultDatatableSettings.tsx b/app/react/kubernetes/datatables/DefaultDatatableSettings.tsx index b2fe5f795..30acd6e99 100644 --- a/app/react/kubernetes/datatables/DefaultDatatableSettings.tsx +++ b/app/react/kubernetes/datatables/DefaultDatatableSettings.tsx @@ -16,10 +16,8 @@ export interface TableSettings export function DefaultDatatableSettings({ settings, - onShowSystemChange, }: { settings: TableSettings; - onShowSystemChange?(showSystem: boolean): void; }) { return ( <> @@ -27,7 +25,6 @@ export function DefaultDatatableSettings({ value={settings.showSystemResources} onChange={(value) => { settings.setShowSystemResources(value); - onShowSystemChange?.(value); }} />