diff --git a/lib/shared/addon/components/confirm-delete/component.js b/lib/shared/addon/components/confirm-delete/component.js index acb1614a1..b0a19c328 100644 --- a/lib/shared/addon/components/confirm-delete/component.js +++ b/lib/shared/addon/components/confirm-delete/component.js @@ -8,6 +8,12 @@ import layout from './template'; import { eachLimit } from 'async'; import C from 'ui/utils/constants'; +function hasSomeOfResourceType(resourceType) { + console.log(get(this, 'resources')); + + return get(this, 'resources') + .some((resource) => get(resource, 'type') === resourceType); +} export default Component.extend(ModalBase, { settings: service(), @@ -101,4 +107,31 @@ export default Component.extend(ModalBase, { return get(namespaces, 'length') > 0; }), + hasNamespaceResourceType: computed('resources', function() { + return hasSomeOfResourceType.call(this, C.RESOURCE_TYPES.NAMESPACE); + }), + + hasProjectResourceType: computed('resources', function() { + return hasSomeOfResourceType.call(this, C.RESOURCE_TYPES.PROJECT); + }), + + hasClusterResourceType: computed('resources', function() { + return hasSomeOfResourceType.call(this, C.RESOURCE_TYPES.CLUSTER); + }), + + resourceType: computed('resources', function() { + if (get(this, 'hasNamespaceResourceType')) { + return C.RESOURCE_TYPES.NAMESPACE; + } + + if (get(this, 'hasProjectResourceType')) { + return C.RESOURCE_TYPES.PROJECT; + } + + if (get(this, 'hasClusterResourceType')) { + return C.RESOURCE_TYPES.CLUSTER; + } + + return null; + }), }); diff --git a/lib/shared/addon/components/confirm-delete/template.hbs b/lib/shared/addon/components/confirm-delete/template.hbs index 3e1c425cd..26bd47c8e 100644 --- a/lib/shared/addon/components/confirm-delete/template.hbs +++ b/lib/shared/addon/components/confirm-delete/template.hbs @@ -1,6 +1,14 @@