@rancher/shell 0.3.17 → 0.3.18

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 (110) hide show
  1. package/assets/translations/en-us.yaml +8 -4
  2. package/assets/translations/zh-hans.yaml +64 -8
  3. package/components/AsyncButton.vue +1 -1
  4. package/components/Inactivity.vue +10 -0
  5. package/components/LazyImage.vue +2 -2
  6. package/components/PromptRestore.vue +7 -5
  7. package/components/ResourceDetail/Masthead.vue +1 -1
  8. package/components/ResourceDetail/index.vue +4 -2
  9. package/components/__tests__/PromptRestore.test.ts +72 -0
  10. package/components/auth/AzureWarning.vue +1 -1
  11. package/components/fleet/FleetResources.vue +3 -64
  12. package/components/form/FileImageSelector.vue +9 -0
  13. package/components/form/FileSelector.vue +2 -1
  14. package/components/form/MatchExpressions.vue +1 -3
  15. package/components/form/__tests__/FileImageSelector.test.ts +42 -0
  16. package/components/form/__tests__/FileSelector.test.ts +76 -0
  17. package/components/formatter/ClusterProvider.vue +3 -1
  18. package/components/formatter/__tests__/ClusterProvider.test.ts +24 -0
  19. package/components/nav/WindowManager/ContainerShell.vue +60 -36
  20. package/components/nav/WindowManager/__tests__/ContainerShell.test.ts +561 -0
  21. package/config/labels-annotations.js +2 -1
  22. package/config/persistentVolume.ts +108 -0
  23. package/config/product/manager.js +5 -1
  24. package/config/types.js +2 -0
  25. package/core/plugin-helpers.js +19 -3
  26. package/core/types.ts +4 -0
  27. package/detail/fleet.cattle.io.gitrepo.vue +10 -2
  28. package/detail/pod.vue +36 -3
  29. package/detail/workload/index.vue +40 -9
  30. package/edit/__tests__/ui.cattle.io.navlink.test.ts +110 -0
  31. package/edit/fleet.cattle.io.clustergroup.vue +14 -3
  32. package/edit/persistentvolume/__tests__/persistentvolume.test.ts +82 -0
  33. package/edit/persistentvolume/index.vue +2 -1
  34. package/edit/persistentvolume/plugins/csi.vue +3 -1
  35. package/edit/persistentvolume/plugins/longhorn.vue +12 -12
  36. package/edit/provisioning.cattle.io.cluster/RegistryConfigs.vue +15 -11
  37. package/edit/provisioning.cattle.io.cluster/index.vue +1 -1
  38. package/edit/provisioning.cattle.io.cluster/rke2.vue +5 -1
  39. package/edit/storage.k8s.io.storageclass/index.vue +1 -2
  40. package/edit/ui.cattle.io.navlink.vue +213 -187
  41. package/layouts/default.vue +1 -1
  42. package/list/group.principal.vue +1 -1
  43. package/middleware/authenticated.js +12 -4
  44. package/mixins/create-edit-view/impl.js +2 -2
  45. package/models/chart.js +1 -1
  46. package/models/fleet.cattle.io.cluster.js +33 -4
  47. package/models/fleet.cattle.io.gitrepo.js +112 -38
  48. package/models/management.cattle.io.kontainerdriver.js +14 -0
  49. package/models/persistentvolume.js +2 -111
  50. package/models/pod.js +30 -0
  51. package/models/rke.cattle.io.etcdsnapshot.js +10 -7
  52. package/package.json +1 -1
  53. package/pages/c/_cluster/auth/group.principal/assign-edit.vue +1 -1
  54. package/pages/c/_cluster/auth/roles/index.vue +1 -1
  55. package/pages/c/_cluster/explorer/index.vue +1 -1
  56. package/pages/c/_cluster/manager/cloudCredential/_id.vue +0 -1
  57. package/pages/c/_cluster/manager/cloudCredential/create.vue +0 -1
  58. package/pages/c/_cluster/settings/brand.vue +11 -8
  59. package/pages/c/_cluster/uiplugins/index.vue +9 -4
  60. package/pages/home.vue +1 -1
  61. package/plugins/dashboard-store/__tests__/actions.spec.ts +165 -0
  62. package/plugins/dashboard-store/__tests__/getters.spec.ts +100 -0
  63. package/plugins/dashboard-store/__tests__/{mutations.spec.js → mutations.spec.ts} +2 -2
  64. package/plugins/dashboard-store/actions.js +1 -1
  65. package/plugins/dashboard-store/resource-class.js +4 -0
  66. package/plugins/steve/__tests__/getters.spec.ts +93 -0
  67. package/plugins/steve/getters.js +21 -1
  68. package/plugins/steve/subscribe.js +1 -3
  69. package/rancher-components/components/BadgeState/BadgeState.spec.ts +12 -0
  70. package/rancher-components/components/BadgeState/BadgeState.vue +111 -0
  71. package/rancher-components/components/BadgeState/index.ts +1 -0
  72. package/rancher-components/components/Banner/Banner.test.ts +63 -0
  73. package/rancher-components/components/Banner/Banner.vue +244 -0
  74. package/rancher-components/components/Banner/index.ts +1 -0
  75. package/rancher-components/components/Card/Card.test.ts +37 -0
  76. package/rancher-components/components/Card/Card.vue +167 -0
  77. package/rancher-components/components/Card/index.ts +1 -0
  78. package/rancher-components/components/Form/Checkbox/Checkbox.test.ts +68 -0
  79. package/rancher-components/components/Form/Checkbox/Checkbox.vue +420 -0
  80. package/rancher-components/components/Form/Checkbox/index.ts +1 -0
  81. package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +23 -0
  82. package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +355 -0
  83. package/rancher-components/components/Form/LabeledInput/index.ts +1 -0
  84. package/rancher-components/components/Form/Radio/RadioButton.test.ts +31 -0
  85. package/rancher-components/components/Form/Radio/RadioButton.vue +287 -0
  86. package/rancher-components/components/Form/Radio/RadioGroup.vue +254 -0
  87. package/rancher-components/components/Form/Radio/index.ts +2 -0
  88. package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +170 -0
  89. package/rancher-components/components/Form/TextArea/index.ts +1 -0
  90. package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.test.ts +94 -0
  91. package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.vue +149 -0
  92. package/rancher-components/components/Form/ToggleSwitch/index.ts +1 -0
  93. package/rancher-components/components/Form/index.ts +5 -0
  94. package/rancher-components/components/LabeledTooltip/LabeledTooltip.vue +151 -0
  95. package/rancher-components/components/LabeledTooltip/index.ts +1 -0
  96. package/rancher-components/components/StringList/StringList.test.ts +484 -0
  97. package/rancher-components/components/StringList/StringList.vue +611 -0
  98. package/rancher-components/components/StringList/index.ts +1 -0
  99. package/scripts/typegen.sh +10 -2
  100. package/store/index.js +1 -3
  101. package/store/store-types.js +2 -0
  102. package/types/api.d.ts +1 -0
  103. package/types/fleet.d.ts +1 -0
  104. package/types/shell/index.d.ts +695 -2
  105. package/types/userPreferences.d.ts +1 -1
  106. package/utils/__mocks__/socket.js +21 -0
  107. package/utils/grafana.js +23 -11
  108. package/utils/selector.js +2 -1
  109. package/utils/validators/formRules/index.ts +3 -3
  110. package/plugins/steve/urloptions.js +0 -47
@@ -0,0 +1,63 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { Banner } from './index';
3
+ import { cleanHtmlDirective } from '@shell/plugins/clean-html-directive';
4
+
5
+ describe('component: Banner', () => {
6
+ it('should display text based on label', () => {
7
+ const label = 'test';
8
+ const wrapper = mount(
9
+ Banner,
10
+ {
11
+ directives: { cleanHtmlDirective },
12
+ propsData: { label }
13
+ });
14
+
15
+ const element = wrapper.find('span').element;
16
+
17
+ expect(element.textContent).toBe(label);
18
+ });
19
+
20
+ it('should display an icon', () => {
21
+ const icon = 'my-icon';
22
+ const wrapper = mount(Banner, { propsData: { icon } });
23
+
24
+ const element = wrapper.find(`.${ icon }`).element;
25
+
26
+ expect(element.classList).toContain(icon);
27
+ });
28
+
29
+ it('should not display an icon', () => {
30
+ const wrapper = mount(Banner);
31
+
32
+ const element = wrapper.find(`[data-testid="banner-icon"]`).element;
33
+
34
+ expect(element).not.toBeDefined();
35
+ });
36
+
37
+ it('should emit close event', () => {
38
+ const wrapper = mount(Banner, { propsData: { closable: true } });
39
+ const element = wrapper.find(`[data-testid="banner-close"]`).element;
40
+
41
+ element.click();
42
+
43
+ expect(wrapper.emitted('close')).toHaveLength(1);
44
+ });
45
+
46
+ it('should add the right color', () => {
47
+ const color = 'red';
48
+ const wrapper = mount(Banner, { propsData: { color } });
49
+
50
+ const element = wrapper.element;
51
+
52
+ expect(element.classList).toContain(color);
53
+ });
54
+
55
+ it('should stack the banner messages', () => {
56
+ const stacked = true;
57
+ const wrapper = mount(Banner, { propsData: { stacked } });
58
+
59
+ const element = wrapper.find(`[data-testid="banner-content"]`).element;
60
+
61
+ expect(element.classList).toContain('stacked');
62
+ });
63
+ });
@@ -0,0 +1,244 @@
1
+ <script lang="ts">
2
+ import Vue from 'vue';
3
+ import { nlToBr } from '@shell/utils/string';
4
+ import { stringify } from '@shell/utils/error';
5
+
6
+ export default Vue.extend({
7
+ props: {
8
+ /**
9
+ * A color class that represents the color of the banner.
10
+ * @values primary, secondary, success, warning, error, info
11
+ */
12
+ color: {
13
+ type: String,
14
+ default: 'secondary'
15
+ },
16
+ /**
17
+ * The label to display as the banner's default content.
18
+ */
19
+ label: {
20
+ type: [String, Error, Object],
21
+ default: null
22
+ },
23
+ /**
24
+ * The i18n key for the label to display as the banner's default content.
25
+ */
26
+ labelKey: {
27
+ type: String,
28
+ default: null
29
+ },
30
+ /**
31
+ * Add icon for the banner
32
+ */
33
+ icon: {
34
+ type: String,
35
+ default: null
36
+ },
37
+ /**
38
+ * Toggles the banner's close button.
39
+ */
40
+ closable: {
41
+ type: Boolean,
42
+ default: false
43
+ },
44
+ /**
45
+ * Toggles the stacked class for the banner.
46
+ */
47
+ stacked: {
48
+ type: Boolean,
49
+ default: false
50
+ }
51
+ },
52
+ computed: {
53
+ /**
54
+ * Return message text as label.
55
+ */
56
+ messageLabel(): string | void {
57
+ return !(typeof this.label === 'string') ? stringify(this.label) : undefined;
58
+ }
59
+ },
60
+ methods: { nlToBr }
61
+ });
62
+ </script>
63
+ <template>
64
+ <div
65
+ class="banner"
66
+ :class="{
67
+ [color]: true,
68
+ }"
69
+ >
70
+ <div
71
+ v-if="icon"
72
+ class="banner__icon"
73
+ data-testid="banner-icon"
74
+ >
75
+ <i
76
+ class="icon icon-2x"
77
+ :class="icon"
78
+ />
79
+ </div>
80
+ <div
81
+ class="banner__content"
82
+ data-testid="banner-content"
83
+ :class="{
84
+ closable,
85
+ stacked,
86
+ icon
87
+ }"
88
+ >
89
+ <slot>
90
+ <t
91
+ v-if="labelKey"
92
+ :k="labelKey"
93
+ :raw="true"
94
+ />
95
+ <span v-else-if="messageLabel">{{ messageLabel }}</span>
96
+ <span
97
+ v-else
98
+ v-clean-html="nlToBr(label)"
99
+ />
100
+ </slot>
101
+ <div
102
+ v-if="closable"
103
+ class="banner__content__closer"
104
+ @click="$emit('close')"
105
+ >
106
+ <i
107
+ data-testid="banner-close"
108
+ class="icon icon-close closer-icon"
109
+ />
110
+ </div>
111
+ </div>
112
+ </div>
113
+ </template>
114
+
115
+ <style lang="scss" scoped>
116
+ $left-border-size: 4px;
117
+ $icon-size: 24px;
118
+
119
+ .banner {
120
+ display: flex;
121
+ margin: 15px 0;
122
+ position: relative;
123
+ width: 100%;
124
+ color: var(--body-text);
125
+
126
+ &__icon {
127
+ width: $icon-size * 2;
128
+ flex-grow: 1;
129
+ display: flex;
130
+ justify-content: center;
131
+ align-items: center;
132
+ box-sizing: content-box;
133
+
134
+ .primary & {
135
+ background: var(--primary);
136
+ }
137
+
138
+ .secondary & {
139
+ background: var(--default);
140
+ }
141
+
142
+ .success & {
143
+ background: var(--success);
144
+ }
145
+
146
+ .info & {
147
+ background: var(--info);
148
+ }
149
+
150
+ .warning & {
151
+ background: var(--warning);
152
+ }
153
+
154
+ .error & {
155
+ background: var(--error);
156
+ color: var(--primary-text);
157
+ }
158
+ }
159
+
160
+ &__content {
161
+ padding: 10px;
162
+ transition: all 0.2s ease;
163
+ line-height: 20px;
164
+ width: 100%;
165
+ border-left: solid $left-border-size transparent;
166
+ display: flex;
167
+ gap: 3px;
168
+
169
+ .primary & {
170
+ background: var(--primary);
171
+ border-color: var(--primary);
172
+ }
173
+
174
+ .secondary & {
175
+ background: var(--default-banner-bg);
176
+ border-color: var(--default);
177
+ }
178
+
179
+ .success & {
180
+ background: var(--success-banner-bg);
181
+ border-color: var(--success);
182
+ }
183
+
184
+ .info & {
185
+ background: var(--info-banner-bg);
186
+ border-color: var(--info);
187
+ }
188
+
189
+ .warning & {
190
+ background: var(--warning-banner-bg);
191
+ border-color: var(--warning);
192
+ }
193
+
194
+ .error & {
195
+ background: var(--error-banner-bg);
196
+ border-color: var(--error);
197
+ color: var(--error);
198
+ }
199
+
200
+ &.stacked {
201
+ padding: 0 10px;
202
+ margin: 0;
203
+ transition: none;
204
+ &:first-child {
205
+ padding-top: 10px;
206
+ }
207
+ &:last-child {
208
+ padding-bottom: 10px;
209
+ }
210
+ }
211
+
212
+ &.closable {
213
+ padding-right: $icon-size * 2;
214
+ }
215
+
216
+ &__closer {
217
+ display: flex;
218
+ align-items: center;
219
+
220
+ cursor: pointer;
221
+ position: absolute;
222
+ top: 0;
223
+ right: 0;
224
+ bottom: 0;
225
+ width: $icon-size;
226
+ line-height: $icon-size;
227
+ text-align: center;
228
+
229
+ .closer-icon {
230
+ opacity: 0.7;
231
+
232
+ &:hover {
233
+ opacity: 1;
234
+ color: var(--link);
235
+ }
236
+ }
237
+ }
238
+
239
+ &.icon {
240
+ border-left: none;
241
+ }
242
+ }
243
+ }
244
+ </style>
@@ -0,0 +1 @@
1
+ export { default as Banner } from './Banner.vue';
@@ -0,0 +1,37 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { Card } from './index';
3
+
4
+ describe('component: Card', () => {
5
+ const title = 'Card title';
6
+ const body = 'Card body';
7
+
8
+ it('should have a card title', () => {
9
+ const wrapper = mount(Card, {
10
+ propsData: { title },
11
+ slots: { title: '<div>Card title</div>' }
12
+ });
13
+
14
+ const element = wrapper.find('[data-testid="card-title-slot"]');
15
+
16
+ expect(element.exists()).toBe(true);
17
+ expect(element.text()).toBe(title);
18
+ });
19
+
20
+ it('should have a card body', () => {
21
+ const wrapper = mount(Card, {
22
+ propsData: { body },
23
+ slots: { body: '<div>Card body</div>' }
24
+ });
25
+ const element = wrapper.find('[data-testid="card-body-slot"]');
26
+
27
+ expect(element.exists()).toBe(true);
28
+ expect(element.text()).toBe(body);
29
+ });
30
+
31
+ it('should display the default card actions', () => {
32
+ const wrapper = mount(Card);
33
+ const element = wrapper.find('[data-testid="card-actions-slot"]');
34
+
35
+ expect(element.exists()).toBe(true);
36
+ });
37
+ });
@@ -0,0 +1,167 @@
1
+ <script lang="ts">
2
+ import Vue from 'vue';
3
+
4
+ export default Vue.extend({
5
+ name: 'Card',
6
+ props: {
7
+ /**
8
+ * The card's title.
9
+ */
10
+ title: {
11
+ type: String,
12
+ default: ''
13
+ },
14
+ /**
15
+ * The text content for the card's body.
16
+ */
17
+ content: {
18
+ type: String,
19
+ default: ''
20
+ },
21
+ /**
22
+ * The function to invoke when the default action button is clicked.
23
+ */
24
+ buttonAction: {
25
+ type: Function,
26
+ default: (): void => { }
27
+ },
28
+ /**
29
+ * The text for the default action button.
30
+ */
31
+ buttonText: {
32
+ type: String,
33
+ default: 'go'
34
+ },
35
+ /**
36
+ * Toggles the card's highlight-border class.
37
+ */
38
+ showHighlightBorder: {
39
+ type: Boolean,
40
+ default: true
41
+ },
42
+ /**
43
+ * Toggles the card's Actions section.
44
+ */
45
+ showActions: {
46
+ type: Boolean,
47
+ default: true
48
+ },
49
+ sticky: {
50
+ type: Boolean,
51
+ default: false,
52
+ },
53
+ }
54
+ });
55
+ </script>
56
+
57
+ <template>
58
+ <div
59
+ class="card-container"
60
+ :class="{'highlight-border': showHighlightBorder, 'card-sticky': sticky}"
61
+ data-testid="card"
62
+ >
63
+ <div class="card-wrap">
64
+ <div
65
+ class="card-title"
66
+ data-testid="card-title-slot"
67
+ >
68
+ <slot name="title">
69
+ {{ title }}
70
+ </slot>
71
+ </div>
72
+ <hr>
73
+ <div
74
+ class="card-body"
75
+ data-testid="card-body-slot"
76
+ >
77
+ <slot name="body">
78
+ {{ content }}
79
+ </slot>
80
+ </div>
81
+ <div
82
+ v-if="showActions"
83
+ class="card-actions"
84
+ data-testid="card-actions-slot"
85
+ >
86
+ <slot name="actions">
87
+ <button
88
+ class="btn role-primary"
89
+ @click="buttonAction"
90
+ >
91
+ {{ buttonText }}
92
+ </button>
93
+ </slot>
94
+ </div>
95
+ </div>
96
+ </div>
97
+ </template>
98
+
99
+ <style lang='scss'>
100
+ .card-container {
101
+ &.highlight-border {
102
+ border-left: 5px solid var(--primary);
103
+ }
104
+ border-radius: var(--border-radius);
105
+ display: flex;
106
+ flex-basis: 40%;
107
+ margin: 10px;
108
+ min-height: 100px;
109
+ padding: 10px;
110
+ box-shadow: 0 0 20px var(--shadow);
111
+ &:not(.top) {
112
+ align-items: top;
113
+ flex-direction: row;
114
+ justify-content: start;
115
+ }
116
+ .card-wrap {
117
+ width: 100%;
118
+ }
119
+ & .card-body {
120
+ color: var(--input-label);
121
+ display: flex;
122
+ flex-direction: column;
123
+ justify-content: center;
124
+ }
125
+ & .card-actions {
126
+ align-self: end;
127
+ display: flex;
128
+ padding-top: 20px;
129
+ }
130
+ & .card-title {
131
+ align-items: center;
132
+ display: flex;
133
+ width: 100%;
134
+ h5 {
135
+ margin: 0;
136
+ }
137
+ .flex-right {
138
+ margin-left: auto;
139
+ }
140
+ }
141
+
142
+ // Sticky mode will stick header and footer to top and bottom with content in the middle scrolling
143
+ &.card-sticky {
144
+ // display: flex;
145
+ // flex-direction: column;
146
+ overflow: hidden;
147
+
148
+ .card-wrap {
149
+ display: flex;
150
+ flex-direction: column;
151
+
152
+ .card-body {
153
+ justify-content: flex-start;
154
+ overflow: scroll;
155
+ }
156
+
157
+ > * {
158
+ flex: 0;
159
+ }
160
+
161
+ .card-body {
162
+ flex: 1;
163
+ }
164
+ }
165
+ }
166
+ }
167
+ </style>
@@ -0,0 +1 @@
1
+ export { default as Card } from './Card.vue';
@@ -0,0 +1,68 @@
1
+ import { shallowMount, Wrapper } from '@vue/test-utils';
2
+ import { Checkbox } from './index';
3
+
4
+ describe('checkbox.vue', () => {
5
+ const event = {
6
+ target: { tagName: 'input', href: null },
7
+ stopPropagation: () => { },
8
+ preventDefault: () => { }
9
+ } as unknown as MouseEvent;
10
+
11
+ it('is unchecked by default', () => {
12
+ const wrapper = shallowMount(Checkbox);
13
+ const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
14
+
15
+ expect(cbInput.checked).toBe(false);
16
+ });
17
+
18
+ it('renders a true value', () => {
19
+ const wrapper = shallowMount(Checkbox, { propsData: { value: true } });
20
+ const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
21
+
22
+ expect(cbInput.checked).toBe(true);
23
+ });
24
+
25
+ it('updates from false to true when props change', async() => {
26
+ const wrapper = shallowMount(Checkbox);
27
+ const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
28
+
29
+ expect(cbInput.checked).toBe(false);
30
+
31
+ await wrapper.setProps({ value: true });
32
+
33
+ expect(cbInput.checked).toBe(true);
34
+ });
35
+
36
+ it('emits an input event with a true value', async() => {
37
+ const wrapper: Wrapper<InstanceType<typeof Checkbox>> = shallowMount(Checkbox);
38
+
39
+ wrapper.vm.clicked(event);
40
+ await wrapper.vm.$nextTick();
41
+
42
+ expect(wrapper.emitted().input?.length).toBe(1);
43
+ expect(wrapper.emitted().input?.[0][0]).toBe(true);
44
+ });
45
+
46
+ it('emits an input event with a custom valueWhenTrue', async() => {
47
+ const valueWhenTrue = 'BIG IF TRUE';
48
+
49
+ const wrapper: Wrapper<InstanceType<typeof Checkbox>> = shallowMount(Checkbox, { propsData: { value: false, valueWhenTrue } });
50
+
51
+ wrapper.vm.clicked(event);
52
+ await wrapper.vm.$nextTick();
53
+
54
+ expect(wrapper.emitted().input?.length).toBe(1);
55
+ expect(wrapper.emitted().input?.[0][0]).toBe(valueWhenTrue);
56
+ });
57
+
58
+ it('updates from valueWhenTrue to falsy', async() => {
59
+ const valueWhenTrue = 'REAL HUGE IF FALSE';
60
+
61
+ const wrapper: Wrapper<InstanceType<typeof Checkbox>> = shallowMount(Checkbox, { propsData: { value: valueWhenTrue, valueWhenTrue } });
62
+
63
+ wrapper.vm.clicked(event);
64
+ await wrapper.vm.$nextTick();
65
+
66
+ expect(wrapper.emitted().input?.[0][0]).toBeNull();
67
+ });
68
+ });