@rancher/shell 0.5.2 → 1.2.0

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 (338) hide show
  1. package/.DS_Store +0 -0
  2. package/assets/images/providers/aks-black.svg +28 -0
  3. package/assets/images/providers/aks.svg +31 -0
  4. package/assets/styles/global/_labeled-input.scss +1 -0
  5. package/assets/styles/global/_layout.scss +0 -99
  6. package/assets/translations/en-us.yaml +77 -71
  7. package/assets/translations/zh-hans.yaml +25 -23
  8. package/babel.config.js +1 -7
  9. package/chart/gatekeeper.vue +11 -2
  10. package/chart/istio.vue +10 -1
  11. package/chart/logging/index.vue +11 -2
  12. package/chart/monitoring/alerting/index.vue +21 -7
  13. package/chart/monitoring/grafana/index.vue +2 -57
  14. package/chart/monitoring/index.vue +26 -52
  15. package/chart/monitoring/prometheus/index.vue +43 -37
  16. package/chart/rancher-backup/index.vue +10 -3
  17. package/cloud-credential/azure.vue +17 -4
  18. package/components/AsyncButton.vue +0 -9
  19. package/components/Carousel.vue +0 -1
  20. package/components/ChartPsp.vue +76 -0
  21. package/components/CodeMirror.vue +21 -19
  22. package/components/CopyCode.vue +2 -6
  23. package/components/CopyToClipboard.vue +1 -2
  24. package/components/CopyToClipboardText.vue +9 -14
  25. package/components/CruResource.vue +0 -1
  26. package/components/EtcdInfoBanner.vue +5 -5
  27. package/components/ExplorerProjectsNamespaces.vue +1 -25
  28. package/components/IconOrSvg.vue +1 -1
  29. package/components/Markdown.vue +12 -16
  30. package/components/Questions/index.vue +1 -1
  31. package/components/ResourceDetail/Masthead.vue +9 -25
  32. package/components/ResourceList/Masthead.vue +18 -1
  33. package/components/ResourceTable.vue +2 -14
  34. package/components/ResourceYaml.vue +0 -5
  35. package/components/SideNav.vue +1 -1
  36. package/components/SortableTable/THead.vue +9 -7
  37. package/components/SortableTable/index.vue +3 -2
  38. package/components/StatusTable.vue +1 -5
  39. package/components/TabTitle.vue +84 -0
  40. package/components/Tabbed/index.vue +0 -12
  41. package/components/__tests__/ChartPsp.test.ts +75 -0
  42. package/components/__tests__/CopyCode.test.ts +4 -5
  43. package/components/fleet/FleetBundles.vue +11 -5
  44. package/components/fleet/FleetRepos.vue +27 -62
  45. package/components/fleet/FleetResources.vue +1 -6
  46. package/components/fleet/FleetStatus.vue +3 -3
  47. package/components/fleet/FleetSummary.vue +30 -35
  48. package/components/form/ArrayList.vue +8 -1
  49. package/components/form/ArrayListSelect.vue +9 -9
  50. package/components/form/KeyValue.vue +0 -1
  51. package/components/form/LabeledSelect.vue +0 -4
  52. package/components/form/Password.vue +1 -3
  53. package/components/form/Select.vue +1 -1
  54. package/components/form/SelectOrCreateAuthSecret.vue +4 -4
  55. package/components/form/__tests__/KeyValue.test.ts +1 -1
  56. package/components/formatter/Checked.vue +3 -11
  57. package/components/formatter/ClusterProvider.vue +18 -1
  58. package/components/formatter/FleetSummaryGraph.vue +11 -23
  59. package/components/formatter/LiveDate.vue +16 -0
  60. package/components/formatter/LiveDuration.vue +1 -1
  61. package/components/formatter/PercentageBar.vue +1 -1
  62. package/components/formatter/__tests__/ClusterProvider.test.ts +28 -0
  63. package/components/nav/Group.vue +2 -2
  64. package/components/nav/Header.vue +2 -1
  65. package/components/nav/TopLevelMenu.vue +3 -29
  66. package/components/nav/Type.vue +3 -1
  67. package/components/nav/WindowManager/ContainerLogs.vue +19 -120
  68. package/components/nav/WindowManager/ContainerShell.vue +1 -6
  69. package/components/nav/WindowManager/index.vue +10 -11
  70. package/components/nav/__tests__/TopLevelMenu.test.ts +0 -33
  71. package/components/nav/__tests__/Type.test.ts +1 -1
  72. package/components/nuxt/nuxt-child.js +78 -14
  73. package/components/nuxt/nuxt.js +1 -1
  74. package/components/user.retention/user-retention-header.vue +34 -0
  75. package/composables/useI18n.ts +26 -0
  76. package/composables/useStore.ts +16 -0
  77. package/config/harvester-manager-types.js +0 -2
  78. package/config/home-links.js +32 -2
  79. package/config/private-label.js +0 -22
  80. package/config/product/explorer.js +4 -4
  81. package/config/product/fleet.js +1 -6
  82. package/config/product/legacy.js +1 -84
  83. package/config/product/manager.js +15 -8
  84. package/config/query-params.js +0 -1
  85. package/config/router.js +368 -385
  86. package/config/settings.ts +9 -2
  87. package/config/store.js +1 -1
  88. package/config/system-namespaces.js +0 -3
  89. package/config/table-headers.js +27 -47
  90. package/config/types.js +5 -0
  91. package/config/uiplugins.js +1 -1
  92. package/core/plugin-helpers.js +5 -3
  93. package/core/plugin-routes.ts +114 -56
  94. package/core/plugin.ts +10 -16
  95. package/core/plugins-loader.js +9 -7
  96. package/core/plugins.js +3 -0
  97. package/core/types-provisioning.ts +0 -7
  98. package/creators/app/init +0 -19
  99. package/detail/fleet.cattle.io.cluster.vue +1 -11
  100. package/detail/node.vue +0 -42
  101. package/detail/pod.vue +1 -68
  102. package/detail/provisioning.cattle.io.cluster.vue +4 -6
  103. package/detail/workload/index.vue +1 -15
  104. package/dialog/ScaleMachineDownDialog.vue +17 -34
  105. package/edit/auth/googleoauth.vue +5 -1
  106. package/edit/catalog.cattle.io.clusterrepo.vue +7 -20
  107. package/edit/cloudcredential.vue +0 -2
  108. package/edit/fleet.cattle.io.gitrepo.vue +4 -3
  109. package/edit/management.cattle.io.project.vue +52 -1
  110. package/edit/management.cattle.io.setting.vue +2 -31
  111. package/edit/monitoring.coreos.com.prometheusrule/AlertingRule.vue +3 -12
  112. package/edit/monitoring.coreos.com.prometheusrule/GroupRules.vue +1 -2
  113. package/edit/networking.k8s.io.networkpolicy/__tests__/PolicyRuleTarget.spec.ts +1 -1
  114. package/edit/provisioning.cattle.io.cluster/{tabs/Basics.vue → Basics.vue} +126 -109
  115. package/edit/provisioning.cattle.io.cluster/{tabs/MachinePool.vue → MachinePool.vue} +7 -1
  116. package/edit/provisioning.cattle.io.cluster/{tabs/registries/RegistryConfigs.vue → RegistryConfigs.vue} +3 -1
  117. package/edit/provisioning.cattle.io.cluster/SelectCredential.vue +7 -15
  118. package/edit/provisioning.cattle.io.cluster/__tests__/Basics.tests.ts +237 -0
  119. package/edit/provisioning.cattle.io.cluster/__tests__/{CustomCommand.test.ts → CustomCommand.tests.ts} +0 -6
  120. package/edit/provisioning.cattle.io.cluster/__tests__/DrainOptions.test.ts +1 -1
  121. package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +1 -7
  122. package/edit/provisioning.cattle.io.cluster/import.vue +2 -2
  123. package/edit/provisioning.cattle.io.cluster/index.vue +37 -99
  124. package/edit/provisioning.cattle.io.cluster/rke2.vue +690 -181
  125. package/edit/service.vue +0 -12
  126. package/edit/workload/Upgrading.vue +2 -3
  127. package/edit/workload/index.vue +1 -2
  128. package/edit/workload/mixins/workload.js +1 -1
  129. package/initialize/App.js +71 -25
  130. package/initialize/client.js +162 -21
  131. package/initialize/index.js +124 -47
  132. package/initialize/layouts.ts +26 -0
  133. package/{components/templates → layouts}/blank.vue +1 -1
  134. package/{components/templates → layouts}/default.vue +98 -8
  135. package/{components/templates → layouts}/error.vue +19 -10
  136. package/{components/templates → layouts}/home.vue +1 -4
  137. package/{components/templates → layouts}/plain.vue +1 -4
  138. package/{components/templates → layouts}/standalone.vue +1 -1
  139. package/{components/templates → layouts}/unauthenticated.vue +1 -1
  140. package/list/management.cattle.io.feature.vue +7 -1
  141. package/list/management.cattle.io.user.vue +25 -1
  142. package/list/node.vue +0 -1
  143. package/machine-config/__tests__/vmwarevsphere.test.ts +161 -56
  144. package/machine-config/amazonec2.vue +1 -0
  145. package/machine-config/azure.vue +37 -21
  146. package/machine-config/vmwarevsphere.vue +47 -42
  147. package/middleware/authenticated.js +19 -14
  148. package/mixins/auth-config.js +7 -2
  149. package/mixins/brand.js +41 -29
  150. package/mixins/fetch.server.js +73 -0
  151. package/mixins/labeled-form-element.ts +1 -6
  152. package/models/__tests__/management.cattle.io.node.ts +0 -85
  153. package/models/__tests__/namespace.test.ts +9 -49
  154. package/models/cluster/node.js +4 -4
  155. package/models/cluster.x-k8s.io.machine.js +1 -1
  156. package/models/cluster.x-k8s.io.machinedeployment.js +0 -14
  157. package/models/fleet.cattle.io.cluster.js +0 -4
  158. package/models/fleet.cattle.io.gitrepo.js +13 -56
  159. package/models/management.cattle.io.cluster.js +3 -11
  160. package/models/management.cattle.io.kontainerdriver.js +0 -1
  161. package/models/management.cattle.io.node.js +14 -18
  162. package/models/management.cattle.io.nodepool.js +0 -17
  163. package/models/management.cattle.io.project.js +36 -0
  164. package/models/management.cattle.io.setting.js +7 -11
  165. package/models/management.cattle.io.user.js +65 -0
  166. package/models/namespace.js +1 -1
  167. package/models/pod.js +0 -20
  168. package/models/provisioning.cattle.io.cluster.js +8 -55
  169. package/models/secret.js +18 -117
  170. package/models/workload.js +0 -16
  171. package/models/workload.service.js +0 -18
  172. package/package.json +10 -12
  173. package/pages/about.vue +1 -0
  174. package/pages/account/create-key.vue +1 -0
  175. package/pages/account/index.vue +1 -0
  176. package/pages/auth/login.vue +1 -0
  177. package/pages/auth/logout.vue +2 -0
  178. package/pages/auth/setup.vue +4 -37
  179. package/pages/auth/verify.vue +8 -14
  180. package/pages/c/_cluster/apps/charts/__tests__/install.helper.test.ts +17 -2
  181. package/pages/c/_cluster/apps/charts/index.vue +58 -64
  182. package/pages/c/_cluster/apps/charts/install.helpers.js +13 -2
  183. package/pages/c/_cluster/apps/charts/install.vue +5 -5
  184. package/pages/c/_cluster/apps/index.vue +2 -0
  185. package/pages/c/_cluster/auth/index.vue +2 -0
  186. package/pages/c/_cluster/auth/user.retention/index.vue +384 -0
  187. package/pages/c/_cluster/ecm/index.vue +2 -0
  188. package/pages/c/_cluster/explorer/index.vue +53 -56
  189. package/pages/c/_cluster/explorer/tools/index.vue +3 -171
  190. package/pages/c/_cluster/fleet/index.vue +1 -1
  191. package/pages/c/_cluster/index.vue +2 -0
  192. package/pages/c/_cluster/manager/pages/_page.vue +5 -4
  193. package/pages/c/_cluster/monitoring/index.vue +1 -17
  194. package/pages/c/_cluster/settings/DefaultLinksEditor.vue +1 -0
  195. package/pages/c/_cluster/settings/banners.vue +2 -0
  196. package/pages/c/_cluster/settings/brand.vue +2 -0
  197. package/pages/c/_cluster/settings/index.vue +2 -0
  198. package/pages/c/_cluster/settings/links.vue +3 -2
  199. package/pages/c/_cluster/settings/performance.vue +1 -0
  200. package/pages/c/_cluster/uiplugins/AddExtensionRepos.vue +4 -4
  201. package/pages/c/_cluster/uiplugins/CatalogList/CatalogLoadDialog.vue +1 -2
  202. package/pages/c/_cluster/uiplugins/CatalogList/index.vue +46 -10
  203. package/pages/c/_cluster/uiplugins/SetupUIPlugins.vue +5 -2
  204. package/pages/c/_cluster/uiplugins/__tests__/AddExtensionRepos.test.ts +96 -0
  205. package/pages/c/_cluster/uiplugins/__tests__/SetupUIPlugins.test.ts +128 -0
  206. package/pages/c/_cluster/uiplugins/index.vue +2 -0
  207. package/pages/c/index.vue +9 -0
  208. package/pages/diagnostic.vue +2 -1
  209. package/pages/fail-whale.vue +1 -0
  210. package/pages/prefs.vue +1 -0
  211. package/pages/rio/mesh.vue +508 -0
  212. package/pages/support/index.vue +8 -2
  213. package/pkg/auto-import.js +1 -1
  214. package/plugins/axios.js +36 -0
  215. package/plugins/back-button.js +5 -3
  216. package/plugins/clean-html-directive.js +19 -1
  217. package/plugins/clean-tooltip-directive.js +1 -1
  218. package/plugins/codemirror-loader.js +1 -1
  219. package/plugins/codemirror.js +0 -41
  220. package/plugins/dashboard-store/__tests__/actions.spec.ts +250 -0
  221. package/plugins/dashboard-store/__tests__/{mutations.test.ts → mutations.spec.ts} +1 -1
  222. package/plugins/dashboard-store/actions.js +21 -22
  223. package/plugins/dashboard-store/classify.js +18 -1
  224. package/plugins/dashboard-store/getters.js +5 -10
  225. package/plugins/dashboard-store/index.js +12 -0
  226. package/plugins/dashboard-store/mutations.js +4 -0
  227. package/plugins/dashboard-store/resource-class.js +18 -59
  228. package/plugins/i18n.js +1 -1
  229. package/plugins/steve/__tests__/getters.spec.ts +56 -24
  230. package/plugins/steve/__tests__/subscribe.spec.ts +106 -0
  231. package/plugins/steve/getters.js +30 -7
  232. package/plugins/steve/mutations.js +5 -2
  233. package/plugins/steve/norman-class.js +0 -19
  234. package/plugins/steve/steve-class.js +0 -22
  235. package/plugins/steve/subscribe.js +34 -13
  236. package/plugins/transitions.js +4 -0
  237. package/plugins/vue-clipboard2.js +4 -0
  238. package/rancher-components/Accordion/Accordion.vue +3 -2
  239. package/rancher-components/BadgeState/BadgeState.vue +3 -3
  240. package/rancher-components/Banner/Banner.test.ts +1 -5
  241. package/rancher-components/Banner/Banner.vue +2 -2
  242. package/rancher-components/Card/Card.vue +4 -4
  243. package/rancher-components/Form/Checkbox/Checkbox.vue +4 -3
  244. package/rancher-components/Form/LabeledInput/LabeledInput.test.ts +1 -1
  245. package/rancher-components/Form/LabeledInput/LabeledInput.vue +55 -24
  246. package/rancher-components/Form/Radio/RadioButton.test.ts +1 -3
  247. package/rancher-components/Form/Radio/RadioButton.vue +13 -7
  248. package/rancher-components/Form/Radio/RadioGroup.vue +4 -3
  249. package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +7 -5
  250. package/rancher-components/Form/ToggleSwitch/ToggleSwitch.vue +7 -4
  251. package/rancher-components/LabeledTooltip/LabeledTooltip.vue +9 -4
  252. package/rancher-components/StringList/StringList.vue +8 -8
  253. package/rancher-components/components/Accordion/Accordion.vue +3 -2
  254. package/rancher-components/components/BadgeState/BadgeState.test.ts +12 -0
  255. package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +2 -19
  256. package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +14 -11
  257. package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +1 -1
  258. package/rancher-components/components/StringList/StringList.test.ts +0 -270
  259. package/rancher-components/components/StringList/StringList.vue +18 -57
  260. package/scripts/extension/bundle +7 -19
  261. package/scripts/extension/helm/scripts/package +3 -11
  262. package/scripts/extension/parse-tag-name +4 -4
  263. package/scripts/extension/publish +9 -20
  264. package/scripts/publish-shell.sh +1 -11
  265. package/scripts/test-plugins-build.sh +9 -85
  266. package/store/catalog.js +1 -1
  267. package/store/features.js +0 -1
  268. package/store/i18n.js +0 -11
  269. package/store/index.js +11 -8
  270. package/store/prefs.js +38 -33
  271. package/store/type-map.js +8 -13
  272. package/tsconfig.default.json +46 -0
  273. package/tsconfig.json +9 -35
  274. package/types/shell/index.d.ts +404 -463
  275. package/utils/__tests__/create-yaml.test.ts +10 -0
  276. package/utils/axios.js +19 -0
  277. package/utils/create-yaml.js +6 -6
  278. package/utils/custom-validators.js +2 -0
  279. package/utils/error.js +1 -16
  280. package/utils/monitoring.js +2 -37
  281. package/utils/nuxt.js +39 -18
  282. package/utils/object.js +0 -14
  283. package/utils/router.scrollBehavior.js +14 -12
  284. package/utils/socket.js +1 -0
  285. package/utils/time.js +1 -1
  286. package/utils/title.ts +3 -0
  287. package/utils/url.ts +1 -1
  288. package/utils/validators/formRules/__tests__/index.test.ts +4 -49
  289. package/utils/validators/formRules/index.ts +9 -12
  290. package/utils/validators/setting.js +10 -6
  291. package/vue.config.js +3 -24
  292. package/chart/monitoring/steps/uninstall-v1.vue +0 -135
  293. package/components/Certificates.vue +0 -164
  294. package/components/fleet/__tests__/FleetSummary.test.ts +0 -316
  295. package/components/formatter/FleetClusterSummaryGraph.vue +0 -27
  296. package/components/formatter/__tests__/Checked.test.ts +0 -19
  297. package/components/nav/WindowManager/__tests__/ContainerLogs.test.ts +0 -186
  298. package/composables/useCompactInput.ts +0 -20
  299. package/composables/useLabeledFormElement.ts +0 -138
  300. package/creators/app/files/.gitlab-ci.yml +0 -14
  301. package/edit/__tests__/service.test.ts +0 -89
  302. package/edit/provisioning.cattle.io.cluster/__tests__/Advanced.test.ts +0 -112
  303. package/edit/provisioning.cattle.io.cluster/__tests__/Basics.test.ts +0 -473
  304. package/edit/provisioning.cattle.io.cluster/__tests__/index.test.ts +0 -73
  305. package/edit/provisioning.cattle.io.cluster/__tests__/utils/cluster.ts +0 -386
  306. package/edit/provisioning.cattle.io.cluster/tabs/AddOnConfig.vue +0 -137
  307. package/edit/provisioning.cattle.io.cluster/tabs/Advanced.vue +0 -157
  308. package/edit/provisioning.cattle.io.cluster/tabs/etcd/index.vue +0 -135
  309. package/edit/provisioning.cattle.io.cluster/tabs/networking/index.vue +0 -189
  310. package/edit/provisioning.cattle.io.cluster/tabs/registries/index.vue +0 -144
  311. package/edit/provisioning.cattle.io.cluster/tabs/upgrade/index.vue +0 -76
  312. package/mixins/v1-workload-metrics.js +0 -43
  313. package/models/__tests__/management.cattle.io.cluster.test.ts +0 -23
  314. package/models/__tests__/management.cattle.io.nodepool.ts +0 -83
  315. package/models/__tests__/provisioning.cattle.io.cluster.test.ts +0 -90
  316. package/models/__tests__/workload.test.ts +0 -91
  317. package/plugins/clean-html.js +0 -53
  318. package/plugins/dashboard-store/__tests__/actions.test.ts +0 -165
  319. package/plugins/dashboard-store/__tests__/resource-class.test.ts +0 -49
  320. package/plugins/dashboard-store/__tests__/utils/store-mocks.ts +0 -7
  321. package/plugins/index.js +0 -11
  322. package/plugins/steve/__tests__/steve-class.spec.ts +0 -59
  323. package/plugins/steve/__tests__/utils/steve-mocks.ts +0 -31
  324. package/scripts/.gitlab/workflows/build-extension-catalog.gitlab-ci.yml +0 -50
  325. package/server/har-file.js +0 -183
  326. package/tsconfig.paths.json +0 -18
  327. package/utils/azure.js +0 -24
  328. package/utils/clipboard.js +0 -5
  329. /package/components/form/__tests__/{NameNsDescription.test.ts → NameNsDescription.ts} +0 -0
  330. /package/edit/networking.k8s.io.networkpolicy/__tests__/utils/{selectors.test.ts → selectors.ts} +0 -0
  331. /package/edit/provisioning.cattle.io.cluster/{tabs/networking/ACE.vue → ACE.vue} +0 -0
  332. /package/edit/provisioning.cattle.io.cluster/{tabs/AgentConfiguration.vue → AgentConfiguration.vue} +0 -0
  333. /package/edit/provisioning.cattle.io.cluster/{tabs/upgrade/DrainOptions.vue → DrainOptions.vue} +0 -0
  334. /package/edit/provisioning.cattle.io.cluster/{tabs/MemberRoles.vue → MemberRoles.vue} +0 -0
  335. /package/edit/provisioning.cattle.io.cluster/{tabs/registries/RegistryMirrors.vue → RegistryMirrors.vue} +0 -0
  336. /package/edit/provisioning.cattle.io.cluster/{tabs/etcd/S3Config.vue → S3Config.vue} +0 -0
  337. /package/plugins/dashboard-store/__tests__/{getters.test.ts → getters.spec.ts} +0 -0
  338. /package/rancher-components/BadgeState/{BadgeState.spec.ts → BadgeState.test.ts} +0 -0
@@ -2,6 +2,7 @@ import {
2
2
  getBlockDescriptor,
3
3
  dumpBlock,
4
4
  } from '@shell/utils/create-yaml';
5
+ import jsyaml from 'js-yaml';
5
6
 
6
7
  const key = 'example';
7
8
  const randomData = '\n foo\n bar\n';
@@ -61,6 +62,15 @@ describe('fx: dumpBlock', () => {
61
62
  });
62
63
  });
63
64
 
65
+ it('should not create a data block when the value of a key is not a string', () => {
66
+ const data = { key: { test: 'test' } };
67
+
68
+ const expectedResult = jsyaml.dump(data);
69
+ const result = dumpBlock(data);
70
+
71
+ expect(result).toStrictEqual(expectedResult);
72
+ });
73
+
64
74
  it('should retain line breaks when a line longer than 80 characters exists', () => {
65
75
  const data = {
66
76
  'managerApiConfiguration.properties': `# Sample XPlanManagerAPI Configuration (if this comment is longer than 80 characters, the output should remain the same)
package/utils/axios.js CHANGED
@@ -75,6 +75,10 @@ const createAxiosInstance = (axiosOptions) => {
75
75
  };
76
76
 
77
77
  const setupProgress = (axios) => {
78
+ if (process.server) {
79
+ return;
80
+ }
81
+
78
82
  // A noop loading inteterface for when $nuxt is not yet ready
79
83
  const noopLoading = {
80
84
  finish: () => { },
@@ -163,6 +167,21 @@ export default (ctx, inject) => {
163
167
  headers
164
168
  };
165
169
 
170
+ // Proxy SSR request headers headers
171
+ if (process.server && ctx.req && ctx.req.headers) {
172
+ const reqHeaders = { ...ctx.req.headers };
173
+
174
+ for (const h of ['accept', 'host', 'cf-ray', 'cf-connecting-ip', 'content-length', 'content-md5', 'content-type']) {
175
+ delete reqHeaders[h];
176
+ }
177
+ axiosOptions.headers.common = { ...reqHeaders, ...axiosOptions.headers.common };
178
+ }
179
+
180
+ if (process.server) {
181
+ // Don't accept brotli encoding because Node can't parse it
182
+ axiosOptions.headers.common['accept-encoding'] = 'gzip, deflate';
183
+ }
184
+
166
185
  const axios = createAxiosInstance(axiosOptions);
167
186
 
168
187
  // Inject axios to the context as $axios
@@ -32,6 +32,7 @@ const ALWAYS_ADD = [
32
32
  ];
33
33
 
34
34
  export const NEVER_ADD = [
35
+ 'metadata.clusterName',
35
36
  'metadata.clusterName',
36
37
  'metadata.creationTimestamp',
37
38
  'metadata.deletionGracePeriodSeconds',
@@ -45,16 +46,11 @@ export const NEVER_ADD = [
45
46
  'metadata.resourceVersion',
46
47
  'metadata.relationships',
47
48
  'metadata.selfLink',
48
- 'metadata.state',
49
49
  'metadata.uid',
50
50
  // CRD -> Schema describes the schema used for validation, pruning, and defaulting of this version of the custom resource. If we allow processing we fall into inf loop on openAPIV3Schema.allOf which contains a cyclical ref of allOf props.
51
51
  'spec.versions.schema',
52
52
  'status',
53
53
  'stringData',
54
- 'links',
55
- '_name',
56
- '_labels',
57
- '_annotations',
58
54
  ];
59
55
 
60
56
  export const ACTIVELY_REMOVE = [
@@ -465,7 +461,11 @@ export function dumpBlock(data, options = {}) {
465
461
 
466
462
  let out = parsed;
467
463
 
468
- const blockFields = Object.keys(data).filter((k) => data[k].includes('\n'));
464
+ const blockFields = Object.keys(data).filter((k) => {
465
+ if (typeof data[k] === 'string') {
466
+ return data[k].includes('\n');
467
+ }
468
+ });
469
469
 
470
470
  if (blockFields.length) {
471
471
  for (const key of blockFields) {
@@ -8,6 +8,7 @@ import { cronSchedule } from '@shell/utils/validators/cron-schedule';
8
8
  import { podAffinity } from '@shell/utils/validators/pod-affinity';
9
9
  import { roleTemplateRules } from '@shell/utils/validators/role-template';
10
10
  import { clusterName } from '@shell/utils/validators/cluster-name';
11
+ import { isHttps } from '@shell/utils/validators/setting';
11
12
 
12
13
  /**
13
14
  * Custom validation functions beyond normal scalr types
@@ -29,4 +30,5 @@ export default {
29
30
  cronSchedule,
30
31
  podAffinity,
31
32
  roleTemplateRules,
33
+ isHttps,
32
34
  };
package/utils/error.js CHANGED
@@ -1,24 +1,9 @@
1
1
  import { isArray } from '@shell/utils/array';
2
2
 
3
3
  export class ClusterNotFoundError extends Error {
4
- static name = 'ClusterNotFoundError'
5
-
6
4
  constructor(message) {
7
5
  super(message);
8
- this.name = ClusterNotFoundError.name;
9
- }
10
- }
11
-
12
- /**
13
- * An error occurred and the user should be redirected to a certain location (where this is handled)
14
- */
15
- export class RedirectToError extends Error {
16
- static name = 'RedirectToError'
17
-
18
- constructor(message, url) {
19
- super(message);
20
- this.url = url;
21
- this.name = RedirectToError.name;
6
+ this.name = 'ClusterNotFoundError';
22
7
  }
23
8
  }
24
9
 
@@ -1,6 +1,6 @@
1
1
  // Helpers for determining if V2 or v1 Monitoring are installed
2
2
 
3
- import { SCHEMA, MONITORING, WORKLOAD_TYPES, ENDPOINTS } from '@shell/config/types';
3
+ import { SCHEMA, MONITORING, ENDPOINTS } from '@shell/config/types';
4
4
  import { normalizeType } from '@shell/plugins/dashboard-store/normalize';
5
5
  import { findBy } from '@shell/utils/array';
6
6
  import { isEmpty } from '@shell/utils/object';
@@ -9,10 +9,7 @@ import { isEmpty } from '@shell/utils/object';
9
9
  export function monitoringStatus() {
10
10
  return {
11
11
  monitoringStatus() {
12
- const status = {
13
- v1: haveV1Monitoring(this.$store.getters),
14
- v2: haveV2Monitoring(this.$store.getters),
15
- };
12
+ const status = { v2: haveV2Monitoring(this.$store.getters) };
16
13
 
17
14
  status.installed = status.v1 || status.v2;
18
15
 
@@ -22,10 +19,6 @@ export function monitoringStatus() {
22
19
  }
23
20
 
24
21
  export function haveV2Monitoring(getters) {
25
- // Can't have V2 and V1 monitoring installed, so if V1 is installed we know v2 is not
26
- if (haveV1Monitoring(getters)) {
27
- return false;
28
- }
29
22
  const inStore = getters['getStoreNameByProductId'];
30
23
 
31
24
  // Just check for the pod monitors CRD
@@ -35,36 +28,8 @@ export function haveV2Monitoring(getters) {
35
28
  return !!exists;
36
29
  }
37
30
 
38
- // For v1 Monitoring, the cluster object indicates presence via status.monitoringStatus
39
- export function haveV1Monitoring(getters) {
40
- const cluster = getters['currentCluster'];
41
-
42
- return !!cluster?.status?.monitoringStatus;
43
- }
44
-
45
31
  export const CATTLE_MONITORING_NAMESPACE = 'cattle-monitoring-system';
46
32
 
47
- export async function haveV1MonitoringWorkloads(store) {
48
- const workloadsByType = await Promise.all(
49
- Object.values(WORKLOAD_TYPES).map((type) => store.dispatch('cluster/findAll', { type })
50
- )
51
- );
52
- const workloads = workloadsByType.flat();
53
-
54
- for (let i = 0; i < workloads.length; i++) {
55
- const workload = workloads[i];
56
-
57
- if (!isEmpty(workload?.spec?.template?.spec?.containers) &&
58
- workload.spec.template.spec.containers.find((c) => c.image?.includes('quay.io/coreos/prometheus-operator') ||
59
- c.image?.includes('rancher/coreos-prometheus-operator')) &&
60
- workload?.metadata?.namespace !== CATTLE_MONITORING_NAMESPACE) {
61
- return Promise.resolve(true);
62
- }
63
-
64
- return Promise.resolve(false);
65
- }
66
- }
67
-
68
33
  async function hasEndpointSubsets(store, id) {
69
34
  if (store.getters['cluster/schemaFor'](ENDPOINTS)) {
70
35
  const endpoints = await store.dispatch('cluster/findAll', { type: ENDPOINTS }) || [];
package/utils/nuxt.js CHANGED
@@ -5,10 +5,12 @@ import {
5
5
 
6
6
  // window.{{globals.loadedCallback}} hook
7
7
  // Useful for jsdom testing or plugins (https://github.com/tmpvar/jsdom#dealing-with-asynchronous-script-loading)
8
- window.onNuxtReadyCbs = [];
9
- window.onNuxtReady = (cb) => {
10
- window.onNuxtReadyCbs.push(cb);
11
- };
8
+ if (process.client) {
9
+ window.onNuxtReadyCbs = [];
10
+ window.onNuxtReady = (cb) => {
11
+ window.onNuxtReadyCbs.push(cb);
12
+ };
13
+ }
12
14
 
13
15
  export function createGetCounter(counterObject, defaultKey = '') {
14
16
  return function getCounter(id = defaultKey) {
@@ -90,6 +92,10 @@ export function applyAsyncData(Component, asyncData) {
90
92
  Component.options.data = function() {
91
93
  const data = ComponentData.call(this, this);
92
94
 
95
+ if (this.$ssrContext) {
96
+ asyncData = this.$ssrContext.asyncData[Component.cid];
97
+ }
98
+
93
99
  return { ...data, ...asyncData };
94
100
  };
95
101
 
@@ -204,14 +210,15 @@ export async function setContext(app, context) {
204
210
  // If context not defined, create it
205
211
  if (!app.context) {
206
212
  app.context = {
207
- isDev: true,
208
- isHMR: false,
213
+ isStatic: process.static,
214
+ isDev: true,
215
+ isHMR: false,
209
216
  app,
210
- store: app.store,
211
- payload: context.payload,
212
- error: context.error,
213
- base: app.router.options.base,
214
- env: {
217
+ store: app.store,
218
+ payload: context.payload,
219
+ error: context.error,
220
+ base: app.router.options.base,
221
+ env: {
215
222
  commit: 'head', version: '0.1.2', dev: true, pl: 1, perfTest: false, rancherEnv: 'web', api: 'http://localhost:8989'
216
223
  }
217
224
  };
@@ -224,6 +231,9 @@ export async function setContext(app, context) {
224
231
  app.context.res = context.res;
225
232
  }
226
233
 
234
+ if (context.ssrContext) {
235
+ app.context.ssrContext = context.ssrContext;
236
+ }
227
237
  app.context.redirect = (status, path, query) => {
228
238
  if (!status) {
229
239
  return;
@@ -250,16 +260,27 @@ export async function setContext(app, context) {
250
260
  });
251
261
  } else {
252
262
  path = withQuery(path, query);
263
+ if (process.server) {
264
+ app.context.next({
265
+ path,
266
+ status
267
+ });
268
+ }
269
+ if (process.client) {
270
+ // https://developer.mozilla.org/en-US/docs/Web/API/Location/replace
271
+ window.location.replace(path);
253
272
 
254
- // https://developer.mozilla.org/en-US/docs/Web/API/Location/replace
255
- window.location.replace(path);
256
-
257
- // Throw a redirect error
258
- throw new Error('ERR_REDIRECT');
273
+ // Throw a redirect error
274
+ throw new Error('ERR_REDIRECT');
275
+ }
259
276
  }
260
277
  };
261
-
262
- app.context.nuxtState = window.__NUXT__;
278
+ if (process.server) {
279
+ app.context.beforeNuxtRender = (fn) => context.beforeRenderFns.push(fn);
280
+ }
281
+ if (process.client) {
282
+ app.context.nuxtState = window.__NUXT__;
283
+ }
263
284
  }
264
285
 
265
286
  // Dynamic keys
package/utils/object.js CHANGED
@@ -110,20 +110,6 @@ export function remove(obj, path) {
110
110
  return obj;
111
111
  }
112
112
 
113
- /**
114
- * `delete` a property at the given path.
115
- *
116
- * This is similar to `remove` but doesn't need any fancy kube obj path splitting
117
- * and doesn't use `Vue.set` (avoids reactivity)
118
- */
119
- export function deleteProperty(obj, path) {
120
- const pathAr = path.split('.');
121
- const propToDelete = pathAr.pop();
122
-
123
- // Walk down path until final prop, then delete final prop
124
- delete pathAr.reduce((o, k) => o[k] || {}, obj)[propToDelete];
125
- }
126
-
127
113
  export function getter(path) {
128
114
  return function(obj) {
129
115
  return get(obj, path);
@@ -1,19 +1,21 @@
1
1
  import { getMatchedComponents, setScrollRestoration } from './nuxt';
2
2
 
3
- if ('scrollRestoration' in window.history) {
4
- setScrollRestoration('manual');
3
+ if (process.client) {
4
+ if ('scrollRestoration' in window.history) {
5
+ setScrollRestoration('manual');
5
6
 
6
- // reset scrollRestoration to auto when leaving page, allowing page reload
7
- // and back-navigation from other pages to use the browser to restore the
8
- // scrolling position.
9
- window.addEventListener('beforeunload', () => {
10
- setScrollRestoration('auto');
11
- });
7
+ // reset scrollRestoration to auto when leaving page, allowing page reload
8
+ // and back-navigation from other pages to use the browser to restore the
9
+ // scrolling position.
10
+ window.addEventListener('beforeunload', () => {
11
+ setScrollRestoration('auto');
12
+ });
12
13
 
13
- // Setting scrollRestoration to manual again when returning to this page.
14
- window.addEventListener('load', () => {
15
- setScrollRestoration('manual');
16
- });
14
+ // Setting scrollRestoration to manual again when returning to this page.
15
+ window.addEventListener('load', () => {
16
+ setScrollRestoration('manual');
17
+ });
18
+ }
17
19
  }
18
20
 
19
21
  function shouldScrollToTop(route) {
package/utils/socket.js CHANGED
@@ -27,6 +27,7 @@ export const EVENT_DISCONNECT_ERROR = 'disconnect_error';
27
27
 
28
28
  export const NO_WATCH = 'NO_WATCH';
29
29
  export const NO_SCHEMA = 'NO_SCHEMA';
30
+ export const NO_PERMS = 'NO_PERMS';
30
31
  export const REVISION_TOO_OLD = 'TOO_OLD';
31
32
 
32
33
  export default class Socket extends EventTarget {
package/utils/time.js CHANGED
@@ -10,7 +10,7 @@ export function diffFrom(value, from, t) {
10
10
  const now = day();
11
11
 
12
12
  from = from || now;
13
- const diff = value.diff(from, 'seconds');
13
+ const diff = value.diff(now, 'seconds');
14
14
 
15
15
  let absDiff = Math.abs(diff);
16
16
 
package/utils/title.ts ADDED
@@ -0,0 +1,3 @@
1
+ export function updatePageTitle(...breadcrumb: (string | null | undefined | false)[]): void {
2
+ document.title = breadcrumb.filter((s) => s).join(' - ');
3
+ }
package/utils/url.ts CHANGED
@@ -2,7 +2,7 @@ type UriField = 'source' | 'protocol' | 'authority' | 'userInfo' | 'user' | 'pas
2
2
  type UriFields = {
3
3
  [key in UriField]: string; // eslint-disable-line no-unused-vars
4
4
  }
5
- export type QueryParams = {
5
+ type QueryParams = {
6
6
  [key: string]: string
7
7
  }
8
8
 
@@ -43,66 +43,21 @@ describe('formRules', () => {
43
43
  expect(formRuleResult).toStrictEqual(expectedResult);
44
44
  });
45
45
 
46
- it('"https" : returns undefined when valid https url value is supplied', () => {
46
+ it('"isHttps" : returns undefined when valid https url value is supplied', () => {
47
47
  const testValue = 'https://url.com';
48
- const formRuleResult = formRules.https(testValue);
48
+ const formRuleResult = formRules.isHttps('server-url')(testValue);
49
49
 
50
50
  expect(formRuleResult).toBeUndefined();
51
51
  });
52
52
 
53
- it('"https" : returns correct message when http url value is supplied', () => {
53
+ it('"isHttps" : returns correct message when http url value is supplied', () => {
54
54
  const testValue = 'http://url.com';
55
- const formRuleResult = formRules.https(testValue);
55
+ const formRuleResult = formRules.isHttps('server-url')(testValue);
56
56
  const expectedResult = JSON.stringify({ message: 'validation.setting.serverUrl.https' });
57
57
 
58
58
  expect(formRuleResult).toStrictEqual(expectedResult);
59
59
  });
60
60
 
61
- describe('localhost', () => {
62
- const message = JSON.stringify({ message: 'validation.setting.serverUrl.localhost' });
63
- const testCases = [
64
- ['http://LOCALhosT:8005', message],
65
- ['http://localhost:8005', message],
66
- ['https://localhost:8005', message],
67
- ['localhost', message],
68
- ['http://127.0.0.1', message],
69
- ['https://127.0.0.1', message],
70
- ['127.0.0.1', message],
71
- ['https://test.com', undefined],
72
- ['https://test.com/localhost', undefined],
73
- [undefined, undefined]
74
- ];
75
-
76
- it.each(testCases)(
77
- 'should return undefined or correct message based on the provided url',
78
- (url, expected) => {
79
- const formRuleResult = formRules.localhost(url);
80
-
81
- expect(formRuleResult).toStrictEqual(expected);
82
- }
83
- );
84
- });
85
-
86
- describe('trailingForwardSlash', () => {
87
- const message = JSON.stringify({ message: 'validation.setting.serverUrl.trailingForwardSlash' });
88
- const testCases = [
89
- ['https://test.com', undefined],
90
- ['https://test.com/', message],
91
- ['https://', undefined],
92
- ['/', undefined],
93
- [undefined, undefined]
94
- ];
95
-
96
- it.each(testCases)(
97
- 'should return undefined or correct message based on the provided url',
98
- (url, expected) => {
99
- const formRuleResult = formRules.trailingForwardSlash(url);
100
-
101
- expect(formRuleResult).toStrictEqual(expected);
102
- }
103
- );
104
- });
105
-
106
61
  it('"interval" : returns undefined when valid hour interval value is supplied', () => {
107
62
  const testValue = '5h';
108
63
  const formRuleResult = formRules.interval(testValue);
@@ -2,11 +2,9 @@ import { RBAC } from '@shell/config/types';
2
2
  import { HCI } from '@shell/config/labels-annotations';
3
3
  import isEmpty from 'lodash/isEmpty';
4
4
  import has from 'lodash/has';
5
- import isUrl from 'is-url';
6
5
  // import uniq from 'lodash/uniq';
7
6
  import cronstrue from 'cronstrue';
8
7
  import { Translation } from '@shell/types/t';
9
- import { isHttps, isLocalhost, hasTrailingForwardSlash } from '@shell/utils/validators/setting';
10
8
 
11
9
  // import uniq from 'lodash/uniq';
12
10
  export type Validator<T = undefined | string> = (val: any, arg?: any) => T;
@@ -36,6 +34,10 @@ export class Port {
36
34
  }
37
35
  }
38
36
 
37
+ const httpsKeys = [
38
+ 'server-url'
39
+ ];
40
+
39
41
  const runValidators = (val: any, validators: Validator[]) => {
40
42
  for (const validator of validators) {
41
43
  const message = validator(val);
@@ -137,13 +139,11 @@ export default function(t: Translation, { key = 'Value' }: ValidationOptions): {
137
139
  }
138
140
  };
139
141
 
140
- const https: Validator = (val: string) => val && !isHttps(val) ? t('validation.setting.serverUrl.https') : undefined;
141
-
142
- const localhost: Validator = (val: string) => isLocalhost(val) ? t('validation.setting.serverUrl.localhost') : undefined;
142
+ const isHttps: ValidatorFactory = (key: string) => {
143
+ const isHttps: Validator = (val: string) => httpsKeys.includes(key) && !val.toLowerCase().startsWith('https://') ? t('validation.setting.serverUrl.https') : undefined;
143
144
 
144
- const trailingForwardSlash: Validator = (val: string) => hasTrailingForwardSlash(val) ? t('validation.setting.serverUrl.trailingForwardSlash') : undefined;
145
-
146
- const url: Validator = (val: string) => val && !isUrl(val) ? t('validation.setting.serverUrl.url') : undefined;
145
+ return isHttps;
146
+ };
147
147
 
148
148
  const interval: Validator = (val: string) => !/^\d+[hms]$/.test(val) ? t('validation.monitoring.route.interval', { key }) : undefined;
149
149
 
@@ -475,10 +475,7 @@ export default function(t: Translation, { key = 'Value' }: ValidationOptions): {
475
475
  hostname,
476
476
  imageUrl,
477
477
  interval,
478
- https,
479
- localhost,
480
- trailingForwardSlash,
481
- url,
478
+ isHttps,
482
479
  matching,
483
480
  maxLength,
484
481
  maxValue,
@@ -1,9 +1,13 @@
1
- import isUrl from 'is-url';
1
+ const httpsKeys = [
2
+ 'server-url'
3
+ ];
2
4
 
3
- export const isServerUrl = (value) => value === 'server-url';
5
+ export function isHttps(value, getters, errors, validatorArgs, displayKey) {
6
+ const key = validatorArgs[0];
4
7
 
5
- export const isHttps = (value) => value.toLowerCase().startsWith('https://');
8
+ if (httpsKeys.includes(key) && !value.toLowerCase().startsWith('https://')) {
9
+ errors.push(getters['i18n/t']('validation.setting.serverUrl.https'));
10
+ }
6
11
 
7
- export const isLocalhost = (value) => (/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1)/i).test(value);
8
-
9
- export const hasTrailingForwardSlash = (value) => isUrl(value) && value?.toLowerCase().endsWith('/');
12
+ return errors;
13
+ }
package/vue.config.js CHANGED
@@ -6,7 +6,6 @@ const { generateDynamicTypeImport } = require('./pkg/auto-import');
6
6
  const CopyWebpackPlugin = require('copy-webpack-plugin');
7
7
  const serverMiddlewares = require('./server/server-middleware.js');
8
8
  const configHelper = require('./vue-config-helper.js');
9
- const har = require('./server/har-file');
10
9
 
11
10
  // Suppress info level logging messages from http-proxy-middleware
12
11
  // This hides all of the "[HPM Proxy created] ..." messages
@@ -292,14 +291,6 @@ module.exports = function(dir, _appConfig) {
292
291
  '/engines-dist': configHelper.proxyOpts('https://127.0.0.1:8000'),
293
292
  };
294
293
 
295
- // HAR File support - load network responses from the specified .har file and use those rather than communicating to the Rancher server
296
- const harFile = process.env.HAR_FILE;
297
- let harData;
298
-
299
- if (harFile) {
300
- harData = har.loadFile(harFile, devPorts ? 8005 : 80, ''); // eslint-disable-line no-console
301
- }
302
-
303
294
  const config = {
304
295
  // Vue server
305
296
  devServer: {
@@ -322,19 +313,6 @@ module.exports = function(dir, _appConfig) {
322
313
 
323
314
  app.use(serverMiddlewares);
324
315
 
325
- if (harData) {
326
- console.log('Installing HAR file middleware'); // eslint-disable-line no-console
327
- app.use(har.harProxy(harData, process.env.HAR_DIR));
328
-
329
- server.websocketProxies.push({
330
- upgrade(req, socket, head) {
331
- const responseHeaders = ['HTTP/1.1 101 Web Socket Protocol Handshake', 'Upgrade: WebSocket', 'Connection: Upgrade'];
332
-
333
- socket.write(`${ responseHeaders.join('\r\n') }\r\n\r\n`);
334
- }
335
- });
336
- }
337
-
338
316
  Object.keys(proxy).forEach((p) => {
339
317
  const px = createProxyMiddleware({
340
318
  ...proxy[p],
@@ -400,7 +378,7 @@ module.exports = function(dir, _appConfig) {
400
378
  config.resolve.alias['@pkg'] = path.join(dir, 'pkg');
401
379
  config.resolve.alias['./node_modules'] = path.join(dir, 'node_modules');
402
380
  config.resolve.alias['@components'] = COMPONENTS_DIR;
403
- config.resolve.alias['vue$'] = dev ? path.resolve(process.cwd(), 'node_modules', 'vue') : 'vue';
381
+ config.resolve.alias['vue$'] = path.resolve(process.cwd(), 'node_modules', 'vue', 'dist', dev ? 'vue.js' : 'vue.min.js');
404
382
  config.resolve.modules.push(__dirname);
405
383
  config.plugins.push(virtualModules);
406
384
  config.plugins.push(autoImport);
@@ -409,6 +387,7 @@ module.exports = function(dir, _appConfig) {
409
387
  // DefinePlugin does string replacement within our code. We may want to consider replacing it with something else. In code we'll see something like
410
388
  // process.env.commit even though process and env aren't even defined objects. This could cause people to be mislead.
411
389
  config.plugins.push(new webpack.DefinePlugin({
390
+ 'process.client': JSON.stringify(true),
412
391
  'process.env.commit': JSON.stringify(commit),
413
392
  'process.env.version': JSON.stringify(dashboardVersion),
414
393
  'process.env.dev': JSON.stringify(dev),
@@ -565,7 +544,7 @@ module.exports = function(dir, _appConfig) {
565
544
  options: { mode: ['body'] }
566
545
  }
567
546
  ]
568
- },
547
+ }
569
548
  ];
570
549
 
571
550
  config.module.rules.push(...loaders);