mirror of https://github.com/rancher/ui.git
Clone Catalog
This commit is contained in:
parent
a788ee6a32
commit
9c2e8bbbd1
|
|
@ -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;
|
||||||
|
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -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'),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue