@rancher/shell 0.3.16 → 0.3.17

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 (144) hide show
  1. package/assets/images/wechat-qr-code.jpg +0 -0
  2. package/assets/translations/en-us.yaml +69 -14
  3. package/assets/translations/zh-hans.yaml +87 -7
  4. package/chart/__tests__/S3.test.ts +50 -0
  5. package/chart/rancher-backup/S3.vue +21 -0
  6. package/chart/rancher-backup/index.vue +4 -0
  7. package/components/CommunityLinks.vue +1 -0
  8. package/components/FileDiff.vue +92 -85
  9. package/components/ResourceDetail/index.vue +4 -12
  10. package/components/ResourceList/index.vue +1 -1
  11. package/components/ResourceTable.vue +50 -2
  12. package/components/YamlEditor.vue +1 -0
  13. package/components/auth/RoleDetailEdit.vue +1 -0
  14. package/components/form/NameNsDescription.vue +28 -12
  15. package/components/form/NodeAffinity.vue +2 -2
  16. package/components/form/PodAffinity.vue +2 -2
  17. package/components/form/ResourceTabs/index.vue +8 -2
  18. package/components/form/Select.vue +16 -0
  19. package/components/form/__tests__/NodeAffinity.test.ts +38 -0
  20. package/components/form/__tests__/PodAffinity.test.ts +46 -0
  21. package/components/formatter/ClusterLink.vue +8 -4
  22. package/components/formatter/ImageName.vue +23 -0
  23. package/components/formatter/PodImages.vue +7 -1
  24. package/components/formatter/__tests__/ClusterLink.test.ts +101 -0
  25. package/components/nav/Header.vue +2 -2
  26. package/config/__test__/home-links.test.ts +62 -0
  27. package/config/home-links.js +15 -3
  28. package/config/labels-annotations.js +5 -1
  29. package/config/router.js +0 -4
  30. package/config/settings.ts +4 -0
  31. package/config/table-headers.js +6 -5
  32. package/config/uiplugins.js +50 -5
  33. package/core/plugin-helpers.js +20 -12
  34. package/core/plugin.ts +9 -0
  35. package/core/plugins.js +1 -1
  36. package/core/types-provisioning.ts +253 -0
  37. package/core/types.ts +17 -3
  38. package/detail/autoscaling.horizontalpodautoscaler/index.vue +50 -1
  39. package/detail/node.vue +6 -6
  40. package/detail/pod.vue +2 -6
  41. package/detail/provisioning.cattle.io.cluster.vue +46 -7
  42. package/detail/workload/index.vue +9 -9
  43. package/edit/__tests__/fleet.cattle.io.gitrepo.test.ts +62 -0
  44. package/edit/auth/github.vue +1 -0
  45. package/edit/autoscaling.horizontalpodautoscaler/hpa-scaling-rule.vue +130 -0
  46. package/edit/autoscaling.horizontalpodautoscaler/index.vue +79 -0
  47. package/edit/fleet.cattle.io.gitrepo.vue +18 -1
  48. package/edit/namespace.vue +9 -1
  49. package/edit/networking.k8s.io.ingress/RulePath.vue +0 -2
  50. package/edit/provisioning.cattle.io.cluster/AgentConfiguration.vue +1 -30
  51. package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +79 -1
  52. package/edit/provisioning.cattle.io.cluster/index.vue +52 -0
  53. package/edit/provisioning.cattle.io.cluster/rke2.vue +330 -150
  54. package/edit/ui.cattle.io.navlink.vue +2 -1
  55. package/initialize/App.js +3 -13
  56. package/initialize/layouts.ts +26 -0
  57. package/list/provisioning.cattle.io.cluster.vue +8 -1
  58. package/middleware/authenticated.js +93 -5
  59. package/mixins/brand.js +39 -3
  60. package/mixins/child-hook.js +2 -2
  61. package/mixins/create-edit-view/impl.js +2 -2
  62. package/models/fleet.cattle.io.gitrepo.js +1 -0
  63. package/models/provisioning.cattle.io.cluster.js +9 -1
  64. package/package.json +2 -2
  65. package/pages/about.vue +8 -2
  66. package/pages/auth/login.vue +1 -1
  67. package/pages/auth/logout.vue +11 -3
  68. package/pages/c/_cluster/apps/charts/index.vue +5 -2
  69. package/pages/c/_cluster/apps/charts/install.vue +5 -0
  70. package/pages/c/_cluster/explorer/index.vue +1 -10
  71. package/pages/c/_cluster/uiplugins/AddExtensionRepos.vue +177 -0
  72. package/pages/c/_cluster/uiplugins/PluginInfoPanel.vue +19 -3
  73. package/pages/c/_cluster/uiplugins/RemoveUIPlugins.vue +90 -21
  74. package/pages/c/_cluster/uiplugins/SetupUIPlugins.vue +107 -37
  75. package/pages/c/_cluster/uiplugins/index.vue +155 -44
  76. package/pages/docs/_doc.vue +9 -3
  77. package/pages/home.vue +5 -5
  78. package/pages/support/index.vue +10 -4
  79. package/pkg/auto-import.js +1 -1
  80. package/plugins/clean-tooltip-directive.js +1 -1
  81. package/plugins/dashboard-store/resource-class.js +35 -2
  82. package/plugins/plugin.js +9 -1
  83. package/rancher-components/BadgeState/BadgeState.vue +5 -1
  84. package/rancher-components/Banner/Banner.test.ts +51 -1
  85. package/rancher-components/Banner/Banner.vue +134 -53
  86. package/rancher-components/Card/Card.vue +24 -7
  87. package/rancher-components/Form/Checkbox/Checkbox.test.ts +20 -29
  88. package/rancher-components/Form/Checkbox/Checkbox.vue +45 -20
  89. package/rancher-components/Form/LabeledInput/LabeledInput.test.ts +2 -8
  90. package/rancher-components/Form/LabeledInput/LabeledInput.vue +22 -10
  91. package/rancher-components/Form/Radio/RadioButton.vue +30 -13
  92. package/rancher-components/Form/Radio/RadioGroup.vue +26 -7
  93. package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +7 -6
  94. package/rancher-components/Form/ToggleSwitch/ToggleSwitch.test.ts +25 -38
  95. package/rancher-components/Form/ToggleSwitch/ToggleSwitch.vue +23 -11
  96. package/rancher-components/LabeledTooltip/LabeledTooltip.vue +19 -5
  97. package/rancher-components/StringList/StringList.test.ts +453 -49
  98. package/rancher-components/StringList/StringList.vue +44 -26
  99. package/scripts/extension/publish +2 -2
  100. package/scripts/typegen.sh +1 -0
  101. package/server/server-middleware.js +4 -12
  102. package/store/index.js +13 -0
  103. package/store/prefs.js +0 -3
  104. package/store/type-map.js +17 -29
  105. package/types/shell/index.d.ts +236 -83
  106. package/utils/kube.js +9 -0
  107. package/utils/object.js +27 -0
  108. package/utils/settings.ts +2 -2
  109. package/vue.config.js +3 -2
  110. package/components/.DS_Store +0 -0
  111. package/components/__tests__/.DS_Store +0 -0
  112. package/creators/pkg/package-lock.json +0 -37
  113. package/pages/safeMode.vue +0 -17
  114. package/rancher-components/components/BadgeState/BadgeState.spec.ts +0 -12
  115. package/rancher-components/components/BadgeState/BadgeState.vue +0 -111
  116. package/rancher-components/components/BadgeState/index.ts +0 -1
  117. package/rancher-components/components/Banner/Banner.test.ts +0 -63
  118. package/rancher-components/components/Banner/Banner.vue +0 -244
  119. package/rancher-components/components/Banner/index.ts +0 -1
  120. package/rancher-components/components/Card/Card.vue +0 -167
  121. package/rancher-components/components/Card/index.ts +0 -1
  122. package/rancher-components/components/Form/Checkbox/Checkbox.test.ts +0 -68
  123. package/rancher-components/components/Form/Checkbox/Checkbox.vue +0 -420
  124. package/rancher-components/components/Form/Checkbox/index.ts +0 -1
  125. package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +0 -23
  126. package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +0 -355
  127. package/rancher-components/components/Form/LabeledInput/index.ts +0 -1
  128. package/rancher-components/components/Form/Radio/RadioButton.vue +0 -287
  129. package/rancher-components/components/Form/Radio/RadioGroup.vue +0 -254
  130. package/rancher-components/components/Form/Radio/index.ts +0 -2
  131. package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +0 -170
  132. package/rancher-components/components/Form/TextArea/index.ts +0 -1
  133. package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.test.ts +0 -94
  134. package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.vue +0 -149
  135. package/rancher-components/components/Form/ToggleSwitch/index.ts +0 -1
  136. package/rancher-components/components/Form/index.ts +0 -5
  137. package/rancher-components/components/LabeledTooltip/LabeledTooltip.vue +0 -151
  138. package/rancher-components/components/LabeledTooltip/index.ts +0 -1
  139. package/rancher-components/components/StringList/StringList.test.ts +0 -484
  140. package/rancher-components/components/StringList/StringList.vue +0 -611
  141. package/rancher-components/components/StringList/index.ts +0 -1
  142. package/yarn-error.log +0 -196
  143. /package/rancher-components/{components/Card → Card}/Card.test.ts +0 -0
  144. /package/rancher-components/{components/Form → Form}/Radio/RadioButton.test.ts +0 -0
@@ -0,0 +1,23 @@
1
+ <script>
2
+ export default {
3
+ props:
4
+ {
5
+ value: {
6
+ type: String,
7
+ default: ''
8
+ }
9
+ }
10
+ };
11
+ </script>
12
+
13
+ <template>
14
+ <span class="formatter-image">
15
+ {{ value }}
16
+ </span>
17
+ </template>
18
+
19
+ <style scoped>
20
+ .formatter-image {
21
+ word-break: break-all;
22
+ }
23
+ </style>
@@ -55,7 +55,7 @@ export default {
55
55
  </script>
56
56
 
57
57
  <template>
58
- <span>
58
+ <span class="formatter-pod-images">
59
59
  <span>{{ mainImage }}</span><br>
60
60
  <span
61
61
  v-if="images.length-1>0"
@@ -64,3 +64,9 @@ export default {
64
64
  >{{ t('generic.plusMore', {n:images.length-1}) }}</span>
65
65
  </span>
66
66
  </template>
67
+
68
+ <style scoped>
69
+ .formatter-pod-images {
70
+ word-break: break-all;
71
+ }
72
+ </style>
@@ -0,0 +1,101 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import ClusterLink from '@shell/components/formatter/ClusterLink.vue';
3
+
4
+ describe('component: ClusterLink', () => {
5
+ const UNAVAILABLE_MACHINES_ICON_SELECTOR = '[data-testid="unavailable-machines-alert-icon"]';
6
+ const TEMPLATE_UPGRADE_ICON_SELECTOR = '[data-testid="rke-template-upgrade-alert-icon"]';
7
+ const CONDITION_HAS_ERROR_ICON_SELECTOR = '[data-testid="conditions-has-error-icon"]';
8
+
9
+ describe('unavailable machines alert icon', () => {
10
+ const testCases = [
11
+ [undefined, false],
12
+ [0, false],
13
+ [1, true],
14
+ [5, true],
15
+ ];
16
+
17
+ it.each(testCases)(
18
+ 'should show/hide properly based on on the number of unavailable machines',
19
+ (unavailableMachines, expected) => {
20
+ const wrapper = mount(ClusterLink, {
21
+ propsData: {
22
+ row: {
23
+ hasError: false,
24
+ status: {},
25
+ unavailableMachines,
26
+ rkeTemplateUpgrade: undefined
27
+ },
28
+ reference: 'any',
29
+ value: 'any'
30
+ }
31
+ });
32
+ const el = wrapper.find(UNAVAILABLE_MACHINES_ICON_SELECTOR);
33
+
34
+ expect(el.exists()).toBe(expected);
35
+ }
36
+ );
37
+ });
38
+
39
+ describe('template upgrade alert icon', () => {
40
+ const testCases = [
41
+ [undefined, false],
42
+ ['any', true],
43
+ ];
44
+
45
+ it.each(testCases)(
46
+ 'should show/hide properly based on rkeTemplateUpgrade',
47
+ (rkeTemplateUpgrade, expected) => {
48
+ const wrapper = mount(ClusterLink, {
49
+ propsData: {
50
+ row: {
51
+ hasError: false,
52
+ status: {},
53
+ unavailableMachines: 0,
54
+ rkeTemplateUpgrade
55
+ },
56
+ reference: 'any',
57
+ value: 'any'
58
+ }
59
+ });
60
+ const el = wrapper.find(TEMPLATE_UPGRADE_ICON_SELECTOR);
61
+
62
+ expect(el.exists()).toBe(expected);
63
+ }
64
+ );
65
+ });
66
+
67
+ describe('conditions has error icon', () => {
68
+ const MOCKED_CONDITIONS_1 = [{
69
+ status: '', type: 'Ready', reason: 'Waiting', error: true // When the only existing error has a type "Ready" and reason "Waiting"
70
+ }];
71
+ const MOCKED_CONDITIONS_2 = [{
72
+ status: 'any', type: 'any', error: true
73
+ }];
74
+
75
+ const testCases = [
76
+ [[], false],
77
+ [MOCKED_CONDITIONS_1, false],
78
+ [MOCKED_CONDITIONS_2, true],
79
+ ];
80
+
81
+ it.each(testCases)(
82
+ 'should show/hide properly based on the status conditions',
83
+ (conditions, expected) => {
84
+ const wrapper = mount(ClusterLink, {
85
+ propsData: {
86
+ row: {
87
+ hasError: true,
88
+ status: { conditions },
89
+ unavailableMachines: 0
90
+ },
91
+ reference: 'any',
92
+ value: 'any'
93
+ }
94
+ });
95
+ const el = wrapper.find(CONDITION_HAS_ERROR_ICON_SELECTOR);
96
+
97
+ expect(el.exists()).toBe(expected);
98
+ }
99
+ );
100
+ });
101
+ });
@@ -181,6 +181,8 @@ export default {
181
181
  $route(nue) {
182
182
  if (nue) {
183
183
  this.extensionHeaderActions = getApplicableExtensionEnhancements(this, ExtensionPoint.ACTION, ActionLocation.HEADER, nue);
184
+
185
+ this.navHeaderRight = this.$plugin?.getDynamic('component', 'NavHeaderRight');
184
186
  }
185
187
  }
186
188
  },
@@ -191,8 +193,6 @@ export default {
191
193
  window.addEventListener('resize', this.debouncedLayoutHeader);
192
194
 
193
195
  this.$nextTick(() => this.layoutHeader(null, true));
194
-
195
- this.navHeaderRight = this.$plugin?.getDynamic('component', 'NavHeaderRight');
196
196
  },
197
197
 
198
198
  beforeDestroy() {
@@ -0,0 +1,62 @@
1
+ import Vuex from 'vuex';
2
+ import { createLocalVue } from '@vue/test-utils';
3
+ import { ensureSupportLink } from '@shell/config/home-links.js';
4
+ import { getters, state, mutations } from '@shell/store/i18n.js';
5
+
6
+ jest.mock('@shell/assets/translations/en-us.yaml', () => ({
7
+ locale: {
8
+ 'en-us': 'English',
9
+ 'zh-hans': '简体中文',
10
+ none: '(None)',
11
+ }
12
+ }));
13
+
14
+ describe('fx: ensureSupportLink', () => {
15
+ const localVue = createLocalVue();
16
+
17
+ localVue.use(Vuex);
18
+
19
+ const store = new Vuex.Store({
20
+ state,
21
+ getters: {
22
+ 'i18n/selectedLocaleLabel': getters.selectedLocaleLabel,
23
+ 'i18n/t': getters.t,
24
+ },
25
+ mutations,
26
+ });
27
+
28
+ store.commit('loadTranslations', {
29
+ locale: 'zh-zhans',
30
+ translations: {
31
+ locale: {
32
+ 'en-us': 'English',
33
+ 'zh-hans': '简体中文',
34
+ none: '(None)',
35
+ }
36
+ }
37
+ });
38
+
39
+ const testCases = [
40
+ ['en-us', false],
41
+ ['zh-hans', true],
42
+ ['none', false],
43
+ [null, false],
44
+ ];
45
+
46
+ it.each(testCases)('should return cn forum link if the language is zh-hans', (language:String, value) => {
47
+ store.commit('setSelected', language);
48
+
49
+ const links = { defaults: [], custom: [] };
50
+ const hasSupport = true;
51
+ const isSupportPage = true;
52
+
53
+ const localThis = {
54
+ $store: store,
55
+ t: store.getters['i18n/t'],
56
+ };
57
+
58
+ const result = ensureSupportLink(links, hasSupport, isSupportPage, localThis.t, store);
59
+
60
+ expect(!!result.defaults.find((link) => link.key === 'cnforums')).toBe(value);
61
+ });
62
+ });
@@ -38,6 +38,12 @@ const SUPPORT_LINK = {
38
38
  readonly: true
39
39
  };
40
40
 
41
+ const CN_FORUMS_LINK = {
42
+ key: 'cnforums',
43
+ value: 'https://forums.rancher.cn/',
44
+ enabled: true,
45
+ };
46
+
41
47
  // We add a version attribute to the setting so we know what has been migrated and which version of the setting we have
42
48
  export const CUSTOM_LINKS_VERSION = 'v1';
43
49
 
@@ -72,7 +78,7 @@ export async function fetchLinks(store, hasSupport, isSupportPage, t) {
72
78
  uiLinks.defaults = defaults;
73
79
  }
74
80
 
75
- return ensureSupportLink(uiLinks, hasSupport, isSupportPage, t);
81
+ return ensureSupportLink(uiLinks, hasSupport, isSupportPage, t, store);
76
82
  }
77
83
 
78
84
  // No new setting, so return the required structure
@@ -117,11 +123,11 @@ export async function fetchLinks(store, hasSupport, isSupportPage, t) {
117
123
  console.warn('Could not parse legacy link settings', e); // eslint-disable-line no-console
118
124
  }
119
125
 
120
- return ensureSupportLink(links, hasSupport, isSupportPage, t);
126
+ return ensureSupportLink(links, hasSupport, isSupportPage, t, store);
121
127
  }
122
128
 
123
129
  // Ensure the support link is added if needed
124
- function ensureSupportLink(links, hasSupport, isSupportPage, t) {
130
+ export function ensureSupportLink(links, hasSupport, isSupportPage, t, store) {
125
131
  if (!hasSupport && !isSupportPage) {
126
132
  const supportLink = links.defaults?.find((link) => link.key === 'commercialSupport');
127
133
 
@@ -130,6 +136,12 @@ function ensureSupportLink(links, hasSupport, isSupportPage, t) {
130
136
  }
131
137
  }
132
138
 
139
+ const selectedLocaleLabel = store.getters['i18n/selectedLocaleLabel'];
140
+
141
+ if (selectedLocaleLabel === t('locale.zh-hans')) {
142
+ links.defaults.push(CN_FORUMS_LINK);
143
+ }
144
+
133
145
  // Localise the default links
134
146
  links.defaults = links.defaults.map((link) => {
135
147
  return {
@@ -54,7 +54,11 @@ export const CAPI = {
54
54
  DELETE_MACHINE: 'cluster.x-k8s.io/delete-machine',
55
55
  PROVIDER: 'provider.cattle.io',
56
56
  SECRET_AUTH: 'v2prov-secret-authorized-for-cluster',
57
- SECRET_WILL_DELETE: 'v2prov-authorized-secret-deletes-on-cluster-removal'
57
+ SECRET_WILL_DELETE: 'v2prov-authorized-secret-deletes-on-cluster-removal',
58
+ /**
59
+ * Annotation for overriding the cluster provider,
60
+ */
61
+ UI_CUSTOM_PROVIDER: 'ui.rancher/provider'
58
62
  };
59
63
 
60
64
  export const CATALOG = {
package/config/router.js CHANGED
@@ -48,10 +48,6 @@ export const routerOptions = {
48
48
  path: '/prefs',
49
49
  component: () => interopDefault(import('../pages/prefs.vue' /* webpackChunkName: "pages/prefs" */)),
50
50
  name: 'prefs'
51
- }, {
52
- path: '/safeMode',
53
- component: () => interopDefault(import('../pages/safeMode.vue' /* webpackChunkName: "pages/safeMode" */)),
54
- name: 'safeMode'
55
51
  }, {
56
52
  path: '/support',
57
53
  component: () => interopDefault(import('../pages/support/index.vue' /* webpackChunkName: "pages/support/index" */)),
@@ -89,6 +89,10 @@ export const SETTING = {
89
89
  */
90
90
  CLUSTER_AGENT_DEFAULT_AFFINITY: 'cluster-agent-default-affinity',
91
91
  FLEET_AGENT_DEFAULT_AFFINITY: 'fleet-agent-default-affinity',
92
+ /**
93
+ * manage rancher repositories in extensions (official, partners repos)
94
+ */
95
+ ADD_EXTENSION_REPOS_BANNER_DISPLAY: 'display-add-extension-repos-banner'
92
96
  };
93
97
 
94
98
  // These are the settings that are allowed to be edited via the UI
@@ -264,11 +264,12 @@ export const DURATION = {
264
264
  formatter: 'LiveDuration',
265
265
  };
266
266
 
267
- export const IMAGE = {
268
- name: 'image',
269
- labelKey: 'tableHeaders.image',
270
- value: 'image',
271
- sort: ['image', 'nameSort'],
267
+ export const IMAGE_NAME = {
268
+ name: 'image',
269
+ labelKey: 'tableHeaders.image',
270
+ value: 'image',
271
+ sort: ['image', 'nameSort'],
272
+ formatter: 'ImageName',
272
273
  };
273
274
 
274
275
  export const POD_IMAGES = {
@@ -29,8 +29,21 @@ export const UI_PLUGINS_REPO_NAME = 'rancher-ui-plugins';
29
29
  export const UI_PLUGINS_REPO_URL = 'https://github.com/rancher/ui-plugin-charts';
30
30
  export const UI_PLUGINS_REPO_BRANCH = 'main';
31
31
 
32
+ // Info for the Helm Chart Repo for Partner Extensions
33
+ export const UI_PLUGINS_PARTNERS_REPO_NAME = 'partner-extensions';
34
+
35
+ export const UI_PLUGINS_PARTNERS_REPO_URL = 'https://github.com/rancher/partner-extensions';
36
+ export const UI_PLUGINS_PARTNERS_REPO_BRANCH = 'main';
37
+
38
+ // Info for the Helm Chart Repo for Community Extensions
39
+ export const UI_PLUGINS_COMMUNITY_REPO_NAME = 'community-extensions';
40
+
41
+ export const UI_PLUGINS_COMMUNITY_REPO_URL = 'https://github.com/rancher/community-extensions';
42
+ export const UI_PLUGINS_COMMUNITY_REPO_BRANCH = 'main';
43
+
32
44
  // Chart annotations
33
45
  export const UI_PLUGIN_CHART_ANNOTATIONS = {
46
+ KUBE_VERSION: 'catalog.cattle.io/kube-version',
34
47
  RANCHER_VERSION: 'catalog.cattle.io/rancher-version',
35
48
  EXTENSIONS_VERSION: 'catalog.cattle.io/ui-extensions-version',
36
49
  UI_VERSION: 'catalog.cattle.io/ui-version',
@@ -121,16 +134,18 @@ export function shouldNotLoadPlugin(plugin, rancherVersion, loadedPlugins) {
121
134
  }
122
135
 
123
136
  // Can a chart version be used for this Rancher (based on the annotations on the chart)?
124
- export function isSupportedChartVersion(chartVersion, rancherVersion) {
137
+ export function isSupportedChartVersion(versionsData) {
138
+ const { version, rancherVersion, kubeVersion } = versionsData;
139
+
125
140
  // Plugin specified a required extension API version
126
- const requiredAPI = chartVersion.annotations?.[UI_PLUGIN_CHART_ANNOTATIONS.EXTENSIONS_VERSION];
141
+ const requiredAPI = version.annotations?.[UI_PLUGIN_CHART_ANNOTATIONS.EXTENSIONS_VERSION];
127
142
 
128
143
  if (requiredAPI && !semver.satisfies(UI_PLUGIN_API_VERSION, requiredAPI)) {
129
144
  return false;
130
145
  }
131
146
 
132
147
  // Host application
133
- const requiredHost = chartVersion.annotations?.[UI_PLUGIN_CHART_ANNOTATIONS.EXTENSIONS_HOST];
148
+ const requiredHost = version.annotations?.[UI_PLUGIN_CHART_ANNOTATIONS.EXTENSIONS_HOST];
134
149
 
135
150
  if (requiredHost && requiredHost !== UI_PLUGIN_HOST_APP) {
136
151
  return false;
@@ -138,24 +153,37 @@ export function isSupportedChartVersion(chartVersion, rancherVersion) {
138
153
 
139
154
  // Rancher version
140
155
  if (rancherVersion) {
141
- const requiredRancherVersion = chartVersion.annotations?.[UI_PLUGIN_CHART_ANNOTATIONS.RANCHER_VERSION];
156
+ const requiredRancherVersion = version.annotations?.[UI_PLUGIN_CHART_ANNOTATIONS.RANCHER_VERSION];
142
157
 
143
158
  if (requiredRancherVersion && !semver.satisfies(rancherVersion, requiredRancherVersion)) {
144
159
  return false;
145
160
  }
146
161
  }
147
162
 
163
+ // Kube version
164
+ if (kubeVersion) {
165
+ const requiredKubeVersion = version.annotations?.[UI_PLUGIN_CHART_ANNOTATIONS.KUBE_VERSION];
166
+
167
+ if (requiredKubeVersion && !semver.satisfies(kubeVersion, requiredKubeVersion)) {
168
+ return false;
169
+ }
170
+ }
171
+
148
172
  return true;
149
173
  }
150
174
 
151
- export function isChartVersionAvailableForInstall(version, rancherVersion, returnObj = false) {
175
+ export function isChartVersionAvailableForInstall(versionsData, returnObj = false) {
176
+ const { version, rancherVersion, kubeVersion } = versionsData;
177
+
152
178
  const parsedRancherVersion = rancherVersion.split('-')?.[0];
153
179
  const regexHashString = new RegExp('^[A-Za-z0-9]{9}$');
154
180
  const isRancherVersionHashString = regexHashString.test(rancherVersion);
155
181
  const requiredUiVersion = version.annotations?.[UI_PLUGIN_CHART_ANNOTATIONS.UI_VERSION];
182
+ const requiredKubeVersion = version.annotations?.[UI_PLUGIN_CHART_ANNOTATIONS.KUBE_VERSION];
156
183
  const versionObj = { ...version };
157
184
 
158
185
  versionObj.isCompatibleWithUi = true;
186
+ versionObj.isCompatibleWithKubeVersion = true;
159
187
 
160
188
  // if it's a head version of Rancher, then we skip the validation and enable them all
161
189
  if (!isRancherVersionHashString && requiredUiVersion && !semver.satisfies(parsedRancherVersion, requiredUiVersion)) {
@@ -164,6 +192,23 @@ export function isChartVersionAvailableForInstall(version, rancherVersion, retur
164
192
  }
165
193
  versionObj.isCompatibleWithUi = false;
166
194
  versionObj.requiredUiVersion = requiredUiVersion;
195
+
196
+ if (returnObj) {
197
+ return versionObj;
198
+ }
199
+ }
200
+
201
+ // check kube version
202
+ if (kubeVersion && requiredKubeVersion && !semver.satisfies(kubeVersion, requiredKubeVersion)) {
203
+ if (!returnObj) {
204
+ return false;
205
+ }
206
+ versionObj.isCompatibleWithKubeVersion = false;
207
+ versionObj.requiredKubeVersion = requiredKubeVersion;
208
+
209
+ if (returnObj) {
210
+ return versionObj;
211
+ }
167
212
  }
168
213
 
169
214
  if (returnObj) {
@@ -3,6 +3,7 @@ import { isMac } from '@shell/utils/platform';
3
3
  import { ucFirst, randomStr } from '@shell/utils/string';
4
4
  import { _EDIT, _CONFIG, _DETAIL, _LIST } from '@shell/config/query-params';
5
5
  import { getProductFromRoute } from '@shell/middleware/authenticated';
6
+ import { isEqual } from '@shell/utils/object';
6
7
 
7
8
  function checkRouteProduct({ name, params, query }, locationConfigParam) {
8
9
  const product = getProductFromRoute({
@@ -34,7 +35,7 @@ function checkRouteMode({ name, query }, locationConfigParam) {
34
35
  return false;
35
36
  }
36
37
 
37
- function checkExtensionRouteBinding($route, locationConfig) {
38
+ function checkExtensionRouteBinding($route, locationConfig, context) {
38
39
  // if no configuration is passed, consider it as global
39
40
  if (!Object.keys(locationConfig).length) {
40
41
  return true;
@@ -43,23 +44,30 @@ function checkExtensionRouteBinding($route, locationConfig) {
43
44
  const { params } = $route;
44
45
 
45
46
  // "params" to be checked based on the locationConfig
47
+ // This has become overloaded with mode and context
46
48
  const paramsToCheck = [
47
49
  'product',
48
50
  'resource',
49
51
  'namespace',
50
52
  'cluster',
51
53
  'id',
52
- 'mode'
54
+ 'mode',
55
+ // url query params
56
+ 'queryParam',
57
+ // Custom context specific params provided by the extension, not to be confused with location params
58
+ 'context',
53
59
  ];
54
60
 
55
- let res = false;
61
+ let res = true;
56
62
 
57
63
  for (let i = 0; i < paramsToCheck.length; i++) {
58
64
  const param = paramsToCheck[i];
59
65
 
60
66
  if (locationConfig[param]) {
61
- for (let x = 0; x < locationConfig[param].length; x++) {
62
- const locationConfigParam = locationConfig[param][x];
67
+ const asArray = Array.isArray(locationConfig[param]) ? locationConfig[param] : [locationConfig[param]];
68
+
69
+ for (let x = 0; x < asArray.length; x++) {
70
+ const locationConfigParam = asArray[x];
63
71
 
64
72
  if (locationConfigParam) {
65
73
  // handle "product" in a separate way...
@@ -68,6 +76,11 @@ function checkExtensionRouteBinding($route, locationConfig) {
68
76
  // also handle "mode" in a separate way because it mainly depends on query params
69
77
  } else if (param === 'mode') {
70
78
  res = checkRouteMode($route, locationConfigParam);
79
+ } else if (param === 'context') {
80
+ // Need all keys and values to match
81
+ res = isEqual(locationConfigParam, context);
82
+ } else if (param === 'queryParam') {
83
+ res = isEqual(locationConfigParam, $route.query);
71
84
  } else if (locationConfigParam === params[param]) {
72
85
  res = true;
73
86
  } else {
@@ -91,7 +104,7 @@ function checkExtensionRouteBinding($route, locationConfig) {
91
104
  return res;
92
105
  }
93
106
 
94
- export function getApplicableExtensionEnhancements(pluginCtx, actionType, uiArea, currRoute, translationCtx = pluginCtx) {
107
+ export function getApplicableExtensionEnhancements(pluginCtx, actionType, uiArea, currRoute, translationCtx = pluginCtx, context) {
95
108
  const extensionEnhancements = [];
96
109
 
97
110
  // gate it so that we prevent errors on older versions of dashboard
@@ -99,7 +112,7 @@ export function getApplicableExtensionEnhancements(pluginCtx, actionType, uiArea
99
112
  const actions = pluginCtx.$plugin.getUIConfig(actionType, uiArea);
100
113
 
101
114
  actions.forEach((action, i) => {
102
- if (checkExtensionRouteBinding(currRoute, action.locationConfig)) {
115
+ if (checkExtensionRouteBinding(currRoute, action.locationConfig, context || {})) {
103
116
  // ADD CARD PLUGIN UI ENHANCEMENT
104
117
  if (actionType === ExtensionPoint.CARD) {
105
118
  // intercept to apply translation
@@ -116,11 +129,6 @@ export function getApplicableExtensionEnhancements(pluginCtx, actionType, uiArea
116
129
  actions[i].label = translationCtx.t(action.labelKey);
117
130
  }
118
131
 
119
- // sets the enabled flag to true if omitted on the config
120
- if (!Object.keys(action).includes('enabled')) {
121
- actions[i].enabled = true;
122
- }
123
-
124
132
  // bulkable flag
125
133
  actions[i].bulkable = actions[i].multiple || actions[i].bulkable;
126
134
 
package/core/plugin.ts CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  PluginRouteConfig, RegisterStore, UnregisterStore, CoreStoreSpecifics, CoreStoreConfig, OnNavToPackage, OnNavAwayFromPackage, OnLogOut
16
16
  } from './types';
17
17
  import coreStore, { coreStoreModule, coreStoreState } from '@shell/plugins/dashboard-store';
18
+ import { registerLayout } from '@shell/initialize/layouts';
18
19
 
19
20
  export type ProductFunction = (plugin: IPlugin, store: any) => void;
20
21
 
@@ -267,6 +268,14 @@ export class Plugin implements IPlugin {
267
268
  }
268
269
 
269
270
  this.l10n[name].push(fn);
271
+ } else if (type === 'layouts') {
272
+ fn().then((component: any) => {
273
+ if (component.default) {
274
+ registerLayout(name, component.default);
275
+ } else {
276
+ console.error(`Failed to load layout ${ name } because the file didn't export a default component.`); // eslint-disable-line no-console
277
+ }
278
+ });
270
279
  } else {
271
280
  if (!this.types[type]) {
272
281
  this.types[type] = {};
package/core/plugins.js CHANGED
@@ -182,7 +182,7 @@ export default function({
182
182
  console.error('Error removing plugin', e); // eslint-disable-line no-console
183
183
  }
184
184
 
185
- delete plugins[plugin.name];
185
+ delete plugins[plugin.id];
186
186
  }
187
187
  },
188
188