Merge pull request #2344 from codyrancher/constraint-clone

Enable models to override their cleanForNew method
This commit is contained in:
Richard Cox 2021-02-19 11:35:26 +00:00 committed by GitHub
commit b0df45baa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -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);

View File

@ -1137,6 +1137,12 @@ export default {
};
},
cleanForNew() {
return () => {
cleanForNew(this);
};
},
yamlForSave() {
return (yaml) => {
try {