@rancher/shell 3.0.8-rc.9 → 3.0.8

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 (146) hide show
  1. package/apis/impl/apis.ts +61 -0
  2. package/apis/index.ts +40 -0
  3. package/apis/intf/modal.ts +90 -0
  4. package/apis/intf/shell.ts +36 -0
  5. package/apis/intf/slide-in.ts +98 -0
  6. package/apis/intf/system.ts +41 -0
  7. package/apis/shell/__tests__/modal.test.ts +80 -0
  8. package/apis/shell/__tests__/notifications.test.ts +71 -0
  9. package/apis/shell/__tests__/slide-in.test.ts +54 -0
  10. package/apis/shell/__tests__/system.test.ts +129 -0
  11. package/apis/shell/index.ts +38 -0
  12. package/apis/shell/modal.ts +41 -0
  13. package/apis/shell/notifications.ts +65 -0
  14. package/apis/shell/slide-in.ts +33 -0
  15. package/apis/shell/system.ts +65 -0
  16. package/apis/vue-shim.d.ts +11 -0
  17. package/assets/styles/global/_tooltip.scss +6 -1
  18. package/assets/translations/en-us.yaml +5 -0
  19. package/components/ActionMenuShell.vue +3 -1
  20. package/components/CruResource.vue +8 -1
  21. package/components/Drawer/ResourceDetailDrawer/__tests__/composables.test.ts +50 -1
  22. package/components/Drawer/ResourceDetailDrawer/composables.ts +19 -0
  23. package/components/Drawer/ResourceDetailDrawer/index.vue +3 -1
  24. package/components/LocaleSelector.vue +2 -2
  25. package/components/ModalManager.vue +11 -1
  26. package/components/Questions/__tests__/Yaml.test.ts +1 -1
  27. package/components/RelatedResources.vue +5 -0
  28. package/components/Resource/Detail/ResourcePopover/index.vue +5 -1
  29. package/components/ResourceDetail/Masthead/latest.vue +23 -21
  30. package/components/ResourceDetail/index.vue +3 -0
  31. package/components/ResourceTable.vue +54 -21
  32. package/components/SlideInPanelManager.vue +16 -11
  33. package/components/SortableTable/THead.vue +2 -1
  34. package/components/SortableTable/index.vue +20 -2
  35. package/components/Tabbed/index.vue +37 -2
  36. package/components/__tests__/NamespaceFilter.test.ts +49 -0
  37. package/components/auth/SelectPrincipal.vue +4 -0
  38. package/components/auth/login/ldap.vue +3 -3
  39. package/components/fleet/FleetSecretSelector.vue +1 -1
  40. package/components/form/KeyValue.vue +1 -1
  41. package/components/form/NameNsDescription.vue +1 -1
  42. package/components/form/NodeScheduling.vue +2 -2
  43. package/components/form/ResourceTabs/composable.ts +2 -2
  44. package/components/form/ResourceTabs/index.vue +0 -2
  45. package/components/form/__tests__/NameNsDescription.test.ts +42 -0
  46. package/components/formatter/LinkName.vue +5 -0
  47. package/components/nav/Group.vue +25 -7
  48. package/components/nav/Header.vue +1 -1
  49. package/components/nav/NamespaceFilter.vue +1 -0
  50. package/components/nav/Type.vue +17 -6
  51. package/components/nav/WindowManager/panels/TabBodyContainer.vue +1 -1
  52. package/components/nav/__tests__/Type.test.ts +59 -0
  53. package/composables/cruResource.ts +27 -0
  54. package/composables/focusTrap.ts +3 -1
  55. package/composables/resourceDetail.ts +15 -0
  56. package/composables/useLabeledFormElement.ts +3 -4
  57. package/config/product/fleet.js +1 -1
  58. package/config/router/navigation-guards/clusters.js +3 -3
  59. package/config/router/navigation-guards/products.js +1 -1
  60. package/config/router/routes.js +1 -5
  61. package/core/__tests__/extension-manager-impl.test.js +437 -0
  62. package/core/extension-manager-impl.js +6 -27
  63. package/core/plugin-helpers.ts +2 -2
  64. package/core/plugin.ts +9 -1
  65. package/core/plugins-loader.js +2 -2
  66. package/core/types-provisioning.ts +4 -0
  67. package/core/types.ts +35 -0
  68. package/detail/provisioning.cattle.io.cluster.vue +8 -6
  69. package/dialog/DeveloperLoadExtensionDialog.vue +1 -1
  70. package/dialog/MoveNamespaceDialog.vue +20 -4
  71. package/dialog/SearchDialog.vue +1 -0
  72. package/dialog/__tests__/MoveNamespaceDialog.test.ts +249 -0
  73. package/directives/__tests__/clean-tooltip.test.ts +298 -0
  74. package/directives/clean-tooltip.ts +234 -0
  75. package/edit/__tests__/fleet.cattle.io.gitrepo.test.ts +2 -2
  76. package/edit/__tests__/fleet.cattle.io.helmop.test.ts +98 -1
  77. package/edit/fleet.cattle.io.helmop.vue +5 -0
  78. package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +21 -21
  79. package/edit/provisioning.cattle.io.cluster/index.vue +5 -5
  80. package/edit/provisioning.cattle.io.cluster/rke2.vue +8 -8
  81. package/edit/resources.cattle.io.restore.vue +1 -1
  82. package/edit/workload/Job.vue +2 -2
  83. package/edit/workload/index.vue +1 -1
  84. package/initialize/install-plugins.js +4 -5
  85. package/machine-config/azure.vue +1 -1
  86. package/machine-config/components/GCEImage.vue +1 -1
  87. package/models/__tests__/provisioning.cattle.io.cluster.test.ts +16 -0
  88. package/models/chart.js +70 -74
  89. package/models/management.cattle.io.cluster.js +1 -1
  90. package/models/provisioning.cattle.io.cluster.js +11 -3
  91. package/package.json +7 -7
  92. package/pages/auth/login.vue +3 -3
  93. package/pages/auth/setup.vue +1 -1
  94. package/pages/auth/verify.vue +3 -3
  95. package/pages/c/_cluster/apps/charts/index.vue +122 -24
  96. package/pages/c/_cluster/apps/charts/install.vue +33 -0
  97. package/pages/c/_cluster/explorer/__tests__/index.test.ts +1 -1
  98. package/pages/c/_cluster/fleet/index.vue +4 -7
  99. package/pages/c/_cluster/settings/index.vue +5 -0
  100. package/pkg/auto-import.js +3 -3
  101. package/pkg/dynamic-importer.lib.js +1 -1
  102. package/pkg/import.js +1 -1
  103. package/plugins/__tests__/mutations.tests.ts +179 -0
  104. package/plugins/dashboard-store/getters.js +1 -1
  105. package/plugins/dashboard-store/model-loader.js +1 -1
  106. package/plugins/dashboard-store/mutations.js +23 -2
  107. package/plugins/dashboard-store/resource-class.js +8 -3
  108. package/plugins/plugin.js +2 -2
  109. package/plugins/steve/__tests__/steve-pagination-utils.test.ts +301 -128
  110. package/plugins/steve/steve-class.js +1 -1
  111. package/plugins/steve/steve-pagination-utils.ts +108 -43
  112. package/rancher-components/Form/Checkbox/Checkbox.vue +1 -1
  113. package/rancher-components/Form/LabeledInput/LabeledInput.vue +1 -1
  114. package/rancher-components/RcDropdown/useDropdownContext.ts +2 -4
  115. package/rancher-components/RcItemCard/RcItemCard.vue +1 -1
  116. package/scripts/publish-shell.sh +25 -0
  117. package/store/__tests__/catalog.test.ts +1 -1
  118. package/store/__tests__/type-map.test.ts +164 -2
  119. package/store/auth.js +23 -11
  120. package/store/i18n.js +3 -3
  121. package/store/index.js +5 -3
  122. package/store/notifications.ts +2 -0
  123. package/store/prefs.js +2 -2
  124. package/store/type-map.js +17 -7
  125. package/types/internal-api/shell/modal.d.ts +6 -6
  126. package/types/notifications/index.ts +126 -15
  127. package/types/rancher/index.d.ts +9 -0
  128. package/types/shell/index.d.ts +16 -1
  129. package/types/vue-shim.d.ts +5 -4
  130. package/utils/__tests__/router.test.js +238 -0
  131. package/utils/cluster.js +4 -1
  132. package/utils/fleet.ts +8 -1
  133. package/utils/pagination-utils.ts +2 -2
  134. package/utils/pagination-wrapper.ts +1 -1
  135. package/utils/router.js +50 -0
  136. package/utils/unit-tests/pagination-utils.spec.ts +8 -8
  137. package/vue.config.js +3 -3
  138. package/composables/useExtensionManager.ts +0 -17
  139. package/core/__test__/extension-manager-impl.test.js +0 -236
  140. package/core/plugins.js +0 -38
  141. package/directives/clean-tooltip.js +0 -32
  142. package/plugins/internal-api/index.ts +0 -37
  143. package/plugins/internal-api/shared/base-api.ts +0 -13
  144. package/plugins/internal-api/shell/shell.api.ts +0 -108
  145. package/types/internal-api/shell/growl.d.ts +0 -25
  146. package/types/internal-api/shell/slideIn.d.ts +0 -15
package/store/type-map.js CHANGED
@@ -35,6 +35,7 @@
35
35
  // ifHave, -- Show this product only if the given capability is available
36
36
  // ifHaveGroup, -- Show this product only if the given group exists in the store [inStore]
37
37
  // ifHaveType, -- Show this product only if the given type exists in the store [inStore], This can also be specified as an object { type: TYPE, store: 'management' } if the type isn't in the current [inStore]
38
+ // ifNotHaveType, -- Hide this product if the given type exists in the store [inStore] (opposite of ifHaveType)
38
39
  // ifHaveVerb, -- In combination with ifHaveTYpe, show it only if the type also has this collectionMethod
39
40
  // inStore, -- Which store to look at for if* above and the left-nav, defaults to "cluster"
40
41
  // rootProduct, -- Optional root (parent) product - if set, used to optimize navigation when product changes stays within root product
@@ -152,6 +153,7 @@ import { haveV2Monitoring } from '@shell/utils/monitoring';
152
153
  import { NEU_VECTOR_NAMESPACE } from '@shell/config/product/neuvector';
153
154
  import { createHeaders, rowValueGetter } from '@shell/store/type-map.utils';
154
155
  import { defineAsyncComponent } from 'vue';
156
+ import { filterLocationValidParams } from '@shell/utils/router';
155
157
 
156
158
  export const NAMESPACED = 'namespaced';
157
159
  export const CLUSTER_LEVEL = 'cluster';
@@ -238,7 +240,7 @@ export function DSL(store, product, module = 'type-map') {
238
240
  };
239
241
 
240
242
  // Convert strings to regex's - we do this once here for efficiency
241
- for ( const k of ['ifHaveGroup', 'ifHaveType'] ) {
243
+ for ( const k of ['ifHaveGroup', 'ifHaveType', 'ifNotHaveType'] ) {
242
244
  if ( opt[k] ) {
243
245
  if (Array.isArray(opt[k])) {
244
246
  opt[k] = opt[k].map((r) => regexToString(ensureRegex(r)));
@@ -365,7 +367,7 @@ export function DSL(store, product, module = 'type-map') {
365
367
 
366
368
  let called = false;
367
369
 
368
- export async function applyProducts(store, $plugin) {
370
+ export async function applyProducts(store, $extension) {
369
371
  if (called) {
370
372
  return;
371
373
  }
@@ -379,7 +381,7 @@ export async function applyProducts(store, $plugin) {
379
381
  }
380
382
  }
381
383
  // Load the products from all plugins
382
- $plugin.loadProducts();
384
+ $extension.loadProducts();
383
385
  }
384
386
 
385
387
  export function productsLoaded() {
@@ -694,7 +696,7 @@ export const getters = {
694
696
  }
695
697
  };
696
698
 
697
- typeObj.route = route;
699
+ typeObj.route = filterLocationValidParams(rootState.$router, route);
698
700
  }
699
701
 
700
702
  // Cluster ID and Product should always be set
@@ -711,7 +713,7 @@ export const getters = {
711
713
  exact: typeObj.exact || false,
712
714
  'exact-path': typeObj['exact-path'] || false,
713
715
  namespaced,
714
- route,
716
+ route: filterLocationValidParams(rootState.$router, route),
715
717
  name: typeObj.name,
716
718
  weight: typeObj.weight || getters.typeWeightFor(typeObj.schema?.id || label, isBasic),
717
719
  overview: !!typeObj.overview,
@@ -1419,6 +1421,14 @@ export const getters = {
1419
1421
  }
1420
1422
  }
1421
1423
 
1424
+ if ( p.ifNotHaveType ) {
1425
+ const haveIds = knownTypes[module].filter((t) => t.match(stringToRegex(p.ifNotHaveType)) );
1426
+
1427
+ if ( haveIds.length ) {
1428
+ return false;
1429
+ }
1430
+ }
1431
+
1422
1432
  if ( p.ifHaveGroup && !knownGroups[module].find((t) => t.match(stringToRegex(p.ifHaveGroup)) ) ) {
1423
1433
  return false;
1424
1434
  }
@@ -2026,7 +2036,7 @@ function hasCustom(state, rootState, kind, key, fallback) {
2026
2036
  }
2027
2037
 
2028
2038
  // Check to see if the custom kind is provided by a plugin (ignore booleans)
2029
- const pluginComponent = rootState.$plugin.getDynamic(kind, key);
2039
+ const pluginComponent = rootState.$extension.getDynamic(kind, key);
2030
2040
 
2031
2041
  if (typeof pluginComponent !== 'boolean' && !!pluginComponent) {
2032
2042
  cache[key] = true;
@@ -2046,7 +2056,7 @@ function hasCustom(state, rootState, kind, key, fallback) {
2046
2056
  }
2047
2057
 
2048
2058
  function loadExtension(rootState, kind, key, fallback) {
2049
- const ext = rootState.$plugin.getDynamic(kind, key);
2059
+ const ext = rootState.$extension.getDynamic(kind, key);
2050
2060
 
2051
2061
  if (ext) {
2052
2062
  if (typeof ext === 'function') {
@@ -14,7 +14,7 @@ export interface ModalConfig {
14
14
  *
15
15
  * this.$shell.modal({
16
16
  * component: MyCustomModal,
17
- * componentProps: { title: 'Hello Modal' }
17
+ * props: { title: 'Hello Modal' }
18
18
  * });
19
19
  * ```
20
20
  */
@@ -25,10 +25,10 @@ export interface ModalConfig {
25
25
  *
26
26
  * Example:
27
27
  * ```ts
28
- * componentProps: { title: 'Hello Modal', isVisible: true }
28
+ * props: { title: 'Hello Modal', isVisible: true }
29
29
  * ```
30
30
  */
31
- componentProps?: Record<string, any>;
31
+ props?: Record<string, any>;
32
32
 
33
33
  /**
34
34
  * Optional array of resources that the modal component might need.
@@ -47,11 +47,11 @@ export interface ModalConfig {
47
47
  *
48
48
  * Examples:
49
49
  * ```ts
50
- * modalWidth: '800px' // Width in pixels
51
- * modalWidth: '75%' // Width as a percentage
50
+ * width: '800px' // Width in pixels
51
+ * width: '75%' // Width as a percentage
52
52
  * ```
53
53
  */
54
- modalWidth?: string;
54
+ width?: string;
55
55
 
56
56
  /**
57
57
  * Determines if clicking outside the modal will close it. Defaults to `true`.
@@ -4,36 +4,102 @@ import { RouteLocationRaw } from 'vue-router';
4
4
  * Type definitions for the Notification Center
5
5
  */
6
6
 
7
- /**
8
- * Notification Level for a notification in the Notification Center
9
- */
10
7
  export enum NotificationLevel {
8
+ /**
9
+ * An announcement. To be used when we want to inform on high-interest topics - news, updates, changes, scheduled maintenance, etc. E.g. “New version available!” <img class="svg-blue" src="https://raw.githubusercontent.com/rancher/icons/refs/heads/master/svg/notify-announcement.svg" width="20" />
10
+ */
11
11
  Announcement = 0, // eslint-disable-line no-unused-vars
12
+ /**
13
+ * A task that is underway. To be used when we want to inform on a process taking place - on-going actions that might take a while. E.g. “Cluster provisioning in progress”. The progress bar will also be shown if the `progress` field is set <img class="svg-blue" src="https://raw.githubusercontent.com/rancher/icons/refs/heads/master/svg/notify-busy.svg" width="20" />
14
+ */
12
15
  Task, // eslint-disable-line no-unused-vars
16
+ /**
17
+ * Information notification. To be used when we want to inform on low-interest topics. E.g. “Welcome to Rancher v2.8" <img class="svg-blue" src="https://raw.githubusercontent.com/rancher/icons/refs/heads/master/svg/notify-info.svg"/>
18
+ */
13
19
  Info, // eslint-disable-line no-unused-vars
20
+ /**
21
+ * Notification that something has completed successfully. To be used when we want to confirm a successful action was completed. E.g. “Cluster provisioning completed” <img class="svg-green" src="https://raw.githubusercontent.com/rancher/icons/refs/heads/master/svg/notify-tick.svg"/>
22
+ */
14
23
  Success, // eslint-disable-line no-unused-vars
24
+ /**
25
+ * Notification of a warning. To be used when we want to warn about a potential risk. E.g. “Nodes limitation warning” <img class="svg-orange" src="https://raw.githubusercontent.com/rancher/icons/refs/heads/master/svg/notify-warning.svg"/>
26
+ */
15
27
  Warning, // eslint-disable-line no-unused-vars
28
+ /**
29
+ * Notification of an error. To be used when we want to alert on a confirmed risk. E.g. “Extension failed to load” <img class="svg-red" src="https://raw.githubusercontent.com/rancher/icons/refs/heads/master/svg/notify-error.svg"/>
30
+ */
16
31
  Error, // eslint-disable-line no-unused-vars
17
32
  Hidden, // eslint-disable-line no-unused-vars
18
33
  }
19
34
 
20
35
  /**
21
- * An action that is shown as a button in the Notification Center
36
+ * Notification Action definition
22
37
  */
23
- export type NotificationAction = {
24
- label: string; // Button label for the action
25
- target?: string; // HREF target when the button is clicked
26
- route?: RouteLocationRaw; // Route to navigate to when the button is clicked
27
- };
38
+ export interface NotificationAction {
39
+ /**
40
+ * Button label for the action
41
+ */
42
+ label: string;
43
+ /**
44
+ * Href target when the button is clicked
45
+ */
46
+ target?: string;
47
+ /**
48
+ * Vue Route to navigate to when the button is clicked
49
+ */
50
+ route?: RouteLocationRaw;
51
+ }
28
52
 
29
53
  /**
30
- * Defines the User Preference linked to a notification
54
+ * Notification Preference definition
31
55
  */
32
- export type NotificationPreference = {
33
- key: string; // User preference key to use when setting the preference when the notification is marked as read/unread
34
- value: string; // User preference value to use when setting the preference when the notification is marked as read
35
- unsetValue?: string; // User preference value to use when setting the preference when the notification is marked as unread - defaults to empty string
36
- };
56
+ export interface NotificationPreference {
57
+ /**
58
+ * User preference key to use when setting the preference when the notification is marked as read
59
+ */
60
+ key: string;
61
+ /**
62
+ * User preference value to use when setting the preference when the notification is marked as read
63
+ */
64
+ value: string;
65
+ /**
66
+ * User preference value to use when setting the preference when the notification is marked as unread - defaults to empty string
67
+ */
68
+ unsetValue?: string;
69
+ }
70
+
71
+ /**
72
+ * Configuration object for the Notification Center
73
+ *
74
+ */
75
+ export interface NotificationConfig {
76
+ /**
77
+ * - **{@link NotificationAction}**
78
+ *
79
+ * Primary action to be shown in the notification
80
+ */
81
+ primaryAction?: NotificationAction;
82
+ /**
83
+ * - **{@link NotificationAction}**
84
+ *
85
+ * Secondary to be shown in the notification
86
+ */
87
+ secondaryAction?: NotificationAction;
88
+ /**
89
+ * Unique ID for the notification
90
+ */
91
+ id?: string;
92
+ /**
93
+ * Progress (0-100) for notifications of type `Task`
94
+ */
95
+ progress?: number;
96
+ /**
97
+ * - **{@link NotificationPreference}**
98
+ *
99
+ * User Preference tied to the notification (the preference will be updated when the notification is marked read)
100
+ */
101
+ preference?: NotificationPreference;
102
+ }
37
103
 
38
104
  /**
39
105
  * Type for Encrypted Notification data that is stored in local storage
@@ -96,3 +162,48 @@ export interface NotificationHandler {
96
162
  */
97
163
  onReadUpdated(notification: Notification, read: boolean): void;
98
164
  }
165
+
166
+ /**
167
+ * API for notifications in the Rancher UI Notification Center
168
+ * * ![notification Example](/img/notification.png)
169
+ */
170
+ export interface NotificationApi {
171
+ /**
172
+ * Sends a notification to the Rancher UI Notification Center
173
+ *
174
+ * Example:
175
+ * ```ts
176
+ * import { NotificationLevel } from '@shell/types/notifications';
177
+ *
178
+ * this.$shell.notification.send(NotificationLevel.Success, 'Some notification title', 'Hello world! Success!', {})
179
+ * ```
180
+ *
181
+ * For usage with the Composition API check usage guide [here](../../shell-api#using-composition-api-in-vue).
182
+ *
183
+ * @param level The `level` specifies the importance of the notification and determines the icon that is shown in the notification
184
+ * @param title The notification title
185
+ * @param message The notification message to be displayed
186
+ * @param config Notifications configuration object
187
+ *
188
+ * @returns notification ID
189
+ *
190
+ */
191
+ send(level: NotificationLevel | NotificationLevel, title: string, message?:string, config?: NotificationConfig): Promise<string>;
192
+
193
+ /**
194
+ * Update notification progress (Only valid for notifications of type `Task`)
195
+ *
196
+ * Example:
197
+ * ```ts
198
+ * this.$shell.notification.updateProgress('some-notification-id', 80)
199
+ * ```
200
+ *
201
+ * For usage with the Composition API check usage guide [here](../../shell-api#using-composition-api-in-vue).
202
+ *
203
+ * @param notificationId Unique ID for the notification
204
+ * @param progress Progress (0-100) for notifications of type `Task`
205
+ *
206
+ */
207
+
208
+ updateProgress(notificationId: string, progress: number): void;
209
+ }
@@ -8,3 +8,12 @@ declare module '@shell/store/type-map' {
8
8
  }
9
9
 
10
10
  declare module '@shell/plugins/dashboard-store';
11
+
12
+ declare module '@shell/config/query-params' {
13
+ export const _DETAIL: string;
14
+ }
15
+
16
+ declare module '@shell/config/version' {
17
+ export const CURRENT_RANCHER_VERSION: string;
18
+ export function getVersionData(): any;
19
+ }
@@ -3255,6 +3255,7 @@ export default class Resource {
3255
3255
  get $state(): any;
3256
3256
  get $rootState(): any;
3257
3257
  get $plugin(): any;
3258
+ get $extension(): any;
3258
3259
  get customValidationRules(): any[];
3259
3260
  get _key(): any;
3260
3261
  get schema(): any;
@@ -4048,7 +4049,7 @@ export function filterHiddenLocalCluster(mgmtClusters: any, store: any): any;
4048
4049
  export function abbreviateClusterName(input: string): string;
4049
4050
  export function labelForAddon(store: any, name: any, configuration?: boolean): any;
4050
4051
  export function filterOutDeprecatedPatchVersions(allVersions: any, currentVersion: any): any;
4051
- export function getAllOptionsAfterCurrentVersion(store: any, versions: any, currentVersion: any, defaultVersion: any): any;
4052
+ export function getAllOptionsAfterCurrentVersion(store: any, versions: any, currentVersion: any, defaultVersion: any, manual?: boolean): any;
4052
4053
  export function initSchedulingCustomization(value: any, features: any, store: any, mode: any): Promise<{
4053
4054
  clusterAgentDefaultPC: any;
4054
4055
  clusterAgentDefaultPDB: any;
@@ -4796,6 +4797,20 @@ export function queryParamsFor(current: any, qp: any, defaults?: {}): any;
4796
4797
  export function getClusterFromRoute(to: any): any;
4797
4798
  export function getProductFromRoute(to: any): any;
4798
4799
  export function findMeta(route: any, key: any): any;
4800
+ /**
4801
+ * Find a route definition given a routeName
4802
+ * @param {*} router VueRouter instance
4803
+ * @param {*} routeName the name we want to look up
4804
+ * @returns the route definition or undefined if it wasn't found
4805
+ */
4806
+ export function findRouteDefinitionByName(router: any, routeName: any): any;
4807
+ /**
4808
+ * Looks for the route definition and then ensures there's only valid params
4809
+ * @param {*} router VueRouter instance
4810
+ * @param {*} routeRecord an object conforming to the Route Record interface
4811
+ * @returns the passed in routeLocation with only valid params.
4812
+ */
4813
+ export function filterLocationValidParams(router: any, routeRecord: any): any;
4799
4814
  export function getPackageFromRoute(route: any): any;
4800
4815
  export function getResourceFromRoute(to: any): any;
4801
4816
  export function routeMatched(to: any, fn: any): boolean;
@@ -1,7 +1,9 @@
1
1
  /* eslint-disable */
2
- import type ShellApi from '@shell/plugins/internal-api/shell/shell.api';
3
2
  import { VuexStore } from '@shell/types/store/vuex';
4
3
 
4
+ // Include the types for the APIs
5
+ /// <reference path="../apis/vue-shim.d.ts" />
6
+
5
7
  export {};
6
8
 
7
9
  declare module 'vue' {
@@ -14,7 +16,6 @@ declare module 'vue' {
14
16
  (key: string, args?: Record<string, any>, raw?: boolean): string;
15
17
  (options: { k: string; raw?: boolean; tag?: string | Record<string, any>; escapehtml?: boolean }): string;
16
18
  },
17
- $store: VuexStore,
18
- $shell: ShellApi,
19
+ $store: VuexStore
19
20
  }
20
- }
21
+ }
@@ -0,0 +1,238 @@
1
+ import { findRouteDefinitionByName, filterLocationValidParams } from '@shell/utils/router';
2
+
3
+ describe('findRouteDefinitionByName', () => {
4
+ const createMockRouter = (routes) => ({ getRoutes: () => routes });
5
+
6
+ it('should find a route by its name', () => {
7
+ const routes = [
8
+ { name: 'home', path: '/' },
9
+ { name: 'about', path: '/about' },
10
+ { name: 'c-cluster', path: '/c/:cluster' },
11
+ ];
12
+ const router = createMockRouter(routes);
13
+
14
+ const result = findRouteDefinitionByName(router, 'about');
15
+
16
+ expect(result).toStrictEqual({ name: 'about', path: '/about' });
17
+ });
18
+
19
+ it('should return the first matching route when name exists', () => {
20
+ const routes = [
21
+ { name: 'c-cluster-explorer', path: '/c/:cluster/explorer' },
22
+ { name: 'c-cluster-apps', path: '/c/:cluster/apps' },
23
+ ];
24
+ const router = createMockRouter(routes);
25
+
26
+ const result = findRouteDefinitionByName(router, 'c-cluster-explorer');
27
+
28
+ expect(result).toStrictEqual({ name: 'c-cluster-explorer', path: '/c/:cluster/explorer' });
29
+ });
30
+
31
+ it('should return undefined when route name is not found', () => {
32
+ const routes = [
33
+ { name: 'home', path: '/' },
34
+ { name: 'about', path: '/about' },
35
+ ];
36
+ const router = createMockRouter(routes);
37
+
38
+ const result = findRouteDefinitionByName(router, 'nonexistent');
39
+
40
+ expect(result).toBeUndefined();
41
+ });
42
+
43
+ it('should return undefined when routes array is empty', () => {
44
+ const router = createMockRouter([]);
45
+
46
+ const result = findRouteDefinitionByName(router, 'any-route');
47
+
48
+ expect(result).toBeUndefined();
49
+ });
50
+
51
+ it('should handle routes with additional properties', () => {
52
+ const routes = [
53
+ {
54
+ name: 'c-cluster-product-resource',
55
+ path: '/c/:cluster/:product/:resource',
56
+ meta: { requiresAuthentication: true },
57
+ props: true,
58
+ },
59
+ ];
60
+ const router = createMockRouter(routes);
61
+
62
+ const result = findRouteDefinitionByName(router, 'c-cluster-product-resource');
63
+
64
+ expect(result).toStrictEqual(routes[0]);
65
+ });
66
+
67
+ it('should match exact route names only', () => {
68
+ const routes = [
69
+ { name: 'c-cluster', path: '/c/:cluster' },
70
+ { name: 'c-cluster-explorer', path: '/c/:cluster/explorer' },
71
+ ];
72
+ const router = createMockRouter(routes);
73
+
74
+ const result = findRouteDefinitionByName(router, 'c-cluster');
75
+
76
+ expect(result).toStrictEqual({ name: 'c-cluster', path: '/c/:cluster' });
77
+ expect(result.name).not.toBe('c-cluster-explorer');
78
+ });
79
+ });
80
+
81
+ describe('filterLocationValidParams', () => {
82
+ const createMockRouter = (routes) => ({ getRoutes: () => routes });
83
+
84
+ it('should filter out params not in route path', () => {
85
+ const routes = [
86
+ { name: 'c-cluster', path: '/c/:cluster' },
87
+ ];
88
+ const router = createMockRouter(routes);
89
+ const routeRecord = {
90
+ name: 'c-cluster',
91
+ params: {
92
+ cluster: 'local',
93
+ product: 'explorer',
94
+ },
95
+ };
96
+
97
+ const result = filterLocationValidParams(router, routeRecord);
98
+
99
+ expect(result.params).toStrictEqual({ cluster: 'local' });
100
+ expect(result.params.product).toBeUndefined();
101
+ });
102
+
103
+ it('should keep all params when all are valid', () => {
104
+ const routes = [
105
+ { name: 'c-cluster-product-resource', path: '/c/:cluster/:product/:resource' },
106
+ ];
107
+ const router = createMockRouter(routes);
108
+ const routeRecord = {
109
+ name: 'c-cluster-product-resource',
110
+ params: {
111
+ cluster: 'local',
112
+ product: 'explorer',
113
+ resource: 'pods',
114
+ },
115
+ };
116
+
117
+ const result = filterLocationValidParams(router, routeRecord);
118
+
119
+ expect(result.params).toStrictEqual({
120
+ cluster: 'local',
121
+ product: 'explorer',
122
+ resource: 'pods',
123
+ });
124
+ });
125
+
126
+ it('should preserve other properties on routeRecord', () => {
127
+ const routes = [
128
+ { name: 'c-cluster', path: '/c/:cluster' },
129
+ ];
130
+ const router = createMockRouter(routes);
131
+ const routeRecord = {
132
+ name: 'c-cluster',
133
+ params: { cluster: 'local' },
134
+ query: { mode: 'edit' },
135
+ hash: '#section',
136
+ };
137
+
138
+ const result = filterLocationValidParams(router, routeRecord);
139
+
140
+ expect(result.query).toStrictEqual({ mode: 'edit' });
141
+ expect(result.hash).toBe('#section');
142
+ expect(result.name).toBe('c-cluster');
143
+ });
144
+
145
+ it('should return routeRecord unchanged when routeRecord is null', () => {
146
+ const router = createMockRouter([]);
147
+
148
+ const result = filterLocationValidParams(router, null);
149
+
150
+ expect(result).toBeNull();
151
+ });
152
+
153
+ it('should return routeRecord unchanged when routeRecord is undefined', () => {
154
+ const router = createMockRouter([]);
155
+
156
+ const result = filterLocationValidParams(router, undefined);
157
+
158
+ expect(result).toBeUndefined();
159
+ });
160
+
161
+ it('should return routeRecord unchanged when name is missing', () => {
162
+ const router = createMockRouter([]);
163
+ const routeRecord = { params: { cluster: 'local' } };
164
+
165
+ const result = filterLocationValidParams(router, routeRecord);
166
+
167
+ expect(result).toStrictEqual(routeRecord);
168
+ });
169
+
170
+ it('should return routeRecord unchanged when params is missing', () => {
171
+ const router = createMockRouter([]);
172
+ const routeRecord = { name: 'c-cluster' };
173
+
174
+ const result = filterLocationValidParams(router, routeRecord);
175
+
176
+ expect(result).toStrictEqual(routeRecord);
177
+ });
178
+
179
+ it('should return routeRecord unchanged when route definition is not found', () => {
180
+ const routes = [
181
+ { name: 'home', path: '/' },
182
+ ];
183
+ const router = createMockRouter(routes);
184
+ const routeRecord = {
185
+ name: 'nonexistent-route',
186
+ params: { cluster: 'local' },
187
+ };
188
+
189
+ const result = filterLocationValidParams(router, routeRecord);
190
+
191
+ expect(result).toStrictEqual(routeRecord);
192
+ });
193
+
194
+ it('should return empty params when no params are valid', () => {
195
+ const routes = [
196
+ { name: 'home', path: '/' },
197
+ ];
198
+ const router = createMockRouter(routes);
199
+ const routeRecord = {
200
+ name: 'home',
201
+ params: {
202
+ cluster: 'local',
203
+ product: 'explorer',
204
+ },
205
+ };
206
+
207
+ const result = filterLocationValidParams(router, routeRecord);
208
+
209
+ expect(result.params).toStrictEqual({});
210
+ });
211
+
212
+ it('should handle optional params in path', () => {
213
+ const routes = [
214
+ { name: 'c-cluster-product-resource-id', path: '/c/:cluster/:product/:resource/:id?' },
215
+ ];
216
+ const router = createMockRouter(routes);
217
+ const routeRecord = {
218
+ name: 'c-cluster-product-resource-id',
219
+ params: {
220
+ cluster: 'local',
221
+ product: 'explorer',
222
+ resource: 'pods',
223
+ id: 'my-pod',
224
+ extra: 'should-be-removed',
225
+ },
226
+ };
227
+
228
+ const result = filterLocationValidParams(router, routeRecord);
229
+
230
+ expect(result.params).toStrictEqual({
231
+ cluster: 'local',
232
+ product: 'explorer',
233
+ resource: 'pods',
234
+ id: 'my-pod',
235
+ });
236
+ expect(result.params.extra).toBeUndefined();
237
+ });
238
+ });
package/utils/cluster.js CHANGED
@@ -242,7 +242,7 @@ export function filterOutDeprecatedPatchVersions(allVersions, currentVersion) {
242
242
  return filteredVersions;
243
243
  }
244
244
 
245
- export function getAllOptionsAfterCurrentVersion(store, versions, currentVersion, defaultVersion) {
245
+ export function getAllOptionsAfterCurrentVersion(store, versions, currentVersion, defaultVersion, manual = false) {
246
246
  const out = (versions || []).filter((obj) => !!obj.serverArgs).map((obj) => {
247
247
  let disabled = false;
248
248
  let experimental = false;
@@ -260,6 +260,9 @@ export function getAllOptionsAfterCurrentVersion(store, versions, currentVersion
260
260
 
261
261
  if (isCurrentVersion) {
262
262
  label = `${ label } ${ store.getters['i18n/t']('cluster.kubernetesVersion.current') }`;
263
+ if (manual) {
264
+ label = `${ label } ${ store.getters['i18n/t']('cluster.kubernetesVersion.manual') }`;
265
+ }
263
266
  }
264
267
 
265
268
  if (experimental) {
package/utils/fleet.ts CHANGED
@@ -184,7 +184,7 @@ class Fleet {
184
184
  }
185
185
 
186
186
  detailLocation(r: Resource, mgmtClusterName: string): any {
187
- return mapStateToEnum(r.state) === STATES_ENUM.MISSING ? undefined : {
187
+ const location = mapStateToEnum(r.state) === STATES_ENUM.MISSING ? undefined : {
188
188
  name: `c-cluster-product-resource${ r.namespace ? '-namespace' : '' }-id`,
189
189
  params: {
190
190
  product: EXPLORER_NAME,
@@ -194,6 +194,13 @@ class Fleet {
194
194
  id: r.name,
195
195
  },
196
196
  };
197
+
198
+ // Having an undefined param can yield a console warning like [Vue Router warn]: Discarded invalid param(s) "namespace" when navigating
199
+ if (location && !location.params.namespace) {
200
+ delete location.params.namespace;
201
+ }
202
+
203
+ return location;
197
204
  }
198
205
 
199
206
  /**
@@ -165,7 +165,7 @@ class PaginationUtils {
165
165
  /**
166
166
  * Is pagination enabled at a global level or for a specific resource
167
167
  */
168
- isEnabled({ rootGetters, $plugin }: any, enabledFor: PaginationResourceContext) {
168
+ isEnabled({ rootGetters, $extension }: any, enabledFor: PaginationResourceContext) {
169
169
  // Cache must be enabled to support pagination api
170
170
  if (!this.isSteveCacheEnabled({ rootGetters })) {
171
171
  return false;
@@ -184,7 +184,7 @@ class PaginationUtils {
184
184
  }
185
185
 
186
186
  // Does an extension say this type is enabled?
187
- const plugin = $plugin as ExtensionManager;
187
+ const plugin = $extension as ExtensionManager;
188
188
  const paginationExtensionPoints = plugin.getAll()[EXT_IDS.SERVER_SIDE_PAGINATION_RESOURCES];
189
189
 
190
190
  if (paginationExtensionPoints) {
@@ -69,7 +69,7 @@ class PaginationWrapper<T extends object> {
69
69
  this.classify = formatResponse?.classify || false;
70
70
  this.reactive = formatResponse?.reactive || false;
71
71
 
72
- this.isEnabled = paginationUtils.isEnabled({ rootGetters: $store.getters, $plugin: this.$store.$plugin }, enabledFor);
72
+ this.isEnabled = paginationUtils.isEnabled({ rootGetters: $store.getters, $extension: this.$store.$extension }, enabledFor);
73
73
  }
74
74
 
75
75
  async request({ pagination, forceWatch }: {