@rancher/shell 3.0.5-rc.2 → 3.0.5-rc.5

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 (289) hide show
  1. package/assets/data/aws-regions.json +2 -0
  2. package/assets/images/icons/document.svg +3 -0
  3. package/assets/images/vendor/cognito.svg +1 -0
  4. package/assets/styles/app.scss +1 -0
  5. package/assets/styles/base/_basic.scss +10 -0
  6. package/assets/styles/base/_spacing.scss +29 -0
  7. package/assets/styles/global/_layout.scss +1 -2
  8. package/assets/styles/themes/_dark.scss +25 -0
  9. package/assets/styles/themes/_light.scss +65 -0
  10. package/assets/translations/en-us.yaml +377 -37
  11. package/assets/translations/zh-hans.yaml +8 -15
  12. package/chart/monitoring/index.vue +1 -1
  13. package/components/AsyncButton.vue +2 -0
  14. package/components/Certificates.vue +5 -0
  15. package/components/CodeMirror.vue +3 -3
  16. package/components/CruResource.vue +103 -15
  17. package/components/ExplorerProjectsNamespaces.vue +7 -2
  18. package/components/FilterPanel.vue +156 -0
  19. package/components/FixedBanner.vue +19 -5
  20. package/components/{fleet/ForceDirectedTreeChart/index.vue → ForceDirectedTreeChart.vue} +47 -41
  21. package/components/IconOrSvg.vue +14 -35
  22. package/components/PaginatedResourceTable.vue +7 -0
  23. package/components/PromptRemove.vue +5 -1
  24. package/components/Resource/Detail/Card/PodsCard/Bubble.vue +13 -0
  25. package/components/Resource/Detail/Card/PodsCard/composable.ts +30 -0
  26. package/components/Resource/Detail/Card/PodsCard/index.vue +118 -0
  27. package/components/Resource/Detail/Card/ResourceUsageCard/composable.ts +51 -0
  28. package/components/Resource/Detail/Card/ResourceUsageCard/index.vue +79 -0
  29. package/components/Resource/Detail/Card/Scaler.vue +89 -0
  30. package/components/Resource/Detail/Card/StateCard/composables.ts +112 -0
  31. package/components/Resource/Detail/Card/StateCard/index.vue +39 -0
  32. package/components/Resource/Detail/Card/VerticalGap.vue +11 -0
  33. package/components/Resource/Detail/Card/__tests__/Card.test.ts +36 -0
  34. package/components/Resource/Detail/Card/__tests__/PodsCard.test.ts +84 -0
  35. package/components/Resource/Detail/Card/__tests__/ResourceUsageCard.test.ts +72 -0
  36. package/components/Resource/Detail/Card/__tests__/Scaler.test.ts +87 -0
  37. package/components/Resource/Detail/Card/__tests__/StateCard.test.ts +53 -0
  38. package/components/Resource/Detail/Card/__tests__/VerticalGap.test.ts +14 -0
  39. package/components/Resource/Detail/Card/__tests__/index.test.ts +36 -0
  40. package/components/Resource/Detail/Card/index.vue +56 -0
  41. package/components/Resource/Detail/Metadata/Annotations/__tests__/index.test.ts +19 -0
  42. package/components/Resource/Detail/Metadata/Annotations/composable.ts +12 -0
  43. package/components/Resource/Detail/Metadata/Annotations/index.vue +26 -0
  44. package/components/Resource/Detail/Metadata/IdentifyingInformation/__tests__/index.test.ts +103 -0
  45. package/components/Resource/Detail/Metadata/IdentifyingInformation/composable.ts +281 -0
  46. package/components/Resource/Detail/Metadata/IdentifyingInformation/index.vue +111 -0
  47. package/components/Resource/Detail/Metadata/KeyValue.vue +130 -0
  48. package/components/Resource/Detail/Metadata/Labels/__tests__/index.test.ts +18 -0
  49. package/components/Resource/Detail/Metadata/Labels/composable.ts +12 -0
  50. package/components/Resource/Detail/Metadata/Labels/index.vue +27 -0
  51. package/components/Resource/Detail/Metadata/Rectangle.vue +32 -0
  52. package/components/Resource/Detail/Metadata/__tests__/KeyValue.test.ts +107 -0
  53. package/components/Resource/Detail/Metadata/__tests__/Rectangle.test.ts +24 -0
  54. package/components/Resource/Detail/Metadata/__tests__/index.test.ts +91 -0
  55. package/components/Resource/Detail/Metadata/composables.ts +29 -0
  56. package/components/Resource/Detail/Metadata/index.vue +66 -0
  57. package/components/Resource/Detail/Page.vue +22 -0
  58. package/components/Resource/Detail/PercentageBar.vue +40 -0
  59. package/components/Resource/Detail/ResourceRow.vue +119 -0
  60. package/components/Resource/Detail/SpacedRow.vue +14 -0
  61. package/components/Resource/Detail/StatusBar.vue +59 -0
  62. package/components/Resource/Detail/StatusRow.vue +61 -0
  63. package/components/Resource/Detail/TitleBar/Title.vue +13 -0
  64. package/components/Resource/Detail/TitleBar/Top.vue +14 -0
  65. package/components/Resource/Detail/TitleBar/__tests__/Title.test.ts +17 -0
  66. package/components/Resource/Detail/TitleBar/__tests__/Top.test.ts +17 -0
  67. package/components/Resource/Detail/TitleBar/__tests__/index.test.ts +142 -0
  68. package/components/Resource/Detail/TitleBar/composable.ts +31 -0
  69. package/components/Resource/Detail/TitleBar/index.vue +124 -0
  70. package/components/Resource/Detail/Top/index.vue +34 -0
  71. package/components/Resource/Detail/__tests__/Page.test.ts +32 -0
  72. package/components/ResourceDetail/Masthead.vue +0 -1
  73. package/components/ResourceDetail/__tests__/index.test.ts +114 -0
  74. package/components/ResourceDetail/index.vue +64 -562
  75. package/components/ResourceDetail/legacy.vue +545 -0
  76. package/components/ResourceList/index.vue +2 -1
  77. package/components/ResourceTable.vue +41 -7
  78. package/components/SlideInPanelManager.vue +77 -10
  79. package/components/SortableTable/index.vue +13 -2
  80. package/components/SortableTable/selection.js +22 -9
  81. package/components/StatusBadge.vue +6 -4
  82. package/components/SubtleLink.vue +25 -0
  83. package/components/Tabbed/index.vue +6 -0
  84. package/components/Wizard.vue +12 -1
  85. package/components/YamlEditor.vue +1 -1
  86. package/components/__tests__/AsyncButton.test.ts +39 -0
  87. package/components/__tests__/CruResource.test.ts +63 -0
  88. package/components/__tests__/FilterPanel.test.ts +81 -0
  89. package/components/__tests__/PromptModal.test.ts +0 -2
  90. package/components/auth/AuthBanner.vue +2 -3
  91. package/components/auth/RoleDetailEdit.vue +45 -3
  92. package/components/auth/login/oidc.vue +6 -1
  93. package/components/fleet/FleetApplications.vue +181 -0
  94. package/components/fleet/FleetHelmOps.vue +115 -0
  95. package/components/fleet/FleetIntro.vue +58 -28
  96. package/components/fleet/FleetNoWorkspaces.vue +5 -1
  97. package/components/fleet/FleetOCIStorageSecret.vue +171 -0
  98. package/components/fleet/FleetRepos.vue +38 -76
  99. package/components/fleet/FleetResources.vue +50 -22
  100. package/components/fleet/FleetSummary.vue +26 -51
  101. package/components/fleet/__tests__/FleetOCIStorageSecret.test.ts +213 -0
  102. package/components/fleet/__tests__/FleetSummary.test.ts +39 -39
  103. package/components/fleet/dashboard/Empty.vue +73 -0
  104. package/components/fleet/dashboard/ResourceCard.vue +183 -0
  105. package/components/fleet/dashboard/ResourceCardSummary.vue +199 -0
  106. package/components/fleet/dashboard/ResourceDetails.vue +196 -0
  107. package/components/fleet/dashboard/ResourcePanel.vue +376 -0
  108. package/components/form/ArrayList.vue +139 -117
  109. package/components/form/BannerSettings.vue +145 -96
  110. package/components/form/KeyValue.vue +10 -7
  111. package/components/form/LabeledSelect.vue +9 -2
  112. package/components/form/MatchExpressions.vue +5 -1
  113. package/components/form/NameNsDescription.vue +1 -1
  114. package/components/form/ResourceSelector.vue +26 -23
  115. package/components/form/ResourceTabs/index.vue +2 -1
  116. package/components/form/Select.vue +9 -2
  117. package/components/form/SimpleSecretSelector.vue +8 -2
  118. package/components/form/UnitInput.vue +13 -0
  119. package/components/form/ValueFromResource.vue +31 -19
  120. package/components/form/__tests__/ArrayList.test.ts +32 -0
  121. package/components/form/__tests__/KeyValue.test.ts +36 -0
  122. package/components/form/__tests__/LabeledSelect.test.ts +33 -0
  123. package/components/form/__tests__/Select.test.ts +34 -1
  124. package/components/form/__tests__/UnitInput.test.ts +23 -1
  125. package/components/formatter/ClusterLink.vue +5 -8
  126. package/components/formatter/Description.vue +30 -0
  127. package/components/formatter/FleetApplicationClustersReady.vue +77 -0
  128. package/components/formatter/FleetApplicationSource.vue +71 -0
  129. package/components/formatter/FleetSummaryGraph.vue +7 -0
  130. package/components/formatter/__tests__/ClusterLink.test.ts +2 -32
  131. package/components/nav/Header.vue +8 -7
  132. package/components/nav/NamespaceFilter.vue +1 -1
  133. package/components/nav/TopLevelMenu.helper.ts +55 -34
  134. package/components/nav/TopLevelMenu.vue +11 -0
  135. package/components/nav/Type.vue +4 -1
  136. package/components/nav/WindowManager/index.vue +1 -0
  137. package/composables/useI18n.ts +12 -11
  138. package/config/labels-annotations.js +14 -11
  139. package/config/product/auth.js +1 -0
  140. package/config/product/explorer.js +16 -13
  141. package/config/product/fleet.js +70 -17
  142. package/config/product/manager.js +1 -28
  143. package/config/query-params.js +3 -1
  144. package/config/roles.ts +1 -0
  145. package/config/router/routes.js +20 -2
  146. package/config/secret.ts +15 -0
  147. package/config/settings.ts +14 -15
  148. package/config/table-headers.js +59 -27
  149. package/config/types.js +2 -0
  150. package/core/plugin-helpers.ts +3 -2
  151. package/detail/catalog.cattle.io.app.vue +0 -1
  152. package/detail/fleet.cattle.io.cluster.vue +28 -15
  153. package/detail/fleet.cattle.io.gitrepo.vue +10 -1
  154. package/detail/fleet.cattle.io.helmop.vue +157 -0
  155. package/detail/provisioning.cattle.io.cluster.vue +13 -3
  156. package/detail/service.vue +0 -1
  157. package/detail/workload/index.vue +21 -34
  158. package/dialog/ExtensionCatalogUninstallDialog.vue +14 -8
  159. package/dialog/HelmOpForceUpdateDialog.vue +132 -0
  160. package/dialog/RedeployWorkloadDialog.vue +164 -0
  161. package/edit/__tests__/fleet.cattle.io.gitrepo.test.ts +56 -67
  162. package/edit/__tests__/service.test.ts +2 -1
  163. package/edit/auth/oidc.vue +159 -93
  164. package/edit/fleet.cattle.io.gitrepo.vue +26 -33
  165. package/edit/fleet.cattle.io.helmop.vue +997 -0
  166. package/edit/management.cattle.io.fleetworkspace.vue +43 -10
  167. package/edit/networking.k8s.io.networkpolicy/PolicyRule.vue +3 -14
  168. package/edit/networking.k8s.io.networkpolicy/PolicyRuleTarget.vue +57 -62
  169. package/edit/networking.k8s.io.networkpolicy/PolicyRules.vue +3 -14
  170. package/edit/networking.k8s.io.networkpolicy/__tests__/PolicyRuleTarget.test.ts +72 -41
  171. package/edit/networking.k8s.io.networkpolicy/__tests__/utils/mock.json +17 -1
  172. package/edit/networking.k8s.io.networkpolicy/index.vue +18 -30
  173. package/edit/provisioning.cattle.io.cluster/index.vue +21 -73
  174. package/edit/service.vue +13 -28
  175. package/list/fleet.cattle.io.gitrepo.vue +1 -1
  176. package/list/fleet.cattle.io.helmop.vue +108 -0
  177. package/list/namespace.vue +5 -2
  178. package/list/workload.vue +6 -1
  179. package/mixins/auth-config.js +8 -1
  180. package/mixins/preset.js +100 -0
  181. package/mixins/resource-fetch-api-pagination.js +57 -43
  182. package/mixins/resource-fetch.js +15 -6
  183. package/mixins/resource-table-watch.js +45 -0
  184. package/models/__tests__/chart.test.ts +273 -0
  185. package/models/__tests__/fleet.cattle.io.gitrepo.test.ts +1 -1
  186. package/models/__tests__/workload.test.ts +1 -0
  187. package/models/chart.js +144 -2
  188. package/models/cluster/node.js +1 -0
  189. package/models/cluster.js +32 -2
  190. package/models/fleet-application.js +385 -0
  191. package/models/fleet.cattle.io.bundle.js +9 -8
  192. package/models/fleet.cattle.io.gitrepo.js +41 -365
  193. package/models/fleet.cattle.io.helmop.js +228 -0
  194. package/models/management.cattle.io.authconfig.js +1 -0
  195. package/models/management.cattle.io.cluster.js +0 -20
  196. package/models/management.cattle.io.fleetworkspace.js +12 -0
  197. package/models/management.cattle.io.node.js +7 -22
  198. package/models/management.cattle.io.nodepool.js +12 -0
  199. package/models/namespace.js +5 -0
  200. package/models/provisioning.cattle.io.cluster.js +18 -64
  201. package/models/service.js +24 -9
  202. package/models/workload.js +84 -49
  203. package/package.json +2 -1
  204. package/pages/auth/verify.vue +13 -1
  205. package/pages/c/_cluster/apps/charts/AddRepoLink.vue +37 -0
  206. package/pages/c/_cluster/apps/charts/AppChartCardFooter.vue +80 -0
  207. package/pages/c/_cluster/apps/charts/AppChartCardSubHeader.vue +54 -0
  208. package/pages/c/_cluster/apps/charts/StatusLabel.vue +33 -0
  209. package/pages/c/_cluster/apps/charts/index.vue +302 -484
  210. package/pages/c/_cluster/apps/charts/install.vue +0 -1
  211. package/pages/c/_cluster/explorer/EventsTable.vue +1 -1
  212. package/pages/c/_cluster/explorer/index.vue +11 -0
  213. package/pages/c/_cluster/fleet/__tests__/index.test.ts +426 -0
  214. package/pages/c/_cluster/fleet/application/_resource/_id.vue +14 -0
  215. package/pages/c/_cluster/fleet/application/_resource/create.vue +14 -0
  216. package/pages/c/_cluster/fleet/application/create.vue +340 -0
  217. package/pages/c/_cluster/fleet/application/index.vue +139 -0
  218. package/pages/c/_cluster/fleet/graph/config.js +277 -0
  219. package/pages/c/_cluster/fleet/index.vue +772 -330
  220. package/pages/c/_cluster/longhorn/index.vue +2 -2
  221. package/pages/c/_cluster/settings/banners.vue +56 -2
  222. package/pages/c/_cluster/settings/performance.vue +7 -26
  223. package/pages/explorer/resource/detail/configmap.vue +19 -0
  224. package/pages/home.vue +11 -52
  225. package/plugins/clean-html.js +2 -0
  226. package/plugins/dashboard-store/__tests__/actions.test.ts +4 -1
  227. package/plugins/dashboard-store/actions.js +153 -30
  228. package/plugins/dashboard-store/getters.js +108 -24
  229. package/plugins/dashboard-store/mutations.js +61 -12
  230. package/plugins/dashboard-store/resource-class.js +36 -4
  231. package/plugins/steve/__tests__/getters.test.ts +18 -11
  232. package/plugins/steve/__tests__/steve-class.test.ts +1 -0
  233. package/plugins/steve/__tests__/subscribe.spec.ts +66 -1
  234. package/plugins/steve/actions.js +37 -12
  235. package/plugins/steve/getters.js +39 -10
  236. package/plugins/steve/steve-class.js +5 -0
  237. package/plugins/steve/steve-pagination-utils.ts +213 -50
  238. package/plugins/steve/subscribe.js +229 -42
  239. package/plugins/steve/worker/web-worker.advanced.js +3 -1
  240. package/rancher-components/BadgeState/BadgeState.vue +3 -1
  241. package/rancher-components/Banner/Banner.test.ts +51 -3
  242. package/rancher-components/Banner/Banner.vue +28 -6
  243. package/rancher-components/Form/Checkbox/Checkbox.vue +2 -2
  244. package/rancher-components/Form/LabeledInput/LabeledInput.test.ts +5 -1
  245. package/rancher-components/Form/ToggleSwitch/ToggleSwitch.vue +21 -1
  246. package/rancher-components/RcItemCard/RcItemCard.test.ts +189 -0
  247. package/rancher-components/RcItemCard/RcItemCard.vue +425 -0
  248. package/rancher-components/RcItemCard/RcItemCardAction.vue +24 -0
  249. package/rancher-components/RcItemCard/index.ts +2 -0
  250. package/store/auth.js +1 -0
  251. package/store/catalog.js +62 -24
  252. package/store/features.js +0 -1
  253. package/store/index.js +33 -14
  254. package/store/slideInPanel.ts +6 -0
  255. package/store/type-map.js +1 -0
  256. package/store/type-map.utils.ts +45 -2
  257. package/types/fleet.d.ts +36 -1
  258. package/types/kube/kube-api.ts +22 -0
  259. package/types/resources/settings.d.ts +19 -5
  260. package/types/shell/index.d.ts +595 -471
  261. package/types/store/dashboard-store.types.ts +41 -4
  262. package/types/store/pagination.types.ts +25 -3
  263. package/types/store/subscribe.types.ts +50 -0
  264. package/utils/auth.js +32 -3
  265. package/utils/cluster.js +24 -20
  266. package/utils/fleet-types.ts +0 -0
  267. package/utils/fleet.ts +200 -1
  268. package/utils/grafana.js +1 -0
  269. package/utils/object.js +0 -12
  270. package/utils/pagination-utils.ts +32 -3
  271. package/utils/pagination-wrapper.ts +132 -50
  272. package/utils/perf-setting.utils.ts +28 -0
  273. package/utils/selector-typed.ts +205 -0
  274. package/utils/selector.js +29 -6
  275. package/utils/settings.ts +4 -1
  276. package/utils/style.ts +39 -0
  277. package/utils/uiplugins.ts +10 -6
  278. package/utils/v-sphere.ts +5 -1
  279. package/utils/validators/formRules/__tests__/index.test.ts +36 -3
  280. package/utils/validators/formRules/index.ts +10 -3
  281. package/utils/window.js +11 -7
  282. package/components/__tests__/ApplicationCard.test.ts +0 -27
  283. package/components/cards/ApplicationCard.vue +0 -145
  284. package/components/fleet/ForceDirectedTreeChart/chartIcons.js +0 -17
  285. package/components/formatter/RKETemplateName.vue +0 -37
  286. package/config/secret.js +0 -14
  287. package/dialog/SaveAsRKETemplateDialog.vue +0 -139
  288. package/pages/c/_cluster/fleet/GitRepoGraphConfig.js +0 -249
  289. /package/{components/form/SSHKnownHosts → dialog}/__tests__/KnownHostsEditDialog.test.ts +0 -0
@@ -1,48 +1,11 @@
1
- import { convert, matching, convertSelectorObj } from '@shell/utils/selector';
2
- import jsyaml from 'js-yaml';
3
- import isEmpty from 'lodash/isEmpty';
4
- import { escapeHtml } from '@shell/utils/string';
5
- import { FLEET, MANAGEMENT } from '@shell/config/types';
6
- import { FLEET as FLEET_ANNOTATIONS } from '@shell/config/labels-annotations';
7
- import { addObject, addObjects, findBy, insertAt } from '@shell/utils/array';
8
1
  import { set } from '@shell/utils/object';
9
- import SteveModel from '@shell/plugins/steve/steve-class';
10
- import { mapStateToEnum, primaryDisplayStatusFromCount, STATES_ENUM } from '@shell/plugins/dashboard-store/resource-class';
2
+ import { insertAt } from '@shell/utils/array';
3
+ import { FLEET } from '@shell/config/types';
4
+ import { FLEET as FLEET_ANNOTATIONS } from '@shell/config/labels-annotations';
5
+ import FleetApplication from '@shell/models/fleet-application';
11
6
  import FleetUtils from '@shell/utils/fleet';
12
7
 
13
- function quacksLikeAHash(str) {
14
- if (str.match(/^[a-f0-9]{40,}$/i)) {
15
- return true;
16
- }
17
-
18
- return false;
19
- }
20
-
21
- function normalizeStateCounts(data) {
22
- if (isEmpty(data)) {
23
- return {
24
- total: 0,
25
- states: {},
26
- };
27
- }
28
- const { desiredReady, ...rest } = data ;
29
- const states = Object.entries(rest).reduce((res, [key, value]) => {
30
- res[mapStateToEnum(key)] = value;
31
-
32
- return res;
33
- }, {});
34
-
35
- return {
36
- total: desiredReady,
37
- states,
38
- };
39
- }
40
-
41
- export default class GitRepo extends SteveModel {
42
- get currentUser() {
43
- return this.$rootGetters['auth/v3User'] || {};
44
- }
45
-
8
+ export default class GitRepo extends FleetApplication {
46
9
  applyDefaults() {
47
10
  const spec = this.spec || {};
48
11
  const meta = this.metadata || {};
@@ -84,7 +47,7 @@ export default class GitRepo extends SteveModel {
84
47
  });
85
48
 
86
49
  insertAt(out, 2, {
87
- action: 'enablePolling',
50
+ action: 'enablePollingAction',
88
51
  label: this.t('fleet.gitRepo.actions.enablePolling.label'),
89
52
  icon: 'icon icon-endpoints_connected',
90
53
  bulkable: true,
@@ -92,7 +55,7 @@ export default class GitRepo extends SteveModel {
92
55
  });
93
56
 
94
57
  insertAt(out, 3, {
95
- action: 'disablePolling',
58
+ action: 'disablePollingAction',
96
59
  label: this.t('fleet.gitRepo.actions.disablePolling.label'),
97
60
  icon: 'icon icon-endpoints_disconnected',
98
61
  bulkable: true,
@@ -113,38 +76,6 @@ export default class GitRepo extends SteveModel {
113
76
  return out;
114
77
  }
115
78
 
116
- pause() {
117
- this.spec.paused = true;
118
- this.save();
119
- }
120
-
121
- unpause() {
122
- this.spec.paused = false;
123
- this.save();
124
- }
125
-
126
- enablePolling() {
127
- this.spec.disablePolling = false;
128
- this.save();
129
- }
130
-
131
- disablePolling() {
132
- this.spec.disablePolling = true;
133
- this.save();
134
- }
135
-
136
- goToClone() {
137
- if (this.metadata?.labels?.[FLEET_ANNOTATIONS.CREATED_BY_USER_ID]) {
138
- delete this.metadata.labels[FLEET_ANNOTATIONS.CREATED_BY_USER_ID];
139
- }
140
-
141
- if (this.metadata?.labels?.[FLEET_ANNOTATIONS.CREATED_BY_USER_NAME]) {
142
- delete this.metadata.labels[FLEET_ANNOTATIONS.CREATED_BY_USER_NAME];
143
- }
144
-
145
- super.goToClone();
146
- }
147
-
148
79
  forceUpdate(resources = [this]) {
149
80
  this.$dispatch('promptModal', {
150
81
  componentProps: { repositories: resources },
@@ -159,84 +90,35 @@ export default class GitRepo extends SteveModel {
159
90
  });
160
91
  }
161
92
 
162
- get state() {
163
- if (this.spec?.paused === true) {
164
- return 'paused';
165
- }
166
-
167
- return this.metadata?.state?.name || 'unknown';
93
+ get isWebhookConfigured() {
94
+ return !!this.status?.webhookCommit;
168
95
  }
169
96
 
170
- get targetClusters() {
171
- const workspace = this.$getters['byId'](FLEET.WORKSPACE, this.metadata.namespace);
172
- const clusters = workspace?.clusters || [];
173
- const groups = workspace?.clusterGroups || [];
174
-
175
- if (workspace?.id === 'fleet-local') {
176
- // should we be getting the clusters from workspace.clusters instead of having to rely on the groups,
177
- // which takes an additional request to be done on the Fleet dashboard screen?
178
- const local = findBy(groups, 'id', 'fleet-local/default');
97
+ get github() {
98
+ const value = this.spec.repo || '';
179
99
 
180
- if (local) {
181
- return local.targetClusters;
182
- }
100
+ const matchHttps = value.match(FleetUtils.GIT_HTTPS_REGEX);
183
101
 
184
- return [];
102
+ if (matchHttps) {
103
+ return matchHttps[1];
185
104
  }
186
105
 
187
- if (!this.spec.targets) {
188
- return [];
189
- }
106
+ const matchSSH = value.match(FleetUtils.GIT_SSH_REGEX);
190
107
 
191
- const out = [];
192
-
193
- for (const tgt of this.spec.targets) {
194
- if (tgt.clusterName) {
195
- const cluster = findBy(clusters, 'metadata.name', tgt.clusterName);
196
-
197
- if (cluster) {
198
- addObject(out, cluster);
199
- }
200
- } else if (tgt.clusterGroup) {
201
- const group = findBy(groups, {
202
- 'metadata.namespace': this.metadata.namespace,
203
- 'metadata.name': tgt.clusterGroup,
204
- });
205
-
206
- if (group) {
207
- addObjects(out, group.targetClusters);
208
- }
209
- } else if (tgt.clusterGroupSelector) {
210
- const expressions = convertSelectorObj(tgt.clusterGroupSelector);
211
- const matchingGroups = matching(groups, expressions);
212
-
213
- for (const group of matchingGroups) {
214
- addObjects(out, group.targetClusters);
215
- }
216
- } else if (tgt.clusterSelector) {
217
- const expressions = convertSelectorObj(tgt.clusterSelector);
218
- const matchingClusters = matching(clusters, expressions);
219
-
220
- addObjects(out, matchingClusters);
221
- }
108
+ if (matchSSH) {
109
+ return FleetUtils.parseSSHUrl(matchSSH[0]).repoPath;
222
110
  }
223
111
 
224
- return out;
112
+ return false;
225
113
  }
226
114
 
227
- get github() {
228
- const match = (this.spec.repo || '').match(/^https?:\/\/github\.com\/(.*?)(\.git)?\/*$/);
229
-
230
- if (match) {
231
- return match[1];
232
- }
233
-
234
- return false;
115
+ get dashboardIcon() {
116
+ return FleetUtils.dashboardIcons[FLEET.GIT_REPO];
235
117
  }
236
118
 
237
- get repoIcon() {
119
+ get resourceIcon() {
238
120
  if (this.github) {
239
- return 'icon icon-github';
121
+ return FleetUtils.resourceIcons[FLEET.GIT_REPO];
240
122
  }
241
123
 
242
124
  return '';
@@ -249,14 +131,14 @@ export default class GitRepo extends SteveModel {
249
131
  return null;
250
132
  }
251
133
 
252
- repo = repo.replace(/.git$/, '');
253
- repo = repo.replace(/^https:\/\//, '');
254
- repo = repo.replace(/\/+$/, '');
255
-
256
134
  if (this.github) {
257
135
  return this.github;
258
136
  }
259
137
 
138
+ repo = repo.replace(/.git$/, '');
139
+ repo = repo.replace(/^https:\/\//, '');
140
+ repo = repo.replace(/\/+$/, '');
141
+
260
142
  return repo;
261
143
  }
262
144
 
@@ -268,7 +150,7 @@ export default class GitRepo extends SteveModel {
268
150
  return null;
269
151
  }
270
152
 
271
- if (spec.revision && quacksLikeAHash(spec.revision)) {
153
+ if (spec.revision && FleetUtils.quacksLikeAHash(spec.revision)) {
272
154
  return spec.revision.substr(0, 7);
273
155
  } else if (spec.revision) {
274
156
  return spec.revision;
@@ -279,99 +161,6 @@ export default class GitRepo extends SteveModel {
279
161
  return hash;
280
162
  }
281
163
 
282
- get targetInfo() {
283
- let mode = null;
284
- let cluster = null;
285
- let clusterGroup = null;
286
- let advanced = null;
287
-
288
- const targets = this.spec.targets || [];
289
-
290
- advanced = jsyaml.dump(targets);
291
-
292
- if (advanced === '[]\n') {
293
- advanced = `# - name:
294
- # clusterSelector:
295
- # matchLabels:
296
- # foo: bar
297
- # matchExpressions:
298
- # - key: foo
299
- # op: In
300
- # values: [bar, baz]
301
- # clusterGroup: foo
302
- # clusterGroupSelector:
303
- # matchLabels:
304
- # foo: bar
305
- # matchExpressions:
306
- # - key: foo
307
- # op: In
308
- # values: [bar, baz]
309
- `;
310
- }
311
-
312
- if (this.metadata.namespace === 'fleet-local') {
313
- mode = 'local';
314
- } else if (!targets.length) {
315
- mode = 'none';
316
- } else if (targets.length === 1) {
317
- const target = targets[0];
318
-
319
- if (Object.keys(target).length > 1) {
320
- // There are multiple properties in a single target, so use the 'advanced' mode
321
- // (otherwise any existing content is nuked for what we provide)
322
- mode = 'advanced';
323
- } else if (target.clusterGroup) {
324
- clusterGroup = target.clusterGroup;
325
-
326
- if (!mode) {
327
- mode = 'clusterGroup';
328
- }
329
- } else if (target.clusterName) {
330
- mode = 'cluster';
331
- cluster = target.clusterName;
332
- } else if (target.clusterSelector) {
333
- if (Object.keys(target.clusterSelector).length === 0) {
334
- mode = 'all';
335
- } else {
336
- const expressions = convert(target.clusterSelector.matchLabels, target.clusterSelector.matchExpressions);
337
-
338
- if (expressions.length === 1 &&
339
- expressions[0].key === FLEET_ANNOTATIONS.CLUSTER_NAME &&
340
- expressions[0].operator === 'In' &&
341
- expressions[0].values.length === 1
342
- ) {
343
- cluster = expressions[0].values[0];
344
- if (!mode) {
345
- mode = 'cluster';
346
- }
347
- }
348
- }
349
- }
350
- }
351
-
352
- if (!mode) {
353
- mode = 'advanced';
354
- }
355
-
356
- return {
357
- mode,
358
- modeDisplay: this.t(`fleet.gitRepo.targetDisplay."${ mode }"`),
359
- cluster,
360
- clusterGroup,
361
- advanced
362
- };
363
- }
364
-
365
- get groupByLabel() {
366
- const name = this.metadata.namespace;
367
-
368
- if (name) {
369
- return this.$rootGetters['i18n/t']('resourceTable.groupLabel.workspace', { name: escapeHtml(name) });
370
- } else {
371
- return this.$rootGetters['i18n/t']('resourceTable.groupLabel.notInAWorkspace');
372
- }
373
- }
374
-
375
164
  get bundles() {
376
165
  return this.$getters['matching'](FLEET.BUNDLE, { [FLEET_ANNOTATIONS.REPO_NAME]: this.name }, this.namespace);
377
166
  }
@@ -380,143 +169,30 @@ export default class GitRepo extends SteveModel {
380
169
  return this.$getters['matching'](FLEET.BUNDLE_DEPLOYMENT, { [FLEET_ANNOTATIONS.REPO_NAME]: this.name });
381
170
  }
382
171
 
383
- get allBundlesStatuses() {
384
- return this.bundles.reduce((acc, bundle) => {
385
- if (isEmpty(bundle.status?.summary)) {
386
- return acc;
387
- }
388
-
389
- const { nonReadyResources, ...summary } = bundle.status?.summary;
390
-
391
- const bdCounts = normalizeStateCounts(summary);
392
- const state = primaryDisplayStatusFromCount(bdCounts.states);
393
-
394
- if (!acc.states[state]) {
395
- acc.states[state] = 0;
396
- }
397
- acc.states[state]++;
398
- acc.total++;
399
-
400
- return acc;
401
- }, { total: 0, states: { [STATES_ENUM.READY]: 0 } } );
402
- }
403
-
404
- get allResourceStatuses() {
405
- return normalizeStateCounts(this.status?.resourceCounts || {});
406
- }
172
+ get source() {
173
+ let value = this.spec.repo || '';
407
174
 
408
- statusResourceCountsForCluster(clusterId) {
409
- if (!this.targetClusters.some((c) => c.id === clusterId)) {
410
- return {};
411
- }
175
+ const matchHttps = value.match(FleetUtils.GIT_HTTPS_REGEX);
176
+ const matchSSH = value.match(FleetUtils.GIT_SSH_REGEX);
412
177
 
413
- return this.status?.perClusterResourceCounts[clusterId] || { desiredReady: 0 };
414
- }
178
+ if (matchSSH) {
179
+ const { sshUserAndHost, repoPath } = FleetUtils.parseSSHUrl(matchSSH[0]);
415
180
 
416
- get resourcesStatuses() {
417
- if (isEmpty(this.status?.resources)) {
418
- return [];
181
+ value = `https://${ sshUserAndHost.replace('git@', '') }/${ repoPath }`;
419
182
  }
420
183
 
421
- const clusters = (this.targetClusters || []).reduce((res, c) => {
422
- res[c.id] = c;
423
-
424
- return res;
425
- }, {});
426
- const resources = this.status?.resources?.reduce((acc, resourceInfo) => {
427
- const { perClusterState, ...resource } = resourceInfo;
428
-
429
- Object.entries(perClusterState).forEach(([state, clusterIds]) => {
430
- clusterIds.filter((id) => !!clusters[id]).forEach((clusterId) => {
431
- acc.push(Object.assign({}, resource, { clusterId, state }));
432
- });
433
- });
434
-
435
- return acc;
436
- }, []);
437
-
438
- return resources.map((r) => {
439
- const { namespace, name, clusterId } = r;
440
- const type = FleetUtils.resourceType(r);
441
- const c = clusters[clusterId];
442
-
443
- return {
444
- key: `${ clusterId }-${ type }-${ namespace }-${ name }`,
445
-
446
- // Needed?
447
- id: FleetUtils.resourceId(r),
448
- type,
449
- clusterId,
450
-
451
- // columns, see FleetResources.vue
452
- state: mapStateToEnum(r.state),
453
- clusterName: c.nameDisplay,
454
- apiVersion: r.apiVersion,
455
- kind: r.kind,
456
- name,
457
- namespace,
458
-
459
- // other properties
460
- detailLocation: FleetUtils.detailLocation(r, c.metadata.labels[FLEET_ANNOTATIONS.CLUSTER_NAME]),
461
- };
462
- });
463
- }
464
-
465
- get clusterInfo() {
466
- const ready = this.status?.readyClusters || 0;
467
- const total = this.status?.desiredReadyClusters || 0;
468
-
469
184
  return {
470
- ready,
471
- unready: total - ready,
472
- total,
185
+ value,
186
+ display: this.repoDisplay,
187
+ icon: this.resourceIcon,
188
+ showLink: matchHttps || matchSSH
473
189
  };
474
190
  }
475
191
 
476
- clusterState(clusterId) {
477
- const resourceCounts = this.statusResourceCountsForCluster(clusterId);
478
-
479
- return primaryDisplayStatusFromCount(resourceCounts) || STATES_ENUM.ACTIVE;
480
- }
481
-
482
- get clustersList() {
483
- return this.$getters['all'](FLEET.CLUSTER);
484
- }
485
-
486
- get authorId() {
487
- return this.metadata?.labels?.[FLEET_ANNOTATIONS.CREATED_BY_USER_ID];
488
- }
489
-
490
- get author() {
491
- if (this.authorId) {
492
- return this.$rootGetters['management/byId'](MANAGEMENT.USER, this.authorId);
493
- }
494
-
495
- return null;
496
- }
497
-
498
- get createdBy() {
499
- const displayName = this.metadata?.labels?.[FLEET_ANNOTATIONS.CREATED_BY_USER_NAME];
500
-
501
- if (!displayName) {
502
- return null;
503
- }
504
-
192
+ get sourceSub() {
505
193
  return {
506
- displayName,
507
- location: !this.author ? null : {
508
- name: 'c-cluster-product-resource-id',
509
- params: {
510
- cluster: '_',
511
- product: 'auth',
512
- resource: MANAGEMENT.USER,
513
- id: this.author.id,
514
- }
515
- }
194
+ value: this.status?.commit,
195
+ display: this.commitDisplay
516
196
  };
517
197
  }
518
-
519
- get showCreatedBy() {
520
- return !!this.createdBy;
521
- }
522
198
  }