mirror of https://github.com/rancher/dashboard.git
Revert changes related to projects in local cluster
This commit is contained in:
parent
d2101013fa
commit
3f977655ef
|
|
@ -274,7 +274,6 @@ export default {
|
||||||
filters
|
filters
|
||||||
} = stevePaginationUtils.createParamsFromNsFilter({
|
} = stevePaginationUtils.createParamsFromNsFilter({
|
||||||
allNamespaces: this.$store.getters[`${ this.currentProduct?.inStore }/all`](NAMESPACE),
|
allNamespaces: this.$store.getters[`${ this.currentProduct?.inStore }/all`](NAMESPACE),
|
||||||
getProject: (id) => this.$store.getters[`management/byId`](MANAGEMENT.PROJECT, id),
|
|
||||||
selection: neu,
|
selection: neu,
|
||||||
isAllNamespaces: this.isAllNamespaces,
|
isAllNamespaces: this.isAllNamespaces,
|
||||||
isLocalCluster: this.$store.getters['currentCluster'].isLocal,
|
isLocalCluster: this.$store.getters['currentCluster'].isLocal,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import {
|
||||||
HPA,
|
HPA,
|
||||||
SECRET
|
SECRET
|
||||||
} from '@shell/config/types';
|
} 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 { Schema } from '@shell/plugins/steve/schema';
|
||||||
import { PaginationSettingsStore } from '@shell/types/resources/settings';
|
import { PaginationSettingsStore } from '@shell/types/resources/settings';
|
||||||
|
|
||||||
|
|
@ -32,28 +32,7 @@ interface Namespace extends ModelNamespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetProject = (id: string) => any
|
|
||||||
|
|
||||||
class NamespaceProjectFilters {
|
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
|
* 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[],
|
allNamespaces: Namespace[],
|
||||||
showDynamicRancherNamespaces: boolean,
|
showDynamicRancherNamespaces: boolean,
|
||||||
productHidesSystemNamespaces: boolean,
|
productHidesSystemNamespaces: boolean,
|
||||||
getProject: GetProject,
|
|
||||||
isLocalCluster: boolean,
|
|
||||||
}): PaginationParamFilter[] {
|
}): PaginationParamFilter[] {
|
||||||
const {
|
const { allNamespaces, showDynamicRancherNamespaces, productHidesSystemNamespaces } = args;
|
||||||
allNamespaces, showDynamicRancherNamespaces, productHidesSystemNamespaces, getProject, isLocalCluster
|
|
||||||
} = args;
|
|
||||||
|
|
||||||
// These are AND'd together
|
// These are AND'd together
|
||||||
// Not ns 1 AND ns 2
|
// Not ns 1 AND ns 2
|
||||||
return allNamespaces.reduce((res, ns) => {
|
return allNamespaces.reduce((res, ns) => {
|
||||||
// Links to ns.isObscure and covers things like `c-`, `user-`, etc (see OBSCURE_NAMESPACE_PREFIX)
|
// Links to ns.isObscure and covers things like `c-`, `user-`, etc (see OBSCURE_NAMESPACE_PREFIX)
|
||||||
let hideObscure = false;
|
const hideObscure = showDynamicRancherNamespaces ? false : ns.isObscure;
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Links to ns.isSystem and covers things like ns with system annotation, hardcoded list, etc
|
// Links to ns.isSystem and covers things like ns with system annotation, hardcoded list, etc
|
||||||
const hideSystem = productHidesSystemNamespaces ? ns.isSystem : false;
|
const hideSystem = productHidesSystemNamespaces ? ns.isSystem : false;
|
||||||
|
|
@ -106,16 +73,9 @@ class NamespaceProjectFilters {
|
||||||
allNamespaces: Namespace[],
|
allNamespaces: Namespace[],
|
||||||
isAllSystem: boolean,
|
isAllSystem: boolean,
|
||||||
isAllUser: boolean,
|
isAllUser: boolean,
|
||||||
getProject: GetProject,
|
|
||||||
isLocalCluster: boolean,
|
|
||||||
}) {
|
}) {
|
||||||
const {
|
const { allNamespaces, isAllSystem } = args;
|
||||||
allNamespaces, isAllSystem, getProject, isLocalCluster
|
const allSystem = allNamespaces.filter((ns) => ns.isSystem);
|
||||||
} = 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);
|
|
||||||
});
|
|
||||||
|
|
||||||
// > Neither of these use projectsOrNamespaces to avoid scenarios where the local cluster provides a namespace which has
|
// > 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
|
// > 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({
|
public createParamsFromNsFilter({
|
||||||
allNamespaces,
|
allNamespaces,
|
||||||
getProject,
|
|
||||||
selection,
|
selection,
|
||||||
isAllNamespaces,
|
isAllNamespaces,
|
||||||
isLocalCluster,
|
isLocalCluster,
|
||||||
|
|
@ -314,21 +273,24 @@ class StevePaginationUtils extends NamespaceProjectFilters {
|
||||||
productHidesSystemNamespaces,
|
productHidesSystemNamespaces,
|
||||||
}: {
|
}: {
|
||||||
allNamespaces: Namespace[],
|
allNamespaces: Namespace[],
|
||||||
getProject: GetProject,
|
|
||||||
selection: string[],
|
selection: string[],
|
||||||
/**
|
/**
|
||||||
* There is no user provided filter
|
* There is no user provided filter
|
||||||
*/
|
*/
|
||||||
isAllNamespaces: boolean,
|
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,
|
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)
|
* Links to ns.isObscure and covers things like `c-`, `user-`, etc (see OBSCURE_NAMESPACE_PREFIX)
|
||||||
*/
|
*/
|
||||||
showDynamicRancherNamespaces: boolean,
|
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
|
* Links to ns.isSystem and covers things like ns with system annotation, hardcoded list, etc
|
||||||
*/
|
*/
|
||||||
productHidesSystemNamespaces: boolean,
|
productHidesSystemNamespaces: boolean,
|
||||||
|
|
@ -364,11 +326,7 @@ class StevePaginationUtils extends NamespaceProjectFilters {
|
||||||
if (!showDynamicRancherNamespaces || productHidesSystemNamespaces) {
|
if (!showDynamicRancherNamespaces || productHidesSystemNamespaces) {
|
||||||
// We need to hide dynamic namespaces ('c-', 'user-', etc) OR system namespaces
|
// We need to hide dynamic namespaces ('c-', 'user-', etc) OR system namespaces
|
||||||
filters = this.handlePrefAndSettingFilter({
|
filters = this.handlePrefAndSettingFilter({
|
||||||
allNamespaces,
|
allNamespaces, showDynamicRancherNamespaces, productHidesSystemNamespaces
|
||||||
showDynamicRancherNamespaces,
|
|
||||||
productHidesSystemNamespaces,
|
|
||||||
getProject,
|
|
||||||
isLocalCluster
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -378,11 +336,7 @@ class StevePaginationUtils extends NamespaceProjectFilters {
|
||||||
if (selection.length === 1 && (isAllSystem || isAllUser)) {
|
if (selection.length === 1 && (isAllSystem || isAllUser)) {
|
||||||
// Filter by resources either in or not in system namespaces
|
// Filter by resources either in or not in system namespaces
|
||||||
filters.push(...this.handleSystemOrUserFilter({
|
filters.push(...this.handleSystemOrUserFilter({
|
||||||
allNamespaces,
|
allNamespaces, isAllSystem, isAllUser
|
||||||
isAllSystem,
|
|
||||||
isAllUser,
|
|
||||||
getProject,
|
|
||||||
isLocalCluster,
|
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
// User has one or more projects or namespaces
|
// User has one or more projects or namespaces
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue