Clone Catalog

This commit is contained in:
Westly Wright 2018-07-11 15:27:53 -07:00
parent a788ee6a32
commit 9c2e8bbbd1
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
2 changed files with 53 additions and 6 deletions

View File

@ -3,6 +3,7 @@ import { inject as service } from '@ember/service';
import { computed } from '@ember/object'; import { computed } from '@ember/object';
import { get } from '@ember/object'; import { get } from '@ember/object';
import { ucFirst } from 'shared/utils/util'; import { ucFirst } from 'shared/utils/util';
import C from 'ui/utils/constants';
export default Resource.extend({ export default Resource.extend({
displayKind: computed('kind', function() { displayKind: computed('kind', function() {
@ -10,6 +11,17 @@ export default Resource.extend({
return ucFirst(get(this, 'kind')); return ucFirst(get(this, 'kind'));
}), }),
canClone: computed('actions.clone', function() {
const name = get(this, 'name');
const catalogNames = get(C, 'CATALOG');
const builtIn = [get(catalogNames, 'LIBRARY_KEY'), get(catalogNames, 'HELM_STABLE_KEY'), get(catalogNames, 'HELM_INCUBATOR_KEY')];
return !builtIn.includes(name);
}),
modalService: service('modal'), modalService: service('modal'),
actions: { actions: {
@ -17,7 +29,29 @@ export default Resource.extend({
this.get('modalService').toggleModal('modal-edit-catalog', this); this.get('modalService').toggleModal('modal-edit-catalog', this);
},
clone() {
debugger;
const clone = this.cloneForNew();
this.get('modalService').toggleModal('modal-edit-catalog', clone);
} }
}, },
cloneForNew() {
var copy = this.clone();
delete copy.id;
delete copy.name;
delete copy.actionLinks;
delete copy.links;
delete copy.uuid;
return copy;
},
}); });

View File

@ -8,6 +8,10 @@ import {
} from '@ember/object'; } from '@ember/object';
import { later } from '@ember/runloop'; import { later } from '@ember/runloop';
const kindChoices = [
{translationKey: 'catalogSettings.more.kind.helm', value: 'helm'},
];
export default Component.extend(ModalBase, NewOrEdit, { export default Component.extend(ModalBase, NewOrEdit, {
layout, layout,
classNames: ['medium-modal'], classNames: ['medium-modal'],
@ -16,12 +20,21 @@ export default Component.extend(ModalBase, NewOrEdit, {
allNamespaces: null, allNamespaces: null,
allProjects: null, allProjects: null,
kindChoices: [ init() {
{ this._super(...arguments);
translationKey: 'catalogSettings.more.kind.helm',
value: 'helm' var orig = this.get('originalModel');
}, var clone = orig.clone();
],
set(clone, 'kind', 'helm');
set(this, 'model', clone);
},
doneSaving: function() {
this.send('cancel');
},
kindChoices: kindChoices,
originalModel: alias('modalService.modalOpts'), originalModel: alias('modalService.modalOpts'),
editing: notEmpty('originalModel.id'), editing: notEmpty('originalModel.id'),