diff --git a/app/models/catalog.js b/app/models/catalog.js index 27f748162..2cf8f961b 100644 --- a/app/models/catalog.js +++ b/app/models/catalog.js @@ -12,6 +12,12 @@ export default Resource.extend({ return ucFirst(get(this, 'kind')); }), + combinedState: computed('id', function() { + if ( !get(this, 'id') ) { + return 'disabled'; + } + }), + canClone: computed('actions.clone', function() { const name = get(this, 'name'); const catalogNames = get(C, 'CATALOG'); @@ -23,15 +29,27 @@ export default Resource.extend({ availableActions: computed('actionLinks.{refresh}', function() { let a = get(this, 'actionLinks') || {}; - return [{ - enabled: !!a.refresh, - label: 'catalogPage.index.refreshBtn', - icon: 'icon icon-refresh', - action: 'refresh' - }]; + return [ + { + action: 'enable', + icon: 'icon icon-plus-circle', + enabled: !this.id, + label: 'generic.enable', + }, + { + enabled: !!a.refresh, + label: 'catalogPage.index.refreshBtn', + icon: 'icon icon-refresh', + action: 'refresh' + } + ]; }), actions: { + enable() { + this.save(); + }, + edit() { get(this, 'modalService').toggleModal('modal-edit-catalog', { model: this, diff --git a/lib/global-admin/addon/catalog/controller.js b/lib/global-admin/addon/catalog/controller.js index 834d3313a..e12d4f81a 100644 --- a/lib/global-admin/addon/catalog/controller.js +++ b/lib/global-admin/addon/catalog/controller.js @@ -15,130 +15,6 @@ export default Controller.extend({ togglingLibrary: false, actions: { - disableLibrary() { - if ( get(this, 'togglingLibrary') ) { - return; - } - - set(this, 'togglingLibrary', true); - get(this, 'library').delete().catch((err) => { - get(this, 'growl').fromError('Error removing Library', err); - }).finally(() => { - set(this, 'togglingLibrary', false); - this.send('refresh'); - }); - }, - enableLibrary() { - if ( get(this, 'togglingLibrary') ) { - return; - } - - set(this, 'togglingLibrary', true); - get(this, 'globalStore').createRecord({ - type: 'catalog', - name: C.CATALOG.LIBRARY_KEY, - url: C.CATALOG.LIBRARY_VALUE, - branch: C.CATALOG.DEFAULT_BRANCH, - kind: 'helm', - }).save().catch((err) => { - get(this, 'growl').fromError('Error saving Library', err); - }) - .finally(() => { - set(this, 'togglingLibrary', false); - this.send('refresh'); - }); - }, - - disableHelmIncubator() { - if ( get(this, 'togglingHelmIncubator') ) { - return; - } - - set(this, 'togglingHelmIncubator', true); - get(this, 'helmIncubator').delete().catch((err) => { - get(this, 'growl').fromError('Error removing Incubator', err); - }).finally(() => { - set(this, 'togglingHelmIncubator', false); - this.send('refresh'); - }); - }, - enableHelmIncubator() { - if ( get(this, 'togglingHelmIncubator') ) { - return; - } - - set(this, 'togglingHelmIncubator', true); - get(this, 'globalStore').createRecord({ - type: 'catalog', - name: C.CATALOG.HELM_INCUBATOR_KEY, - url: C.CATALOG.HELM_INCUBATOR_VALUE, - branch: C.CATALOG.DEFAULT_BRANCH, - kind: 'helm', - }).save().catch((err) => { - get(this, 'growl').fromError('Error saving Incubator', err); - }) - .finally(() => { - set(this, 'togglingHelmIncubator', false); - this.send('refresh'); - }); - }, - - disableHelmStable() { - if ( get(this, 'togglingHelmStable') ) { - return; - } - - set(this, 'togglingHelmStable', true); - get(this, 'helmStable').delete().catch((err) => { - get(this, 'growl').fromError('Error removing Stable', err); - }).finally(() => { - set(this, 'togglingHelmStable', false); - this.send('refresh'); - }); - }, - enableHelmStable() { - if ( get(this, 'togglingHelmStable') ) { - return; - } - - set(this, 'togglingHelmStable', true); - get(this, 'globalStore').createRecord({ - type: 'catalog', - name: C.CATALOG.HELM_STABLE_KEY, - url: C.CATALOG.HELM_STABLE_VALUE, - branch: C.CATALOG.DEFAULT_BRANCH, - kind: 'helm', - }).save().catch((err) => { - get(this, 'growl').fromError('Error saving Stable', err); - }) - .finally(() => { - set(this, 'togglingHelmStable', false); - this.send('refresh'); - }); - }, - - enableCommunity() { - get(this, 'globalStore').createRecord({ - type: 'catalog', - name: C.CATALOG.COMMUNITY_KEY, - url: C.CATALOG.COMMUNITY_VALUE, - branch: C.CATALOG.COMMUNITY_BRANCH, - }).save().catch((err) => { - get(this, 'growl').fromError('Error saving Community', err); - }) - .finally(() => { - this.send('refresh', this) - }); - }, - - disableCommunity() { - get(this, 'stdCommunity').delete().catch((err) => { - get(this, 'growl').fromError('Error removing Community', err); - }).finally(() => { - this.send('refresh', this) - }); - }, - add() { const record = get(this, 'globalStore').createRecord({ type: 'catalog', @@ -152,62 +28,4 @@ export default Controller.extend({ }); }, }, - - library: computed('model.@each.{name,url,branch}', function() { - return this.findMatch( - C.CATALOG.LIBRARY_KEY, - C.CATALOG.LIBRARY_VALUE - ); - }), - - helmStable: computed('model.@each.{name,url,branch}', function() { - return this.findMatch( - C.CATALOG.HELM_STABLE_KEY, - C.CATALOG.HELM_STABLE_VALUE, - ); - }), - - helmIncubator: computed('model.@each.{name,url,branch}', function() { - return this.findMatch( - C.CATALOG.HELM_INCUBATOR_KEY, - C.CATALOG.HELM_INCUBATOR_VALUE, - ); - }), - - custom: computed('library', 'helmStable', 'helmIncubator', function() { - const hide = [ - get(this, 'library'), - get(this, 'helmStable'), - get(this, 'helmIncubator'), - ]; - - return get(this, 'model').filter((x) => !hide.includes(x)); - }), - - customLibrary: computed('custom.@each.{name}', function() { - return get(this, 'custom').findBy('name', 'library') - }), - - customHelmStable: computed('custom.@each.{name}', function() { - return get(this, 'custom').findBy('name', 'helm') - }), - - customHelmIncubator: computed('custom.@each.{name}', function() { - return get(this, 'custom').findBy('name', 'helm-incubator') - }), - - findMatch(name, url, branch) { - const entry = get(this, 'model').findBy('name', name); - - if ( !entry ) { - return null; - } - - if ( get(entry, 'url') === url && - (!branch || get(entry, 'branch') === branch) - ) { - return entry; - } - }, - }); diff --git a/lib/global-admin/addon/catalog/template.hbs b/lib/global-admin/addon/catalog/template.hbs index 70e0856a5..a3754ec7f 100644 --- a/lib/global-admin/addon/catalog/template.hbs +++ b/lib/global-admin/addon/catalog/template.hbs @@ -8,92 +8,6 @@
- {{t 'catalogSettings.library.detail' appName=settings.appName}} -
- {{#if library.showTransitioningMessage}} -{{uc-first library.transitioningMessage}}
- {{t 'catalogSettings.helm.stable.detail'}} -
- {{#if helmStable.showTransitioningMessage}} -{{uc-first helmStable.transitioningMessage}}
- {{t 'catalogSettings.helm.incubator.detail'}} -
- {{#if helmIncubator.showTransitioningMessage}} -{{uc-first helmIncubator.transitioningMessage}}
{{t 'catalogSettings.more.helpText.header' htmlSafe=true}}
-