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>
|
<script>
|
||||||
import { cleanForNew } from '@/plugins/steve/normalize';
|
|
||||||
import CreateEditView from '@/mixins/create-edit-view/impl';
|
import CreateEditView from '@/mixins/create-edit-view/impl';
|
||||||
import Loading from '@/components/Loading';
|
import Loading from '@/components/Loading';
|
||||||
import ResourceYaml from '@/components/ResourceYaml';
|
import ResourceYaml from '@/components/ResourceYaml';
|
||||||
|
|
@ -135,7 +134,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( realMode === _CLONE || realMode === _STAGE ) {
|
if ( realMode === _CLONE || realMode === _STAGE ) {
|
||||||
cleanForNew(model);
|
model.cleanForNew();
|
||||||
yaml = model.cleanYaml(yaml, realMode);
|
yaml = model.cleanYaml(yaml, realMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import jsyaml from 'js-yaml';
|
import jsyaml from 'js-yaml';
|
||||||
|
import { cleanForNew } from '@/plugins/steve/normalize';
|
||||||
|
|
||||||
export const ENFORCEMENT_ACTION_VALUES = {
|
export const ENFORCEMENT_ACTION_VALUES = {
|
||||||
DENY: 'deny',
|
DENY: 'deny',
|
||||||
|
|
@ -23,6 +24,15 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cleanForNew() {
|
||||||
|
return () => {
|
||||||
|
cleanForNew(this);
|
||||||
|
if (this.constraint) {
|
||||||
|
delete this.constraint;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
saveYaml() {
|
saveYaml() {
|
||||||
return (yaml) => {
|
return (yaml) => {
|
||||||
const parsed = jsyaml.safeLoad(yaml);
|
const parsed = jsyaml.safeLoad(yaml);
|
||||||
|
|
|
||||||
|
|
@ -1137,6 +1137,12 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cleanForNew() {
|
||||||
|
return () => {
|
||||||
|
cleanForNew(this);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
yamlForSave() {
|
yamlForSave() {
|
||||||
return (yaml) => {
|
return (yaml) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue