diff --git a/shell/mixins/resource-fetch-api-pagination.js b/shell/mixins/resource-fetch-api-pagination.js index 91d7a4789e..892c048f68 100644 --- a/shell/mixins/resource-fetch-api-pagination.js +++ b/shell/mixins/resource-fetch-api-pagination.js @@ -274,7 +274,6 @@ export default { filters } = stevePaginationUtils.createParamsFromNsFilter({ allNamespaces: this.$store.getters[`${ this.currentProduct?.inStore }/all`](NAMESPACE), - getProject: (id) => this.$store.getters[`management/byId`](MANAGEMENT.PROJECT, id), selection: neu, isAllNamespaces: this.isAllNamespaces, isLocalCluster: this.$store.getters['currentCluster'].isLocal, diff --git a/shell/plugins/steve/steve-pagination-utils.ts b/shell/plugins/steve/steve-pagination-utils.ts index 26670ef198..3dcf409a15 100644 --- a/shell/plugins/steve/steve-pagination-utils.ts +++ b/shell/plugins/steve/steve-pagination-utils.ts @@ -15,7 +15,7 @@ import { HPA, SECRET } from '@shell/config/types'; -import { CAPI as CAPI_LAB_AND_ANO, CATTLE_PUBLIC_ENDPOINTS, DEFAULT_PROJECT } from '@shell/config/labels-annotations'; +import { CAPI as CAPI_LAB_AND_ANO, CATTLE_PUBLIC_ENDPOINTS } from '@shell/config/labels-annotations'; import { Schema } from '@shell/plugins/steve/schema'; import { PaginationSettingsStore } from '@shell/types/resources/settings'; @@ -32,28 +32,7 @@ interface Namespace extends ModelNamespace { } } -type GetProject = (id: string) => any - class NamespaceProjectFilters { - protected isNamespaceLocalProject(ns: Namespace, getProject: GetProject, isLocalCluster: boolean): boolean { - // Are we in the local cluster? If not we can skip everything - if (!isLocalCluster) { - return false; - } - - // Is this a upstream namespace for a downstream cluster? - if (ns.id.startsWith('local-p')) { - return true; - } - - // Is this the upstream namespace for the `Default` project - if (getProject(`local/${ ns.id }`)?.metadata.labels[DEFAULT_PROJECT] === 'true') { - return true; - } - - return false; - } - /** * User needs all resources.... except if there's some settings which should remove resources in specific circumstances */ @@ -61,26 +40,14 @@ class NamespaceProjectFilters { allNamespaces: Namespace[], showDynamicRancherNamespaces: boolean, productHidesSystemNamespaces: boolean, - getProject: GetProject, - isLocalCluster: boolean, }): PaginationParamFilter[] { - const { - allNamespaces, showDynamicRancherNamespaces, productHidesSystemNamespaces, getProject, isLocalCluster - } = args; + const { allNamespaces, showDynamicRancherNamespaces, productHidesSystemNamespaces } = args; // These are AND'd together // Not ns 1 AND ns 2 return allNamespaces.reduce((res, ns) => { // Links to ns.isObscure and covers things like `c-`, `user-`, etc (see OBSCURE_NAMESPACE_PREFIX) - let hideObscure = false; - - if (!showDynamicRancherNamespaces) { - // if we are to hide dynamic rancher namespaces ... then hide obscure namespaces - if (ns.isObscure) { - // don't count local cluster ns's that are local cluster projects - hideObscure = !this.isNamespaceLocalProject(ns, getProject, isLocalCluster); - } - } + const hideObscure = showDynamicRancherNamespaces ? false : ns.isObscure; // Links to ns.isSystem and covers things like ns with system annotation, hardcoded list, etc const hideSystem = productHidesSystemNamespaces ? ns.isSystem : false; @@ -106,16 +73,9 @@ class NamespaceProjectFilters { allNamespaces: Namespace[], isAllSystem: boolean, isAllUser: boolean, - getProject: GetProject, - isLocalCluster: boolean, }) { - const { - allNamespaces, isAllSystem, getProject, isLocalCluster - } = args; - const allSystem = allNamespaces.filter((ns) => { - // don't count local cluster ns's that are local cluster projects as system projects (we want their resources to show) - return ns.isSystem && !this.isNamespaceLocalProject(ns, getProject, isLocalCluster); - }); + const { allNamespaces, isAllSystem } = args; + const allSystem = allNamespaces.filter((ns) => ns.isSystem); // > Neither of these use projectsOrNamespaces to avoid scenarios where the local cluster provides a namespace which has // > a matching project... which could lead to results in the user project resource being included in the system filter @@ -306,7 +266,6 @@ class StevePaginationUtils extends NamespaceProjectFilters { */ public createParamsFromNsFilter({ allNamespaces, - getProject, selection, isAllNamespaces, isLocalCluster, @@ -314,21 +273,24 @@ class StevePaginationUtils extends NamespaceProjectFilters { productHidesSystemNamespaces, }: { allNamespaces: Namespace[], - getProject: GetProject, selection: string[], /** * There is no user provided filter */ isAllNamespaces: boolean, /** - * Weird things be happening if the target cluster is local / upstream. Uses this to check what cluster we're in + * Weird things be happening if the target cluster is local / upstream. Use this to check what cluster we're in */ isLocalCluster: boolean, /** + * User preference states we should show dynamic rancher namespaces. Preference description "Show dynamic Namespaces managed by Rancher (not intended for editing or deletion)" + * * Links to ns.isObscure and covers things like `c-`, `user-`, etc (see OBSCURE_NAMESPACE_PREFIX) */ showDynamicRancherNamespaces: boolean, /** + * Product config states that system namespaces should be hidden + * * Links to ns.isSystem and covers things like ns with system annotation, hardcoded list, etc */ productHidesSystemNamespaces: boolean, @@ -364,11 +326,7 @@ class StevePaginationUtils extends NamespaceProjectFilters { if (!showDynamicRancherNamespaces || productHidesSystemNamespaces) { // We need to hide dynamic namespaces ('c-', 'user-', etc) OR system namespaces filters = this.handlePrefAndSettingFilter({ - allNamespaces, - showDynamicRancherNamespaces, - productHidesSystemNamespaces, - getProject, - isLocalCluster + allNamespaces, showDynamicRancherNamespaces, productHidesSystemNamespaces }); } @@ -378,11 +336,7 @@ class StevePaginationUtils extends NamespaceProjectFilters { if (selection.length === 1 && (isAllSystem || isAllUser)) { // Filter by resources either in or not in system namespaces filters.push(...this.handleSystemOrUserFilter({ - allNamespaces, - isAllSystem, - isAllUser, - getProject, - isLocalCluster, + allNamespaces, isAllSystem, isAllUser })); } else { // User has one or more projects or namespaces