@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
@@ -1,186 +0,0 @@
1
- import { shallowMount } from '@vue/test-utils';
2
- import ContainerLogs from '@shell/components/nav/WindowManager/ContainerLogs.vue';
3
- import { base64Encode } from '@shell/utils/crypto';
4
- import { Buffer } from 'buffer';
5
- import { addEventListener } from '@shell/utils/socket';
6
-
7
- jest.mock('@shell/utils/socket');
8
-
9
- const getDefaultOptions = () => {
10
- return {
11
- propsData: {
12
- tab: {},
13
- active: true,
14
- height: 100,
15
- pod: {
16
- spec: { nodeName: 'nodeId' },
17
- links: { view: 'url' },
18
- os: 'linux'
19
- },
20
- },
21
- data() {
22
- return { range: '30 minute' };
23
- },
24
- mocks: {
25
- $store: {
26
- getters: {
27
- 'prefs/get': jest.fn(),
28
- 'i18n/t': jest.fn(),
29
- currentProduct: { inStore: 'cluster' }
30
- }
31
- }
32
- }
33
- };
34
- };
35
-
36
- describe('component: ContainerLogs', () => {
37
- it('should receive messages correctly', async() => {
38
- jest.clearAllMocks();
39
- const wrapper = await shallowMount(ContainerLogs, getDefaultOptions());
40
-
41
- const data1 = 'container logs test1\n';
42
- const messageCallback = addEventListener.mock.calls.find(([e]) => e === 'message')[1];
43
-
44
- messageCallback({ detail: { data: base64Encode(data1) } });
45
-
46
- await wrapper.vm.$nextTick();
47
- expect(wrapper.vm.backlog).toHaveLength(1);
48
- expect(wrapper.vm.backlog[0].rawMsg).toBe(data1.trimEnd());
49
- const data2 = 'container logs test2 中文日志内容测试\n';
50
-
51
- messageCallback({ detail: { data: base64Encode(data2) } });
52
- await wrapper.vm.$nextTick();
53
- expect(wrapper.vm.backlog).toHaveLength(2);
54
- expect(wrapper.vm.backlog[1].rawMsg).toBe(data2.trimEnd());
55
- });
56
-
57
- it('should not fail for an empty message/string', async() => {
58
- jest.clearAllMocks();
59
- const wrapper = await shallowMount(ContainerLogs, getDefaultOptions());
60
-
61
- const data1 = '';
62
- const messageCallback = addEventListener.mock.calls.find(([e]) => e === 'message')[1];
63
-
64
- messageCallback({ detail: { data: base64Encode(data1) } });
65
- await wrapper.vm.$nextTick();
66
- expect(wrapper.vm.backlog).toHaveLength(0);
67
- expect(wrapper.vm.filtered).toHaveLength(0);
68
- });
69
-
70
- it('should merge the message which be truncated line', async() => {
71
- jest.clearAllMocks();
72
- const wrapper = await shallowMount(ContainerLogs, getDefaultOptions());
73
- const part1 = 'container logs part1';
74
- const messageCallback = addEventListener.mock.calls.find(([e]) => e === 'message')[1];
75
-
76
- messageCallback({ detail: { data: base64Encode(part1) } });
77
- await wrapper.vm.$nextTick();
78
-
79
- expect(wrapper.vm.backlog).toHaveLength(0);
80
- const part2 = 'container logs part2\n';
81
-
82
- messageCallback({ detail: { data: base64Encode(part2) } });
83
- await wrapper.vm.$nextTick();
84
- expect(wrapper.vm.backlog).toHaveLength(1);
85
- expect(wrapper.vm.backlog[0].rawMsg).toBe(`${ part1 }${ part2 }`.trimEnd());
86
- });
87
-
88
- it('should merge truncated 2-byte utf-8 character messages', async() => {
89
- jest.clearAllMocks();
90
- const wrapper = await shallowMount(ContainerLogs, getDefaultOptions());
91
- // Contains 2-byte utf-8 character message with one character truncation
92
- const message = '¡¢£¤¥\n';
93
- const arr = Buffer.from(message);
94
-
95
- const part1 = arr.slice(0, 3).toString('base64');
96
- const part2 = arr.slice(3).toString('base64');
97
-
98
- const messageCallback = addEventListener.mock.calls.find(([e]) => e === 'message')[1];
99
-
100
- messageCallback({ detail: { data: part1 } });
101
- await wrapper.vm.$nextTick();
102
- expect(wrapper.vm.backlog).toHaveLength(0);
103
- messageCallback({ detail: { data: part2 } });
104
- await wrapper.vm.$nextTick();
105
- expect(wrapper.vm.backlog).toHaveLength(1);
106
- expect(wrapper.vm.backlog[0].rawMsg).toBe(message.trimEnd());
107
- });
108
- it('should merge truncated 3-byte utf-8 character messages', async() => {
109
- jest.clearAllMocks();
110
- const wrapper = await shallowMount(ContainerLogs, getDefaultOptions());
111
- // Contains 3-byte utf-8 character message with one character truncation
112
- const message = 'ࠀࠁࠂࠃ\n';
113
- const arr = Buffer.from(message);
114
- // Truncate at the fourth byte
115
- const part1 = arr.slice(0, 4).toString('base64');
116
- const part2 = arr.slice(4).toString('base64');
117
-
118
- const messageCallback = addEventListener.mock.calls.find(([e]) => e === 'message')[1];
119
-
120
- messageCallback({ detail: { data: part1 } });
121
- await wrapper.vm.$nextTick();
122
- expect(wrapper.vm.backlog).toHaveLength(0);
123
- messageCallback({ detail: { data: part2 } });
124
- await wrapper.vm.$nextTick();
125
- expect(wrapper.vm.backlog).toHaveLength(1);
126
- expect(wrapper.vm.backlog[0].rawMsg).toBe(message.trimEnd());
127
-
128
- // Truncate at the fifth byte
129
- const part3 = arr.slice(0, 5).toString('base64');
130
- const part4 = arr.slice(5).toString('base64');
131
-
132
- messageCallback({ detail: { data: part3 } });
133
- await wrapper.vm.$nextTick();
134
- expect(wrapper.vm.backlog).toHaveLength(1);
135
- messageCallback({ detail: { data: part4 } });
136
- await wrapper.vm.$nextTick();
137
- expect(wrapper.vm.backlog).toHaveLength(2);
138
- expect(wrapper.vm.backlog[1].rawMsg).toBe(message.trimEnd());
139
- });
140
-
141
- it('should merge truncated 4-byte utf-8 character messages', async() => {
142
- jest.clearAllMocks();
143
- const wrapper = await shallowMount(ContainerLogs, getDefaultOptions());
144
- // Contains 4-byte utf-8 character message with one character truncation
145
- const message = '𐀀𐀁𐀂𐀃\n';
146
- const arr = Buffer.from(message);
147
-
148
- // Truncate at the fifth byte
149
- const part1 = arr.slice(0, 5).toString('base64');
150
- const part2 = arr.slice(5).toString('base64');
151
-
152
- const messageCallback = addEventListener.mock.calls.find(([e]) => e === 'message')[1];
153
-
154
- messageCallback({ detail: { data: part1 } });
155
- await wrapper.vm.$nextTick();
156
- expect(wrapper.vm.backlog).toHaveLength(0);
157
- messageCallback({ detail: { data: part2 } });
158
- await wrapper.vm.$nextTick();
159
- expect(wrapper.vm.backlog).toHaveLength(1);
160
- expect(wrapper.vm.backlog[0].rawMsg).toBe(message.trimEnd());
161
-
162
- // Truncate at the sixth byte
163
- const part3 = arr.slice(0, 6).toString('base64');
164
- const part4 = arr.slice(6).toString('base64');
165
-
166
- messageCallback({ detail: { data: part3 } });
167
- await wrapper.vm.$nextTick();
168
- expect(wrapper.vm.backlog).toHaveLength(1);
169
- messageCallback({ detail: { data: part4 } });
170
- await wrapper.vm.$nextTick();
171
- expect(wrapper.vm.backlog).toHaveLength(2);
172
- expect(wrapper.vm.backlog[1].rawMsg).toBe(message.trimEnd());
173
-
174
- // Truncate at the seventh byte
175
- const part5 = arr.slice(0, 7).toString('base64');
176
- const part6 = arr.slice(7).toString('base64');
177
-
178
- messageCallback({ detail: { data: part5 } });
179
- await wrapper.vm.$nextTick();
180
- expect(wrapper.vm.backlog).toHaveLength(2);
181
- messageCallback({ detail: { data: part6 } });
182
- await wrapper.vm.$nextTick();
183
- expect(wrapper.vm.backlog).toHaveLength(3);
184
- expect(wrapper.vm.backlog[2].rawMsg).toBe(message.trimEnd());
185
- });
186
- });
@@ -1,20 +0,0 @@
1
- import { computed, ComputedRef } from 'vue';
2
-
3
- interface CompactInputProps {
4
- compact?: boolean;
5
- label?: string;
6
- labelKey?: string;
7
- }
8
-
9
- interface UseCompactInput {
10
- isCompact: ComputedRef<boolean>;
11
- }
12
-
13
- export const useCompactInput = (props: CompactInputProps): UseCompactInput => {
14
- const isCompact = computed(() => {
15
- // Compact if explicitly set - otherwise compact if there is no label
16
- return props.compact !== null ? !!props.compact : !(props.label || props.labelKey);
17
- });
18
-
19
- return { isCompact };
20
- };
@@ -1,138 +0,0 @@
1
- import { ref, computed, ComputedRef, Ref } from 'vue';
2
- import { _VIEW, _EDIT } from '@shell/config/query-params';
3
-
4
- interface LabeledFormElementProps {
5
- mode: string;
6
- value: string | number | Record<string, any>
7
- required: boolean;
8
- disabled: boolean;
9
- rules: Array<any>;
10
- }
11
-
12
- interface UseLabeledFormElement {
13
- raised: Ref<boolean>;
14
- focused: Ref<boolean>;
15
- blurred: Ref<number | null>;
16
- requiredField: ComputedRef<any>;
17
- isDisabled: ComputedRef<any>;
18
- validationMessage: ComputedRef<any>;
19
- onFocusLabeled: () => void;
20
- onBlurLabeled: () => void;
21
- }
22
-
23
- export const labeledFormElementProps = {
24
- tooltipKey: {
25
- type: String,
26
- default: null
27
- },
28
- placeholder: {
29
- type: [String, Number],
30
- default: ''
31
- },
32
- placeholderKey: {
33
- type: String,
34
- default: null
35
- },
36
- label: {
37
- type: String,
38
- default: null
39
- },
40
- labelKey: {
41
- type: String,
42
- default: null
43
- },
44
- value: {
45
- type: [String, Number, Object],
46
- default: ''
47
- },
48
- mode: {
49
- type: String,
50
- default: _EDIT,
51
- },
52
- rules: {
53
- default: (): Array<unknown> => [],
54
- type: Array,
55
- // we only want functions in the rules array
56
- validator: (rules: Array<unknown>): boolean => rules.every((rule: unknown) => ['function'].includes(typeof rule))
57
- },
58
- required: {
59
- type: Boolean,
60
- default: false,
61
- },
62
- disabled: {
63
- type: Boolean,
64
- default: false,
65
- },
66
- };
67
-
68
- export const useLabeledFormElement = (props: LabeledFormElementProps, emit: (event: string, ...args: any[]) => void): UseLabeledFormElement => {
69
- const raised = ref(props.mode === _VIEW || !!`${ props.value }`);
70
- const focused = ref(false);
71
- const blurred = ref<number | null>(null);
72
-
73
- const requiredField = computed(() => {
74
- return props.required || props.rules?.some((rule: any) => rule?.name === 'required');
75
- });
76
-
77
- const isView = computed(() => {
78
- return props.mode === _VIEW;
79
- });
80
-
81
- const isDisabled = computed(() => {
82
- return props.disabled || isView.value;
83
- });
84
-
85
- const validationMessage = computed(() => {
86
- const requiredRule = props.rules.find((rule: any) => rule?.name === 'required') as Function;
87
- const ruleMessages = [];
88
- const value = props.value;
89
-
90
- if (requiredRule && blurred.value && !focused.value) {
91
- const message = requiredRule(value);
92
-
93
- if (!!message) {
94
- return message;
95
- }
96
- }
97
-
98
- for (const rule of props.rules) {
99
- const message = rule(value);
100
-
101
- if (!!message && rule.name !== 'required') {
102
- ruleMessages.push(message);
103
- }
104
- }
105
-
106
- if (ruleMessages.length > 0 && (blurred.value || focused.value)) {
107
- return ruleMessages.join(', ');
108
- } else {
109
- return undefined;
110
- }
111
- });
112
-
113
- const onFocusLabeled = () => {
114
- raised.value = true;
115
- focused.value = true;
116
- };
117
-
118
- const onBlurLabeled = () => {
119
- focused.value = false;
120
-
121
- if (!props.value) {
122
- raised.value = false;
123
- }
124
-
125
- blurred.value = Date.now();
126
- };
127
-
128
- return {
129
- raised,
130
- focused,
131
- blurred,
132
- onFocusLabeled,
133
- onBlurLabeled,
134
- isDisabled,
135
- validationMessage,
136
- requiredField
137
- };
138
- };
@@ -1,14 +0,0 @@
1
- image: registry.suse.com/bci/bci-base:latest
2
-
3
- stages:
4
- - check_version
5
- - build_catalog
6
-
7
- variables:
8
- REGISTRY: $CI_REGISTRY
9
- REGISTRY_USER: $CI_REGISTRY_USER
10
- REGISTRY_PASSWORD: $CI_REGISTRY_PASSWORD
11
- IMAGE_NAMESPACE: $CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME
12
-
13
- include:
14
- - remote: 'https://raw.githubusercontent.com/rancher/dashboard/master/shell/scripts/.gitlab/workflows/build-extension-catalog.gitlab-ci.yml'
@@ -1,89 +0,0 @@
1
- import { shallowMount, Wrapper } from '@vue/test-utils';
2
-
3
- import { _CLONE } from '@shell/config/query-params';
4
- import { cleanHtmlDirective } from '@shell/plugins/clean-html-directive';
5
-
6
- import ServicePage from '@shell/edit/service.vue';
7
-
8
- const createEditViewMock = {
9
- data() {
10
- return { errors: [] };
11
- },
12
- computed: {
13
- isCreate: () => false,
14
- isEdit: () => true,
15
- isView: () => false,
16
- schema: () => ({}),
17
- isNamespaced: () => false,
18
- labels: {
19
- get: jest.fn(() => ({})),
20
- set: jest.fn(),
21
- },
22
- annotations: {
23
- get: jest.fn(() => ({})),
24
- set: jest.fn(),
25
- },
26
- doneRoute: () => 'mockedRoute',
27
- doneParams: () => ({}),
28
- },
29
- methods: {
30
- done: jest.fn(),
31
- conflict: jest.fn(() => Promise.resolve([])),
32
- save: jest.fn(() => Promise.resolve()),
33
- actuallySave: jest.fn(() => Promise.resolve()),
34
- setErrors: jest.fn()
35
- }
36
- };
37
-
38
- const formValidationMock = {};
39
-
40
- describe('service edit', () => {
41
- let wrapper: Wrapper<InstanceType<typeof ServicePage>>;
42
-
43
- const createComponent = (propsData: any) => {
44
- wrapper = shallowMount(ServicePage,
45
- {
46
- propsData,
47
- mixins: [createEditViewMock, formValidationMock],
48
- mocks: {
49
- $store: {
50
- getters: {
51
- 'management/all': jest.fn(),
52
- 'i18n/t': jest.fn()
53
- }
54
- }
55
- },
56
- computed: { provisioningCluster: jest.fn() },
57
- directives: { cleanHtmlDirective },
58
- }
59
- );
60
- };
61
-
62
- it('sets clusterIP to an empty string and deletes clusterIPs when in clone mode', () => {
63
- const value = {
64
- spec: {
65
- clusterIP: '10.43.1.1',
66
- clusterIPs: ['10.43.1.1', '10.43.1.2'],
67
- }
68
- };
69
-
70
- createComponent({ realMode: _CLONE, value });
71
-
72
- expect(wrapper.vm.value.spec.clusterIP).toBe('');
73
- expect(wrapper.vm.value.spec.clusterIPs).toBeUndefined();
74
- });
75
-
76
- it('does not change clusterIP and clusterIPs when not in clone mode', () => {
77
- const value = {
78
- spec: {
79
- clusterIP: '10.43.1.1',
80
- clusterIPs: ['10.43.1.1', '10.43.1.2'],
81
- }
82
- };
83
-
84
- createComponent({ realMode: 'someOtherMode', value });
85
-
86
- expect(wrapper.vm.value.spec.clusterIP).toBe('10.43.1.1');
87
- expect(wrapper.vm.value.spec.clusterIPs).toStrictEqual(['10.43.1.1', '10.43.1.2']);
88
- });
89
- });
@@ -1,112 +0,0 @@
1
- /* eslint-disable jest/no-hooks */
2
- import { mount, Wrapper } from '@vue/test-utils';
3
- import Advanced from '@shell/edit/provisioning.cattle.io.cluster/tabs/Advanced.vue';
4
- import { _YAML, _VIEW } from '@shell/config/query-params';
5
- import { clone } from '@shell/utils/object';
6
- import { PROV_CLUSTER, VERSION_CLUSTER } from '@shell/edit/provisioning.cattle.io.cluster/__tests__/utils/cluster';
7
-
8
- describe('component: Advanced', () => {
9
- let wrapper: Wrapper<InstanceType<typeof Advanced>>;
10
-
11
- const mountOptions = {
12
- propsData: {
13
- value: {},
14
- mode: _VIEW,
15
- haveArgInfo: true,
16
- selectedVersion: VERSION_CLUSTER
17
- },
18
- mocks: {
19
- $store: {
20
- getters: {
21
- currentStore: () => 'current_store',
22
- 'current_store/schemaFor': jest.fn(),
23
- 'current_store/all': jest.fn(),
24
- 'i18n/t': jest.fn(),
25
- 'i18n/exists': jest.fn(),
26
- }
27
- },
28
- $route: { query: { AS: _YAML } },
29
- $router: { applyQuery: jest.fn() },
30
- }
31
- };
32
-
33
- describe('cluster configurations', () => {
34
- it(`should support empty machineSelectorConfig`, () => {
35
- const value = clone(PROV_CLUSTER);
36
-
37
- value.spec.rkeConfig.machineSelectorConfig = [];
38
-
39
- mountOptions.propsData.value = value;
40
-
41
- wrapper = mount(
42
- Advanced,
43
- mountOptions
44
- );
45
-
46
- const inputElem = wrapper.find('[data-testid="array-list-box0"]').element as HTMLElement;
47
-
48
- expect(inputElem).toBeUndefined();
49
- });
50
-
51
- describe(`'protect-kernel-defaults'`, () => {
52
- it(`should show value from machineGlobalConfig`, () => {
53
- const value = clone(PROV_CLUSTER);
54
-
55
- value.spec.rkeConfig.machineGlobalConfig['protect-kernel-defaults'] = true;
56
- value.spec.rkeConfig.machineSelectorConfig = [{
57
- config: {},
58
- machineLabelSelector: {
59
- matchExpressions: [{
60
- key: 'foo',
61
- operator: 'In',
62
- values: ['bar'],
63
- }],
64
- matchLabels: { foo1: 'bar1' },
65
- }
66
- }];
67
-
68
- mountOptions.propsData.mode = _VIEW;
69
- mountOptions.propsData.value = value;
70
-
71
- wrapper = mount(
72
- Advanced,
73
- mountOptions
74
- );
75
-
76
- const checkbox = wrapper.find('[data-testid="protect-kernel-defaults"]').find('[type="checkbox"]').element as HTMLInputElement;
77
-
78
- expect(checkbox.value).toBe('true');
79
- });
80
-
81
- it(`should show value from machineSelectorConfig.config`, () => {
82
- const value = clone(PROV_CLUSTER);
83
-
84
- value.spec.rkeConfig.machineGlobalConfig['protect-kernel-defaults'] = false;
85
- value.spec.rkeConfig.machineSelectorConfig = [{
86
- config: {},
87
- machineLabelSelector: {
88
- config: { 'protect-kernel-defaults': true },
89
- matchExpressions: [{
90
- key: 'foo',
91
- operator: 'In',
92
- values: ['bar'],
93
- }],
94
- matchLabels: { foo1: 'bar1' },
95
- }
96
- }];
97
-
98
- mountOptions.propsData.mode = _VIEW;
99
- mountOptions.propsData.value = value;
100
-
101
- wrapper = mount(
102
- Advanced,
103
- mountOptions
104
- );
105
-
106
- const checkbox = wrapper.find('[data-testid="protect-kernel-defaults"]').find('[type="checkbox"]').element as HTMLInputElement;
107
-
108
- expect(checkbox.value).toBe('true');
109
- });
110
- });
111
- });
112
- });