diff --git a/assets/translations/en-us.yaml b/assets/translations/en-us.yaml index a49c37fbf5..ea1c428b8c 100644 --- a/assets/translations/en-us.yaml +++ b/assets/translations/en-us.yaml @@ -4,6 +4,7 @@ locale: generic: customize: Customize + comingSoon: Coming Soon header: backToRancher: "← Back to Rancher" diff --git a/components/ResourceYaml.vue b/components/ResourceYaml.vue index 3b1b41dc98..1b04a5ff11 100644 --- a/components/ResourceYaml.vue +++ b/components/ResourceYaml.vue @@ -10,8 +10,6 @@ import { _UNFLAG, } from '@/config/query-params'; -// import { mapPref, DIFF } from '@/store/prefs'; - export default { components: { Footer, diff --git a/components/form/LabeledSelect.vue b/components/form/LabeledSelect.vue index 98c675af17..442dd0af0e 100644 --- a/components/form/LabeledSelect.vue +++ b/components/form/LabeledSelect.vue @@ -27,9 +27,17 @@ export default { type: Boolean, default: false }, + optionKey: { + type: String, + default: null + }, optionLabel: { type: String, default: 'label' + }, + optionKey: { + type: String, + default: null } }, data() { diff --git a/components/form/Labels.vue b/components/form/Labels.vue index 34e0c982f9..95b481f3cf 100644 --- a/components/form/Labels.vue +++ b/components/form/Labels.vue @@ -20,6 +20,11 @@ export default { }, computed: { + containerClass() { + return this.displaySideBySide + ? 'row' + : ''; + }, sectionClass() { return this.displaySideBySide ? 'col span-6' @@ -39,7 +44,7 @@ export default { }; diff --git a/edit/workload/Scheduling.vue b/edit/workload/Scheduling.vue index b534fe9868..7329c42908 100644 --- a/edit/workload/Scheduling.vue +++ b/edit/workload/Scheduling.vue @@ -1,14 +1,13 @@ - - - - diff --git a/edit/workload/index.vue b/edit/workload/index.vue index f258578548..8c5d67ac72 100644 --- a/edit/workload/index.vue +++ b/edit/workload/index.vue @@ -22,6 +22,23 @@ import WorkloadPorts from '@/edit/workload/WorkloadPorts'; import { defaultAsyncData } from '@/components/ResourceDetail.vue'; import { _EDIT } from '@/config/query-params'; +const workloadTypeOptions = [ + { value: WORKLOAD_TYPES.DEPLOYMENT, label: 'Deployment' }, + + { value: WORKLOAD_TYPES.DAEMON_SET, label: 'Daemon Set' }, + + { value: WORKLOAD_TYPES.STATEFUL_SET, label: 'Stateful Set' }, + + { value: WORKLOAD_TYPES.REPLICA_SET, label: 'Replica Set' }, + + { value: WORKLOAD_TYPES.JOB, label: 'Job' }, + + { value: WORKLOAD_TYPES.CRON_JOB, label: 'Cron Job' }, + + { value: WORKLOAD_TYPES.REPLICATION_CONTROLLER, label: 'Replication Controller' } + +]; + export default { name: 'CruWorkload', components: { @@ -39,15 +56,17 @@ export default { Networking, Footer, Job, - WorkloadPorts + WorkloadPorts, }, mixins: [CreateEditView, LoadDeps], + props: { value: { type: Object, required: true, }, + mode: { type: String, default: 'create' @@ -55,23 +74,6 @@ export default { }, data() { - const typeOpts = []; - const workloadMap = { - [WORKLOAD_TYPES.DEPLOYMENT]: 'Deployment', - [WORKLOAD_TYPES.DAEMON_SET]: 'Daemon Set', - [WORKLOAD_TYPES.STATEFUL_SET]: 'Stateful Set', - [WORKLOAD_TYPES.REPLICA_SET]: 'Replica Set', - [WORKLOAD_TYPES.JOB]: 'Job', - [WORKLOAD_TYPES.CRON_JOB]: 'Cron Job', - [WORKLOAD_TYPES.REPLICATION_CONTROLLER]: 'Replication Controller' - }; - - for (const key in workloadMap) { - typeOpts.push({ value: key, label: workloadMap[key] }); - } - - const selectNode = false; - let type = this.value._type || this.value.type || WORKLOAD_TYPES.DEPLOYMENT; if (type === 'workload') { @@ -90,45 +92,62 @@ export default { } return { - selectNode, spec, type, - typeOpts, - allConfigMaps: null, - allSecrets: null, - allNodes: null, - showTabs: false + workloadTypeOptions, + allConfigMaps: null, + allSecrets: null, + allNodes: null, + showTabs: false, }; }, computed: { - schema() { - return this.$store.getters['cluster/schemaFor']( this.type ); + + isEdit() { + return this.mode === _EDIT; + }, + + isJob() { + return this.type === WORKLOAD_TYPES.JOB || this.isCronJob; + }, + + isCronJob() { + return this.type === WORKLOAD_TYPES.CRON_JOB; + }, + + isReplicable() { + return (this.type === WORKLOAD_TYPES.DEPLOYMENT || this.type === WORKLOAD_TYPES.REPLICA_SET || this.type === WORKLOAD_TYPES.REPLICATION_CONTROLLER || this.type === WORKLOAD_TYPES.STATEFUL_SET); + }, + + // if this is a cronjob, grab pod spec from within job template spec + podTemplateSpec: { + get() { + return this.isCronJob ? this.spec.jobTemplate.spec.template.spec : this.spec.template.spec; + }, + set(neu) { + if (this.isJob) { + this.$set(this.spec.jobTemplate.spec.template, 'spec', neu); + } else { + this.$set(this.spec.template, 'spec', neu); + } + } }, container: { get() { - let template = this.spec.template; - - if (this.isCronJob) { - template = this.spec.jobTemplate.spec.template; - } - const { containers } = template.spec; + const { containers } = this.podTemplateSpec; if (!containers) { - this.$set(template.spec, 'containers', [{ name: this.value.metadata.name }]); + this.$set(this.podTemplateSpec, 'containers', [{ name: this.value.metadata.name }]); } - return template.spec.containers[0]; + // TODO account for multiple containers (sidecar) + return this.podTemplateSpec.containers[0]; }, set(neu) { - let template = this.spec.template; - - if (this.isCronJob) { - template = this.spec.jobTemplate.spec.template; - } - this.$set(template.spec.containers, 0, { ...neu, name: this.value.metadata.name }); + this.$set(this.podTemplateSpec.containers, 0, { ...neu, name: this.value.metadata.name }); } }, @@ -150,18 +169,11 @@ export default { } }, - canReplicate() { - return (this.type === WORKLOAD_TYPES.DEPLOYMENT || this.type === WORKLOAD_TYPES.REPLICA_SET || this.type === WORKLOAD_TYPES.REPLICATION_CONTROLLER || this.type === WORKLOAD_TYPES.STATEFUL_SET); - }, - - isJob() { - return this.type === WORKLOAD_TYPES.JOB || this.isCronJob; - }, - - isCronJob() { - return this.type === WORKLOAD_TYPES.CRON_JOB; + schema() { + return this.$store.getters['cluster/schemaFor']( this.type ); }, + // show cron schedule in human-readable format cronLabel() { const { schedule } = this.spec; @@ -182,9 +194,6 @@ export default { return { 'workload.user.cattle.io/workloadselector': `${ 'deployment' }-${ this.value.metadata.namespace }-${ this.value.metadata.name }` }; }, - isEdit() { - return this.mode === _EDIT; - }, }, watch: { @@ -198,7 +207,7 @@ export default { this.$set(template.spec, 'restartPolicy', restartPolicy); - if (!this.canReplicate) { + if (!this.isReplicable) { delete this.spec.replicas; } @@ -273,7 +282,7 @@ export default { @@ -288,7 +297,7 @@ export default { {{ cronLabel }} -