@rancher/shell 3.0.9 → 3.0.11

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 (104) hide show
  1. package/assets/styles/base/_color.scss +4 -0
  2. package/assets/styles/themes/_light.scss +6 -6
  3. package/assets/styles/themes/_modern.scss +14 -6
  4. package/assets/translations/en-us.yaml +9 -10
  5. package/chart/__tests__/rancher-backup-index.test.ts +248 -0
  6. package/chart/rancher-backup/index.vue +41 -2
  7. package/components/BrandImage.vue +6 -5
  8. package/components/ConsumptionGauge.vue +12 -4
  9. package/components/CopyToClipboard.vue +28 -0
  10. package/components/CopyToClipboardText.vue +4 -0
  11. package/components/CruResource.vue +1 -0
  12. package/components/DynamicContent/DynamicContentIcon.vue +3 -2
  13. package/components/ExplorerProjectsNamespaces.vue +1 -4
  14. package/components/GlobalRoleBindings.vue +1 -5
  15. package/components/LazyImage.vue +2 -1
  16. package/components/Resource/Detail/Card/Scaler.vue +4 -4
  17. package/components/ResourceDetail/index.vue +0 -21
  18. package/components/Tabbed/index.vue +6 -0
  19. package/components/__tests__/ConsumptionGauge.test.ts +31 -0
  20. package/components/__tests__/CruResource.test.ts +35 -1
  21. package/components/form/ProjectMemberEditor.vue +0 -10
  22. package/components/nav/TopLevelMenu.helper.ts +7 -79
  23. package/components/nav/__tests__/TopLevelMenu.helper.test.ts +2 -53
  24. package/composables/useIsNewDetailPageEnabled.test.ts +98 -0
  25. package/composables/useIsNewDetailPageEnabled.ts +12 -0
  26. package/config/private-label.js +2 -1
  27. package/config/product/apps.js +1 -0
  28. package/config/product/explorer.js +11 -1
  29. package/config/table-headers.js +0 -9
  30. package/config/types.js +0 -1
  31. package/core/__tests__/extension-manager-impl.test.js +187 -2
  32. package/core/extension-manager-impl.js +4 -2
  33. package/core/plugin-helpers.ts +31 -0
  34. package/detail/__tests__/node.test.ts +83 -0
  35. package/detail/management.cattle.io.oidcclient.vue +2 -1
  36. package/detail/node.vue +1 -0
  37. package/edit/auth/github-app-steps.vue +2 -0
  38. package/edit/auth/github-steps.vue +2 -0
  39. package/edit/catalog.cattle.io.clusterrepo.vue +17 -3
  40. package/edit/cloudcredential.vue +2 -1
  41. package/edit/management.cattle.io.user.vue +60 -35
  42. package/edit/monitoring.coreos.com.alertmanagerconfig/receiverConfig.vue +11 -6
  43. package/edit/provisioning.cattle.io.cluster/index.vue +5 -4
  44. package/edit/provisioning.cattle.io.cluster/shared.ts +4 -2
  45. package/edit/secret/generic.vue +1 -0
  46. package/edit/secret/index.vue +2 -1
  47. package/edit/service.vue +2 -14
  48. package/edit/token.vue +29 -68
  49. package/list/management.cattle.io.feature.vue +7 -1
  50. package/list/provisioning.cattle.io.cluster.vue +0 -49
  51. package/mixins/brand.js +2 -1
  52. package/models/catalog.cattle.io.clusterrepo.js +9 -0
  53. package/models/cluster.x-k8s.io.machinedeployment.js +8 -3
  54. package/models/management.cattle.io.authconfig.js +2 -1
  55. package/models/management.cattle.io.cluster.js +4 -3
  56. package/models/monitoring.coreos.com.receiver.js +11 -6
  57. package/models/provisioning.cattle.io.cluster.js +2 -2
  58. package/models/token.js +0 -4
  59. package/package.json +12 -12
  60. package/pages/account/index.vue +67 -96
  61. package/pages/c/_cluster/apps/charts/AppChartCardFooter.vue +66 -9
  62. package/pages/c/_cluster/apps/charts/index.vue +3 -8
  63. package/pages/c/_cluster/apps/charts/install.vue +8 -9
  64. package/pages/c/_cluster/explorer/index.vue +2 -19
  65. package/pages/c/_cluster/istio/index.vue +4 -2
  66. package/pages/c/_cluster/longhorn/index.vue +2 -1
  67. package/pages/c/_cluster/monitoring/index.vue +2 -2
  68. package/pages/c/_cluster/neuvector/index.vue +2 -1
  69. package/pages/c/_cluster/settings/performance.vue +0 -5
  70. package/pages/c/_cluster/uiplugins/PluginInfoPanel.vue +2 -1
  71. package/pages/c/_cluster/uiplugins/index.vue +2 -1
  72. package/pkg/auto-import.js +41 -0
  73. package/plugins/dashboard-store/resource-class.js +2 -2
  74. package/plugins/steve/__tests__/steve-class.test.ts +1 -1
  75. package/plugins/steve/steve-class.js +3 -3
  76. package/plugins/steve/steve-pagination-utils.ts +2 -5
  77. package/plugins/steve/subscribe.js +29 -4
  78. package/rancher-components/Pill/RcCounterBadge/RcCounterBadge.vue +7 -7
  79. package/rancher-components/Pill/RcStatusBadge/RcStatusBadge.vue +5 -2
  80. package/rancher-components/RcButton/RcButton.vue +3 -3
  81. package/rancher-components/RcButtonSplit/RcButtonSplit.test.ts +253 -0
  82. package/rancher-components/RcButtonSplit/RcButtonSplit.vue +158 -0
  83. package/rancher-components/RcButtonSplit/index.ts +1 -0
  84. package/rancher-components/RcIcon/types.ts +2 -2
  85. package/rancher-components/RcSection/RcSection.test.ts +323 -0
  86. package/rancher-components/RcSection/RcSection.vue +252 -0
  87. package/rancher-components/RcSection/RcSectionActions.test.ts +212 -0
  88. package/rancher-components/RcSection/RcSectionActions.vue +85 -0
  89. package/rancher-components/RcSection/RcSectionBadges.test.ts +149 -0
  90. package/rancher-components/RcSection/RcSectionBadges.vue +29 -0
  91. package/rancher-components/RcSection/index.ts +12 -0
  92. package/rancher-components/RcSection/types.ts +86 -0
  93. package/scripts/test-plugins-build.sh +9 -8
  94. package/types/shell/index.d.ts +93 -108
  95. package/utils/__tests__/require-asset.test.ts +98 -0
  96. package/utils/async.ts +1 -5
  97. package/utils/brand.ts +3 -1
  98. package/utils/favicon.js +4 -3
  99. package/utils/require-asset.ts +95 -0
  100. package/utils/style.ts +17 -0
  101. package/utils/units.js +14 -5
  102. package/vue.config.js +4 -3
  103. package/components/HarvesterServiceAddOnConfig.vue +0 -207
  104. package/models/ext.cattle.io.token.js +0 -48
@@ -0,0 +1,253 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { defineComponent } from 'vue';
3
+ import RcButtonSplit from './RcButtonSplit.vue';
4
+ import { ButtonVariant, ButtonSize } from '@components/RcButton/types';
5
+
6
+ // v-dropdown is provided by floating-vue and must be mocked in unit tests.
7
+ // The default slot is the trigger anchor; the popper slot is the dropdown content.
8
+ const vDropdownMock = defineComponent({
9
+ template: `
10
+ <div>
11
+ <slot />
12
+ <slot name="popper" />
13
+ </div>
14
+ `,
15
+ });
16
+
17
+ const globalConfig = { global: { components: { 'v-dropdown': vDropdownMock } } };
18
+
19
+ // RcButton and RcDropdownTrigger both use single-root attribute inheritance, so
20
+ // the class added to the component falls through to the rendered <button> element.
21
+ // Selectors like '.rc-button-split-action' refer directly to the <button> element.
22
+
23
+ describe('rcButtonSplit.vue', () => {
24
+ it('renders the main action button', () => {
25
+ const wrapper = mount(RcButtonSplit, globalConfig);
26
+
27
+ expect(wrapper.find('.rc-button-split-action').exists()).toBe(true);
28
+ });
29
+
30
+ it('renders the dropdown trigger', () => {
31
+ const wrapper = mount(RcButtonSplit, globalConfig);
32
+
33
+ expect(wrapper.find('.rc-button-split-trigger').exists()).toBe(true);
34
+ });
35
+
36
+ it('emits click when the main action button is clicked', async() => {
37
+ const wrapper = mount(RcButtonSplit, globalConfig);
38
+
39
+ await wrapper.find('.rc-button-split-action').trigger('click');
40
+
41
+ expect(wrapper.emitted('click')).toHaveLength(1);
42
+ expect(wrapper.emitted('click')![0][0]).toBeInstanceOf(MouseEvent);
43
+ });
44
+
45
+ it('does not emit click when the dropdown trigger is clicked', async() => {
46
+ const wrapper = mount(RcButtonSplit, globalConfig);
47
+
48
+ await wrapper.find('.rc-button-split-trigger').trigger('click');
49
+
50
+ expect(wrapper.emitted('click')).toBeUndefined();
51
+ });
52
+
53
+ describe('variant prop', () => {
54
+ it.each([
55
+ ['primary', 'variant-primary'],
56
+ ['secondary', 'variant-secondary'],
57
+ ['tertiary', 'variant-tertiary'],
58
+ ] as [ButtonVariant, string][])('applies %s variant class to the action button', (variant, className) => {
59
+ const wrapper = mount(RcButtonSplit, { ...globalConfig, props: { variant } });
60
+
61
+ expect(wrapper.find('.rc-button-split-action').classes()).toContain(className);
62
+ });
63
+
64
+ it.each([
65
+ ['primary', 'variant-primary'],
66
+ ['secondary', 'variant-secondary'],
67
+ ['tertiary', 'variant-tertiary'],
68
+ ] as [ButtonVariant, string][])('applies %s variant class to the dropdown trigger button', (variant, className) => {
69
+ const wrapper = mount(RcButtonSplit, { ...globalConfig, props: { variant } });
70
+
71
+ expect(wrapper.find('.rc-button-split-trigger').classes()).toContain(className);
72
+ });
73
+ });
74
+
75
+ describe('size prop', () => {
76
+ it.each([
77
+ ['small', 'btn-small'],
78
+ ['medium', 'btn-medium'],
79
+ ['large', 'btn-large'],
80
+ ] as [ButtonSize, string][])('applies %s size class to the action button', (size, className) => {
81
+ const wrapper = mount(RcButtonSplit, { ...globalConfig, props: { size } });
82
+
83
+ expect(wrapper.find('.rc-button-split-action').classes()).toContain(className);
84
+ });
85
+
86
+ it.each([
87
+ ['small', 'btn-small'],
88
+ ['medium', 'btn-medium'],
89
+ ['large', 'btn-large'],
90
+ ] as [ButtonSize, string][])('applies %s size class to the dropdown trigger button', (size, className) => {
91
+ const wrapper = mount(RcButtonSplit, { ...globalConfig, props: { size } });
92
+
93
+ expect(wrapper.find('.rc-button-split-trigger').classes()).toContain(className);
94
+ });
95
+ });
96
+
97
+ describe('slots', () => {
98
+ it('renders default slot content in the main button', () => {
99
+ const wrapper = mount(RcButtonSplit, {
100
+ ...globalConfig,
101
+ slots: { default: 'Save' },
102
+ });
103
+
104
+ expect(wrapper.find('.rc-button-split-action').text()).toContain('Save');
105
+ });
106
+
107
+ it('renders before slot content in the main button', () => {
108
+ const wrapper = mount(RcButtonSplit, {
109
+ ...globalConfig,
110
+ slots: {
111
+ default: 'Save',
112
+ before: '<span class="before-content">Before</span>',
113
+ },
114
+ });
115
+
116
+ expect(wrapper.find('.rc-button-split-action .before-content').exists()).toBe(true);
117
+ });
118
+
119
+ it('renders after slot content in the main button', () => {
120
+ const wrapper = mount(RcButtonSplit, {
121
+ ...globalConfig,
122
+ slots: {
123
+ default: 'Save',
124
+ after: '<span class="after-content">After</span>',
125
+ },
126
+ });
127
+
128
+ expect(wrapper.find('.rc-button-split-action .after-content').exists()).toBe(true);
129
+ });
130
+
131
+ it('renders dropdownCollection slot content', () => {
132
+ const wrapper = mount(RcButtonSplit, {
133
+ ...globalConfig,
134
+ slots: { dropdownCollection: '<div class="dropdown-item-test">Item 1</div>' },
135
+ });
136
+
137
+ expect(wrapper.find('.dropdown-item-test').exists()).toBe(true);
138
+ expect(wrapper.find('.dropdown-item-test').text()).toStrictEqual('Item 1');
139
+ });
140
+ });
141
+
142
+ it('dropdown trigger has aria-haspopup="menu" attribute', () => {
143
+ const wrapper = mount(RcButtonSplit, globalConfig);
144
+
145
+ expect(wrapper.find('.rc-button-split-trigger').attributes('aria-haspopup')).toBe('menu');
146
+ });
147
+
148
+ it('emits update:open when dropdown open state changes', async() => {
149
+ const wrapper = mount(RcButtonSplit, globalConfig);
150
+
151
+ await wrapper.findComponent({ name: 'RcDropdown' }).vm.$emit('update:open', true);
152
+
153
+ expect(wrapper.emitted('update:open')).toHaveLength(1);
154
+ expect(wrapper.emitted('update:open')![0]).toStrictEqual([true]);
155
+ });
156
+
157
+ it('applies default variant "primary" when no variant is provided', () => {
158
+ const wrapper = mount(RcButtonSplit, globalConfig);
159
+
160
+ expect(wrapper.find('.rc-button-split-action').classes()).toContain('variant-primary');
161
+ });
162
+
163
+ it('applies default size "medium" when no size is provided', () => {
164
+ const wrapper = mount(RcButtonSplit, globalConfig);
165
+
166
+ expect(wrapper.find('.rc-button-split-action').classes()).toContain('btn-medium');
167
+ });
168
+
169
+ describe('aria label props', () => {
170
+ it('ariaLabel is applied to the action button', () => {
171
+ const wrapper = mount(RcButtonSplit, { ...globalConfig, props: { ariaLabel: 'Save document' } });
172
+
173
+ expect(wrapper.find('.rc-button-split-action').attributes('aria-label')).toBe('Save document');
174
+ });
175
+
176
+ it('ariaLabel is absent from the trigger button', () => {
177
+ const wrapper = mount(RcButtonSplit, { ...globalConfig, props: { ariaLabel: 'Save document' } });
178
+
179
+ expect(wrapper.find('.rc-button-split-trigger').attributes('aria-label')).toBeUndefined();
180
+ });
181
+
182
+ it('ariaLabelTrigger is applied to the trigger button', () => {
183
+ const wrapper = mount(RcButtonSplit, { ...globalConfig, props: { ariaLabelTrigger: 'More save options' } });
184
+
185
+ expect(wrapper.find('.rc-button-split-trigger').attributes('aria-label')).toBe('More save options');
186
+ });
187
+
188
+ it('ariaLabelTrigger is absent from the action button', () => {
189
+ const wrapper = mount(RcButtonSplit, { ...globalConfig, props: { ariaLabelTrigger: 'More save options' } });
190
+
191
+ expect(wrapper.find('.rc-button-split-action').attributes('aria-label')).toBeUndefined();
192
+ });
193
+
194
+ it('ariaLabelDropdown is forwarded to RcDropdown', () => {
195
+ const wrapper = mount(RcButtonSplit, { ...globalConfig, props: { ariaLabelDropdown: 'Save actions' } });
196
+
197
+ expect(wrapper.findComponent({ name: 'RcDropdown' }).props('ariaLabel')).toBe('Save actions');
198
+ });
199
+ });
200
+
201
+ describe('items prop', () => {
202
+ const items = [
203
+ { id: 'draft', label: 'Save as Draft' },
204
+ { id: 'template', label: 'Save as Template' },
205
+ { id: 'discard', label: 'Discard Changes' },
206
+ ];
207
+
208
+ it('renders an RcDropdownItem for each entry in items', () => {
209
+ const wrapper = mount(RcButtonSplit, { ...globalConfig, props: { items } });
210
+
211
+ const dropdownItems = wrapper.findAllComponents({ name: 'RcDropdownItem' });
212
+
213
+ expect(dropdownItems).toHaveLength(3);
214
+ });
215
+
216
+ it('renders each item\'s label text', () => {
217
+ const wrapper = mount(RcButtonSplit, { ...globalConfig, props: { items } });
218
+
219
+ const dropdownItems = wrapper.findAllComponents({ name: 'RcDropdownItem' });
220
+
221
+ expect(dropdownItems[0].text()).toContain('Save as Draft');
222
+ expect(dropdownItems[1].text()).toContain('Save as Template');
223
+ expect(dropdownItems[2].text()).toContain('Discard Changes');
224
+ });
225
+
226
+ it('emits select with the item id when a prop item is clicked', async() => {
227
+ const wrapper = mount(RcButtonSplit, { ...globalConfig, props: { items } });
228
+
229
+ await wrapper.findAllComponents({ name: 'RcDropdownItem' })[0].trigger('click');
230
+
231
+ expect(wrapper.emitted('select')).toHaveLength(1);
232
+ expect(wrapper.emitted('select')![0]).toStrictEqual(['draft']);
233
+ });
234
+
235
+ it('does not emit select when no items prop is provided', async() => {
236
+ const wrapper = mount(RcButtonSplit, globalConfig);
237
+
238
+ expect(wrapper.emitted('select')).toBeUndefined();
239
+ });
240
+
241
+ it('renders both prop items and dropdownCollection slot content when both are supplied', () => {
242
+ const wrapper = mount(RcButtonSplit, {
243
+ ...globalConfig,
244
+ props: { items: [{ id: 'draft', label: 'Save as Draft' }] },
245
+ slots: { dropdownCollection: '<div class="slot-item">Slot Item</div>' },
246
+ });
247
+
248
+ expect(wrapper.findAllComponents({ name: 'RcDropdownItem' })).toHaveLength(1);
249
+ expect(wrapper.find('.slot-item').exists()).toBe(true);
250
+ expect(wrapper.find('.slot-item').text()).toStrictEqual('Slot Item');
251
+ });
252
+ });
253
+ });
@@ -0,0 +1,158 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * A split button that combines a primary action button with a dropdown trigger
4
+ * for secondary actions.
5
+ *
6
+ * Example:
7
+ *
8
+ * <rc-button-split variant="primary" @click="doAction" @update:open="onOpen">
9
+ * Save
10
+ * <template #dropdownCollection>
11
+ * <rc-dropdown-item @click="doOtherAction">Save as Draft</rc-dropdown-item>
12
+ * </template>
13
+ * </rc-button-split>
14
+ */
15
+ import { RcButton } from '@components/RcButton';
16
+ import { RcDropdown, RcDropdownItem, RcDropdownTrigger } from '@components/RcDropdown';
17
+ import RcIcon from '@components/RcIcon/RcIcon.vue';
18
+ import { ButtonVariant, ButtonSize, IconProps } from '@components/RcButton/types';
19
+ import type { Placement } from 'floating-vue';
20
+
21
+ type RcButtonSplitVariant = Exclude<ButtonVariant, 'link' | 'ghost' | 'multiAction'>;
22
+
23
+ type RcButtonSplitItem = {
24
+ id: string;
25
+ label: string;
26
+ };
27
+
28
+ type RcButtonSplitProps = {
29
+ disabled?: boolean;
30
+ variant?: RcButtonSplitVariant;
31
+ size?: ButtonSize;
32
+ ariaLabel?: string;
33
+ ariaLabelTrigger?: string;
34
+ ariaLabelDropdown?: string;
35
+ placement?: Placement;
36
+ distance?: number;
37
+ items?: RcButtonSplitItem[];
38
+ } & IconProps;
39
+
40
+ withDefaults(
41
+ defineProps<RcButtonSplitProps>(),
42
+ {
43
+ disabled: false,
44
+ variant: 'primary',
45
+ size: 'medium',
46
+ ariaLabel: undefined,
47
+ ariaLabelTrigger: undefined,
48
+ ariaLabelDropdown: undefined,
49
+ placement: 'bottom-end',
50
+ distance: undefined,
51
+ items: undefined,
52
+ });
53
+
54
+ const emit = defineEmits<{
55
+ click: [event: MouseEvent];
56
+ 'update:open': [open: boolean];
57
+ select: [id: string];
58
+ }>();
59
+ </script>
60
+
61
+ <template>
62
+ <RcDropdown
63
+ :aria-label="ariaLabelDropdown"
64
+ :placement="placement"
65
+ :distance="distance"
66
+ @update:open="emit('update:open', $event)"
67
+ >
68
+ <div class="rc-button-split">
69
+ <RcButton
70
+ class="rc-button-split-action"
71
+ :aria-label="ariaLabel"
72
+ :disabled="disabled"
73
+ :variant="variant"
74
+ :size="size"
75
+ :left-icon="leftIcon"
76
+ :right-icon="rightIcon"
77
+ @click="emit('click', $event)"
78
+ >
79
+ <template
80
+ v-if="$slots.before"
81
+ #before
82
+ >
83
+ <slot name="before" />
84
+ </template>
85
+ <slot />
86
+ <template
87
+ v-if="$slots.after"
88
+ #after
89
+ >
90
+ <slot name="after" />
91
+ </template>
92
+ </RcButton>
93
+
94
+ <RcDropdownTrigger
95
+ class="rc-button-split-trigger"
96
+ :aria-label="ariaLabelTrigger"
97
+ :disabled="disabled"
98
+ :variant="variant"
99
+ :size="size"
100
+ >
101
+ <RcIcon
102
+ type="chevron-down"
103
+ size="inherit"
104
+ />
105
+ </RcDropdownTrigger>
106
+ </div>
107
+
108
+ <template #dropdownCollection>
109
+ <RcDropdownItem
110
+ v-for="item in items"
111
+ :key="item.id"
112
+ @click="emit('select', item.id)"
113
+ >
114
+ {{ item.label }}
115
+ </RcDropdownItem>
116
+ <slot name="dropdownCollection" />
117
+ </template>
118
+ </RcDropdown>
119
+ </template>
120
+
121
+ <style lang="scss" scoped>
122
+ .rc-button-split {
123
+ display: inline-flex;
124
+
125
+ // Round only the outer left edge of the main button
126
+ :deep(.rc-button-split-action) {
127
+ border-top-right-radius: 0;
128
+ border-bottom-right-radius: 0;
129
+ }
130
+
131
+ // Round only the outer right edge of the trigger button; narrow padding
132
+ :deep(button.rc-button-split-trigger) {
133
+ border-top-left-radius: 0;
134
+ border-bottom-left-radius: 0;
135
+ padding-left: 8px;
136
+ padding-right: 8px;
137
+ min-width: unset;
138
+ }
139
+
140
+ :deep(button.btn-small.rc-button-split-trigger) {
141
+ padding-left: 4px;
142
+ padding-right: 4px;
143
+ }
144
+
145
+ // Primary: semi-transparent right border as separator
146
+ :deep(.rc-button-split-trigger.variant-primary),
147
+ :deep(.rc-button-split-trigger.variant-secondary),
148
+ :deep(.rc-button-split-trigger.variant-tertiary) {
149
+ border-left: 1px solid rgba(255, 255, 255, 0.3);
150
+ }
151
+
152
+ // Link/Ghost: subtle separator
153
+ :deep(.rc-button-split-action.variant-link),
154
+ :deep(.rc-button-split-action.variant-ghost) {
155
+ border-right: 1px solid var(--border);
156
+ }
157
+ }
158
+ </style>
@@ -0,0 +1 @@
1
+ export { default as RcButtonSplit } from './RcButtonSplit.vue';
@@ -148,8 +148,8 @@ export const RcIconTypeToClass = {
148
148
  export const RcIconSizeToCSS = {
149
149
  xxlarge: '40px',
150
150
  xlarge: '32px',
151
- large: '25px',
152
- medium: '18px',
151
+ large: '24px',
152
+ medium: '16px',
153
153
  small: '14px',
154
154
  inherit: 'inherit'
155
155
  };