From e93b6f08cba8ff2032d0445497b4178c2f652d56 Mon Sep 17 00:00:00 2001 From: Cody Jackson Date: Thu, 16 Apr 2020 12:17:55 -0700 Subject: [PATCH 1/5] Updating configMaps to be better inline with mocks rancher/dashboard#265 --- assets/translations/en-us.yaml | 1 + components/form/Labels.vue | 7 +- config/table-headers.js | 8 ++ detail/configmap.vue | 131 +++++++++++++++++++++------------ edit/configmap.vue | 8 +- 5 files changed, 103 insertions(+), 52 deletions(-) diff --git a/assets/translations/en-us.yaml b/assets/translations/en-us.yaml index a49c37fbf5..2bc6cbda92 100644 --- a/assets/translations/en-us.yaml +++ b/assets/translations/en-us.yaml @@ -4,6 +4,7 @@ locale: generic: customize: Customize + commingSoon: Comming Soon header: backToRancher: "← Back to Rancher" 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 { }; From c5052b7cb72c6ce79aa2877308ec75d49154d6f4 Mon Sep 17 00:00:00 2001 From: Cody Jackson Date: Thu, 16 Apr 2020 13:35:34 -0700 Subject: [PATCH 2/5] Fixing warnings This fixes runtime and lint warnings. It also makes the linter treat warnings as errors now so we'll stop checking in code that has warnings. If you want to avoid prs with warnings consider adding a 'yarn lint' or 'yarn build' to .git/hooks/pre-push. --- components/ResourceYaml.vue | 2 -- components/form/LabeledSelect.vue | 4 ++++ components/form/NameNsDescription.vue | 2 +- package.json | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/ResourceYaml.vue b/components/ResourceYaml.vue index 274fbc8e15..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..7cdd2d58a9 100644 --- a/components/form/LabeledSelect.vue +++ b/components/form/LabeledSelect.vue @@ -27,6 +27,10 @@ export default { type: Boolean, default: false }, + optionKey: { + type: String, + default: null + }, optionLabel: { type: String, default: 'label' diff --git a/components/form/NameNsDescription.vue b/components/form/NameNsDescription.vue index e32d40257c..e08ddd5a01 100644 --- a/components/form/NameNsDescription.vue +++ b/components/form/NameNsDescription.vue @@ -182,7 +182,7 @@ export default { v-model="name" label="Name" :disabled="nameDisabled" - :mode="nameMode" + :mode="mode" :min-height="30" /> diff --git a/package.json b/package.json index eced0d1004..6d6c560762 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "node": ">=10" }, "scripts": { - "lint": "./node_modules/.bin/eslint --ext .js,.vue .", + "lint": "./node_modules/.bin/eslint --max-warnings 0 --ext .js,.vue .", "test": "./node_modules/.bin/nyc ava --serial --verbose", "nuxt": "./node_modules/.bin/nuxt", "dev": "./node_modules/.bin/nuxt dev", From fb26c1b7caae0f99cbfe4464ba8d22610a299486 Mon Sep 17 00:00:00 2001 From: Nancy Butler <42977925+mantis-toboggan-md@users.noreply.github.com> Date: Fri, 17 Apr 2020 13:41:13 -0700 Subject: [PATCH 3/5] add description to WL detail refactor nodeAffinity in workload create --- components/form/LabeledSelect.vue | 4 + .../form/NodeAffinity/NodeSelectorTerm.vue | 184 +++++++++++++++++ components/form/NodeAffinity/index.vue | 101 ++++++++++ detail/workload.vue | 6 + edit/workload/Scheduling.vue | 67 ++---- edit/workload/Selectors.vue | 190 ------------------ edit/workload/index.vue | 132 ++++++------ models/workload.js | 3 +- 8 files changed, 382 insertions(+), 305 deletions(-) create mode 100644 components/form/NodeAffinity/NodeSelectorTerm.vue create mode 100644 components/form/NodeAffinity/index.vue delete mode 100644 edit/workload/Selectors.vue diff --git a/components/form/LabeledSelect.vue b/components/form/LabeledSelect.vue index 98c675af17..3270fe7fe6 100644 --- a/components/form/LabeledSelect.vue +++ b/components/form/LabeledSelect.vue @@ -30,6 +30,10 @@ export default { optionLabel: { type: String, default: 'label' + }, + optionKey: { + type: String, + default: null } }, data() { diff --git a/components/form/NodeAffinity/NodeSelectorTerm.vue b/components/form/NodeAffinity/NodeSelectorTerm.vue new file mode 100644 index 0000000000..aaaf52d57e --- /dev/null +++ b/components/form/NodeAffinity/NodeSelectorTerm.vue @@ -0,0 +1,184 @@ + + + + + diff --git a/components/form/NodeAffinity/index.vue b/components/form/NodeAffinity/index.vue new file mode 100644 index 0000000000..d7f1e43c6b --- /dev/null +++ b/components/form/NodeAffinity/index.vue @@ -0,0 +1,101 @@ + + + + + diff --git a/detail/workload.vue b/detail/workload.vue index 249b7fd970..ebbe5d120e 100644 --- a/detail/workload.vue +++ b/detail/workload.vue @@ -9,6 +9,7 @@ import Date from '@/components/formatter/Date'; import LoadDeps from '@/mixins/load-deps'; import { allHash } from '@/utils/promise'; import WorkloadPorts from '@/edit/workload/WorkloadPorts'; +import { DESCRIPTION } from '@/config/labels-annotations'; export default { components: { @@ -126,10 +127,15 @@ export default { detailTopColumns() { return [ + { title: 'Namespace', content: get(this.value, 'metadata.namespace') }, + { + title: 'Description', + content: this.value?.metadata?.annotations[DESCRIPTION] + }, { title: 'Image', content: this.container.image 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 }} -