@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
@@ -0,0 +1,300 @@
1
+ <script>
2
+ import ChartReadme from '@shell/components/ChartReadme';
3
+ import { Banner } from '@components/Banner';
4
+ import LazyImage from '@shell/components/LazyImage';
5
+
6
+ export default {
7
+ components: {
8
+ Banner,
9
+ ChartReadme,
10
+ LazyImage
11
+ },
12
+
13
+ data() {
14
+ return {
15
+ showSlideIn: false,
16
+ info: undefined,
17
+ infoVersion: undefined,
18
+ versionInfo: undefined,
19
+ versionError: undefined,
20
+ defaultIcon: require('~shell/assets/images/generic-plugin.svg'),
21
+ };
22
+ },
23
+
24
+ methods: {
25
+ show(info) {
26
+ this.info = info;
27
+ this.showSlideIn = true;
28
+ this.version = null;
29
+ this.versionInfo = null;
30
+ this.versionError = null;
31
+
32
+ this.loadPluginVersionInfo();
33
+ },
34
+
35
+ hide() {
36
+ this.showSlideIn = false;
37
+ },
38
+
39
+ async loadPluginVersionInfo(version) {
40
+ this.versionError = false;
41
+ this.versionInfo = undefined;
42
+
43
+ const versionName = version || this.info.displayVersion;
44
+
45
+ this.infoVersion = versionName;
46
+
47
+ if (!this.info.chart) {
48
+ return;
49
+ }
50
+
51
+ try {
52
+ this.versionInfo = await this.$store.dispatch('catalog/getVersionInfo', {
53
+ repoType: this.info.chart.repoType,
54
+ repoName: this.info.chart.repoName,
55
+ chartName: this.info.chart.chartName,
56
+ versionName
57
+ });
58
+ // Here we set us versionInfo. The returned
59
+ // object contains everything all info
60
+ // about a currently installed app, and it has the
61
+ // following keys:
62
+ //
63
+ // - appReadme: A short overview of what the app does. This
64
+ // forms the first few paragraphs of the chart info when
65
+ // you install a Helm chart app through Rancher.
66
+ // - chart: Metadata about the Helm chart, including the
67
+ // name and version.
68
+ // - readme: This is more detailed information that appears
69
+ // under the heading "Chart Information (Helm README)" when
70
+ // you install or upgrade a Helm chart app through Rancher,
71
+ // below the app README.
72
+ // - values: All Helm chart values for the currently installed
73
+ // app.
74
+ } catch (e) {
75
+ this.versionError = true;
76
+ console.error('Unable to fetch VersionInfo: ', e); // eslint-disable-line no-console
77
+ }
78
+ }
79
+ }
80
+ };
81
+ </script>
82
+ <template>
83
+ <div class="plugin-info-panel">
84
+ <div v-if="showSlideIn" class="glass" @click="hide()" />
85
+ <div class="slideIn" :class="{'hide': false, 'slideIn__show': showSlideIn}">
86
+ <div v-if="info" class="plugin-info-content">
87
+ <div class="plugin-header">
88
+ <div class="plugin-icon">
89
+ <LazyImage
90
+ v-if="info.icon"
91
+ :initial-src="defaultIcon"
92
+ :error-src="defaultIcon"
93
+ :src="info.icon"
94
+ class="icon plugin-icon-img"
95
+ />
96
+ <img
97
+ v-else
98
+ :src="defaultIcon"
99
+ class="icon plugin-icon-img"
100
+ />
101
+ </div>
102
+ <div class="plugin-title">
103
+ <h2 class="slideIn__header">
104
+ {{ info.name }}
105
+ </h2>
106
+ <p class="plugin-description">
107
+ {{ info.description }}
108
+ </p>
109
+ </div>
110
+ <div class="plugin-close">
111
+ <div class="slideIn__header__buttons">
112
+ <div class="slideIn__header__button" @click="showSlideIn = false">
113
+ <i class="icon icon-close" />
114
+ </div>
115
+ </div>
116
+ </div>
117
+ </div>
118
+ <div>
119
+ <Banner v-if="info.error" color="error" :label="info.error" class="mt-10" />
120
+ <Banner v-if="!info.certified" color="warning" :label="t('plugins.descriptions.third-party')" class="mt-10" />
121
+ <Banner v-if="info.experimental" color="warning" :label="t('plugins.descriptions.experimental')" class="mt-10" />
122
+ </div>
123
+
124
+ <h3 v-if="info.versions.length">
125
+ {{ t('plugins.info.versions') }}
126
+ </h3>
127
+ <div class="plugin-versions mb-10">
128
+ <div v-for="v in info.versions" :key="v.version">
129
+ <a
130
+ class="version-link"
131
+ :class="{'version-active': v.version === infoVersion}"
132
+ @click="loadPluginVersionInfo(v.version)"
133
+ >
134
+ {{ v.version }}
135
+ </a>
136
+ </div>
137
+ </div>
138
+
139
+ <div v-if="versionError">
140
+ {{ t('plugins.info.versionError') }}
141
+ </div>
142
+ <h3 v-if="versionInfo">
143
+ {{ t('plugins.info.detail') }}
144
+ </h3>
145
+ <div v-if="versionInfo" class="plugin-info-detail">
146
+ <ChartReadme v-if="versionInfo" :version-info="versionInfo" />
147
+ </div>
148
+ <div v-if="!info.versions.length">
149
+ <h3>
150
+ {{ t('plugins.version', { version: info.displayVersion }) }}
151
+ </h3>
152
+ </div>
153
+ </div>
154
+ </div>
155
+ </div>
156
+ </template>
157
+ <style lang="scss" scoped>
158
+ .plugin-info-panel {
159
+ position: fixed;
160
+ top: 0;
161
+ left: 0;
162
+
163
+ $slideout-width: 35%;
164
+ $title-height: 50px;
165
+ $padding: 5px;
166
+ $slideout-width: 35%;
167
+ $header-height: 54px;
168
+
169
+ .glass {
170
+ z-index: 9;
171
+ position: fixed;
172
+ top: $header-height;
173
+ height: calc(100% - $header-height);
174
+ left: 0;
175
+ width: 100%;
176
+ opacity: 0;
177
+ }
178
+
179
+ .slideIn {
180
+ border-left: var(--header-border-size) solid var(--header-border);
181
+ position: fixed;
182
+ top: $header-height;
183
+ right: -$slideout-width;
184
+ height: calc(100% - $header-height);
185
+ background-color: var(--topmenu-bg);
186
+ width: $slideout-width;
187
+ z-index: 10;
188
+ display: flex;
189
+ flex-direction: column;
190
+
191
+ padding: 10px;
192
+
193
+ transition: right .5s ease;
194
+
195
+ .plugin-info-content {
196
+ display: flex;
197
+ flex-direction: column;
198
+ overflow: hidden;
199
+
200
+ .plugin-info-detail {
201
+ overflow: auto;
202
+ }
203
+ }
204
+
205
+ h3 {
206
+ font-size: 14px;
207
+ margin: 15px 0 10px 0;
208
+ opacity: 0.7;
209
+ text-transform: uppercase;
210
+ }
211
+
212
+ .plugin-header {
213
+ border-bottom: 1px solid var(--border);
214
+ display: flex;
215
+ padding-bottom: 20px;
216
+
217
+ .plugin-title {
218
+ flex: 1;
219
+ }
220
+ }
221
+
222
+ .plugin-icon {
223
+ font-size: 40px;
224
+ margin-right:10px;
225
+ color: #888;
226
+
227
+ .plugin-icon-img {
228
+ height: 40px;
229
+ width: 40px;
230
+ }
231
+ }
232
+
233
+ .plugin-versions {
234
+ display: flex;
235
+ }
236
+
237
+ .plugin-description {
238
+ font-size: 15px;
239
+ }
240
+
241
+ .version-link {
242
+ cursor: pointer;
243
+ border: 1px solid var(--link);
244
+ padding: 2px 8px;
245
+ border-radius: 5px;
246
+ user-select: none;
247
+ margin-right: 5px;
248
+
249
+ &.version-active {
250
+ color: var(--link-text);
251
+ background: var(--link);
252
+ }
253
+ }
254
+
255
+ &__header {
256
+ display: flex;
257
+ align-items: center;
258
+ justify-content: space-between;
259
+
260
+ &__buttons {
261
+ display: flex;
262
+ }
263
+
264
+ &__button {
265
+ cursor: pointer;
266
+ display: flex;
267
+ align-items: center;
268
+ justify-content: center;
269
+ padding: 2px;
270
+ > i {
271
+ font-size: 20px;
272
+ opacity: 0.5;
273
+ }
274
+ &:hover {
275
+ background-color: var(--wm-closer-hover-bg);
276
+ }
277
+ }
278
+ }
279
+
280
+ .chart-content__tabs {
281
+ display: flex;
282
+ flex-direction: column;
283
+ flex: 1;
284
+
285
+ height: 0;
286
+
287
+ padding-bottom: 10px;
288
+
289
+ ::v-deep .chart-readmes {
290
+ flex: 1;
291
+ overflow: auto;
292
+ }
293
+ }
294
+
295
+ &__show {
296
+ right: 0;
297
+ }
298
+ }
299
+ }
300
+ </style>
@@ -0,0 +1,125 @@
1
+ <script>
2
+ import { CATALOG, UI_PLUGIN } from '@shell/config/types';
3
+ import Dialog from '@shell/components/Dialog.vue';
4
+ import Checkbox from '@components/Form/Checkbox/Checkbox.vue';
5
+ import {
6
+ UI_PLUGIN_NAMESPACE,
7
+ UI_PLUGIN_CHARTS,
8
+ UI_PLUGINS_REPO_NAME,
9
+ UI_PLUGINS_REPO_URL,
10
+ } from '@shell/config/uiplugins';
11
+
12
+ export default {
13
+ components: {
14
+ Checkbox,
15
+ Dialog,
16
+ },
17
+
18
+ async fetch() {
19
+ if (this.$store.getters['management/schemaFor'](CATALOG.CLUSTER_REPO)) {
20
+ const repos = await this.$store.dispatch('management/findAll', { type: CATALOG.CLUSTER_REPO, opt: { force: true } });
21
+
22
+ this.defaultRepo = repos.find(r => r.name === UI_PLUGINS_REPO_NAME && r.spec.gitRepo === UI_PLUGINS_REPO_URL);
23
+ }
24
+ },
25
+
26
+ data() {
27
+ return {
28
+ errors: [],
29
+ defaultRepo: undefined,
30
+ removeRepo: false,
31
+ };
32
+ },
33
+
34
+ methods: {
35
+ async removeChart(name) {
36
+ const apps = await this.$store.dispatch('management/findAll', { type: CATALOG.APP });
37
+ const found = apps.find((app) => {
38
+ return app.namespace === UI_PLUGIN_NAMESPACE && app.name === name;
39
+ });
40
+
41
+ if (found) {
42
+ return found.remove();
43
+ }
44
+
45
+ // TODO - Return rejected promise - error
46
+ return null;
47
+ },
48
+
49
+ showDialog() {
50
+ this.removeRepo = !!this.defaultRepo;
51
+ this.$modal.show('confirm-uiplugins-remove');
52
+ },
53
+
54
+ async doRemove(btnCb) {
55
+ this.errors = [];
56
+
57
+ // Remove the charts in the reverse order that we install them in
58
+ const uninstall = [...UI_PLUGIN_CHARTS].reverse();
59
+
60
+ for (let i = 0; i < uninstall.length; i++) {
61
+ const chart = uninstall[i];
62
+
63
+ try {
64
+ await this.removeChart(chart);
65
+ } catch (e) {
66
+ this.errors.push(e.message);
67
+ }
68
+ }
69
+
70
+ if (this.removeRepo && this.defaultRepo) {
71
+ try {
72
+ await this.defaultRepo.remove();
73
+ } catch (e) {
74
+ this.errors.push(e.message);
75
+ }
76
+ }
77
+
78
+ this.$store.dispatch('management/forgetType', UI_PLUGIN);
79
+
80
+ await new Promise(resolve => setTimeout(resolve, 5000));
81
+
82
+ this.$emit('done');
83
+
84
+ btnCb(true);
85
+ },
86
+ }
87
+ };
88
+ </script>
89
+ <template>
90
+ <Dialog
91
+ name="confirm-uiplugins-remove"
92
+ :title="t('plugins.setup.remove.title')"
93
+ mode="disable"
94
+ @okay="doRemove"
95
+ >
96
+ <template>
97
+ <p>
98
+ {{ t('plugins.setup.remove.prompt') }}
99
+ </p>
100
+ <div v-if="!!defaultRepo" class="mt-20">
101
+ <Checkbox v-model="removeRepo" :primary="true" label-key="plugins.setup.remove.registry.title" />
102
+ <div class="checkbox-info">
103
+ {{ t('plugins.setup.remove.registry.prompt') }}
104
+ </div>
105
+ </div>
106
+ </template>
107
+ </Dialog>
108
+ </template>
109
+ <style lang="scss" scoped>
110
+ .enable-plugin-support {
111
+ font-size: 14px;
112
+ margin-top: 20px;
113
+ }
114
+
115
+ .plugin-setup-error {
116
+ font-size: 14px;
117
+ color: var(--error);
118
+ margin: 10px 0 0 0;
119
+ }
120
+
121
+ .checkbox-info {
122
+ margin-left: 20px;
123
+ opacity: 0.7;
124
+ }
125
+ </style>
@@ -0,0 +1,261 @@
1
+ <script>
2
+ import AsyncButton from '@shell/components/AsyncButton';
3
+ import IconMessage from '@shell/components/IconMessage.vue';
4
+ import { CATALOG, MANAGEMENT } from '@shell/config/types';
5
+ import { CATALOG as CATALOG_ANNOTATIONS } from '@shell/config/labels-annotations';
6
+ import Dialog from '@shell/components/Dialog.vue';
7
+ import Checkbox from '@components/Form/Checkbox/Checkbox.vue';
8
+ import { ASYNC_BUTTON_STATES } from '@shell/components/AsyncButton.vue';
9
+ import {
10
+ UI_PLUGIN_NAMESPACE,
11
+ UI_PLUGIN_CHARTS,
12
+ UI_PLUGIN_OPERATOR_REPO_NAME,
13
+ UI_PLUGINS_REPO_NAME,
14
+ UI_PLUGINS_REPO_URL,
15
+ UI_PLUGINS_REPO_BRANCH,
16
+ } from '@shell/config/uiplugins';
17
+
18
+ export default {
19
+ components: {
20
+ AsyncButton,
21
+ Checkbox,
22
+ IconMessage,
23
+ Dialog,
24
+ },
25
+
26
+ async fetch() {
27
+ // Check to see that the charts we need are available
28
+ const c = this.$store.getters['catalog/rawCharts'];
29
+ const charts = Object.values(c);
30
+ const found = [];
31
+
32
+ UI_PLUGIN_CHARTS.forEach((c) => {
33
+ const f = charts.find(chart => chart.repoName === UI_PLUGIN_OPERATOR_REPO_NAME & chart.chartName === c);
34
+
35
+ if (f) {
36
+ found.push(f);
37
+ }
38
+ });
39
+
40
+ this.haveCharts = (found.length === UI_PLUGIN_CHARTS.length);
41
+
42
+ if (this.haveCharts) {
43
+ this.installCharts = found;
44
+
45
+ if (this.$store.getters['management/schemaFor'](CATALOG.CLUSTER_REPO)) {
46
+ await this.$store.dispatch('management/findAll', { type: CATALOG.CLUSTER_REPO });
47
+ }
48
+ }
49
+
50
+ this.defaultRegistrySetting = await this.$store.dispatch('management/find', {
51
+ type: MANAGEMENT.SETTING,
52
+ id: 'system-default-registry'
53
+ });
54
+
55
+ this.loading = false;
56
+ },
57
+
58
+ data() {
59
+ return {
60
+ loading: true,
61
+ haveCharts: false,
62
+ installCharts: [],
63
+ errors: [],
64
+ addRepo: true,
65
+ buttonState: ASYNC_BUTTON_STATES.ACTION,
66
+ defaultRegistrySetting: null,
67
+ };
68
+ },
69
+
70
+ computed: {
71
+ hasRancherUIPluginsRepo() {
72
+ // Look to see if the Rancher UI Plugins repository is already installed
73
+ const repos = this.$store.getters['catalog/repos'];
74
+
75
+ return !!repos.find(r => r.name === UI_PLUGINS_REPO_NAME);
76
+ }
77
+ },
78
+
79
+ methods: {
80
+ async installChart(installChart) {
81
+ const version = installChart.versions[0];
82
+ const repoType = version.repoType;
83
+ const repoName = version.repoName;
84
+ const repo = this.$store.getters['catalog/repo']({ repoType, repoName });
85
+
86
+ const chart = {
87
+ chartName: installChart.chartName,
88
+ version: version.version,
89
+ releaseName: installChart.chartName,
90
+ annotations: {
91
+ [CATALOG_ANNOTATIONS.SOURCE_REPO_TYPE]: repoType,
92
+ [CATALOG_ANNOTATIONS.SOURCE_REPO_NAME]: repoName
93
+ },
94
+ values: {}
95
+ };
96
+
97
+ // Pass in the system default registry property if set
98
+ const defaultRegistry = this.defaultRegistrySetting?.value || '';
99
+
100
+ if (defaultRegistry) {
101
+ chart.values.global = chart.values.global || {};
102
+ chart.values.global.cattle = chart.values.global.cattle || {};
103
+ chart.values.global.cattle.systemDefaultRegistry = defaultRegistry;
104
+ }
105
+
106
+ const input = {
107
+ charts: [chart],
108
+ wait: true,
109
+ namespace: UI_PLUGIN_NAMESPACE,
110
+ };
111
+
112
+ const action = 'install';
113
+ const res = await repo.doAction(action, input);
114
+ const operationId = `${ res.operationNamespace }/${ res.operationName }`;
115
+
116
+ await repo.waitForOperation(operationId);
117
+
118
+ return this.$store.dispatch(`management/find`, {
119
+ type: CATALOG.OPERATION,
120
+ id: operationId
121
+ });
122
+ },
123
+
124
+ enable() {
125
+ this.errors = [];
126
+
127
+ // Reset checkbox bsed on if the repo is already installed
128
+ this.addRepo = !this.hasRancherUIPluginsRepo;
129
+
130
+ this.$modal.show('confirm-uiplugins-setup');
131
+ },
132
+
133
+ async dialogClosed(ok) {
134
+ this.errors = [];
135
+
136
+ // User wants to proceed
137
+ if (ok) {
138
+ this.buttonState = ASYNC_BUTTON_STATES.WAITING;
139
+
140
+ if (this.addRepo) {
141
+ await this.addDefaultHelmRepository();
142
+ }
143
+
144
+ await this.installPluginCharts();
145
+
146
+ await new Promise(resolve => setTimeout(resolve, 5000));
147
+
148
+ this.buttonState = this.errors.length > 0 ? ASYNC_BUTTON_STATES.ERROR : ASYNC_BUTTON_STATES.ACTION;
149
+
150
+ this.$emit('done');
151
+ }
152
+ },
153
+
154
+ async addDefaultHelmRepository() {
155
+ const name = UI_PLUGINS_REPO_NAME;
156
+
157
+ try {
158
+ const pluginCR = await this.$store.dispatch('management/create', {
159
+ type: CATALOG.CLUSTER_REPO,
160
+ metadata: { name },
161
+ spec: {
162
+ gitBranch: UI_PLUGINS_REPO_BRANCH,
163
+ gitRepo: UI_PLUGINS_REPO_URL,
164
+ }
165
+ });
166
+
167
+ return pluginCR.save();
168
+ } catch (e) {
169
+ console.error(e); // eslint-disable-line no-console
170
+
171
+ this.errors.push(e.message);
172
+ }
173
+ },
174
+
175
+ async installPluginCharts() {
176
+ for (let i = 0; i < this.installCharts.length; i++) {
177
+ const chart = this.installCharts[i];
178
+
179
+ try {
180
+ await this.installChart(chart);
181
+ } catch (e) {
182
+ this.errors.push(e.message);
183
+ }
184
+ }
185
+
186
+ return new Promise(resolve => setTimeout(resolve, 2000));
187
+ }
188
+ }
189
+ };
190
+ </script>
191
+ <template>
192
+ <div>
193
+ <IconMessage
194
+ :vertical="true"
195
+ :subtle="false"
196
+ icon="icon-gear"
197
+ >
198
+ <template v-slot:message>
199
+ <h2>
200
+ {{ t('plugins.setup.title') }}
201
+ </h2>
202
+ <div v-if="!loading">
203
+ <div v-if="!haveCharts">
204
+ <p>
205
+ {{ t('plugins.setup.prompt.cant') }}
206
+ </p>
207
+ </div>
208
+ <div v-else>
209
+ <p>
210
+ {{ t('plugins.setup.prompt.can') }}
211
+ </p>
212
+ <AsyncButton
213
+ mode="enable"
214
+ :manual="true"
215
+ :current-phase="buttonState"
216
+ class="enable-plugin-support"
217
+ @click="enable"
218
+ />
219
+ </div>
220
+ <div v-for="(e, i) in errors" :key="i" class="plugin-setup-error">
221
+ {{ e }}
222
+ </div>
223
+ </div>
224
+ </template>
225
+ </IconMessage>
226
+ <Dialog
227
+ name="confirm-uiplugins-setup"
228
+ :title="t('plugins.setup.install.title')"
229
+ @closed="dialogClosed"
230
+ >
231
+ <template>
232
+ <p>
233
+ {{ t('plugins.setup.install.prompt') }}
234
+ </p>
235
+ <div v-if="!hasRancherUIPluginsRepo" class="mt-20">
236
+ <Checkbox v-model="addRepo" :primary="true" label-key="plugins.setup.install.addRancherRepo" />
237
+ <div class="checkbox-info">
238
+ {{ t('plugins.setup.install.airgap') }}
239
+ </div>
240
+ </div>
241
+ </template>
242
+ </Dialog>
243
+ </div>
244
+ </template>
245
+ <style lang="scss" scoped>
246
+ .enable-plugin-support {
247
+ font-size: 14px;
248
+ margin-top: 20px;
249
+ }
250
+
251
+ .plugin-setup-error {
252
+ font-size: 14px;
253
+ color: var(--error);
254
+ margin: 10px 0 0 0;
255
+ }
256
+
257
+ .checkbox-info {
258
+ margin-left: 20px;
259
+ opacity: 0.7;
260
+ }
261
+ </style>