@rancher/shell 0.1.3 → 0.1.21

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 (245) hide show
  1. package/assets/brand/suse/dark/rancher-logo.svg +1 -148
  2. package/assets/brand/suse/favicon.png +0 -0
  3. package/assets/brand/suse/rancher-logo.svg +1 -130
  4. package/assets/images/featured/img1.jpg +0 -0
  5. package/assets/images/featured.jpg +0 -0
  6. package/assets/images/generic-plugin.svg +1 -0
  7. package/assets/styles/themes/_dark.scss +3 -0
  8. package/assets/styles/themes/_light.scss +3 -0
  9. package/assets/styles/themes/_suse.scss +1 -1
  10. package/assets/translations/en-us.yaml +219 -47
  11. package/assets/translations/zh-hans.yaml +21 -24
  12. package/components/AsyncButton.vue +17 -2
  13. package/components/ButtonDropdown.vue +4 -0
  14. package/components/Carousel.vue +291 -0
  15. package/components/CommunityLinks.vue +64 -22
  16. package/components/CruResource.vue +11 -3
  17. package/components/Dialog.vue +102 -0
  18. package/components/ExplorerMembers.vue +2 -4
  19. package/components/ExplorerProjectsNamespaces.vue +25 -9
  20. package/components/IconMessage.vue +9 -1
  21. package/components/LazyImage.vue +21 -8
  22. package/components/LocaleSelector.vue +62 -29
  23. package/components/PromptRemove.vue +2 -2
  24. package/components/ResourceList/Masthead.vue +21 -1
  25. package/components/ResourceList/ResourceLoadingIndicator.vue +0 -8
  26. package/components/ResourceList/index.vue +9 -23
  27. package/components/ResourceTable.vue +7 -2
  28. package/components/SimpleBox.vue +6 -4
  29. package/components/SortableTable/index.vue +18 -25
  30. package/components/Tabbed/Tab.vue +5 -0
  31. package/components/Tabbed/index.vue +54 -9
  32. package/components/TypeDescription.vue +10 -1
  33. package/components/auth/Principal.vue +1 -0
  34. package/components/fleet/FleetBundles.vue +8 -3
  35. package/components/fleet/FleetClusters.vue +6 -0
  36. package/components/fleet/FleetRepos.vue +7 -1
  37. package/components/fleet/FleetSummary.vue +6 -0
  38. package/components/form/Command.vue +5 -0
  39. package/components/form/EnvVars.vue +5 -0
  40. package/components/form/KeyValue.vue +80 -58
  41. package/components/form/NameNsDescription.vue +13 -5
  42. package/components/form/NodeScheduling.vue +6 -1
  43. package/components/form/PodAffinity.vue +5 -0
  44. package/components/form/ResourceTabs/index.vue +5 -1
  45. package/components/form/ServiceNameSelect.vue +5 -0
  46. package/components/form/ValueFromResource.vue +7 -1
  47. package/components/formatter/ClusterLink.vue +3 -7
  48. package/components/nav/NamespaceFilter.vue +3 -3
  49. package/components/nav/TopLevelMenu.vue +12 -29
  50. package/config/home-links.js +155 -0
  51. package/config/labels-annotations.js +2 -1
  52. package/config/private-label.js +1 -1
  53. package/config/product/explorer.js +5 -4
  54. package/config/product/legacy.js +0 -47
  55. package/config/product/manager.js +0 -2
  56. package/config/product/multi-cluster-apps.js +0 -12
  57. package/config/product/settings.js +12 -1
  58. package/config/product/uiplugins.js +17 -0
  59. package/config/settings.js +23 -2
  60. package/config/types.js +5 -1
  61. package/config/uiplugins.js +117 -0
  62. package/config/version.js +17 -0
  63. package/content/docs/en-us/getting-started.md +1 -26
  64. package/core/plugin.ts +12 -0
  65. package/core/plugins.js +38 -2
  66. package/core/types.ts +6 -0
  67. package/creators/app/{.eslintignore → files/.eslintignore} +0 -0
  68. package/creators/app/{.eslintrc.js → files/.eslintrc.js} +0 -0
  69. package/creators/app/{.vscode → files/.vscode}/settings.json +0 -0
  70. package/creators/app/{babel.config.js → files/babel.config.js} +0 -0
  71. package/creators/app/{nuxt.config.js → files/nuxt.config.js} +0 -0
  72. package/creators/app/{tsconfig.json → files/tsconfig.json} +2 -1
  73. package/creators/app/init +16 -17
  74. package/creators/app/package.json +6 -0
  75. package/creators/pkg/{babel.config.js → files/babel.config.js} +0 -0
  76. package/creators/pkg/{index.ts → files/index.ts} +0 -0
  77. package/creators/pkg/{tsconfig.json → files/tsconfig.json} +13 -12
  78. package/creators/pkg/{vue.config.js → files/vue.config.js} +0 -0
  79. package/creators/pkg/init +1 -1
  80. package/creators/update/init +54 -0
  81. package/creators/update/package.json +20 -0
  82. package/creators/update/upgrade +56 -0
  83. package/creators/update/yarn-error.log +54 -0
  84. package/detail/provisioning.cattle.io.cluster.vue +3 -3
  85. package/detail/workload/index.vue +3 -2
  86. package/dialog/DiagnosticTimingsDialog.vue +116 -0
  87. package/dialog/RotateCertificatesDialog.vue +9 -3
  88. package/edit/auth/azuread.vue +28 -9
  89. package/edit/networking.k8s.io.ingress/index.vue +2 -2
  90. package/edit/persistentvolume/index.vue +51 -13
  91. package/edit/persistentvolumeclaim.vue +31 -13
  92. package/edit/pod.vue +27 -0
  93. package/edit/provisioning.cattle.io.cluster/rke2.vue +103 -24
  94. package/edit/service.vue +7 -5
  95. package/edit/workload/__tests__/Upgrading.test.ts +1 -0
  96. package/edit/workload/index.vue +32 -10
  97. package/edit/workload/mixins/workload.js +121 -126
  98. package/edit/workload/storage/ContainerMountPaths.vue +240 -0
  99. package/edit/workload/storage/Mount.vue +1 -0
  100. package/edit/workload/storage/awsElasticBlockStore.vue +20 -1
  101. package/edit/workload/storage/azureDisk.vue +22 -2
  102. package/edit/workload/storage/azureFile.vue +20 -2
  103. package/edit/workload/storage/csi/index.vue +23 -1
  104. package/edit/workload/storage/gcePersistentDisk.vue +20 -2
  105. package/edit/workload/storage/index.vue +33 -65
  106. package/edit/workload/storage/persistentVolumeClaim/index.vue +5 -0
  107. package/edit/workload/storage/secret.vue +6 -1
  108. package/edit/workload/storage/vsphereVolume.vue +11 -1
  109. package/layouts/default.vue +14 -8
  110. package/layouts/home.vue +9 -4
  111. package/layouts/plain.vue +10 -5
  112. package/list/catalog.cattle.io.app.vue +10 -9
  113. package/list/catalog.cattle.io.clusterrepo.vue +6 -61
  114. package/list/cis.cattle.io.clusterscan.vue +12 -12
  115. package/list/fleet.cattle.io.bundle.vue +33 -28
  116. package/list/fleet.cattle.io.cluster.vue +26 -22
  117. package/list/fleet.cattle.io.clustergroup.vue +6 -0
  118. package/list/fleet.cattle.io.clusterregistrationtoken.vue +28 -24
  119. package/list/fleet.cattle.io.gitrepo.vue +25 -14
  120. package/list/helm.cattle.io.projecthelmchart.vue +52 -33
  121. package/list/logging.banzaicloud.io.clusterflow.vue +7 -12
  122. package/list/logging.banzaicloud.io.flow.vue +7 -14
  123. package/list/management.cattle.io.cluster.vue +26 -15
  124. package/list/management.cattle.io.feature.vue +13 -8
  125. package/list/management.cattle.io.setting.vue +3 -3
  126. package/list/management.cattle.io.user.vue +38 -19
  127. package/list/monitoring.coreos.com.alertmanagerconfig.vue +8 -15
  128. package/list/namespace.vue +14 -1
  129. package/list/node.vue +13 -16
  130. package/list/persistentvolume.vue +16 -9
  131. package/list/persistentvolumeclaim.vue +5 -8
  132. package/list/provisioning.cattle.io.cluster.vue +35 -9
  133. package/list/service.vue +24 -12
  134. package/list/ui.cattle.io.navlink.vue +6 -0
  135. package/list/workload.vue +2 -2
  136. package/machine-config/harvester.vue +5 -3
  137. package/middleware/authenticated.js +6 -0
  138. package/mixins/resource-fetch.js +12 -18
  139. package/mixins/resource-manager.js +126 -0
  140. package/models/catalog.cattle.io.uiplugin.js +38 -0
  141. package/models/cluster/node.js +25 -2
  142. package/models/fleet.cattle.io.bundle.js +1 -1
  143. package/models/harvesterhci.io.management.cluster.js +11 -5
  144. package/models/pod.js +15 -5
  145. package/models/provisioning.cattle.io.cluster.js +16 -6
  146. package/models/workload.js +5 -3
  147. package/models/workload.service.js +10 -0
  148. package/nuxt.config.js +70 -25
  149. package/package.json +108 -109
  150. package/pages/auth/login.vue +11 -1
  151. package/pages/auth/verify.vue +9 -0
  152. package/pages/c/_cluster/apps/charts/index.vue +46 -1
  153. package/pages/c/_cluster/apps/charts/install.vue +10 -9
  154. package/pages/c/_cluster/explorer/index.vue +72 -9
  155. package/pages/c/_cluster/explorer/tools/index.vue +12 -5
  156. package/pages/c/_cluster/mcapps/index.vue +1 -1
  157. package/pages/c/_cluster/settings/DefaultLinksEditor.vue +108 -0
  158. package/pages/c/_cluster/settings/brand.vue +0 -40
  159. package/pages/c/_cluster/settings/links.vue +152 -0
  160. package/pages/c/_cluster/settings/performance.vue +90 -7
  161. package/pages/c/_cluster/uiplugins/DeveloperInstallDialog.vue +232 -0
  162. package/pages/c/_cluster/uiplugins/InstallDialog.vue +293 -0
  163. package/pages/c/_cluster/uiplugins/PluginInfoPanel.vue +300 -0
  164. package/pages/c/_cluster/uiplugins/RemoveUIPlugins.vue +125 -0
  165. package/pages/c/_cluster/uiplugins/SetupUIPlugins.vue +261 -0
  166. package/pages/c/_cluster/uiplugins/UninstallDialog.vue +122 -0
  167. package/pages/c/_cluster/uiplugins/index.vue +808 -0
  168. package/pages/diagnostic.vue +185 -101
  169. package/pages/docs/_doc.vue +3 -1
  170. package/pages/home.vue +21 -56
  171. package/pages/prefs.vue +108 -88
  172. package/pages/safeMode.vue +17 -0
  173. package/pages/support/index.vue +34 -137
  174. package/pkg/dynamic-importer.lib.js +4 -0
  175. package/plugins/dashboard-store/actions.js +19 -0
  176. package/plugins/dashboard-store/getters.js +20 -3
  177. package/plugins/dashboard-store/mutations.js +13 -7
  178. package/plugins/dashboard-store/resource-class.js +2 -2
  179. package/plugins/formatters.js +15 -0
  180. package/plugins/plugin.js +61 -6
  181. package/plugins/steve/getters.js +12 -0
  182. package/plugins/steve/mutations.js +1 -1
  183. package/plugins/steve/subscribe.js +94 -72
  184. package/plugins/steve/web-worker.steve-sub-worker.js +24 -15
  185. package/plugins/version.js +21 -0
  186. package/promptRemove/management.cattle.io.globalrole.vue +47 -0
  187. package/promptRemove/management.cattle.io.roletemplate.vue +47 -0
  188. package/promptRemove/mixin/roleDeletionCheck.js +97 -0
  189. package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +6 -7
  190. package/rancher-components/components/BadgeState/BadgeState.spec.ts +12 -0
  191. package/rancher-components/components/BadgeState/BadgeState.vue +107 -0
  192. package/rancher-components/components/BadgeState/index.ts +1 -0
  193. package/rancher-components/components/Banner/Banner.test.ts +13 -0
  194. package/rancher-components/components/Banner/Banner.vue +163 -0
  195. package/rancher-components/components/Banner/index.ts +1 -0
  196. package/rancher-components/components/Card/Card.vue +150 -0
  197. package/rancher-components/components/Card/index.ts +1 -0
  198. package/rancher-components/components/Form/Checkbox/Checkbox.test.ts +77 -0
  199. package/rancher-components/components/Form/Checkbox/Checkbox.vue +395 -0
  200. package/rancher-components/components/Form/Checkbox/index.ts +1 -0
  201. package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +29 -0
  202. package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +343 -0
  203. package/rancher-components/components/Form/LabeledInput/index.ts +1 -0
  204. package/rancher-components/components/Form/Radio/RadioButton.vue +270 -0
  205. package/rancher-components/components/Form/Radio/RadioGroup.vue +235 -0
  206. package/rancher-components/components/Form/Radio/index.ts +2 -0
  207. package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +168 -0
  208. package/rancher-components/components/Form/TextArea/index.ts +1 -0
  209. package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.test.ts +107 -0
  210. package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.vue +137 -0
  211. package/rancher-components/components/Form/ToggleSwitch/index.ts +1 -0
  212. package/rancher-components/components/Form/index.ts +5 -0
  213. package/rancher-components/components/LabeledTooltip/LabeledTooltip.vue +137 -0
  214. package/rancher-components/components/LabeledTooltip/index.ts +1 -0
  215. package/scripts/publish-shell.sh +40 -7
  216. package/scripts/record-deps.js +37 -0
  217. package/scripts/sync-shell-deps +37 -0
  218. package/scripts/test-plugins-build.sh +8 -5
  219. package/scripts/typegen.sh +84 -0
  220. package/store/auth.js +3 -0
  221. package/store/catalog.js +9 -8
  222. package/store/i18n.js +10 -1
  223. package/store/index.js +12 -3
  224. package/store/prefs.js +16 -0
  225. package/store/type-map.js +32 -5
  226. package/store/uiplugins.ts +15 -61
  227. package/types/shell/index.d.ts +3046 -0
  228. package/utils/__tests__/object.test.ts +0 -24
  229. package/utils/__tests__/selector.test.ts +1 -1
  230. package/utils/dynamic-importer.js +4 -0
  231. package/utils/favicon.js +8 -2
  232. package/utils/gc/gc-interval.ts +40 -0
  233. package/utils/gc/gc-root-store.js +76 -0
  234. package/utils/gc/gc-route-changed.ts +44 -0
  235. package/utils/gc/gc-types.ts +21 -0
  236. package/utils/gc/gc.ts +282 -0
  237. package/utils/grafana.js +2 -6
  238. package/utils/socket.js +41 -20
  239. package/utils/string.js +1 -7
  240. package/utils/validators/formRules/__tests__/index.test.ts +108 -0
  241. package/utils/validators/formRules/index.ts +9 -1
  242. package/config/footer.js +0 -19
  243. package/creators/pkg/nuxt.config.js +0 -6
  244. package/pages/plugins.vue +0 -387
  245. package/server/verdaccio-middleware.js +0 -56
@@ -7,6 +7,7 @@ import { LabeledInput } from '@components/Form/LabeledInput';
7
7
  import { MANAGEMENT } from '@shell/config/types';
8
8
  import { DEFAULT_PERF_SETTING, SETTING } from '@shell/config/settings';
9
9
  import { _EDIT, _VIEW } from '@shell/config/query-params';
10
+ import UnitInput from '@shell/components/form/UnitInput';
10
11
 
11
12
  export default {
12
13
  layout: 'authenticated',
@@ -16,6 +17,7 @@ export default {
16
17
  AsyncButton,
17
18
  Banner,
18
19
  LabeledInput,
20
+ UnitInput
19
21
  },
20
22
 
21
23
  async fetch() {
@@ -30,15 +32,21 @@ export default {
30
32
 
31
33
  const sValue = this.uiPerfSetting?.value || JSON.stringify(DEFAULT_PERF_SETTING);
32
34
 
33
- this.value = JSON.parse(sValue);
35
+ this.value = {
36
+ ...DEFAULT_PERF_SETTING,
37
+ ...JSON.parse(sValue),
38
+ };
39
+
40
+ this.gcStartedEnabled = this.value.garbageCollection.enabled;
34
41
  },
35
42
 
36
43
  data() {
37
44
  return {
38
- uiPerfSetting: DEFAULT_PERF_SETTING,
39
- bannerVal: {},
40
- value: {},
41
- errors: [],
45
+ uiPerfSetting: DEFAULT_PERF_SETTING,
46
+ bannerVal: {},
47
+ value: {},
48
+ errors: [],
49
+ gcStartedEnabled: null
42
50
  };
43
51
  },
44
52
 
@@ -57,12 +65,19 @@ export default {
57
65
 
58
66
  try {
59
67
  await this.uiPerfSetting.save();
68
+
69
+ this.$store.dispatch('gcPreferencesUpdated', {
70
+ previouslyEnabled: this.gcStartedEnabled,
71
+ newPreferences: this.value.garbageCollection
72
+ }, { root: true });
73
+
74
+ this.gcStartedEnabled = this.value.garbageCollection.enabled;
60
75
  btnCB(true);
61
76
  } catch (err) {
62
77
  this.errors.push(err);
63
78
  btnCB(false);
64
79
  }
65
- },
80
+ }
66
81
  }
67
82
  };
68
83
  </script>
@@ -75,7 +90,7 @@ export default {
75
90
  <div>
76
91
  <div class="ui-perf-setting">
77
92
  <!-- Websocket Notifications -->
78
- <div class="mt-40">
93
+ <div class="mt-20">
79
94
  <h2>{{ t('performance.websocketNotification.label') }}</h2>
80
95
  <p>{{ t('performance.websocketNotification.description') }}</p>
81
96
  <Checkbox
@@ -134,6 +149,74 @@ export default {
134
149
  />
135
150
  </div>
136
151
  </div>
152
+ <!-- Enable GC of resources from store -->
153
+ <div class="mt-40">
154
+ <h2 v-t="'performance.gc.label'" />
155
+ <p>{{ t('performance.gc.description') }}</p>
156
+ <Banner color="error" label-key="performance.gc.banner" />
157
+ <Checkbox
158
+ v-model="value.garbageCollection.enabled"
159
+ :label="t('performance.gc.checkboxLabel')"
160
+ class="mt-10 mb-20"
161
+ :primary="true"
162
+ />
163
+ <div class="ml-20">
164
+ <h3>{{ t('performance.gc.whenRun.description') }}</h3>
165
+ <div class="ml-20 mb-10">
166
+ <Checkbox
167
+ v-model="value.garbageCollection.enabledInterval"
168
+ :class="{ 'text-muted': !value.garbageCollection.enabled }"
169
+ :label="t('performance.gc.whenRun.intervalCheckBox.label')"
170
+ class="mt-10 mb-10"
171
+ :disabled="!value.garbageCollection.enabled"
172
+ :primary="true"
173
+ />
174
+ <div class="ml-20">
175
+ <UnitInput
176
+ v-model="value.garbageCollection.interval"
177
+ :suffix="t('suffix.seconds', { count: value.garbageCollection.interval })"
178
+ :label="t('performance.gc.whenRun.interval.inputLabel')"
179
+ :disabled="!value.garbageCollection.enabled || !value.garbageCollection.enabledInterval"
180
+ min="30"
181
+ class="input"
182
+ />
183
+ </div>
184
+ <Checkbox
185
+ v-model="value.garbageCollection.enabledOnNavigate"
186
+ :class="{ 'text-muted': !value.garbageCollection.enabled }"
187
+ :label="t('performance.gc.whenRun.route.description')"
188
+ class="mt-20 mb-10"
189
+ :disabled="!value.garbageCollection.enabled"
190
+ :primary="true"
191
+ />
192
+ </div>
193
+ <h3>{{ t('performance.gc.howRun.description') }}</h3>
194
+ <div class="ml-20">
195
+ <p :class="{ 'text-muted': !value.garbageCollection.enabled }">
196
+ {{ t('performance.gc.howRun.age.description', {}, true) }}
197
+ </p>
198
+ <UnitInput
199
+ v-model="value.garbageCollection.ageThreshold"
200
+ :suffix="t('suffix.seconds', { count: value.garbageCollection.ageThreshold })"
201
+ :label="t('performance.gc.howRun.age.inputLabel')"
202
+ :disabled="!value.garbageCollection.enabled"
203
+ min="30"
204
+ class="input"
205
+ />
206
+ <p class="mt-20" :class="{ 'text-muted': !value.garbageCollection.enabled }">
207
+ {{ t('performance.gc.howRun.count.description') }}
208
+ </p>
209
+ <LabeledInput
210
+ v-model.number="value.garbageCollection.countThreshold"
211
+ :label="t('performance.gc.howRun.count.inputLabel')"
212
+ :disabled="!value.garbageCollection.enabled"
213
+ class="input"
214
+ type="number"
215
+ min="0"
216
+ />
217
+ </div>
218
+ </div>
219
+ </div>
137
220
  </div>
138
221
  </div>
139
222
  <template v-for="err in errors">
@@ -0,0 +1,232 @@
1
+ <script>
2
+ import AsyncButton from '@shell/components/AsyncButton';
3
+ import { LabeledInput } from '@components/Form/LabeledInput';
4
+ import Checkbox from '@components/Form/Checkbox/Checkbox.vue';
5
+ import { UI_PLUGIN } from '@shell/config/types';
6
+ import { UI_PLUGIN_NAMESPACE } from '@shell/config/uiplugins';
7
+
8
+ export default {
9
+ components: {
10
+ AsyncButton,
11
+ Checkbox,
12
+ LabeledInput,
13
+ },
14
+
15
+ data() {
16
+ return {
17
+ name: '',
18
+ location: '',
19
+ persist: false,
20
+ canModifyName: true,
21
+ canModifyLocation: true,
22
+ };
23
+ },
24
+
25
+ watch: {
26
+ name(neu, old) {
27
+ if (this.canModifyLocation) {
28
+ this.location = `/pkg/${ neu }/${ neu }.umd.min.js`;
29
+ }
30
+ },
31
+ location(neu, old) {
32
+ if (this.canModifyName) {
33
+ const names = neu.split('/');
34
+ let last = names[names.length - 1];
35
+ let index = last.indexOf('.umd.min.js');
36
+
37
+ if (index !== -1) {
38
+ last = last.substr(0, index);
39
+ } else {
40
+ index = last.indexOf('.umd.js');
41
+ if (index !== -1) {
42
+ last = last.substr(0, index);
43
+ }
44
+ }
45
+
46
+ this.name = last;
47
+ }
48
+ }
49
+ },
50
+
51
+ methods: {
52
+ showDialog() {
53
+ this.$modal.show('developerInstallPluginDialog');
54
+ },
55
+ closeDialog(result) {
56
+ this.$modal.hide('developerInstallPluginDialog');
57
+ this.$emit('closed', result);
58
+ },
59
+
60
+ updateName(v) {
61
+ this.canModifyName = v.length === 0;
62
+ },
63
+
64
+ updateLocation(v) {
65
+ this.canModifyLocation = v.length === 0;
66
+ },
67
+
68
+ async loadPlugin(btnCb) {
69
+ let name = this.name;
70
+ const url = this.location;
71
+
72
+ if (!name) {
73
+ const parts = url.split('/');
74
+ const n = parts[parts.length - 1];
75
+
76
+ // Split on '.'
77
+ name = n.split('.')[0];
78
+ }
79
+
80
+ // Try and parse version number from the name
81
+ let version = '0.0.1';
82
+ let crdName = name;
83
+
84
+ const parts = name.split('-');
85
+
86
+ if (parts.length >= 2) {
87
+ version = parts.pop();
88
+ crdName = parts.join('-');
89
+ }
90
+
91
+ if (this.persist) {
92
+ const pluginCR = await this.$store.dispatch('management/create', {
93
+ type: UI_PLUGIN,
94
+ metadata: {
95
+ name,
96
+ namespace: UI_PLUGIN_NAMESPACE
97
+ },
98
+ spec: {
99
+ plugin: {
100
+ name: crdName,
101
+ version,
102
+ endpoint: url,
103
+ noCache: true,
104
+ metadata: {
105
+ developer: 'true',
106
+ direct: 'true'
107
+ }
108
+ }
109
+ }
110
+ });
111
+
112
+ try {
113
+ await pluginCR.save({ url: `/v1/${ UI_PLUGIN }`, method: 'POST' });
114
+ } catch (e) {
115
+ console.error('Could not create CRD for plugin', e); // eslint-disable-line no-console
116
+ btnCb(false);
117
+ }
118
+ }
119
+
120
+ this.$plugin.loadAsync(name, url).then(() => {
121
+ this.closeDialog(true);
122
+ this.$store.dispatch('growl/success', {
123
+ title: this.t('plugins.success.title', { name }),
124
+ message: this.t('plugins.success.message'),
125
+ timeout: 3000,
126
+ }, { root: true });
127
+ btnCb(true);
128
+ }).catch((error) => {
129
+ btnCb(false);
130
+ // this.closeDialog(false);
131
+ const message = typeof error === 'object' ? this.t('plugins.error.message') : error;
132
+
133
+ this.$store.dispatch('growl/error', {
134
+ title: this.t('plugins.error.title'),
135
+ message,
136
+ timeout: 5000
137
+ }, { root: true });
138
+ });
139
+ }
140
+ }
141
+ };
142
+ </script>
143
+
144
+ <template>
145
+ <modal
146
+ name="developerInstallPluginDialog"
147
+ height="auto"
148
+ :scrollable="true"
149
+ >
150
+ <div class="plugin-install-dialog">
151
+ <h4>
152
+ {{ t('plugins.developer.title') }}
153
+ </h4>
154
+ <p>
155
+ {{ t('plugins.developer.prompt') }}
156
+ </p>
157
+ <div class="custom mt-10">
158
+ <div class="fields">
159
+ <LabeledInput v-model="location" v-focus label-key="plugins.developer.fields.url" @input="updateLocation" />
160
+ </div>
161
+ </div>
162
+ <div class="custom mt-10">
163
+ <div class="fields">
164
+ <LabeledInput v-model="name" label-key="plugins.developer.fields.name" @input="updateName" />
165
+ </div>
166
+ <div class="fields mt-10">
167
+ <Checkbox v-model="persist" label-key="plugins.developer.fields.persist" />
168
+ </div>
169
+ <div class="dialog-buttons mt-20">
170
+ <button class="btn role-secondary" @click="closeDialog()">
171
+ {{ t('generic.cancel') }}
172
+ </button>
173
+ <AsyncButton
174
+ mode="load"
175
+ @click="loadPlugin"
176
+ />
177
+ </div>
178
+ </div>
179
+ </div>
180
+ </modal>
181
+ </template>
182
+
183
+ <style lang="scss" scoped>
184
+ .plugin-install-dialog {
185
+ padding: 10px;
186
+
187
+ h4 {
188
+ font-weight: bold;
189
+ }
190
+
191
+ .dialog-panel {
192
+ display: flex;
193
+ flex-direction: column;
194
+ min-height: 100px;
195
+
196
+ p {
197
+ margin-bottom: 5px;
198
+ }
199
+
200
+ .dialog-info {
201
+ flex: 1;
202
+ }
203
+
204
+ .toggle-advanced {
205
+ display: flex;
206
+ align-items: center;
207
+ cursor: pointer;
208
+ margin: 10px 0;
209
+
210
+ &:hover {
211
+ text-decoration: none;
212
+ color: var(--link);
213
+ }
214
+ }
215
+
216
+ .version-selector {
217
+ margin: 0 10px 10px 10px;
218
+ width: auto;
219
+ }
220
+ }
221
+
222
+ .dialog-buttons {
223
+ display: flex;
224
+ justify-content: flex-end;
225
+ margin-top: 10px;
226
+
227
+ > *:not(:last-child) {
228
+ margin-right: 10px;
229
+ }
230
+ }
231
+ }
232
+ </style>
@@ -0,0 +1,293 @@
1
+ <script>
2
+ import AsyncButton from '@shell/components/AsyncButton';
3
+ import LabeledSelect from '@shell/components/form/LabeledSelect';
4
+ import { CATALOG, MANAGEMENT } from '@shell/config/types';
5
+ import { CATALOG as CATALOG_ANNOTATIONS } from '@shell/config/labels-annotations';
6
+ import { UI_PLUGIN_NAMESPACE } from '@shell/config/uiplugins';
7
+ import Banner from '@components/Banner/Banner.vue';
8
+
9
+ // Note: This dialog handles installation and update of a plugin
10
+
11
+ export default {
12
+ components: {
13
+ AsyncButton,
14
+ Banner,
15
+ LabeledSelect,
16
+ },
17
+
18
+ async fetch() {
19
+ this.defaultRegistrySetting = await this.$store.dispatch('management/find', {
20
+ type: MANAGEMENT.SETTING,
21
+ id: 'system-default-registry'
22
+ });
23
+ },
24
+
25
+ data() {
26
+ return {
27
+ defaultRegistrySetting: null,
28
+ plugin: undefined,
29
+ busy: false,
30
+ version: '',
31
+ update: false,
32
+ mode: '',
33
+ };
34
+ },
35
+
36
+ computed: {
37
+ showVersionSelector() {
38
+ return this.plugin?.versions.length > 1;
39
+ },
40
+
41
+ versionOptions() {
42
+ if (!this.plugin) {
43
+ return [];
44
+ }
45
+
46
+ return this.plugin.versions.map((version) => {
47
+ return {
48
+ label: version.version,
49
+ value: version.version,
50
+ };
51
+ });
52
+ },
53
+
54
+ buttonMode() {
55
+ return this.update ? 'update' : 'install';
56
+ }
57
+ },
58
+
59
+ methods: {
60
+ showDialog(plugin, mode) {
61
+ this.plugin = plugin;
62
+ this.mode = mode;
63
+
64
+ // Default to latest version on install (this is default on the plugin)
65
+ this.version = plugin.displayVersion;
66
+
67
+ if (mode === 'update') {
68
+ // Update to latest version, so take the first version
69
+ if (plugin.versions.length > 0) {
70
+ this.version = plugin.versions[0].version;
71
+ }
72
+ } else if (mode === 'rollback') {
73
+ // Find the newest version once we remove the current version
74
+ const versionNames = plugin.versions.filter(v => v.version !== plugin.displayVersion);
75
+
76
+ if (versionNames.length > 0) {
77
+ this.version = versionNames[0].version;
78
+ }
79
+ }
80
+
81
+ // Make sure we have the version available
82
+ const versionChart = plugin.versions?.find(v => v.version === this.version);
83
+
84
+ if (!versionChart) {
85
+ this.version = plugin.versions[0].version;
86
+ }
87
+
88
+ this.busy = false;
89
+ this.update = mode !== 'install';
90
+ this.$modal.show('installPluginDialog');
91
+ },
92
+
93
+ closeDialog(result) {
94
+ this.$modal.hide('installPluginDialog');
95
+ this.$emit('closed', result);
96
+ },
97
+
98
+ async install() {
99
+ this.busy = true;
100
+
101
+ const plugin = this.plugin;
102
+
103
+ this.$emit('update', plugin.name, 'install');
104
+
105
+ // Find the version that the user wants to install
106
+ const version = plugin.versions?.find(v => v.version === this.version);
107
+
108
+ if (!version) {
109
+ this.busy = false;
110
+
111
+ return;
112
+ }
113
+
114
+ // is the image used by the chart in the rancher org?
115
+ let isRancherImage = false;
116
+
117
+ try {
118
+ const chartVersionInfo = await this.$store.dispatch('catalog/getVersionInfo', {
119
+ repoType: version.repoType,
120
+ repoName: version.repoName,
121
+ chartName: plugin.chart.chartName,
122
+ versionName: this.version,
123
+ });
124
+
125
+ const image = chartVersionInfo?.values?.image?.repository || '';
126
+
127
+ isRancherImage = image.startsWith('rancher/');
128
+ } catch (e) {}
129
+
130
+ // See if there is already a plugin with this name
131
+ let exists = false;
132
+
133
+ try {
134
+ const app = await this.$store.dispatch('management/find', {
135
+ type: CATALOG.APP,
136
+ id: `${ UI_PLUGIN_NAMESPACE }/${ plugin.chart.chartName }`,
137
+ opt: { force: true },
138
+ });
139
+
140
+ exists = !!app;
141
+ } catch (e) {}
142
+
143
+ const repoType = version.repoType;
144
+ const repoName = version.repoName;
145
+ const repo = this.$store.getters['catalog/repo']({ repoType, repoName });
146
+
147
+ const chart = {
148
+ chartName: plugin.chart.chartName,
149
+ version: this.version,
150
+ releaseName: plugin.chart.chartName,
151
+ annotations: {
152
+ [CATALOG_ANNOTATIONS.SOURCE_REPO_TYPE]: plugin.repoType,
153
+ [CATALOG_ANNOTATIONS.SOURCE_REPO_NAME]: plugin.repoName
154
+ },
155
+ values: {}
156
+ };
157
+
158
+ // Pass in the system default registry property if set - only if the image is in the rancher org
159
+ const defaultRegistry = this.defaultRegistrySetting?.value || '';
160
+
161
+ if (isRancherImage && defaultRegistry) {
162
+ chart.values.global = chart.values.global || {};
163
+ chart.values.global.cattle = chart.values.global.cattle || {};
164
+ chart.values.global.cattle.systemDefaultRegistry = defaultRegistry;
165
+ }
166
+
167
+ const input = {
168
+ charts: [chart],
169
+ // timeout: this.cmdOptions.timeout > 0 ? `${ this.cmdOptions.timeout }s` : null,
170
+ // wait: this.cmdOptions.wait === true,
171
+ namespace: UI_PLUGIN_NAMESPACE,
172
+ };
173
+
174
+ // Helm action
175
+ const action = (exists || this.update) ? 'upgrade' : 'install';
176
+
177
+ try {
178
+ const res = await repo.doAction(action, input);
179
+ const operationId = `${ res.operationNamespace }/${ res.operationName }`;
180
+
181
+ this.closeDialog(plugin);
182
+
183
+ await repo.waitForOperation(operationId);
184
+
185
+ await this.$store.dispatch(`management/find`, {
186
+ type: CATALOG.OPERATION,
187
+ id: operationId
188
+ });
189
+ } catch (e) {
190
+ this.$store.dispatch('growl/error', {
191
+ title: this.t('plugins.error.generic'),
192
+ message: e.message ? e.message : e,
193
+ timeout: 10000
194
+ }, { root: true });
195
+
196
+ this.closeDialog(plugin);
197
+ }
198
+ }
199
+ }
200
+ };
201
+ </script>
202
+
203
+ <template>
204
+ <modal
205
+ name="installPluginDialog"
206
+ height="auto"
207
+ :scrollable="true"
208
+ >
209
+ <div v-if="plugin" class="plugin-install-dialog">
210
+ <h4 class="mt-10">
211
+ {{ t(`plugins.${ mode }.title`, { name: plugin.name }) }}
212
+ </h4>
213
+ <div class="custom mt-10">
214
+ <div class="dialog-panel">
215
+ <p>
216
+ {{ t(`plugins.${ mode }.prompt`) }}
217
+ </p>
218
+ <Banner v-if="!plugin.certified" color="warning" :label="t('plugins.install.warnNotCertified')" />
219
+ <LabeledSelect
220
+ v-if="showVersionSelector"
221
+ v-model="version"
222
+ label-key="plugins.install.version"
223
+ :options="versionOptions"
224
+ class="version-selector mt-10"
225
+ />
226
+ <div v-else>
227
+ {{ t('plugins.install.version') }} {{ version }}
228
+ </div>
229
+ </div>
230
+ <div class="dialog-buttons">
231
+ <button :disabled="busy" class="btn role-secondary" @click="closeDialog(false)">
232
+ {{ t('generic.cancel') }}
233
+ </button>
234
+ <AsyncButton
235
+ :mode="buttonMode"
236
+ @click="install"
237
+ />
238
+ </div>
239
+ </div>
240
+ </div>
241
+ </modal>
242
+ </template>
243
+
244
+ <style lang="scss" scoped>
245
+ .plugin-install-dialog {
246
+ padding: 10px;
247
+
248
+ h4 {
249
+ font-weight: bold;
250
+ }
251
+
252
+ .dialog-panel {
253
+ display: flex;
254
+ flex-direction: column;
255
+ min-height: 100px;
256
+
257
+ p {
258
+ margin-bottom: 5px;
259
+ }
260
+
261
+ .dialog-info {
262
+ flex: 1;
263
+ }
264
+
265
+ .toggle-advanced {
266
+ display: flex;
267
+ align-items: center;
268
+ cursor: pointer;
269
+ margin: 10px 0;
270
+
271
+ &:hover {
272
+ text-decoration: none;
273
+ color: var(--link);
274
+ }
275
+ }
276
+
277
+ .version-selector {
278
+ margin: 0 10px 10px 10px;
279
+ width: auto;
280
+ }
281
+ }
282
+
283
+ .dialog-buttons {
284
+ display: flex;
285
+ justify-content: flex-end;
286
+ margin-top: 10px;
287
+
288
+ > *:not(:last-child) {
289
+ margin-right: 10px;
290
+ }
291
+ }
292
+ }
293
+ </style>