@rancher/shell 3.0.4 → 3.0.5-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/assets/styles/base/_basic.scss +6 -0
  2. package/assets/styles/global/_button.scss +1 -0
  3. package/assets/translations/en-us.yaml +37 -3
  4. package/cloud-credential/aws.vue +2 -0
  5. package/components/AssignTo.vue +25 -11
  6. package/components/AsyncButton.vue +24 -7
  7. package/components/BannerGraphic.vue +1 -0
  8. package/components/CommunityLinks.vue +3 -3
  9. package/components/CopyToClipboardText.vue +2 -1
  10. package/components/DetailText.vue +5 -0
  11. package/components/DisableAuthProviderModal.vue +1 -0
  12. package/components/ExplorerMembers.vue +1 -1
  13. package/components/ExplorerProjectsNamespaces.vue +56 -14
  14. package/components/LandingPagePreference.vue +5 -3
  15. package/components/LocaleSelector.vue +38 -94
  16. package/components/ModalWithCard.vue +1 -0
  17. package/components/MoveModal.vue +1 -0
  18. package/components/PromptRemove.vue +1 -0
  19. package/components/PromptRestore.vue +1 -0
  20. package/components/ResourceCancelModal.vue +1 -0
  21. package/components/SortableTable/index.vue +10 -11
  22. package/components/__tests__/AsyncButton.test.ts +2 -2
  23. package/components/auth/__tests__/RoleDetailEdit.test.ts +3 -2
  24. package/components/form/ArrayList.vue +66 -54
  25. package/components/form/Command.vue +6 -15
  26. package/components/form/EnvVars.vue +15 -8
  27. package/components/form/HealthCheck.vue +3 -3
  28. package/components/form/HookOption.vue +11 -16
  29. package/components/form/LabeledSelect.vue +2 -1
  30. package/components/form/LifecycleHooks.vue +3 -3
  31. package/components/form/MatchExpressions.vue +10 -7
  32. package/components/form/NameNsDescription.vue +123 -103
  33. package/components/form/Networking.vue +20 -12
  34. package/components/form/NodeAffinity.vue +31 -23
  35. package/components/form/NodeScheduling.vue +13 -3
  36. package/components/form/PodAffinity.vue +43 -43
  37. package/components/form/Probe.vue +67 -66
  38. package/components/form/ResourceQuota/Project.vue +5 -1
  39. package/components/form/ResourceSelector.vue +7 -9
  40. package/components/form/SSHKnownHosts/KnownHostsEditDialog.vue +6 -3
  41. package/components/form/SSHKnownHosts/__tests__/KnownHostsEditDialog.test.ts +12 -1
  42. package/components/form/SSHKnownHosts/index.vue +16 -2
  43. package/components/form/Security.vue +54 -56
  44. package/components/form/Select.vue +31 -6
  45. package/components/form/ShellInput.vue +5 -1
  46. package/components/form/Tolerations.vue +5 -1
  47. package/components/form/ValueFromResource.vue +134 -121
  48. package/components/form/WorkloadPorts.vue +18 -18
  49. package/components/form/__tests__/ArrayList.test.ts +3 -0
  50. package/components/form/__tests__/MatchExpressions.test.ts +12 -12
  51. package/components/form/__tests__/NameNsDescription.test.ts +115 -14
  52. package/components/form/__tests__/Probe.test.ts +12 -8
  53. package/components/form/__tests__/SSHKnownHosts.test.ts +11 -0
  54. package/components/form/__tests__/Select.test.ts +37 -0
  55. package/components/formatter/InternalExternalIP.vue +2 -0
  56. package/components/formatter/SecretData.vue +20 -7
  57. package/components/nav/Group.vue +15 -1
  58. package/components/nav/Header.vue +1 -0
  59. package/components/nav/Type.vue +12 -1
  60. package/components/templates/blank.vue +4 -1
  61. package/components/templates/default.vue +2 -0
  62. package/components/templates/home.vue +4 -1
  63. package/components/templates/plain.vue +4 -1
  64. package/composables/useRuntimeFlag.ts +29 -0
  65. package/config/router/routes.js +20 -13
  66. package/core/types.ts +5 -0
  67. package/dialog/AddCustomBadgeDialog.vue +1 -0
  68. package/dialog/DeactivateDriverDialog.vue +1 -0
  69. package/dialog/ForceMachineRemoveDialog.vue +4 -1
  70. package/edit/__tests__/monitoring.coreos.com.prometheusrule.test.ts +16 -3
  71. package/edit/auth/__tests__/oidc.test.ts +152 -109
  72. package/edit/auth/azuread.vue +1 -0
  73. package/edit/auth/googleoauth.vue +4 -0
  74. package/edit/auth/oidc.vue +37 -4
  75. package/edit/cloudcredential.vue +1 -0
  76. package/edit/logging.banzaicloud.io.output/__tests__/logging.banzaicloud.io.output.test.ts +40 -9
  77. package/edit/networking.k8s.io.ingress/IngressClass.vue +7 -3
  78. package/edit/networking.k8s.io.ingress/__tests__/IngressClass.test.ts +58 -0
  79. package/edit/persistentvolume/__tests__/persistentvolume.test.ts +14 -2
  80. package/edit/provisioning.cattle.io.cluster/SelectCredential.vue +1 -0
  81. package/edit/provisioning.cattle.io.cluster/rke2.vue +25 -34
  82. package/edit/provisioning.cattle.io.cluster/tabs/AgentConfiguration.vue +6 -1
  83. package/edit/provisioning.cattle.io.cluster/tabs/MachinePool.vue +29 -1
  84. package/edit/provisioning.cattle.io.cluster/tabs/etcd/index.vue +2 -2
  85. package/edit/token.vue +2 -0
  86. package/edit/workload/index.vue +1 -0
  87. package/edit/workload/mixins/workload.js +0 -2
  88. package/list/management.cattle.io.feature.vue +1 -0
  89. package/list/provisioning.cattle.io.cluster.vue +20 -12
  90. package/models/__tests__/namespace.test.ts +25 -1
  91. package/models/cloudcredential.js +5 -0
  92. package/models/kontainerdriver.js +6 -3
  93. package/models/management.cattle.io.node.js +3 -3
  94. package/models/namespace.js +4 -5
  95. package/models/nodedriver.js +6 -3
  96. package/models/workload.js +4 -1
  97. package/package.json +3 -3
  98. package/pages/account/index.vue +4 -1
  99. package/pages/auth/login.vue +11 -3
  100. package/pages/auth/logout.vue +4 -1
  101. package/pages/auth/setup.vue +1 -0
  102. package/pages/auth/verify.vue +4 -1
  103. package/pages/c/_cluster/apps/charts/chart.vue +1 -1
  104. package/pages/diagnostic.vue +47 -2
  105. package/pages/fail-whale.vue +6 -3
  106. package/pages/home.vue +24 -18
  107. package/pages/support/index.vue +4 -1
  108. package/rancher-components/Form/Radio/RadioGroup.vue +25 -23
  109. package/rancher-components/RcDropdown/RcDropdown.vue +3 -2
  110. package/rancher-components/RcDropdown/RcDropdownTrigger.vue +10 -0
  111. package/rancher-components/RcDropdown/useDropdownCollection.ts +8 -0
  112. package/rancher-components/RcDropdown/useDropdownContext.ts +9 -3
  113. package/scripts/extension/publish +1 -0
  114. package/server/har-file.js +25 -3
  115. package/store/features.js +2 -1
  116. package/store/type-map.js +4 -0
  117. package/types/shell/index.d.ts +8 -1
  118. package/utils/cluster.js +35 -0
  119. package/utils/validators/machine-pool.ts +20 -0
  120. package/components/formatter/ExtensionCache.vue +0 -74
  121. package/components/formatter/Port.vue +0 -24
  122. package/components/formatter/SecretType.vue +0 -41
@@ -1,5 +1,7 @@
1
1
  <script>
2
- import { mapGetters, mapActions } from 'vuex';
2
+ import { computed, ref, toRef, watch } from 'vue';
3
+ import { mapActions, useStore } from 'vuex';
4
+
3
5
  import { get, set } from '@shell/utils/object';
4
6
  import { sortBy } from '@shell/utils/sort';
5
7
  import { NAMESPACE } from '@shell/config/types';
@@ -8,6 +10,7 @@ import { _VIEW, _EDIT, _CREATE } from '@shell/config/query-params';
8
10
  import { LabeledInput } from '@components/Form/LabeledInput';
9
11
  import LabeledSelect from '@shell/components/form/LabeledSelect';
10
12
  import { normalizeName } from '@shell/utils/kube';
13
+ import { useI18n } from '@shell/composables/useI18n';
11
14
 
12
15
  export default {
13
16
  name: 'NameNsDescription',
@@ -169,81 +172,74 @@ export default {
169
172
  },
170
173
 
171
174
  data() {
172
- const v = this.value;
173
- const metadata = v.metadata;
174
- let namespace, name, description;
175
+ return { createNamespace: false };
176
+ },
175
177
 
176
- if (this.nameKey) {
177
- name = get(v, this.nameKey);
178
- } else {
179
- name = metadata?.name;
180
- }
178
+ setup(props, { emit }) {
179
+ const v = toRef(props.value);
180
+ const metadata = v.value.metadata;
181
+ const namespace = ref(null);
182
+ const name = ref(null);
183
+ const description = ref(null);
181
184
 
182
- if (this.namespaced) {
183
- if (this.forceNamespace) {
184
- namespace = this.forceNamespace;
185
- this.updateNamespace(namespace);
186
- } else if (this.namespaceKey) {
187
- namespace = get(v, this.namespaceKey);
188
- } else {
189
- namespace = metadata?.namespace;
185
+ watch(name, (val) => {
186
+ if (props.normalizeName) {
187
+ val = normalizeName(val);
190
188
  }
191
189
 
192
- if (!namespace && !this.noDefaultNamespace) {
193
- namespace = this.$store.getters['defaultNamespace'];
194
- if (metadata) {
195
- metadata.namespace = namespace;
196
- }
190
+ if (props.nameKey) {
191
+ set(props.value, props.nameKey, val);
192
+ } else {
193
+ props.value.metadata['name'] = val;
197
194
  }
198
- }
195
+ emit('update:value', props.value);
196
+ });
199
197
 
200
- if (this.descriptionKey) {
201
- description = get(v, this.descriptionKey);
198
+ if (props.nameKey) {
199
+ name.value = get(v.value, props.nameKey);
202
200
  } else {
203
- description = metadata?.annotations?.[DESCRIPTION];
201
+ name.value = metadata?.name || '';
204
202
  }
205
203
 
206
- const inStore = this.$store.getters['currentStore']();
207
- const nsSchema = this.$store.getters[`${ inStore }/schemaFor`](NAMESPACE);
204
+ const isCreate = computed(() => {
205
+ return props.mode === _CREATE;
206
+ });
208
207
 
209
- return {
210
- namespace,
211
- name,
212
- description,
213
- createNamespace: false,
214
- nsSchema
215
- };
216
- },
208
+ const store = useStore();
209
+ const { t } = useI18n(store);
210
+ const allowedNamespaces = computed(() => store.getters.allowedNamespaces());
211
+ const storeNamespaces = computed(() => store.getters.namespaces());
212
+ const currentCluster = computed(() => store.getters.currentCluster);
217
213
 
218
- computed: {
219
- ...mapGetters(['currentProduct', 'currentCluster', 'namespaces', 'allowedNamespaces']),
220
- ...mapActions('cru-resource', ['setCreateNamespace']),
221
- namespaceReallyDisabled() {
222
- return (
223
- !!this.forceNamespace || this.namespaceDisabled || this.mode === _EDIT
224
- ); // namespace is never editable
225
- },
214
+ const inStore = computed(() => {
215
+ return store.getters['currentStore']();
216
+ });
226
217
 
227
- nameReallyDisabled() {
228
- return this.nameDisabled || (this.mode === _EDIT && !this.nameEditable);
229
- },
218
+ const nsSchema = computed(() => {
219
+ return store.getters[`${ inStore.value }/schemaFor`](NAMESPACE);
220
+ });
221
+
222
+ const canCreateNamespace = computed(() => {
223
+ // Check if user can push to namespaces... and as the ns is outside of a project restrict to admins and cluster owners
224
+ return (nsSchema.value?.collectionMethods || []).includes('POST') && currentCluster.value?.canUpdate;
225
+ });
230
226
 
231
227
  /**
232
228
  * Map namespaces from the store to options, adding divider and create button
233
229
  */
234
- options() {
230
+ const options = computed(() => {
235
231
  let namespaces;
236
232
 
237
- if (this.namespacesOverride) {
233
+ if (props.namespacesOverride) {
238
234
  // Use the resources provided
239
- namespaces = this.namespacesOverride;
235
+ namespaces = props.namespacesOverride;
240
236
  } else {
241
- if (this.namespaceOptions) {
237
+ if (props.namespaceOptions) {
242
238
  // Use the namespaces provided
243
- namespaces = (this.namespaceOptions.map((ns) => ns.name) || []).sort();
239
+ namespaces = (props.namespaceOptions.map((ns) => ns.name) || []).sort();
244
240
  } else {
245
241
  // Determine the namespaces
246
- const namespaceObjs = this.isCreate ? this.allowedNamespaces() : this.namespaces();
242
+ const namespaceObjs = isCreate.value ? allowedNamespaces.value : storeNamespaces.value;
247
243
 
248
244
  namespaces = Object.keys(namespaceObjs);
249
245
  }
@@ -251,22 +247,22 @@ export default {
251
247
 
252
248
  const options = namespaces
253
249
  .map((namespace) => ({ nameDisplay: namespace, id: namespace }))
254
- .map(this.namespaceMapper || ((obj) => ({
250
+ .map(props.namespaceMapper || ((obj) => ({
255
251
  label: obj.nameDisplay,
256
252
  value: obj.id,
257
253
  })));
258
254
 
259
255
  const sortedByLabel = sortBy(options, 'label');
260
256
 
261
- if (this.forceNamespace) {
257
+ if (props.forceNamespace) {
262
258
  sortedByLabel.unshift({
263
- label: this.forceNamespace,
264
- value: this.forceNamespace,
259
+ label: props.forceNamespace,
260
+ value: props.forceNamespace,
265
261
  });
266
262
  }
267
263
 
268
264
  const createButton = {
269
- label: this.t('namespace.createNamespace'),
265
+ label: t('namespace.createNamespace'),
270
266
  value: '',
271
267
  kind: 'highlighted'
272
268
  };
@@ -276,20 +272,78 @@ export default {
276
272
  kind: 'divider'
277
273
  };
278
274
 
279
- const createOverhead = this.canCreateNamespace || this.createNamespaceOverride ? [createButton, divider] : [];
275
+ const createOverhead = canCreateNamespace.value || props.createNamespaceOverride ? [createButton, divider] : [];
280
276
 
281
277
  return [
282
278
  ...createOverhead,
283
279
  ...sortedByLabel
284
280
  ];
281
+ });
282
+
283
+ const updateNamespace = (val) => {
284
+ if (props.forceNamespace) {
285
+ val = props.forceNamespace;
286
+ }
287
+
288
+ if (props.namespaced) {
289
+ emit('isNamespaceNew', !val || (options.value && !options.value.find((n) => n.value === val)));
290
+ }
291
+
292
+ if (props.namespaceKey) {
293
+ set(props.value, props.namespaceKey, val);
294
+ } else {
295
+ props.value.metadata.namespace = val;
296
+ }
297
+ };
298
+
299
+ if (props.namespaced) {
300
+ if (props.forceNamespace) {
301
+ namespace.value = toRef(props.forceNamespace);
302
+ updateNamespace(namespace);
303
+ } else if (props.namespaceKey) {
304
+ namespace.value = get(v, props.namespaceKey);
305
+ } else {
306
+ namespace.value = metadata?.namespace;
307
+ }
308
+
309
+ if (!namespace.value && !props.noDefaultNamespace) {
310
+ namespace.value = store.getters['defaultNamespace'];
311
+ if (metadata) {
312
+ metadata.namespace = namespace;
313
+ }
314
+ }
315
+ }
316
+
317
+ if (props.descriptionKey) {
318
+ description.value = get(v, props.descriptionKey);
319
+ } else {
320
+ description.value = metadata?.annotations?.[DESCRIPTION];
321
+ }
322
+
323
+ return {
324
+ namespace,
325
+ name,
326
+ description,
327
+ isCreate,
328
+ options,
329
+ updateNamespace,
330
+ };
331
+ },
332
+
333
+ computed: {
334
+ ...mapActions('cru-resource', ['setCreateNamespace']),
335
+ namespaceReallyDisabled() {
336
+ return (
337
+ !!this.forceNamespace || this.namespaceDisabled || this.mode === _EDIT
338
+ ); // namespace is never editable
285
339
  },
286
340
 
287
- isView() {
288
- return this.mode === _VIEW;
341
+ nameReallyDisabled() {
342
+ return this.nameDisabled || (this.mode === _EDIT && !this.nameEditable);
289
343
  },
290
344
 
291
- isCreate() {
292
- return this.mode === _CREATE;
345
+ isView() {
346
+ return this.mode === _VIEW;
293
347
  },
294
348
 
295
349
  showCustomize() {
@@ -308,27 +362,9 @@ export default {
308
362
 
309
363
  return `span-${ span }`;
310
364
  },
311
-
312
- canCreateNamespace() {
313
- // Check if user can push to namespaces... and as the ns is outside of a project restrict to admins and cluster owners
314
- return (this.nsSchema?.collectionMethods || []).includes('POST') && this.currentCluster?.canUpdate;
315
- }
316
365
  },
317
366
 
318
367
  watch: {
319
- name(val) {
320
- if (this.normalizeName) {
321
- val = normalizeName(val);
322
- }
323
-
324
- if (this.nameKey) {
325
- set(this.value, this.nameKey, val);
326
- } else {
327
- this.value.metadata['name'] = val;
328
- }
329
- this.$emit('update:value', this.value);
330
- },
331
-
332
368
  namespace(val) {
333
369
  this.updateNamespace(val);
334
370
  this.$emit('update:value', this.value);
@@ -346,29 +382,13 @@ export default {
346
382
 
347
383
  mounted() {
348
384
  this.$nextTick(() => {
349
- if (this.$refs.name) {
350
- this.$refs.name.focus();
385
+ if (this.$refs.nameInput) {
386
+ this.$refs.nameInput.focus();
351
387
  }
352
388
  });
353
389
  },
354
390
 
355
391
  methods: {
356
- updateNamespace(val) {
357
- if (this.forceNamespace) {
358
- val = this.forceNamespace;
359
- }
360
-
361
- if (this.namespaced) {
362
- this.$emit('isNamespaceNew', !val || (this.options && !this.options.find((n) => n.value === val)));
363
- }
364
-
365
- if (this.namespaceKey) {
366
- set(this.value, this.namespaceKey, val);
367
- } else {
368
- this.value.metadata.namespace = val;
369
- }
370
- },
371
-
372
392
  changeNameAndNamespace(e) {
373
393
  this.name = (e.text || '').toLowerCase();
374
394
  this.namespace = e.selected;
@@ -389,7 +409,7 @@ export default {
389
409
  true,
390
410
  );
391
411
  this.$emit('isNamespaceNew', true);
392
- this.$nextTick(() => this.$refs.namespace.focus());
412
+ this.$nextTick(() => this.$refs.namespaceInput.focus());
393
413
  } else {
394
414
  this.createNamespace = false;
395
415
  this.$store.dispatch(
@@ -411,7 +431,7 @@ export default {
411
431
  class="col span-3"
412
432
  >
413
433
  <LabeledInput
414
- ref="namespace"
434
+ ref="namespaceInput"
415
435
  v-model:value="namespace"
416
436
  :label="t('namespace.label')"
417
437
  :placeholder="t('namespace.createNamespace')"
@@ -459,9 +479,10 @@ export default {
459
479
  class="col span-3"
460
480
  >
461
481
  <LabeledInput
462
- ref="name"
482
+ ref="nameInput"
463
483
  key="name"
464
484
  v-model:value="name"
485
+ data-testid="NameNsDescriptionNameInput"
465
486
  :label="t(nameLabel)"
466
487
  :placeholder="t(namePlaceholder)"
467
488
  :disabled="nameReallyDisabled"
@@ -473,7 +494,6 @@ export default {
473
494
  </div>
474
495
 
475
496
  <slot name="customize" />
476
- <!-- // TODO: here goes the custom component -->
477
497
  <div
478
498
  v-show="!descriptionHidden"
479
499
  :data-testid="componentTestid + '-description'"
@@ -29,6 +29,20 @@ export default {
29
29
 
30
30
  data() {
31
31
  const t = this.$store.getters['i18n/t'];
32
+
33
+ return {
34
+ dnsPolicy: this.value.dnsPolicy || 'ClusterFirst',
35
+ networkMode: this.value.hostNetwork ? { label: t('workload.networking.networkMode.options.hostNetwork'), value: true } : { label: t('workload.networking.networkMode.options.normal'), value: false },
36
+ hostAliases: [],
37
+ nameservers: null,
38
+ searches: null,
39
+ hostname: null,
40
+ subdomain: null,
41
+ options: null,
42
+ };
43
+ },
44
+
45
+ created() {
32
46
  const hostAliases = (this.value.hostAliases || []).map((entry) => {
33
47
  return {
34
48
  ip: entry.ip,
@@ -38,18 +52,12 @@ export default {
38
52
  const { dnsConfig = {}, hostname, subdomain } = this.value;
39
53
  const { nameservers, searches, options } = dnsConfig;
40
54
 
41
- const out = {
42
- dnsPolicy: this.value.dnsPolicy || 'ClusterFirst',
43
- networkMode: this.value.hostNetwork ? { label: t('workload.networking.networkMode.options.hostNetwork'), value: true } : { label: t('workload.networking.networkMode.options.normal'), value: false },
44
- hostAliases,
45
- nameservers,
46
- searches,
47
- hostname,
48
- subdomain,
49
- options
50
- };
51
-
52
- return out;
55
+ this.hostAliases = hostAliases;
56
+ this.nameservers = nameservers;
57
+ this.searches = searches;
58
+ this.hostname = hostname;
59
+ this.subdomain = subdomain;
60
+ this.options = options;
53
61
  },
54
62
 
55
63
  computed: {
@@ -42,31 +42,18 @@ export default {
42
42
  data() {
43
43
  // VolumeNodeAffinity only has 'required' field
44
44
  if (this.value.required) {
45
- return { nodeSelectorTerms: this.value.required.nodeSelectorTerms };
46
45
  } else {
47
- const { preferredDuringSchedulingIgnoredDuringExecution = [], requiredDuringSchedulingIgnoredDuringExecution = {} } = this.value;
48
- const { nodeSelectorTerms = [] } = requiredDuringSchedulingIgnoredDuringExecution;
49
- const allSelectorTerms = [...preferredDuringSchedulingIgnoredDuringExecution, ...nodeSelectorTerms].map((term) => {
50
- const neu = clone(term);
51
-
52
- neu._id = randomStr(4);
53
- if (term.preference) {
54
- Object.assign(neu, term.preference);
55
- delete neu.preference;
56
- }
57
-
58
- return neu;
59
- });
60
-
61
- return {
62
- allSelectorTerms,
63
- weightedNodeSelectorTerms: preferredDuringSchedulingIgnoredDuringExecution,
64
- defaultWeight: 1,
65
- // rules in MatchExpressions.vue can not catch changes what happens on parent component
66
- // we need re-render it via key changing
67
- rerenderNums: randomStr(4)
68
- };
69
46
  }
47
+
48
+ return {
49
+ nodeSelectorTerms: null,
50
+ allSelectorTerms: null,
51
+ weightedNodeSelectorTerms: null,
52
+ defaultWeight: 1,
53
+ // rules in MatchExpressions.vue can not catch changes what happens on parent component
54
+ // we need re-render it via key changing
55
+ rerenderNums: randomStr(4)
56
+ };
70
57
  },
71
58
 
72
59
  computed: {
@@ -88,6 +75,27 @@ export default {
88
75
  },
89
76
 
90
77
  created() {
78
+ if (this.value.required) {
79
+ this.nodeSelectorTerms = this.value.required.nodeSelectorTerms;
80
+ } else {
81
+ const { preferredDuringSchedulingIgnoredDuringExecution = [], requiredDuringSchedulingIgnoredDuringExecution = {} } = this.value;
82
+ const { nodeSelectorTerms = [] } = requiredDuringSchedulingIgnoredDuringExecution;
83
+ const allSelectorTerms = [...preferredDuringSchedulingIgnoredDuringExecution, ...nodeSelectorTerms].map((term) => {
84
+ const neu = clone(term);
85
+
86
+ neu._id = randomStr(4);
87
+ if (term.preference) {
88
+ Object.assign(neu, term.preference);
89
+ delete neu.preference;
90
+ }
91
+
92
+ return neu;
93
+ });
94
+
95
+ this.allSelectorTerms = allSelectorTerms;
96
+ this.weightedNodeSelectorTerms = preferredDuringSchedulingIgnoredDuringExecution;
97
+ }
98
+
91
99
  this.queueUpdate = debounce(this.update, 500);
92
100
  },
93
101
 
@@ -40,6 +40,15 @@ export default {
40
40
  },
41
41
 
42
42
  data() {
43
+ return {
44
+ selectNode: null,
45
+ nodeName: '',
46
+ nodeAffinity: {},
47
+ nodeSelector: {},
48
+ };
49
+ },
50
+
51
+ created() {
43
52
  const isHarvester = this.$store.getters['currentProduct'].inStore === VIRTUAL;
44
53
 
45
54
  let { nodeName = '' } = this.value;
@@ -65,9 +74,10 @@ export default {
65
74
  nodeAffinity['preferredDuringSchedulingIgnoredDuringExecution'] = [];
66
75
  }
67
76
 
68
- return {
69
- selectNode, nodeName, nodeAffinity, nodeSelector
70
- };
77
+ this.selectNode = selectNode;
78
+ this.nodeName = nodeName;
79
+ this.nodeAffinity = nodeAffinity;
80
+ this.nodeSelector = nodeSelector;
71
81
  },
72
82
 
73
83
  computed: {
@@ -84,53 +84,14 @@ export default {
84
84
  },
85
85
 
86
86
  data() {
87
- if (!this.value[this.field]) {
88
- this.value[this.field] = {};
89
- }
90
- const { podAffinity = {}, podAntiAffinity = {} } = this.value[this.field];
91
- const allAffinityTerms = [...(podAffinity.preferredDuringSchedulingIgnoredDuringExecution || []), ...(podAffinity.requiredDuringSchedulingIgnoredDuringExecution || [])].map((term) => {
92
- let out = clone(term);
93
-
94
- out._id = randomStr(4);
95
- out._anti = false;
96
- if (term.podAffinityTerm) {
97
- Object.assign(out, term.podAffinityTerm);
98
- out = this.parsePodAffinityTerm(out);
99
-
100
- delete out.podAffinityTerm;
101
- } else {
102
- out = this.parsePodAffinityTerm(out);
103
- }
104
-
105
- return out;
106
- });
107
- const allAntiTerms = [...(podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution || []), ...(podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution || [])].map((term) => {
108
- let out = clone(term);
109
-
110
- out._id = randomStr(4);
111
- out._anti = true;
112
- if (term.podAffinityTerm) {
113
- Object.assign(out, term.podAffinityTerm);
114
- out = this.parsePodAffinityTerm(out);
115
-
116
- delete out.podAffinityTerm;
117
- } else {
118
- out = this.parsePodAffinityTerm(out);
119
- }
120
-
121
- return out;
122
- });
123
-
124
- const allSelectorTerms = [...allAffinityTerms, ...allAntiTerms];
125
-
126
87
  return {
127
- allSelectorTerms,
128
- defaultWeight: 1,
88
+ allSelectorTerms: [],
89
+ defaultWeight: 1,
129
90
  // rules in MatchExpressions.vue can not catch changes what happens on parent component
130
91
  // we need re-render it via key changing
131
- rerenderNums: randomStr(4),
92
+ rerenderNums: randomStr(4),
132
93
  NAMESPACE_SELECTION_OPTION_VALUES,
133
- defaultAddValue: {
94
+ defaultAddValue: {
134
95
  _namespaceOption: NAMESPACE_SELECTION_OPTION_VALUES.POD,
135
96
  matchExpressions: [],
136
97
  namespaces: null,
@@ -138,6 +99,7 @@ export default {
138
99
  }
139
100
  };
140
101
  },
102
+
141
103
  computed: {
142
104
  ...mapGetters({ t: 'i18n/t' }),
143
105
  isView() {
@@ -226,6 +188,44 @@ export default {
226
188
  },
227
189
 
228
190
  created() {
191
+ if (!this.value[this.field]) {
192
+ this.value[this.field] = {};
193
+ }
194
+ const { podAffinity = {}, podAntiAffinity = {} } = this.value[this.field];
195
+ const allAffinityTerms = [...(podAffinity.preferredDuringSchedulingIgnoredDuringExecution || []), ...(podAffinity.requiredDuringSchedulingIgnoredDuringExecution || [])].map((term) => {
196
+ let out = clone(term);
197
+
198
+ out._id = randomStr(4);
199
+ out._anti = false;
200
+ if (term.podAffinityTerm) {
201
+ Object.assign(out, term.podAffinityTerm);
202
+ out = this.parsePodAffinityTerm(out);
203
+
204
+ delete out.podAffinityTerm;
205
+ } else {
206
+ out = this.parsePodAffinityTerm(out);
207
+ }
208
+
209
+ return out;
210
+ });
211
+ const allAntiTerms = [...(podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution || []), ...(podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution || [])].map((term) => {
212
+ let out = clone(term);
213
+
214
+ out._id = randomStr(4);
215
+ out._anti = true;
216
+ if (term.podAffinityTerm) {
217
+ Object.assign(out, term.podAffinityTerm);
218
+ out = this.parsePodAffinityTerm(out);
219
+
220
+ delete out.podAffinityTerm;
221
+ } else {
222
+ out = this.parsePodAffinityTerm(out);
223
+ }
224
+
225
+ return out;
226
+ });
227
+
228
+ this.allSelectorTerms = [...allAffinityTerms, ...allAntiTerms];
229
229
  this.queueUpdate = debounce(this.update, 500);
230
230
  },
231
231