mirror of https://github.com/rancher/dashboard.git
HARVESTER: filter namespace in harvester cluster
This commit is contained in:
parent
6d99fba638
commit
ae390c96fe
|
|
@ -1,10 +1,12 @@
|
|||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import { get } from '@/utils/object';
|
||||
import { mapPref, GROUP_RESOURCES } from '@/store/prefs';
|
||||
import ButtonGroup from '@/components/ButtonGroup';
|
||||
import SortableTable from '@/components/SortableTable';
|
||||
import { NAMESPACE } from '@/config/table-headers';
|
||||
import { findBy } from '@/utils/array';
|
||||
import { NAME as HARVESTER } from '@/config/product/harvester';
|
||||
|
||||
export default {
|
||||
components: { ButtonGroup, SortableTable },
|
||||
|
|
@ -64,6 +66,7 @@ export default {
|
|||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters(['isVirtualCluster']),
|
||||
isNamespaced() {
|
||||
if ( this.namespaced !== null ) {
|
||||
return this.namespaced;
|
||||
|
|
@ -115,9 +118,10 @@ export default {
|
|||
|
||||
filteredRows() {
|
||||
const isAll = this.$store.getters['isAllNamespaces'];
|
||||
const isVirutalProduct = this.$store.getters['currentProduct'].name === HARVESTER;
|
||||
|
||||
// If the resources isn't namespaced or we want ALL of them, there's nothing to do.
|
||||
if ( !this.isNamespaced || isAll ) {
|
||||
if ( (!this.isNamespaced || isAll) && !isVirutalProduct) {
|
||||
return this.rows || [];
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +133,11 @@ export default {
|
|||
}
|
||||
|
||||
return this.rows.filter((row) => {
|
||||
return !!includedNamespaces[row.metadata.namespace];
|
||||
if (this.isVirtualCluster && this.isNamespaced) {
|
||||
return !!includedNamespaces[row.metadata.namespace] && !row.isSystemResource;
|
||||
} else {
|
||||
return !!includedNamespaces[row.metadata.namespace];
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import { get, set } from '@/utils/object';
|
||||
import { sortBy } from '@/utils/sort';
|
||||
import { NAMESPACE } from '@/config/types';
|
||||
|
|
@ -170,6 +171,7 @@ export default {
|
|||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters(['isVirtualCluster']),
|
||||
namespaceReallyDisabled() {
|
||||
return (
|
||||
!!this.forceNamespace || this.namespaceDisabled || this.mode === _EDIT
|
||||
|
|
@ -185,7 +187,9 @@ export default {
|
|||
const choices = this.$store.getters[`${ inStore }/all`](this.namespaceType);
|
||||
|
||||
const out = sortBy(
|
||||
choices.map((obj) => {
|
||||
choices.filter( (N) => {
|
||||
return this.isVirtualCluster ? !N.isSystem && !N.isFleetManaged : true;
|
||||
}).map((obj) => {
|
||||
return {
|
||||
label: obj.nameDisplay,
|
||||
value: obj.id,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { NAMESPACE, MANAGEMENT } from '@/config/types';
|
|||
import { sortBy } from '@/utils/sort';
|
||||
import { isArray, addObjects, findBy, filterBy } from '@/utils/array';
|
||||
import Select from '@/components/form/Select';
|
||||
import { NAME as HARVESTER } from '@/config/product/harvester';
|
||||
|
||||
export default {
|
||||
components: { Select },
|
||||
|
|
@ -76,7 +77,12 @@ export default {
|
|||
const namespaces = sortBy(
|
||||
this.$store.getters[`${ inStore }/all`](NAMESPACE),
|
||||
['nameDisplay']
|
||||
).filter( N => this.isVirtualCluster ? !N.isSystem : true);
|
||||
).filter( (N) => {
|
||||
const needFilter = !N.isSystem && !N.isFleetManaged;
|
||||
const isVirtualProduct = this.$store.getters['currentProduct'].name === HARVESTER;
|
||||
|
||||
return this.isVirtualCluster && isVirtualProduct ? needFilter : true;
|
||||
});
|
||||
|
||||
if (this.$store.getters['isRancher'] || this.isMultiVirtualCluster) {
|
||||
const cluster = this.$store.getters['currentCluster'];
|
||||
|
|
@ -104,7 +110,7 @@ export default {
|
|||
projectId = null;
|
||||
}
|
||||
|
||||
let entry = namespacesByProject[namespace.projectId];
|
||||
let entry = namespacesByProject[projectId];
|
||||
|
||||
if (!entry) {
|
||||
entry = [];
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ export const FLEET = {
|
|||
CLUSTER_DISPLAY_NAME: 'management.cattle.io/cluster-display-name',
|
||||
CLUSTER_NAME: 'management.cattle.io/cluster-name',
|
||||
BUNDLE_ID: 'fleet.cattle.io/bundle-id',
|
||||
MANAGED: 'fleet.cattle.io/managed'
|
||||
};
|
||||
|
||||
export const RBAC = { PRODUCT: 'management.cattle.io/ui-product' };
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@ export const SETTING = {
|
|||
LOGO_DARK: 'ui-logo-dark',
|
||||
PRIMARY_COLOR: 'ui-primary-color',
|
||||
LINK_COLOR: 'ui-link-color',
|
||||
COMMUNITY_LINKS: 'ui-community-links'
|
||||
COMMUNITY_LINKS: 'ui-community-links',
|
||||
SYSTEM_NAMESPACES: 'system-namespaces'
|
||||
};
|
||||
|
||||
// These are the settings that are allowed to be edited via the UI
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ export default {
|
|||
:headers="headers"
|
||||
:groupable="true"
|
||||
default-sort-by="age"
|
||||
:namespaced="true"
|
||||
:rows="rows"
|
||||
:schema="schema"
|
||||
key-field="_key"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import ResourceTable from '@/components/ResourceTable';
|
||||
|
||||
export default {
|
||||
name: 'ListNamespace',
|
||||
components: { ResourceTable },
|
||||
|
|
@ -16,11 +17,13 @@ export default {
|
|||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters(['isSingleVirtualCluster']),
|
||||
...mapGetters(['isVirtualCluster']),
|
||||
|
||||
filterRow() {
|
||||
if (this.isSingleVirtualCluster) {
|
||||
return this.rows.filter( N => !N.isSystem);
|
||||
if (this.isVirtualCluster) {
|
||||
return this.rows.filter( (N) => {
|
||||
return !N.isSystem && !N.isFleetManaged;
|
||||
});
|
||||
} else {
|
||||
return this.rows;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import SYSTEM_NAMESPACES from '@/config/system-namespaces';
|
||||
import { PROJECT, SYSTEM_NAMESPACE, ISTIO as ISTIO_LABELS } from '@/config/labels-annotations';
|
||||
import { PROJECT, SYSTEM_NAMESPACE, ISTIO as ISTIO_LABELS, FLEET } from '@/config/labels-annotations';
|
||||
import { ISTIO, MANAGEMENT } from '@/config/types';
|
||||
|
||||
import { get } from '@/utils/object';
|
||||
import { escapeHtml } from '@/utils/string';
|
||||
import { insertAt, isArray } from '@/utils/array';
|
||||
|
||||
|
|
@ -81,6 +82,10 @@ export default {
|
|||
return false;
|
||||
},
|
||||
|
||||
isFleetManaged() {
|
||||
return get(this, `metadata.labels."${ FLEET.MANAGED }"`) === 'true';
|
||||
},
|
||||
|
||||
// These are namespaces that are created by rancher to serve purposes in the background but the user shouldn't have
|
||||
// to worry themselves about them.
|
||||
isObscure() {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { PROJECT_ID } from '@/config/query-params';
|
|||
import Masthead from '@/components/ResourceList/Masthead';
|
||||
import { mapPref, GROUP_RESOURCES, DEV } from '@/store/prefs';
|
||||
import MoveModal from '@/components/MoveModal';
|
||||
import { NAME as HARVESTER } from '@/config/product/harvester';
|
||||
|
||||
export default {
|
||||
name: 'ListNamespace',
|
||||
|
|
@ -110,9 +111,10 @@ export default {
|
|||
}
|
||||
|
||||
const isVirtualCluster = this.$store.getters['isVirtualCluster'];
|
||||
const isVirutalProduct = this.$store.getters['currentProduct'].name === HARVESTER;
|
||||
|
||||
return this.namespaces.filter((namespace) => {
|
||||
return isVirtualCluster ? (!namespace.isSystem && !namespace.isObscure) : !namespace.isObscure;
|
||||
return isVirtualCluster && isVirutalProduct ? (!namespace.isSystem && !namespace.isObscure) : !namespace.isObscure;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -607,6 +607,16 @@ export default {
|
|||
};
|
||||
},
|
||||
|
||||
isSystemResource() {
|
||||
const systemNamespaces = this.$rootGetters['systemNamespaces'];
|
||||
|
||||
if ( systemNamespaces.includes(this.metadata?.namespace) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
isCondition() {
|
||||
return (condition, withStatus = 'True') => {
|
||||
if ( !this.status || !this.status.conditions ) {
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ export const state = () => {
|
|||
cameFromError: false,
|
||||
pageActions: [],
|
||||
serverVersion: null,
|
||||
systemNamespaces: []
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -83,6 +84,10 @@ export const getters = {
|
|||
return state.pageActions;
|
||||
},
|
||||
|
||||
systemNamespaces(state) {
|
||||
return state.systemNamespaces;
|
||||
},
|
||||
|
||||
currentCluster(state, getters) {
|
||||
return getters['management/byId'](MANAGEMENT.CLUSTER, state.clusterId);
|
||||
},
|
||||
|
|
@ -451,6 +456,10 @@ export const mutations = {
|
|||
|
||||
setServerVersion(state, version) {
|
||||
state.serverVersion = version;
|
||||
},
|
||||
|
||||
setSystemNamespaces(state, namespaces) {
|
||||
state.systemNamespaces = namespaces;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -523,6 +532,7 @@ export const actions = {
|
|||
|
||||
const pl = res.settings?.find(x => x.name === 'ui-pl')?.value;
|
||||
const brand = res.settings?.find(x => x.name === SETTING.BRAND)?.value;
|
||||
const systemNamespaces = res.settings?.find(x => x.name === SETTING.SYSTEM_NAMESPACES);
|
||||
|
||||
if ( pl ) {
|
||||
setVendor(pl);
|
||||
|
|
@ -532,6 +542,12 @@ export const actions = {
|
|||
setBrand(brand);
|
||||
}
|
||||
|
||||
if (systemNamespaces) {
|
||||
const namespace = (systemNamespaces.value || systemNamespaces.default)?.split(',');
|
||||
|
||||
commit('setSystemNamespaces', namespace);
|
||||
}
|
||||
|
||||
commit('managementChanged', {
|
||||
ready: true,
|
||||
isMultiCluster,
|
||||
|
|
|
|||
Loading…
Reference in New Issue