From 05d719477e57350348e22f1d904dedb1bc7520a4 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Fri, 3 Apr 2020 19:18:06 -0700 Subject: [PATCH] Filter out volumes that don't match the chosen namespace --- ui/app/controllers/csi/volumes/index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ui/app/controllers/csi/volumes/index.js b/ui/app/controllers/csi/volumes/index.js index 27b30b22d..4a634687a 100644 --- a/ui/app/controllers/csi/volumes/index.js +++ b/ui/app/controllers/csi/volumes/index.js @@ -1,4 +1,5 @@ import { inject as service } from '@ember/service'; +import { computed } from '@ember/object'; import { alias, readOnly } from '@ember/object/computed'; import Controller, { inject as controller } from '@ember/controller'; import SortableFactory from 'nomad-ui/mixins/sortable-factory'; @@ -30,7 +31,23 @@ export default Controller.extend( sortProperty: 'id', sortDescending: false, - listToSort: alias('model'), + /** + Visible volumes are those that match the selected namespace + */ + visibleVolumes: computed('model.[]', 'model.@each.parent', function() { + if (!this.model) return []; + + // Namespace related properties are ommitted from the dependent keys + // due to a prop invalidation bug caused by region switching. + const hasNamespaces = this.get('system.namespaces.length'); + const activeNamespace = this.get('system.activeNamespace.id') || 'default'; + + return this.model + .compact() + .filter(volume => !hasNamespaces || volume.get('namespace.id') === activeNamespace); + }), + + listToSort: alias('visibleVolumes'), sortedVolumes: alias('listSorted'), // TODO: Remove once this page gets search capability