Skip to content

Commit

Permalink
Filter out volumes that don't match the chosen namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
DingoEatingFuzz committed Apr 4, 2020
1 parent d74a6c9 commit 05d7194
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion 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';
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 05d7194

Please sign in to comment.