@rancher/shell 0.5.0 → 0.5.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 (46) hide show
  1. package/components/AsyncButton.vue +5 -17
  2. package/components/Certificates.vue +4 -4
  3. package/components/DraggableZone.vue +2 -2
  4. package/components/PodSecurityAdmission.vue +2 -2
  5. package/components/form/Error.vue +3 -3
  6. package/components/form/Footer.vue +2 -2
  7. package/components/form/GitPicker.vue +38 -83
  8. package/composables/useCompactInput.ts +2 -2
  9. package/edit/catalog.cattle.io.clusterrepo.vue +18 -0
  10. package/edit/management.cattle.io.podsecurityadmissionconfigurationtemplate.vue +2 -2
  11. package/mixins/create-edit-view/index.js +2 -2
  12. package/package.json +1 -1
  13. package/rancher-components/Accordion/Accordion.vue +2 -3
  14. package/rancher-components/BadgeState/BadgeState.vue +3 -3
  15. package/rancher-components/Banner/Banner.vue +2 -2
  16. package/rancher-components/Card/Card.vue +3 -3
  17. package/rancher-components/Form/Checkbox/Checkbox.vue +3 -3
  18. package/rancher-components/Form/LabeledInput/LabeledInput.test.ts +1 -1
  19. package/rancher-components/Form/LabeledInput/LabeledInput.vue +23 -53
  20. package/rancher-components/Form/Radio/RadioButton.vue +7 -13
  21. package/rancher-components/Form/Radio/RadioGroup.vue +3 -4
  22. package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +4 -6
  23. package/rancher-components/Form/ToggleSwitch/ToggleSwitch.vue +4 -7
  24. package/rancher-components/LabeledTooltip/LabeledTooltip.vue +4 -9
  25. package/rancher-components/StringList/StringList.vue +8 -8
  26. package/rancher-components/components/Accordion/Accordion.vue +2 -3
  27. package/rancher-components/components/BadgeState/BadgeState.vue +3 -3
  28. package/rancher-components/components/Banner/Banner.vue +2 -2
  29. package/rancher-components/components/Card/Card.vue +3 -3
  30. package/rancher-components/components/Form/Checkbox/Checkbox.vue +3 -3
  31. package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +1 -1
  32. package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +23 -53
  33. package/rancher-components/components/Form/Radio/RadioButton.vue +7 -13
  34. package/rancher-components/components/Form/Radio/RadioGroup.vue +3 -4
  35. package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +4 -6
  36. package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.vue +4 -7
  37. package/rancher-components/components/LabeledTooltip/LabeledTooltip.vue +4 -9
  38. package/rancher-components/components/StringList/StringList.vue +8 -8
  39. package/tsconfig.paths.json +1 -4
  40. package/types/shell/index.d.ts +20 -82
  41. package/utils/git.ts +1 -1
  42. package/composables/useCompactInput.test.ts +0 -36
  43. package/composables/useLabeledFormElement.test.ts +0 -135
  44. package/types/vue-shim.d.ts +0 -42
  45. /package/rancher-components/BadgeState/{BadgeState.test.ts → BadgeState.spec.ts} +0 -0
  46. /package/rancher-components/components/BadgeState/{BadgeState.test.ts → BadgeState.spec.ts} +0 -0
@@ -1,9 +1,8 @@
1
1
  <script lang="ts">
2
- import { defineComponent } from 'vue';
2
+ import Vue from 'vue';
3
3
  import { _VIEW } from '@shell/config/query-params';
4
- import { randomStr } from '@shell/utils/string';
5
4
 
6
- export default defineComponent({
5
+ export default Vue.extend({
7
6
  props: {
8
7
  /**
9
8
  * The name of the input, for grouping.
@@ -72,10 +71,7 @@ export default defineComponent({
72
71
  },
73
72
 
74
73
  data() {
75
- return {
76
- isChecked: this.value === this.val,
77
- randomString: `${ randomStr() }-radio`,
78
- };
74
+ return { isChecked: this.value === this.val };
79
75
  },
80
76
 
81
77
  computed: {
@@ -119,15 +115,13 @@ export default defineComponent({
119
115
  /**
120
116
  * Emits the input event.
121
117
  */
122
- clicked(event: MouseEvent | KeyboardEvent) {
123
- const target = event.target;
124
-
125
- if (this.isDisabled || (target instanceof HTMLElement && target.tagName === 'A')) {
118
+ clicked({ target }: { target?: HTMLElement }) {
119
+ if (this.isDisabled || target?.tagName === 'A') {
126
120
  return;
127
121
  }
128
122
 
129
123
  this.$emit('input', this.val);
130
- },
124
+ }
131
125
  }
132
126
  });
133
127
  </script>
@@ -140,7 +134,7 @@ export default defineComponent({
140
134
  @click.stop="clicked($event)"
141
135
  >
142
136
  <input
143
- :id="randomString"
137
+ :id="_uid+'-radio'"
144
138
  :disabled="isDisabled"
145
139
  :name="name"
146
140
  :value="''+val"
@@ -1,15 +1,14 @@
1
1
  <script lang="ts">
2
- import { PropType, defineComponent } from 'vue';
2
+ import Vue, { PropType } from 'vue';
3
3
  import { _VIEW } from '@shell/config/query-params';
4
4
  import RadioButton from '@components/Form/Radio/RadioButton.vue';
5
5
 
6
6
  interface Option {
7
7
  value: unknown,
8
- label: string,
9
- description?: string,
8
+ label: string
10
9
  }
11
10
 
12
- export default defineComponent({
11
+ export default Vue.extend({
13
12
  components: { RadioButton },
14
13
  props: {
15
14
  /**
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { defineComponent } from 'vue';
2
+ import Vue from 'vue';
3
3
  import debounce from 'lodash/debounce';
4
4
  import { _EDIT, _VIEW } from '@shell/config/query-params';
5
5
 
@@ -10,7 +10,7 @@ declare module 'vue/types/vue' {
10
10
  }
11
11
  }
12
12
 
13
- export default defineComponent({
13
+ export default Vue.extend({
14
14
  inheritAttrs: false,
15
15
 
16
16
  props: {
@@ -115,9 +115,7 @@ export default defineComponent({
115
115
  /**
116
116
  * Emits the input event and resizes the Text Area.
117
117
  */
118
- onInput(event: Event): void {
119
- const val = (event?.target as HTMLInputElement)?.value;
120
-
118
+ onInput(val: string): void {
121
119
  this.$emit('input', val);
122
120
  this.queueResize();
123
121
  },
@@ -165,7 +163,7 @@ export default defineComponent({
165
163
  v-bind="$attrs"
166
164
  :spellcheck="spellcheck"
167
165
  @paste="$emit('paste', $event)"
168
- @input="onInput($event)"
166
+ @input="onInput($event.target.value)"
169
167
  @focus="$emit('focus', $event)"
170
168
  @blur="$emit('blur', $event)"
171
169
  />
@@ -1,9 +1,6 @@
1
1
  <script lang="ts">
2
- import { defineComponent } from 'vue';
3
-
4
- type StateType = boolean | 'true' | 'false' | undefined;
5
-
6
- export default defineComponent({
2
+ import Vue from 'vue';
3
+ export default Vue.extend({
7
4
  props: {
8
5
  value: {
9
6
  type: [Boolean, String, Number],
@@ -31,7 +28,7 @@ export default defineComponent({
31
28
  },
32
29
  },
33
30
  data() {
34
- return { state: false as StateType };
31
+ return { state: false as boolean | string | number };
35
32
  },
36
33
 
37
34
  watch: {
@@ -44,7 +41,7 @@ export default defineComponent({
44
41
  },
45
42
 
46
43
  methods: {
47
- toggle(neu: StateType | null) {
44
+ toggle(neu: boolean | string | number) {
48
45
  this.state = neu === null ? !this.state : neu;
49
46
  this.$emit('input', this.state ? this.onValue : this.offValue);
50
47
  }
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
- import { defineComponent } from 'vue';
2
+ import Vue from 'vue';
3
3
 
4
- export default defineComponent({
4
+ export default Vue.extend({
5
5
  props: {
6
6
  /**
7
7
  * The Labeled Tooltip value.
@@ -29,14 +29,9 @@ export default defineComponent({
29
29
  }
30
30
  },
31
31
  computed: {
32
- iconClass(): string {
32
+ iconClass() {
33
33
  return this.status === 'error' ? 'icon-warning' : 'icon-info';
34
34
  }
35
- },
36
- methods: {
37
- isObject(value: string | Record<string, unknown>): value is Record<string, unknown> {
38
- return typeof value === 'object' && value !== null && !!value.content;
39
- }
40
35
  }
41
36
  });
42
37
  </script>
@@ -49,7 +44,7 @@ export default defineComponent({
49
44
  >
50
45
  <template v-if="hover">
51
46
  <i
52
- v-clean-tooltip="isObject(value) ? { ...{content: value.content, classes: [`tooltip-${status}`]}, ...value } : value"
47
+ v-clean-tooltip="value.content ? { ...{content: value.content, classes: [`tooltip-${status}`]}, ...value } : value"
53
48
  :class="{'hover':!value, [iconClass]: true}"
54
49
  class="icon status-icon"
55
50
  />
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import Vue, { PropType, defineComponent } from 'vue';
2
+ import Vue, { PropType } from 'vue';
3
3
 
4
4
  import LabeledInput from '@components/Form/LabeledInput/LabeledInput.vue';
5
5
  import { findStringIndex, hasDuplicatedStrings } from '@shell/utils/array';
@@ -29,7 +29,7 @@ const CLASS = {
29
29
  /**
30
30
  * Manage a list of strings
31
31
  */
32
- export default defineComponent({
32
+ export default Vue.extend({
33
33
 
34
34
  name: 'StringList',
35
35
  components: { LabeledInput },
@@ -92,9 +92,9 @@ export default defineComponent({
92
92
  },
93
93
  data() {
94
94
  return {
95
- value: undefined as string | undefined,
95
+ value: null as string | null,
96
96
  selected: null as string | null,
97
- editedItem: undefined as string | undefined,
97
+ editedItem: null as string | null,
98
98
  isCreateItem: false,
99
99
  errors: { duplicate: false } as Record<Error, boolean>
100
100
  };
@@ -281,7 +281,7 @@ export default defineComponent({
281
281
  this.isCreateItem = true;
282
282
  this.setFocus(INPUT.create);
283
283
  } else {
284
- this.value = undefined;
284
+ this.value = null;
285
285
  this.toggleError('duplicate', false);
286
286
  this.onSelectLeave();
287
287
 
@@ -303,11 +303,11 @@ export default defineComponent({
303
303
  this.editedItem = item || '';
304
304
  this.setFocus(INPUT.edit);
305
305
  } else {
306
- this.value = undefined;
306
+ this.value = null;
307
307
  this.toggleError('duplicate', false);
308
308
  this.onSelectLeave();
309
309
 
310
- this.editedItem = undefined;
310
+ this.editedItem = null;
311
311
  }
312
312
  },
313
313
 
@@ -502,7 +502,7 @@ export default defineComponent({
502
502
  <button
503
503
  data-testid="button-add"
504
504
  class="btn btn-sm role-tertiary add-button"
505
- :disabled="!!isCreateItem || !!editedItem"
505
+ :disabled="isCreateItem || editedItem"
506
506
  @click.prevent="onClickPlusButton"
507
507
  >
508
508
  <span class="icon icon-plus icon-sm" />
@@ -12,10 +12,7 @@
12
12
  ],
13
13
  "@pkg/*": [
14
14
  "../shell/pkg/*"
15
- ],
16
- "@components/*": [
17
- "../pkg/rancher-components/src/components/*"
18
15
  ]
19
16
  },
20
17
  },
21
- }
18
+ }
@@ -2134,97 +2134,35 @@ export default _default;
2134
2134
  // @shell/mixins/create-edit-view
2135
2135
 
2136
2136
  declare module '@shell/mixins/create-edit-view' {
2137
- declare var _default: import("vue").DefineComponent<{
2138
- mode: {
2139
- type: StringConstructor;
2140
- default: any;
2141
- };
2142
- realMode: {
2143
- type: StringConstructor;
2144
- default: any;
2145
- };
2146
- as: {
2147
- type: StringConstructor;
2148
- default: any;
2149
- };
2150
- value: {
2151
- type: ObjectConstructor;
2152
- required: true;
2153
- };
2154
- initialValue: {
2155
- type: ObjectConstructor;
2156
- default: any;
2157
- };
2158
- liveValue: {
2159
- type: ObjectConstructor;
2160
- default: any;
2161
- };
2162
- doneEvent: {
2163
- type: BooleanConstructor;
2164
- default: boolean;
2165
- };
2166
- }, {}, {
2137
+ declare var _default: import("vue/types/vue").ExtendedVue<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, any>>, {
2167
2138
  errors: any[];
2168
- }, {
2169
- isCreate(): boolean;
2170
- isEdit(): boolean;
2171
- isView(): boolean;
2172
- schema(): any;
2173
- isNamespaced(): any;
2174
- labels: {
2175
- get(): any;
2176
- set(neu: any): void;
2177
- };
2178
- annotations: {
2179
- get(): any;
2180
- set(neu: any): void;
2181
- };
2182
- doneRoute(): any;
2183
- doneParams(): any;
2184
2139
  }, {
2185
2140
  done(): any;
2186
2141
  conflict(): Promise<any>;
2187
2142
  save(buttonDone: any, url: any, depth?: number): any;
2188
2143
  actuallySave(url: any): Promise<void>;
2189
2144
  setErrors(errors: any): void;
2190
- }, any, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{
2191
- mode: {
2192
- type: StringConstructor;
2193
- default: any;
2194
- };
2195
- realMode: {
2196
- type: StringConstructor;
2197
- default: any;
2198
- };
2199
- as: {
2200
- type: StringConstructor;
2201
- default: any;
2202
- };
2203
- value: {
2204
- type: ObjectConstructor;
2205
- required: true;
2206
- };
2207
- initialValue: {
2208
- type: ObjectConstructor;
2209
- default: any;
2210
- };
2211
- liveValue: {
2212
- type: ObjectConstructor;
2213
- default: any;
2214
- };
2215
- doneEvent: {
2216
- type: BooleanConstructor;
2217
- default: boolean;
2218
- };
2219
- }>>, {
2220
- as: string;
2221
- mode: string;
2145
+ }, {
2146
+ isCreate: boolean;
2147
+ isEdit: boolean;
2148
+ isView: boolean;
2149
+ schema: any;
2150
+ isNamespaced: any;
2151
+ labels: any;
2152
+ annotations: any;
2153
+ doneRoute: any;
2154
+ doneParams: any;
2155
+ }, {
2156
+ mode: any;
2157
+ realMode: any;
2158
+ as: any;
2159
+ value: any;
2160
+ initialValue: any;
2161
+ liveValue: any;
2222
2162
  doneEvent: boolean;
2223
- initialValue: Record<string, any>;
2224
- liveValue: Record<string, any>;
2225
- realMode: string;
2226
- }>;
2163
+ }, {}, any, import("vue/types/v3-component-options").ComponentOptionsMixin>;
2227
2164
  export default _default;
2165
+ import Vue from "vue";
2228
2166
  }
2229
2167
 
2230
2168
  // @shell/models/namespace
package/utils/git.ts CHANGED
@@ -9,7 +9,7 @@ interface Repo {
9
9
  name: string,
10
10
  }
11
11
 
12
- export interface Commit {
12
+ interface Commit {
13
13
  message: string,
14
14
  htmlUrl: string,
15
15
  sha?: string,
@@ -1,36 +0,0 @@
1
- import { ref } from 'vue';
2
- import { useCompactInput } from './useCompactInput';
3
-
4
- describe('useCompactInput', () => {
5
- it('should compute isCompact correctly when compact is explicitly set', () => {
6
- const props = ref({
7
- compact: true,
8
- label: 'Test Label',
9
- labelKey: 'testLabel',
10
- });
11
-
12
- const { isCompact } = useCompactInput(props.value);
13
-
14
- expect(isCompact.value).toBe(true);
15
-
16
- // When compact is explicitly set to false, isCompact should be false
17
- props.value.compact = false;
18
- expect(isCompact.value).toBe(false);
19
- });
20
-
21
- it('should compute isCompact correctly when compact is not explicitly set', () => {
22
- const props = ref({
23
- label: '',
24
- labelKey: '',
25
- });
26
-
27
- const { isCompact } = useCompactInput(props.value);
28
-
29
- // When there is no label and labelKey is also not present, isCompact should be true
30
- expect(isCompact.value).toBe(true);
31
-
32
- // When label is present, isCompact should be false
33
- props.value.label = 'Updated Label';
34
- expect(isCompact.value).toBe(false);
35
- });
36
- });
@@ -1,135 +0,0 @@
1
- import { ref } from 'vue';
2
- import { useLabeledFormElement } from './useLabeledFormElement';
3
-
4
- describe('useLabeledFormElement', () => {
5
- it('should set raised to true when focused', () => {
6
- const props = {
7
- mode: 'edit',
8
- value: '',
9
- required: true,
10
- disabled: false,
11
- rules: [],
12
- };
13
-
14
- const emit = jest.fn();
15
- const { onFocusLabeled, onBlurLabeled, raised } = useLabeledFormElement(props, emit);
16
-
17
- onFocusLabeled();
18
- expect(raised.value).toBe(true);
19
-
20
- onBlurLabeled();
21
- expect(raised.value).toBe(false);
22
- });
23
-
24
- it('should set focused to true when focused', () => {
25
- const props = {
26
- mode: 'edit',
27
- value: '',
28
- required: true,
29
- disabled: false,
30
- rules: [],
31
- };
32
-
33
- const emit = jest.fn();
34
- const { onFocusLabeled, onBlurLabeled, focused } = useLabeledFormElement(props, emit);
35
-
36
- onFocusLabeled();
37
- expect(focused.value).toBe(true);
38
-
39
- onBlurLabeled();
40
- expect(focused.value).toBe(false);
41
- });
42
-
43
- it('should set blurred to current timestamp when blurred', () => {
44
- const props = {
45
- mode: 'edit',
46
- value: '',
47
- required: true,
48
- disabled: false,
49
- rules: [],
50
- };
51
-
52
- const emit = jest.fn();
53
- const { onBlurLabeled, blurred } = useLabeledFormElement(props, emit);
54
-
55
- onBlurLabeled();
56
- expect(blurred.value).toBeTruthy();
57
- });
58
-
59
- it('should compute isDisabled correctly', () => {
60
- const props = ref({
61
- mode: 'edit',
62
- value: '',
63
- required: true,
64
- disabled: false,
65
- rules: [],
66
- });
67
-
68
- const emit = jest.fn();
69
- const { isDisabled } = useLabeledFormElement(props.value, emit);
70
-
71
- expect(isDisabled.value).toBe(false);
72
-
73
- props.value.disabled = true;
74
- expect(isDisabled.value).toBe(true);
75
-
76
- props.value.mode = 'view';
77
- expect(isDisabled.value).toBe(true);
78
- });
79
-
80
- it('should compute validationMessage correctly for required field', () => {
81
- const props = ref({
82
- mode: 'edit',
83
- value: '',
84
- required: true,
85
- disabled: false,
86
- rules: [
87
- (value: string[]) => (value.length < 5 ? 'This field is required' : undefined),
88
- ],
89
- });
90
-
91
- const emit = jest.fn();
92
- const { validationMessage, onBlurLabeled } = useLabeledFormElement(props.value, emit);
93
-
94
- onBlurLabeled();
95
- expect(validationMessage.value).toBe('This field is required');
96
- });
97
-
98
- it('should compute validationMessage correctly for custom rules', () => {
99
- const props = ref({
100
- mode: 'edit',
101
- value: 'test',
102
- required: false,
103
- disabled: false,
104
- rules: [
105
- (value: string[]) => (value.length < 5 ? 'Value must be at least 5 characters long' : undefined),
106
- (value: string[]) => (value.includes('test') ? 'Value cannot contain the word "test"' : undefined),
107
- ],
108
- });
109
-
110
- const emit = jest.fn();
111
- const { validationMessage, onBlurLabeled } = useLabeledFormElement(props.value, emit);
112
-
113
- onBlurLabeled();
114
- expect(validationMessage.value).toBe('Value must be at least 5 characters long, Value cannot contain the word "test"');
115
- });
116
-
117
- it('should compute requiredField correctly', () => {
118
- const props = ref({
119
- mode: 'edit',
120
- value: '',
121
- required: true,
122
- disabled: false,
123
- rules: [],
124
- });
125
-
126
- const emit = jest.fn();
127
- const { requiredField } = useLabeledFormElement(props.value, emit);
128
-
129
- expect(requiredField.value).toBe(true);
130
-
131
- // When the field is not required, requiredField should be false
132
- props.value.required = false;
133
- expect(requiredField.value).toBe(false);
134
- });
135
- });
@@ -1,42 +0,0 @@
1
- // eslint-disable-next-line no-unused-vars
2
- import Vue, { ComponentCustomProperties } from 'vue';
3
- declare module '*.vue' {
4
- export default Vue;
5
- }
6
-
7
- // This is required to keep typescript from complaining. It is required for
8
- // our i18n plugin. For more info see:
9
- // https://v2.vuejs.org/v2/guide/typescript.html?redirect=true#Augmenting-Types-for-Use-with-Plugins
10
- declare module 'vue/types/vue' {
11
- // eslint-disable-next-line no-unused-vars
12
- interface Vue {
13
- /**
14
- * Lookup a given string with the given arguments
15
- * @param raw if set, do not do HTML escaping.
16
- */
17
- t: {
18
- (key: string, args?: Record<string, any>, raw?: boolean): string;
19
- (options: { k: string; raw?: boolean; tag?: string | Record<string, any>; escapehtml?: boolean }): string;
20
- };
21
- }
22
- }
23
-
24
- declare module '@vue/runtime-core' {
25
- // eslint-disable-next-line no-unused-vars
26
- interface Vue {
27
- t: {
28
- (key: string, args?: Record<string, any>, raw?: boolean): string;
29
- (options: { k: string; raw?: boolean; tag?: string | Record<string, any>; escapehtml?: boolean }): string;
30
- }
31
- }
32
-
33
- // eslint-disable-next-line no-unused-vars
34
- interface ComponentCustomProperties {
35
- $t: {
36
- (key: string, args?: Record<string, any>, raw?: boolean): string;
37
- (options: { k: string; raw?: boolean; tag?: string | Record<string, any>; escapehtml?: boolean }): string;
38
- }
39
- }
40
- }
41
-
42
- declare module 'js-yaml';