mirror of https://github.com/rancher/dashboard.git
Merge pull request #2344 from codyrancher/constraint-clone
Enable models to override their cleanForNew method
This commit is contained in:
commit
b0df45baa9
|
|
@ -1,5 +1,4 @@
|
|||
<script>
|
||||
import { cleanForNew } from '@/plugins/steve/normalize';
|
||||
import CreateEditView from '@/mixins/create-edit-view/impl';
|
||||
import Loading from '@/components/Loading';
|
||||
import ResourceYaml from '@/components/ResourceYaml';
|
||||
|
|
@ -135,7 +134,7 @@ export default {
|
|||
}
|
||||
|
||||
if ( realMode === _CLONE || realMode === _STAGE ) {
|
||||
cleanForNew(model);
|
||||
model.cleanForNew();
|
||||
yaml = model.cleanYaml(yaml, realMode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import jsyaml from 'js-yaml';
|
||||
import { cleanForNew } from '@/plugins/steve/normalize';
|
||||
|
||||
export const ENFORCEMENT_ACTION_VALUES = {
|
||||
DENY: 'deny',
|
||||
|
|
@ -23,6 +24,15 @@ export default {
|
|||
};
|
||||
},
|
||||
|
||||
cleanForNew() {
|
||||
return () => {
|
||||
cleanForNew(this);
|
||||
if (this.constraint) {
|
||||
delete this.constraint;
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
saveYaml() {
|
||||
return (yaml) => {
|
||||
const parsed = jsyaml.safeLoad(yaml);
|
||||
|
|
|
|||
|
|
@ -1137,6 +1137,12 @@ export default {
|
|||
};
|
||||
},
|
||||
|
||||
cleanForNew() {
|
||||
return () => {
|
||||
cleanForNew(this);
|
||||
};
|
||||
},
|
||||
|
||||
yamlForSave() {
|
||||
return (yaml) => {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue