From 0bb2d4e994cdad93c6190e37931866813c7d450d Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Thu, 12 Jul 2018 12:02:15 -0700 Subject: [PATCH] config-maps clone --- .../project/config-maps/new/controller.js | 3 +++ app/authenticated/project/config-maps/new/route.js | 9 ++++++++- app/models/configmap.js | 10 +++++++++- .../addon/mixins/cattle-transitioning-resource.js | 3 ++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/authenticated/project/config-maps/new/controller.js b/app/authenticated/project/config-maps/new/controller.js index 78ea6074b..5de359f64 100644 --- a/app/authenticated/project/config-maps/new/controller.js +++ b/app/authenticated/project/config-maps/new/controller.js @@ -1,6 +1,9 @@ import Controller from '@ember/controller'; export default Controller.extend({ + queryParams: ['id'], + id: null, + actions: { back() { diff --git a/app/authenticated/project/config-maps/new/route.js b/app/authenticated/project/config-maps/new/route.js index d6aa70856..53eef887e 100644 --- a/app/authenticated/project/config-maps/new/route.js +++ b/app/authenticated/project/config-maps/new/route.js @@ -1,7 +1,14 @@ import Route from '@ember/routing/route'; +import { get } from '@ember/object'; export default Route.extend({ - model(/* params, transition*/) { + model(params/* , transition */) { + + if (get(params, 'id')) { + const record = get(this, 'store').getById('configMap', get(params, 'id')); + + return record.cloneForNew(); + } return this.get('store').createRecord({ type: 'configMap' }); diff --git a/app/models/configmap.js b/app/models/configmap.js index 10a531606..8ababcf9c 100644 --- a/app/models/configmap.js +++ b/app/models/configmap.js @@ -17,7 +17,8 @@ export default Resource.extend({ router: service(), clusterStore: service(), - state: 'active', + state: 'active', + canClone: true, actions: { edit() { @@ -25,6 +26,13 @@ export default Resource.extend({ get(this, 'router').transitionTo('authenticated.project.config-maps.detail.edit', get(this, 'id')); }, + + clone() { + + get(this, 'router').transitionTo('authenticated.project.config-maps.new', get(this, 'projectId'), { queryParams: { id: get(this, 'id') } }); + + } + }, }); diff --git a/lib/shared/addon/mixins/cattle-transitioning-resource.js b/lib/shared/addon/mixins/cattle-transitioning-resource.js index 421f4a3a7..ca71d57e4 100644 --- a/lib/shared/addon/mixins/cattle-transitioning-resource.js +++ b/lib/shared/addon/mixins/cattle-transitioning-resource.js @@ -622,9 +622,10 @@ export default Mixin.create({ var copy = this.clone(); - delete copy.id; delete copy.actionLinks; + delete copy.id; delete copy.links; + delete copy.name; delete copy.uuid; return copy;