@rancher/shell 0.3.17 → 0.3.19

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 (118) hide show
  1. package/assets/translations/en-us.yaml +8 -4
  2. package/assets/translations/zh-hans.yaml +64 -8
  3. package/components/AsyncButton.vue +1 -1
  4. package/components/Inactivity.vue +10 -0
  5. package/components/LazyImage.vue +2 -2
  6. package/components/PromptRestore.vue +8 -6
  7. package/components/ResourceDetail/Masthead.vue +1 -1
  8. package/components/ResourceDetail/index.vue +4 -2
  9. package/components/__tests__/PromptRestore.test.ts +142 -0
  10. package/components/auth/AzureWarning.vue +1 -1
  11. package/components/auth/RoleDetailEdit.vue +2 -0
  12. package/components/fleet/FleetResources.vue +3 -64
  13. package/components/form/FileImageSelector.vue +9 -0
  14. package/components/form/FileSelector.vue +2 -1
  15. package/components/form/MatchExpressions.vue +1 -3
  16. package/components/form/__tests__/FileImageSelector.test.ts +42 -0
  17. package/components/form/__tests__/FileSelector.test.ts +76 -0
  18. package/components/formatter/ClusterProvider.vue +3 -1
  19. package/components/formatter/__tests__/ClusterProvider.test.ts +24 -0
  20. package/components/nav/WindowManager/ContainerShell.vue +60 -36
  21. package/components/nav/WindowManager/__tests__/ContainerShell.test.ts +561 -0
  22. package/config/labels-annotations.js +2 -1
  23. package/config/persistentVolume.ts +108 -0
  24. package/config/product/manager.js +5 -1
  25. package/config/types.js +2 -0
  26. package/core/plugin-helpers.js +19 -3
  27. package/core/types.ts +4 -0
  28. package/detail/fleet.cattle.io.gitrepo.vue +10 -2
  29. package/detail/pod.vue +36 -3
  30. package/detail/workload/index.vue +40 -9
  31. package/dialog/DiagnosticTimingsDialog.vue +1 -0
  32. package/edit/__tests__/ui.cattle.io.navlink.test.ts +110 -0
  33. package/edit/fleet.cattle.io.clustergroup.vue +14 -3
  34. package/edit/persistentvolume/__tests__/persistentvolume.test.ts +82 -0
  35. package/edit/persistentvolume/index.vue +2 -1
  36. package/edit/persistentvolume/plugins/csi.vue +3 -1
  37. package/edit/persistentvolume/plugins/longhorn.vue +12 -12
  38. package/edit/provisioning.cattle.io.cluster/RegistryConfigs.vue +15 -11
  39. package/edit/provisioning.cattle.io.cluster/index.vue +1 -1
  40. package/edit/provisioning.cattle.io.cluster/rke2.vue +5 -1
  41. package/edit/storage.k8s.io.storageclass/index.vue +1 -2
  42. package/edit/ui.cattle.io.navlink.vue +213 -186
  43. package/layouts/default.vue +1 -1
  44. package/list/group.principal.vue +1 -1
  45. package/middleware/authenticated.js +12 -4
  46. package/mixins/create-edit-view/impl.js +2 -2
  47. package/models/chart.js +1 -1
  48. package/models/etcdbackup.js +2 -1
  49. package/models/fleet.cattle.io.cluster.js +33 -4
  50. package/models/fleet.cattle.io.gitrepo.js +112 -38
  51. package/models/management.cattle.io.cluster.js +13 -3
  52. package/models/management.cattle.io.kontainerdriver.js +14 -0
  53. package/models/persistentvolume.js +2 -111
  54. package/models/pod.js +30 -0
  55. package/models/rke.cattle.io.etcdsnapshot.js +10 -7
  56. package/package.json +1 -1
  57. package/pages/c/_cluster/apps/charts/install.vue +74 -25
  58. package/pages/c/_cluster/auth/group.principal/assign-edit.vue +1 -1
  59. package/pages/c/_cluster/auth/roles/index.vue +1 -1
  60. package/pages/c/_cluster/explorer/index.vue +1 -1
  61. package/pages/c/_cluster/manager/cloudCredential/_id.vue +0 -1
  62. package/pages/c/_cluster/manager/cloudCredential/create.vue +0 -1
  63. package/pages/c/_cluster/settings/brand.vue +11 -8
  64. package/pages/c/_cluster/uiplugins/index.vue +9 -4
  65. package/pages/diagnostic.vue +5 -3
  66. package/pages/home.vue +1 -1
  67. package/plugins/dashboard-store/__tests__/actions.spec.ts +165 -0
  68. package/plugins/dashboard-store/__tests__/getters.spec.ts +100 -0
  69. package/plugins/dashboard-store/__tests__/{mutations.spec.js → mutations.spec.ts} +2 -2
  70. package/plugins/dashboard-store/actions.js +1 -1
  71. package/plugins/dashboard-store/resource-class.js +4 -0
  72. package/plugins/steve/__tests__/getters.spec.ts +93 -0
  73. package/plugins/steve/getters.js +21 -1
  74. package/plugins/steve/subscribe.js +1 -3
  75. package/rancher-components/components/BadgeState/BadgeState.spec.ts +12 -0
  76. package/rancher-components/components/BadgeState/BadgeState.vue +111 -0
  77. package/rancher-components/components/BadgeState/index.ts +1 -0
  78. package/rancher-components/components/Banner/Banner.test.ts +63 -0
  79. package/rancher-components/components/Banner/Banner.vue +244 -0
  80. package/rancher-components/components/Banner/index.ts +1 -0
  81. package/rancher-components/components/Card/Card.test.ts +37 -0
  82. package/rancher-components/components/Card/Card.vue +167 -0
  83. package/rancher-components/components/Card/index.ts +1 -0
  84. package/rancher-components/components/Form/Checkbox/Checkbox.test.ts +68 -0
  85. package/rancher-components/components/Form/Checkbox/Checkbox.vue +420 -0
  86. package/rancher-components/components/Form/Checkbox/index.ts +1 -0
  87. package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +23 -0
  88. package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +355 -0
  89. package/rancher-components/components/Form/LabeledInput/index.ts +1 -0
  90. package/rancher-components/components/Form/Radio/RadioButton.test.ts +31 -0
  91. package/rancher-components/components/Form/Radio/RadioButton.vue +287 -0
  92. package/rancher-components/components/Form/Radio/RadioGroup.vue +254 -0
  93. package/rancher-components/components/Form/Radio/index.ts +2 -0
  94. package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +170 -0
  95. package/rancher-components/components/Form/TextArea/index.ts +1 -0
  96. package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.test.ts +94 -0
  97. package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.vue +149 -0
  98. package/rancher-components/components/Form/ToggleSwitch/index.ts +1 -0
  99. package/rancher-components/components/Form/index.ts +5 -0
  100. package/rancher-components/components/LabeledTooltip/LabeledTooltip.vue +151 -0
  101. package/rancher-components/components/LabeledTooltip/index.ts +1 -0
  102. package/rancher-components/components/StringList/StringList.test.ts +484 -0
  103. package/rancher-components/components/StringList/StringList.vue +611 -0
  104. package/rancher-components/components/StringList/index.ts +1 -0
  105. package/scripts/extension/publish +54 -14
  106. package/scripts/typegen.sh +10 -2
  107. package/store/index.js +1 -3
  108. package/store/store-types.js +2 -0
  109. package/types/api.d.ts +1 -0
  110. package/types/fleet.d.ts +1 -0
  111. package/types/shell/index.d.ts +696 -2
  112. package/types/userPreferences.d.ts +1 -1
  113. package/utils/__mocks__/socket.js +21 -0
  114. package/utils/grafana.js +23 -11
  115. package/utils/selector.js +2 -1
  116. package/utils/socket.js +1 -0
  117. package/utils/validators/formRules/index.ts +3 -3
  118. package/plugins/steve/urloptions.js +0 -47
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line no-unused-vars
2
- interface UserPreferences {
2
+ export interface UserPreferences {
3
3
  'after-login-route': string,
4
4
  cluster: string,
5
5
  'group-by': string,
@@ -0,0 +1,21 @@
1
+ export const addEventListener = jest.fn();
2
+ export const connect = jest.fn();
3
+ export const disconnect = jest.fn();
4
+ export const send = jest.fn();
5
+
6
+ export const EVENT_CONNECTED = 'connected';
7
+ export const EVENT_CONNECTING = 'connecting';
8
+ export const EVENT_DISCONNECTED = 'disconnected';
9
+ export const EVENT_MESSAGE = 'message';
10
+ export const EVENT_CONNECT_ERROR = 'connect_error';
11
+
12
+ const mock = jest.fn().mockImplementation(() => {
13
+ return {
14
+ addEventListener,
15
+ connect,
16
+ disconnect,
17
+ send
18
+ };
19
+ });
20
+
21
+ export default mock;
package/utils/grafana.js CHANGED
@@ -32,14 +32,19 @@ export function computeDashboardUrl(monitoringVersion, embedUrl, clusterId, para
32
32
  return newUrl;
33
33
  }
34
34
 
35
- export async function dashboardExists(monitoringVersion, store, clusterId, embedUrl, storeName = 'cluster') {
35
+ export async function dashboardExists(monitoringVersion, store, clusterId, embedUrl, storeName = 'cluster', projectId = null) {
36
36
  if ( !haveV2Monitoring(store.getters) ) {
37
37
  return false;
38
38
  }
39
39
 
40
40
  const url = parseUrl(embedUrl);
41
- const prefix = `${ getClusterPrefix(monitoringVersion, clusterId) }/api/v1/namespaces/cattle-monitoring-system/services/http:rancher-monitoring-grafana:80/proxy/`;
42
- const delimiter = 'http:rancher-monitoring-grafana:80/proxy/';
41
+ let prefix = `${ getClusterPrefix(monitoringVersion, clusterId) }/api/v1/namespaces/cattle-monitoring-system/services/http:rancher-monitoring-grafana:80/proxy/`;
42
+ let delimiter = 'http:rancher-monitoring-grafana:80/proxy/';
43
+
44
+ if (projectId) {
45
+ prefix = `${ getClusterPrefix(monitoringVersion, clusterId) }/api/v1/namespaces/cattle-project-${ projectId }-monitoring/services/http:cattle-project-${ projectId }-monitoring-grafana:80/proxy/`;
46
+ delimiter = `http:cattle-project-${ projectId }-monitoring-grafana:80/proxy/`;
47
+ }
43
48
  const path = url.path.split(delimiter)[1];
44
49
  const uid = path.split('/')[1];
45
50
  const newUrl = `${ prefix }api/dashboards/uid/${ uid }`;
@@ -53,18 +58,25 @@ export async function dashboardExists(monitoringVersion, store, clusterId, embed
53
58
  }
54
59
  }
55
60
 
56
- export async function allDashboardsExist(store, clusterId, embeddedUrls, storeName = 'cluster') {
61
+ export async function allDashboardsExist(store, clusterId, embeddedUrls, storeName = 'cluster', projectId = null) {
57
62
  let res;
58
63
 
59
- try {
60
- res = await store.dispatch(`${ storeName }/find`, { type: CATALOG.APP, id: 'cattle-monitoring-system/rancher-monitoring' });
61
- } catch (err) {
62
- return false;
63
- }
64
+ let monitoringVersion = '';
65
+
66
+ if (!projectId) {
67
+ try {
68
+ res = await store.dispatch(`${ storeName }/find`, {
69
+ type: CATALOG.APP,
70
+ id: 'cattle-monitoring-system/rancher-monitoring'
71
+ });
72
+ } catch (err) {
73
+ return false;
74
+ }
64
75
 
65
- const monitoringVersion = res?.currentVersion;
76
+ monitoringVersion = res?.currentVersion;
77
+ }
66
78
 
67
- const existPromises = embeddedUrls.map((url) => dashboardExists(monitoringVersion, store, clusterId, url, storeName));
79
+ const existPromises = embeddedUrls.map((url) => dashboardExists(monitoringVersion, store, clusterId, url, storeName, projectId));
68
80
 
69
81
  return (await Promise.all(existPromises)).every((exists) => exists);
70
82
  }
package/utils/selector.js CHANGED
@@ -198,7 +198,8 @@ export function matches(obj, selector, labelKey = 'metadata.labels') {
198
198
  }
199
199
  break;
200
200
  case 'In':
201
- if ( !value || !rule.values.length || !rule.values.includes(value) ) {
201
+ // we need to cater empty strings because when creating a label with value = null it's translated into a empty string value ''
202
+ if ( !rule.values.length || !rule.values.includes(value) ) {
202
203
  return false;
203
204
  }
204
205
  break;
package/utils/socket.js CHANGED
@@ -11,6 +11,7 @@ const SECURE = 'wss://';
11
11
 
12
12
  const STATE_DISCONNECTED = 'disconnected';
13
13
 
14
+ export const addEventListener = EventTarget.addEventListener;
14
15
  export const STATE_CONNECTING = 'connecting';
15
16
  export const STATE_CONNECTED = 'connected';
16
17
  const STATE_CLOSING = 'closing';
@@ -7,7 +7,7 @@ import cronstrue from 'cronstrue';
7
7
  import { Translation } from '@shell/types/t';
8
8
 
9
9
  // import uniq from 'lodash/uniq';
10
- export type Validator = (val: any, arg?: any) => undefined | string;
10
+ export type Validator<T = undefined | string> = (val: any, arg?: any) => T;
11
11
 
12
12
  export type ValidatorFactory = (arg1: any, arg2?: any) => Validator
13
13
 
@@ -53,7 +53,7 @@ export interface ValidationOptions {
53
53
  }
54
54
 
55
55
  // "t" is the function name we use for getting a translated string
56
- export default function(t: Translation, { key = 'Value' }: ValidationOptions): unknown {
56
+ export default function(t: Translation, { key = 'Value' }: ValidationOptions): { [key:string]: Validator<any> | ValidatorFactory } {
57
57
  // utility validators these validators only get used by other validators
58
58
  const startDot: ValidatorFactory = (label: string): Validator => (val: string) => val?.slice(0, 1) === '.' ? t(`validation.dns.${ label }.startDot`, { key }) : undefined;
59
59
 
@@ -257,7 +257,7 @@ export default function(t: Translation, { key = 'Value' }: ValidationOptions): u
257
257
 
258
258
  const clusterName: ValidatorFactory = (isRke2: boolean): Validator => (val: string | undefined) => isRke2 && (val || '')?.match(/^(c-.{5}|local)$/i) ? t('validation.cluster.name') : undefined;
259
259
 
260
- const servicePort = (val: ServicePort) => {
260
+ const servicePort: Validator<string | Port | undefined> = (val: ServicePort) => {
261
261
  const {
262
262
  name,
263
263
  idx
@@ -1,47 +0,0 @@
1
- import { isArray } from '@shell/utils/array';
2
-
3
- export default function urlOptions(url, opt) {
4
- opt = opt || {};
5
-
6
- // Filter
7
- if ( opt.filter ) {
8
- const keys = Object.keys(opt.filter);
9
-
10
- keys.forEach((key) => {
11
- let vals = opt.filter[key];
12
-
13
- if ( !isArray(vals) ) {
14
- vals = [vals];
15
- }
16
-
17
- vals.forEach((val) => {
18
- url += `${ (url.includes('?') ? '&' : '?') + encodeURIComponent(key) }=${ encodeURIComponent(val) }`;
19
- });
20
- });
21
- }
22
- // End: Filter
23
-
24
- // Limit
25
- const limit = opt.limit;
26
-
27
- if ( limit ) {
28
- url += `${ url.includes('?') ? '&' : '?' }limit=${ limit }`;
29
- }
30
- // End: Limit
31
-
32
- // Sort
33
- const sortBy = opt.sortBy;
34
-
35
- if ( sortBy ) {
36
- url += `${ url.includes('?') ? '&' : '?' }sort=${ encodeURIComponent(sortBy) }`;
37
- }
38
-
39
- const orderBy = opt.sortOrder;
40
-
41
- if ( orderBy ) {
42
- url += `${ url.includes('?') ? '&' : '?' }order=${ encodeURIComponent(orderBy) }`;
43
- }
44
- // End: Sort
45
-
46
- return url;
47
- }