@rancher/shell 3.0.5-rc.5 → 3.0.5-rc.7
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.
- package/assets/data/aws-regions.json +1 -0
- package/assets/images/key.svg +17 -0
- package/assets/styles/base/_spacing.scss +2 -2
- package/assets/styles/base/_variables.scss +17 -11
- package/assets/styles/global/_form.scss +1 -1
- package/assets/styles/global/_labeled-input.scss +1 -1
- package/assets/styles/themes/_dark.scss +5 -0
- package/assets/styles/themes/_light.scss +11 -2
- package/assets/styles/vendor/vue-select.scss +1 -1
- package/assets/translations/en-us.yaml +426 -64
- package/assets/translations/zh-hans.yaml +3 -4
- package/cloud-credential/gcp.vue +9 -1
- package/components/AppModal.vue +2 -0
- package/components/CodeMirror.vue +2 -2
- package/components/ConfigMapSettings/Settings.vue +377 -0
- package/components/ConfigMapSettings/index.vue +354 -0
- package/components/CruResource.vue +1 -2
- package/components/DetailText.vue +61 -11
- package/components/Drawer/Chrome.vue +115 -0
- package/components/Drawer/ResourceDetailDrawer/ConfigTab.vue +61 -0
- package/components/Drawer/ResourceDetailDrawer/YamlTab.vue +48 -0
- package/components/Drawer/ResourceDetailDrawer/__tests__/ConfigTab.test.ts +54 -0
- package/components/Drawer/ResourceDetailDrawer/__tests__/YamlTab.test.ts +80 -0
- package/components/Drawer/ResourceDetailDrawer/__tests__/composables.test.ts +106 -0
- package/components/Drawer/ResourceDetailDrawer/__tests__/helpers.test.ts +42 -0
- package/components/Drawer/ResourceDetailDrawer/composables.ts +53 -0
- package/components/Drawer/ResourceDetailDrawer/helpers.ts +10 -0
- package/components/Drawer/ResourceDetailDrawer/index.vue +111 -0
- package/components/GrowlManager.vue +16 -15
- package/components/IconOrSvg.vue +5 -0
- package/components/KeyValueView.vue +1 -1
- package/components/Loading.vue +1 -1
- package/components/LocaleSelector.vue +9 -1
- package/components/PaginatedResourceTable.vue +46 -1
- package/components/ProgressBarMulti.vue +1 -0
- package/components/PromptModal.vue +6 -1
- package/components/PromptRestore.vue +22 -44
- package/components/RelatedResources.vue +4 -12
- package/components/Resource/Detail/Additional.vue +46 -0
- package/components/Resource/Detail/Metadata/Annotations/__tests__/index.test.ts +1 -1
- package/components/Resource/Detail/Metadata/Annotations/index.vue +5 -0
- package/components/Resource/Detail/Metadata/IdentifyingInformation/__tests__/identifying-fields.test.ts +223 -0
- package/components/Resource/Detail/Metadata/IdentifyingInformation/composable.ts +47 -256
- package/components/Resource/Detail/Metadata/IdentifyingInformation/identifying-fields.ts +317 -0
- package/components/Resource/Detail/Metadata/IdentifyingInformation/index.vue +34 -5
- package/components/Resource/Detail/Metadata/KeyValue.vue +32 -22
- package/components/Resource/Detail/Metadata/Labels/__tests__/index.test.ts +1 -1
- package/components/Resource/Detail/Metadata/Labels/index.vue +4 -0
- package/components/Resource/Detail/Metadata/Rectangle.vue +3 -1
- package/components/Resource/Detail/Metadata/__tests__/KeyValue.test.ts +1 -1
- package/components/Resource/Detail/Metadata/__tests__/Rectangle.test.ts +1 -1
- package/components/Resource/Detail/Metadata/__tests__/composables.test.ts +75 -0
- package/components/Resource/Detail/Metadata/composables.ts +60 -11
- package/components/Resource/Detail/Metadata/index.vue +12 -5
- package/components/Resource/Detail/Page.vue +15 -0
- package/components/Resource/Detail/ResourceRow.vue +37 -18
- package/components/Resource/Detail/ResourceTabs/ConfigMapDataTab/__tests__/composables.test.ts +29 -0
- package/components/Resource/Detail/ResourceTabs/ConfigMapDataTab/__tests__/index.test.ts +48 -0
- package/components/Resource/Detail/ResourceTabs/ConfigMapDataTab/composables.ts +31 -0
- package/components/Resource/Detail/ResourceTabs/ConfigMapDataTab/index.vue +50 -0
- package/components/Resource/Detail/ResourceTabs/KnownHostsTab/__tests__/composables.test.ts +66 -0
- package/components/Resource/Detail/ResourceTabs/KnownHostsTab/composables.ts +21 -0
- package/components/Resource/Detail/ResourceTabs/KnownHostsTab/index.vue +31 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/Basic.vue +45 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/BasicAuth.vue +31 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/Certificate.vue +31 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/Registry.vue +22 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/ServiceAccountToken.vue +31 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/Ssh.vue +32 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/__tests__/Basic.test.ts +40 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/__tests__/BasicAuth.test.ts +33 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/__tests__/Certificate.test.ts +33 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/__tests__/Registry.test.ts +27 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/__tests__/ServiceAccountToken.test.ts +33 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/__tests__/Ssh.test.ts +33 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/__tests__/auth-types.test.ts +186 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/__tests__/composables.test.ts +102 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/auth-types.ts +109 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/composeables.ts +52 -0
- package/components/Resource/Detail/ResourceTabs/SecretDataTab/index.vue +71 -0
- package/components/Resource/Detail/SpacedRow.vue +1 -1
- package/components/Resource/Detail/TitleBar/Title.vue +2 -1
- package/components/Resource/Detail/TitleBar/__tests__/Title.test.ts +1 -1
- package/components/Resource/Detail/TitleBar/__tests__/Top.test.ts +1 -1
- package/components/Resource/Detail/TitleBar/__tests__/composables.test.ts +63 -0
- package/components/Resource/Detail/TitleBar/__tests__/index.test.ts +1 -1
- package/components/Resource/Detail/TitleBar/composables.ts +45 -0
- package/components/Resource/Detail/TitleBar/index.vue +85 -13
- package/components/Resource/Detail/composables.ts +45 -0
- package/components/ResourceDetail/Masthead/__tests__/index.test.ts +70 -0
- package/components/ResourceDetail/{__tests__/Masthead.test.ts → Masthead/__tests__/legacy.test.ts} +3 -3
- package/components/ResourceDetail/Masthead/index.vue +65 -0
- package/components/ResourceDetail/Masthead/latest.vue +44 -0
- package/components/ResourceDetail/{Masthead.vue → Masthead/legacy.vue} +1 -1
- package/components/ResourceDetail/__tests__/index.test.ts +26 -5
- package/components/ResourceDetail/index.vue +33 -17
- package/components/ResourceDetail/legacy.vue +18 -1
- package/components/ResourceList/Masthead.vue +6 -0
- package/components/ResourceList/index.vue +1 -0
- package/components/ResourceTable.vue +6 -1
- package/components/ResourceYaml.vue +15 -2
- package/components/RichTranslation.vue +106 -0
- package/components/SlideInPanelManager.vue +46 -11
- package/components/SortableTable/index.vue +1 -1
- package/components/SortableTable/selection.js +0 -1
- package/components/StateDot/index.vue +28 -0
- package/components/Tabbed/index.vue +17 -16
- package/components/Wizard.vue +4 -2
- package/components/__tests__/ConfigMapSettings.test.ts +376 -0
- package/components/__tests__/GrowlManager.test.ts +0 -25
- package/components/__tests__/PromptRestore.test.ts +1 -65
- package/components/__tests__/RichTranslation.test.ts +115 -0
- package/components/auth/login/ldap.vue +1 -1
- package/components/fleet/FleetApplications.vue +0 -7
- package/components/fleet/FleetClusterTargets/TargetsList.vue +66 -0
- package/components/fleet/FleetClusterTargets/index.vue +455 -0
- package/components/fleet/FleetClusters.vue +25 -6
- package/components/fleet/FleetGitRepoPaths.vue +476 -0
- package/components/fleet/FleetHelmOps.vue +8 -0
- package/components/fleet/FleetRepos.vue +1 -6
- package/components/fleet/FleetResources.vue +4 -5
- package/components/fleet/FleetValuesFrom.vue +295 -0
- package/components/fleet/__tests__/FleetClusterTargets.test.ts +1224 -0
- package/components/fleet/__tests__/FleetGitRepoPaths.test.ts +265 -0
- package/components/fleet/__tests__/FleetOCIStorageSecret.test.ts +13 -13
- package/components/fleet/__tests__/FleetValuesFrom.test.ts +300 -0
- package/components/fleet/dashboard/ResourceCard.vue +1 -0
- package/components/fleet/dashboard/ResourceCardSummary.vue +1 -5
- package/components/fleet/dashboard/ResourceDetails.vue +8 -10
- package/components/fleet/dashboard/ResourcePanel.vue +17 -9
- package/components/form/ArrayList.vue +13 -2
- package/components/form/ChangePassword.vue +3 -1
- package/components/form/FileImageSelector.vue +1 -1
- package/components/form/Footer.vue +10 -4
- package/components/form/KeyValue.vue +81 -43
- package/components/form/LabeledSelect.vue +56 -16
- package/components/form/Labels.vue +90 -17
- package/components/form/MatchExpressions.vue +46 -5
- package/components/form/NameNsDescription.vue +2 -1
- package/components/form/Networking.vue +24 -19
- package/components/form/ResourceLabeledSelect.vue +4 -3
- package/components/form/ResourceSelector.vue +1 -0
- package/components/form/ResourceTabs/index.vue +5 -0
- package/components/form/SecretSelector.vue +9 -2
- package/components/form/Select.vue +57 -19
- package/components/form/SelectOrCreateAuthSecret.vue +6 -3
- package/components/form/SimpleSecretSelector.vue +9 -2
- package/components/form/Taints.vue +21 -2
- package/components/form/UnitInput.vue +8 -0
- package/components/form/ValueFromResource.vue +1 -1
- package/components/form/__tests__/LabeledSelect.test.ts +8 -4
- package/components/form/__tests__/Labels.test.ts +360 -0
- package/components/form/__tests__/MatchExpressions.test.ts +16 -13
- package/components/form/__tests__/Networking.test.ts +116 -0
- package/components/form/__tests__/Select.test.ts +5 -2
- package/components/formatter/FleetApplicationSource.vue +1 -1
- package/components/formatter/PodImages.vue +1 -1
- package/components/formatter/WorkloadHealthScale.vue +1 -1
- package/components/formatter/__tests__/LiveDate.test.ts +10 -2
- package/components/google/AccountAccess.vue +209 -0
- package/components/google/types/gcp.d.ts +136 -0
- package/components/google/types/index.d.ts +101 -0
- package/components/google/util/__mocks__/gcp.ts +465 -0
- package/components/google/util/formatter.ts +82 -0
- package/components/google/util/gcp.ts +134 -0
- package/components/google/util/index.d.ts +11 -0
- package/components/nav/Favorite.vue +1 -1
- package/components/nav/Group.vue +71 -45
- package/components/nav/Header.vue +5 -1
- package/components/nav/NamespaceFilter.vue +13 -1
- package/components/nav/NotificationCenter/Notification.vue +510 -0
- package/components/nav/NotificationCenter/NotificationHeader.vue +112 -0
- package/components/nav/NotificationCenter/index.vue +148 -0
- package/composables/drawer.ts +26 -0
- package/composables/resources.test.ts +63 -0
- package/composables/resources.ts +38 -0
- package/composables/useIsNewDetailPageEnabled.ts +17 -0
- package/config/labels-annotations.js +8 -0
- package/config/pagination-table-headers.js +8 -1
- package/config/product/auth.js +16 -1
- package/config/product/{cis.js → compliance.js} +23 -26
- package/config/product/explorer.js +32 -3
- package/config/product/fleet.js +7 -0
- package/config/product/manager.js +0 -1
- package/config/product/settings.js +22 -11
- package/config/query-params.js +13 -0
- package/config/roles.ts +1 -1
- package/config/router/navigation-guards/authentication.js +51 -2
- package/config/router/routes.js +47 -31
- package/config/settings.ts +21 -3
- package/config/store.js +2 -0
- package/config/system-namespaces.js +1 -1
- package/config/table-headers.js +32 -3
- package/config/types.js +16 -7
- package/config/version.js +1 -1
- package/core/plugin.ts +32 -7
- package/core/types.ts +18 -1
- package/detail/{cis.cattle.io.clusterscan.vue → compliance.cattle.io.clusterscan.vue} +22 -18
- package/detail/management.cattle.io.fleetworkspace.vue +18 -27
- package/detail/management.cattle.io.oidcclient.vue +369 -0
- package/detail/node.vue +2 -2
- package/detail/pod.vue +2 -2
- package/detail/provisioning.cattle.io.cluster.vue +3 -47
- package/detail/service.vue +10 -1
- package/detail/workload/index.vue +8 -2
- package/dialog/ExtensionCatalogUninstallDialog.vue +7 -4
- package/dialog/GenericPrompt.vue +1 -1
- package/dialog/ImportDialog.vue +8 -8
- package/dialog/OidcClientSecretDialog.vue +117 -0
- package/dialog/RotateEncryptionKeyDialog.vue +10 -30
- package/edit/__tests__/cis.cattle.io.clusterscan.test.ts +3 -3
- package/edit/__tests__/fleet.cattle.io.gitrepo.test.ts +5 -2
- package/edit/auth/ldap/__tests__/config.test.ts +14 -0
- package/edit/auth/ldap/config.vue +24 -0
- package/edit/autoscaling.horizontalpodautoscaler/index.vue +4 -1
- package/edit/{cis.cattle.io.clusterscan.vue → compliance.cattle.io.clusterscan.vue} +30 -31
- package/edit/{cis.cattle.io.clusterscanbenchmark.vue → compliance.cattle.io.clusterscanbenchmark.vue} +4 -4
- package/edit/{cis.cattle.io.clusterscanprofile.vue → compliance.cattle.io.clusterscanprofile.vue} +5 -5
- package/edit/configmap.vue +8 -2
- package/edit/constraints.gatekeeper.sh.constraint/index.vue +1 -0
- package/edit/fleet.cattle.io.gitrepo.vue +44 -222
- package/edit/fleet.cattle.io.helmop.vue +44 -269
- package/edit/helm.cattle.io.projecthelmchart.vue +1 -0
- package/edit/k8s.cni.cncf.io.networkattachmentdefinition.vue +1 -0
- package/edit/logging-flow/index.vue +1 -0
- package/edit/logging.banzaicloud.io.output/index.vue +1 -0
- package/edit/management.cattle.io.fleetworkspace.vue +1 -0
- package/edit/management.cattle.io.oidcclient.vue +162 -0
- package/edit/management.cattle.io.project.vue +4 -1
- package/edit/monitoring.coreos.com.alertmanagerconfig/index.vue +1 -1
- package/edit/monitoring.coreos.com.alertmanagerconfig/receiverConfig.vue +5 -0
- package/edit/monitoring.coreos.com.prometheusrule/index.vue +1 -0
- package/edit/monitoring.coreos.com.receiver/auth.vue +30 -30
- package/edit/monitoring.coreos.com.receiver/index.vue +1 -0
- package/edit/monitoring.coreos.com.receiver/types/email.vue +1 -1
- package/edit/monitoring.coreos.com.route.vue +1 -0
- package/edit/namespace.vue +1 -0
- package/edit/networking.istio.io.destinationrule/index.vue +4 -1
- package/edit/networking.k8s.io.ingress/Certificate.vue +12 -12
- package/edit/networking.k8s.io.ingress/__tests__/Certificate.test.ts +165 -0
- package/edit/networking.k8s.io.ingress/index.vue +4 -1
- package/edit/networking.k8s.io.networkpolicy/PolicyRules.vue +7 -2
- package/edit/networking.k8s.io.networkpolicy/index.vue +6 -2
- package/edit/node.vue +1 -0
- package/edit/persistentvolume/index.vue +4 -1
- package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +3 -2
- package/edit/provisioning.cattle.io.cluster/rke2.vue +516 -426
- package/edit/provisioning.cattle.io.cluster/tabs/Basics.vue +48 -39
- package/edit/provisioning.cattle.io.cluster/tabs/MachinePool.vue +5 -0
- package/edit/provisioning.cattle.io.cluster/tabs/registries/RegistryConfigs.vue +2 -2
- package/edit/resources.cattle.io.restore.vue +1 -1
- package/edit/secret/basic.vue +1 -0
- package/edit/secret/index.vue +127 -15
- package/edit/service.vue +4 -1
- package/edit/serviceaccount.vue +4 -1
- package/edit/storage.k8s.io.storageclass/index.vue +4 -1
- package/edit/workload/index.vue +5 -0
- package/list/{cis.cattle.io.clusterscan.vue → compliance.cattle.io.clusterscan.vue} +2 -2
- package/list/management.cattle.io.oidcclient.vue +108 -0
- package/list/node.vue +2 -0
- package/list/projectsecret.vue +345 -0
- package/list/secret.vue +109 -0
- package/machine-config/amazonec2.vue +3 -24
- package/machine-config/components/GCEImage.vue +374 -0
- package/machine-config/google.vue +617 -0
- package/mixins/__tests__/brand.spec.ts +170 -0
- package/mixins/brand.js +16 -17
- package/mixins/create-edit-view/impl.js +10 -1
- package/mixins/create-edit-view/index.js +5 -0
- package/mixins/resource-fetch-api-pagination.js +24 -8
- package/mixins/resource-fetch.js +3 -1
- package/mixins/vue-select-overrides.js +1 -0
- package/models/cluster.x-k8s.io.machinedeployment.js +11 -2
- package/models/{cis.cattle.io.clusterscan.js → compliance.cattle.io.clusterscan.js} +8 -8
- package/models/{cis.cattle.io.clusterscanbenchmark.js → compliance.cattle.io.clusterscanbenchmark.js} +1 -1
- package/models/{cis.cattle.io.clusterscanprofile.js → compliance.cattle.io.clusterscanprofile.js} +5 -5
- package/models/{cis.cattle.io.clusterscanreport.js → compliance.cattle.io.clusterscanreport.js} +1 -1
- package/models/fleet-application.js +8 -79
- package/models/fleet.cattle.io.cluster.js +13 -2
- package/models/fleet.cattle.io.gitrepo.js +2 -2
- package/models/fleet.cattle.io.helmop.js +9 -39
- package/models/management.cattle.io.fleetworkspace.js +2 -1
- package/models/management.cattle.io.oidcclient.js +18 -0
- package/models/management.cattle.io.registration.js +3 -0
- package/models/provisioning.cattle.io.cluster.js +29 -33
- package/models/secret.js +157 -2
- package/models/service.js +4 -0
- package/models/workload.js +5 -0
- package/package.json +2 -2
- package/pages/about.vue +4 -58
- package/pages/auth/login.vue +1 -1
- package/pages/c/_cluster/apps/charts/AddRepoLink.vue +0 -1
- package/pages/c/_cluster/apps/charts/index.vue +296 -81
- package/pages/c/_cluster/auth/user.retention/index.vue +87 -78
- package/pages/c/_cluster/explorer/index.vue +3 -3
- package/pages/c/_cluster/explorer/projectsecret.vue +34 -0
- package/pages/c/_cluster/explorer/tools/pages/_page.vue +0 -1
- package/pages/c/_cluster/fleet/application/create.vue +3 -2
- package/pages/c/_cluster/fleet/index.vue +94 -57
- package/pages/c/_cluster/fleet/settings/index.vue +229 -0
- package/pages/c/_cluster/longhorn/index.vue +5 -2
- package/pages/c/_cluster/uiplugins/CatalogList/index.vue +16 -1
- package/pages/c/_cluster/uiplugins/PluginInfoPanel.vue +2 -2
- package/pages/explorer/resource/detail/configmap.vue +30 -7
- package/pages/explorer/resource/detail/projectsecret.vue +9 -0
- package/pages/explorer/resource/detail/secret.vue +63 -0
- package/pages/home.vue +9 -55
- package/pages/support/index.vue +4 -6
- package/plugins/dashboard-store/__tests__/normalize.test.ts +223 -0
- package/plugins/dashboard-store/__tests__/resource-class.test.ts +191 -0
- package/plugins/dashboard-store/__tests__/utils/normalize-usecases.ts +1526 -0
- package/plugins/dashboard-store/actions.js +19 -5
- package/plugins/dashboard-store/getters.js +4 -0
- package/plugins/dashboard-store/normalize.js +29 -17
- package/plugins/dashboard-store/resource-class.js +68 -19
- package/plugins/steve/steve-pagination-utils.ts +38 -19
- package/plugins/steve/subscribe.js +6 -1
- package/rancher-components/Banner/Banner.vue +13 -0
- package/rancher-components/Form/Checkbox/Checkbox.vue +9 -4
- package/rancher-components/Form/LabeledInput/LabeledInput.vue +1 -1
- package/rancher-components/LabeledTooltip/LabeledTooltip.vue +1 -0
- package/rancher-components/RcItemCard/RcItemCard.vue +8 -3
- package/store/auth.js +2 -0
- package/store/catalog.js +23 -1
- package/store/growl.js +97 -8
- package/store/index.js +6 -0
- package/store/notifications.ts +426 -0
- package/store/prefs.js +0 -1
- package/store/type-map.js +19 -16
- package/store/uiplugins.ts +15 -1
- package/types/fleet.d.ts +24 -0
- package/types/kube/kube-api.ts +12 -0
- package/types/notifications/index.ts +74 -0
- package/types/shell/index.d.ts +661 -589
- package/types/store/dashboard-store.types.ts +16 -0
- package/types/store/pagination.types.ts +16 -6
- package/utils/__tests__/create-yaml.test.ts +235 -0
- package/utils/__tests__/fleet.test.ts +148 -0
- package/utils/__tests__/object.test.ts +54 -1
- package/utils/__tests__/string.test.ts +273 -1
- package/utils/__tests__/time.test.ts +31 -0
- package/utils/auth.js +9 -2
- package/utils/create-yaml.js +103 -9
- package/utils/crypto/encryption.ts +103 -0
- package/utils/cspAdaptor.ts +51 -0
- package/utils/fleet.ts +54 -65
- package/utils/object.js +36 -0
- package/utils/pagination-utils.ts +19 -1
- package/utils/release-notes.ts +48 -0
- package/utils/selector-typed.ts +7 -2
- package/utils/string.js +24 -0
- package/utils/{time.js → time.ts} +25 -6
- package/utils/uiplugins.ts +22 -0
- package/utils/validators/formRules/index.ts +3 -0
- package/components/Resource/Detail/TitleBar/composable.ts +0 -31
- package/config/product/legacy.js +0 -62
- package/models/etcdbackup.js +0 -45
- package/pages/c/_cluster/legacy/pages/_page.vue +0 -29
- package/pages/c/_cluster/legacy/project/_page.vue +0 -57
- package/pages/c/_cluster/legacy/project/index.vue +0 -32
- package/pages/c/_cluster/legacy/project/pipelines.vue +0 -96
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { decodeHtml, resourceNames } from '@shell/utils/string';
|
|
1
|
+
import { decodeHtml, resourceNames, pathArrayToTree } from '@shell/utils/string';
|
|
2
2
|
|
|
3
3
|
describe('fx: decodeHtml', () => {
|
|
4
4
|
it('should decode HTML values from escaped string into valid markup', () => {
|
|
@@ -89,3 +89,275 @@ describe('fx: resourceNames', () => {
|
|
|
89
89
|
});
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
|
+
|
|
93
|
+
describe('fx: pathArrayToTree', () => {
|
|
94
|
+
interface TreeNode {
|
|
95
|
+
name: string;
|
|
96
|
+
children: TreeNode[];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function sortTree(nodes: TreeNode[]): void {
|
|
100
|
+
if (!nodes) return;
|
|
101
|
+
nodes.sort((a, b) => a.name.localeCompare(b.name));
|
|
102
|
+
nodes.forEach((node) => {
|
|
103
|
+
if (node.children && node.children.length > 0) {
|
|
104
|
+
sortTree(node.children);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
it('should return an empty array for an empty input array', () => {
|
|
110
|
+
const paths: string[] = [];
|
|
111
|
+
|
|
112
|
+
expect(pathArrayToTree(paths)).toStrictEqual([]);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should convert simple single-level paths correctly', () => {
|
|
116
|
+
const paths: string[] = [
|
|
117
|
+
'file1.txt',
|
|
118
|
+
'folderA',
|
|
119
|
+
'itemB'
|
|
120
|
+
];
|
|
121
|
+
const expected: TreeNode[] = [
|
|
122
|
+
{ name: 'file1.txt', children: [] },
|
|
123
|
+
{ name: 'folderA', children: [] },
|
|
124
|
+
{ name: 'itemB', children: [] },
|
|
125
|
+
];
|
|
126
|
+
const actual = pathArrayToTree(paths);
|
|
127
|
+
|
|
128
|
+
sortTree(actual); // Sort the actual output for deterministic comparison
|
|
129
|
+
expect(actual).toStrictEqual(expected);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should convert two-level nested paths correctly', () => {
|
|
133
|
+
const paths: string[] = [
|
|
134
|
+
'folderA/file1.txt',
|
|
135
|
+
'folderC/file3.txt'
|
|
136
|
+
];
|
|
137
|
+
const expected: TreeNode[] = [
|
|
138
|
+
{
|
|
139
|
+
name: 'folderA',
|
|
140
|
+
children: [
|
|
141
|
+
{ name: 'file1.txt', children: [] },
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: 'folderC',
|
|
146
|
+
children: [
|
|
147
|
+
{ name: 'file3.txt', children: [] }
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
];
|
|
151
|
+
const actual = pathArrayToTree(paths);
|
|
152
|
+
|
|
153
|
+
sortTree(actual);
|
|
154
|
+
expect(actual).toStrictEqual(expected);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('should handle deep nesting and common prefixes correctly', () => {
|
|
158
|
+
const paths: string[] = [
|
|
159
|
+
'root/level1/level2/file.doc',
|
|
160
|
+
'root/level1/another_file.txt',
|
|
161
|
+
'root/diff_level1/config.json'
|
|
162
|
+
];
|
|
163
|
+
const expected: TreeNode[] = [
|
|
164
|
+
{
|
|
165
|
+
name: 'root',
|
|
166
|
+
children: [
|
|
167
|
+
{
|
|
168
|
+
name: 'diff_level1',
|
|
169
|
+
children: [
|
|
170
|
+
{ name: 'config.json', children: [] }
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: 'level1',
|
|
175
|
+
children: [
|
|
176
|
+
{ name: 'another_file.txt', children: [] },
|
|
177
|
+
{
|
|
178
|
+
name: 'level2',
|
|
179
|
+
children: [
|
|
180
|
+
{ name: 'file.doc', children: [] }
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
];
|
|
188
|
+
const actual = pathArrayToTree(paths);
|
|
189
|
+
|
|
190
|
+
sortTree(actual);
|
|
191
|
+
expect(actual).toStrictEqual(expected);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('should handle leading/trailing/multiple slashes by treating them as path segments', () => {
|
|
195
|
+
const paths: string[] = [
|
|
196
|
+
'/path/to/file.txt', // Starts with a slash
|
|
197
|
+
'path/to/another.txt/', // Ends with a slash (adds an empty segment)
|
|
198
|
+
'//root/item//subitem//', // Multiple slashes (adds empty segments)
|
|
199
|
+
'root/item/another_subitem'
|
|
200
|
+
];
|
|
201
|
+
const expected: TreeNode[] = [
|
|
202
|
+
{
|
|
203
|
+
name: '',
|
|
204
|
+
children: [
|
|
205
|
+
{
|
|
206
|
+
name: '',
|
|
207
|
+
children: [
|
|
208
|
+
{
|
|
209
|
+
name: 'root',
|
|
210
|
+
children: [
|
|
211
|
+
{
|
|
212
|
+
name: 'item',
|
|
213
|
+
children: [
|
|
214
|
+
{
|
|
215
|
+
name: '',
|
|
216
|
+
children: [
|
|
217
|
+
{
|
|
218
|
+
name: 'subitem',
|
|
219
|
+
children: [
|
|
220
|
+
{
|
|
221
|
+
name: '',
|
|
222
|
+
children: [
|
|
223
|
+
{
|
|
224
|
+
name: '',
|
|
225
|
+
children: [
|
|
226
|
+
],
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: 'path',
|
|
242
|
+
children: [
|
|
243
|
+
{
|
|
244
|
+
name: 'to',
|
|
245
|
+
children: [
|
|
246
|
+
{
|
|
247
|
+
name: 'file.txt',
|
|
248
|
+
children: [
|
|
249
|
+
],
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: 'path',
|
|
259
|
+
children: [
|
|
260
|
+
{
|
|
261
|
+
name: 'to',
|
|
262
|
+
children: [
|
|
263
|
+
{
|
|
264
|
+
name: 'another.txt',
|
|
265
|
+
children: [
|
|
266
|
+
{
|
|
267
|
+
name: '',
|
|
268
|
+
children: [
|
|
269
|
+
],
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
name: 'root',
|
|
279
|
+
children: [
|
|
280
|
+
{
|
|
281
|
+
name: 'item',
|
|
282
|
+
children: [
|
|
283
|
+
{
|
|
284
|
+
name: 'another_subitem',
|
|
285
|
+
children: [
|
|
286
|
+
],
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
},
|
|
292
|
+
];
|
|
293
|
+
const actual = pathArrayToTree(paths);
|
|
294
|
+
|
|
295
|
+
sortTree(actual);
|
|
296
|
+
expect(actual).toStrictEqual(expected);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('should produce the same structure regardless of input order', () => {
|
|
300
|
+
const paths1: string[] = ['a/b', 'a/c'];
|
|
301
|
+
const paths2: string[] = ['a/c', 'a/b'];
|
|
302
|
+
|
|
303
|
+
const actual1 = pathArrayToTree(paths1);
|
|
304
|
+
|
|
305
|
+
sortTree(actual1);
|
|
306
|
+
const actual2 = pathArrayToTree(paths2);
|
|
307
|
+
|
|
308
|
+
sortTree(actual2);
|
|
309
|
+
|
|
310
|
+
expect(actual1).toStrictEqual(actual2);
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it('should handle names with special characters (not slashes) correctly', () => {
|
|
314
|
+
const paths: string[] = [
|
|
315
|
+
'my-folder/file_name.1.txt',
|
|
316
|
+
'another folder/item with spaces'
|
|
317
|
+
];
|
|
318
|
+
const expected: TreeNode[] = [
|
|
319
|
+
{
|
|
320
|
+
name: 'another folder',
|
|
321
|
+
children: [
|
|
322
|
+
{ name: 'item with spaces', children: [] }
|
|
323
|
+
]
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
name: 'my-folder',
|
|
327
|
+
children: [
|
|
328
|
+
{ name: 'file_name.1.txt', children: [] }
|
|
329
|
+
]
|
|
330
|
+
}
|
|
331
|
+
];
|
|
332
|
+
const actual = pathArrayToTree(paths);
|
|
333
|
+
|
|
334
|
+
sortTree(actual);
|
|
335
|
+
expect(actual).toStrictEqual(expected);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
it('should handle duplicate paths correctly, only adding unique structure', () => {
|
|
339
|
+
const paths: string[] = [
|
|
340
|
+
'folder/file.txt',
|
|
341
|
+
'folder/file.txt', // Duplicate
|
|
342
|
+
'other_folder/another_file.txt'
|
|
343
|
+
];
|
|
344
|
+
const expected: TreeNode[] = [
|
|
345
|
+
{
|
|
346
|
+
name: 'folder',
|
|
347
|
+
children: [
|
|
348
|
+
{ name: 'file.txt', children: [] }
|
|
349
|
+
]
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
name: 'other_folder',
|
|
353
|
+
children: [
|
|
354
|
+
{ name: 'another_file.txt', children: [] }
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
];
|
|
358
|
+
const actual = pathArrayToTree(paths);
|
|
359
|
+
|
|
360
|
+
sortTree(actual);
|
|
361
|
+
expect(actual).toStrictEqual(expected);
|
|
362
|
+
});
|
|
363
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DATE_FORMAT, TIME_FORMAT } from '@shell/store/prefs';
|
|
2
|
+
import { dateTimeFormat } from '@shell/utils/time';
|
|
3
|
+
import { type Store } from 'vuex';
|
|
4
|
+
|
|
5
|
+
describe('function: dateTimeFormat', () => {
|
|
6
|
+
jest.useFakeTimers()
|
|
7
|
+
.setSystemTime(new Date('21-10-2010 4:29:00'));
|
|
8
|
+
const store = {
|
|
9
|
+
getters: {
|
|
10
|
+
'prefs/get': (key: string) => {
|
|
11
|
+
return {
|
|
12
|
+
[DATE_FORMAT]: 'ddd, MMM D YYYY',
|
|
13
|
+
[TIME_FORMAT]: 'h:mm:ss a',
|
|
14
|
+
}[key];
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
} as Store<any>;
|
|
18
|
+
|
|
19
|
+
it('should format date and time correctly', () => {
|
|
20
|
+
const date = new Date('2010-10-21T04:29:00Z');
|
|
21
|
+
const formattedDate = dateTimeFormat(date.toISOString(), store);
|
|
22
|
+
|
|
23
|
+
expect(formattedDate).toBe('Thu, Oct 21 2010 4:29:00 am');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should return empty string for undefined value', () => {
|
|
27
|
+
const formattedDate = dateTimeFormat(undefined, store);
|
|
28
|
+
|
|
29
|
+
expect(formattedDate).toBe('');
|
|
30
|
+
});
|
|
31
|
+
});
|
package/utils/auth.js
CHANGED
|
@@ -8,6 +8,7 @@ import { allHash } from '@shell/utils/promise';
|
|
|
8
8
|
import { getProductFromRoute, getResourceFromRoute } from '@shell/utils/router';
|
|
9
9
|
import { NAME as EXPLORER } from '@shell/config/product/explorer';
|
|
10
10
|
import { findBy } from '@shell/utils/array';
|
|
11
|
+
import { onExtensionsReady } from '@shell/utils/uiplugins';
|
|
11
12
|
|
|
12
13
|
export const AUTH_BROADCAST_CHANNEL_NAME = 'rancher-auth-test-callback';
|
|
13
14
|
|
|
@@ -333,9 +334,15 @@ export async function tryInitialSetup(store, password = 'admin') {
|
|
|
333
334
|
/**
|
|
334
335
|
* Record in our state management that we're indeed logged in
|
|
335
336
|
*/
|
|
336
|
-
export function isLoggedIn(store,
|
|
337
|
+
export async function isLoggedIn(store, userData) {
|
|
337
338
|
store.commit('auth/hasAuth', true);
|
|
338
|
-
store.commit('auth/loggedInAs',
|
|
339
|
+
store.commit('auth/loggedInAs', userData.id);
|
|
340
|
+
|
|
341
|
+
// Init the notification center now that we know who the user is
|
|
342
|
+
await store.dispatch('notifications/init', userData);
|
|
343
|
+
|
|
344
|
+
// Let the extensions know that the user is logged in
|
|
345
|
+
await onExtensionsReady(store);
|
|
339
346
|
}
|
|
340
347
|
|
|
341
348
|
/**
|
package/utils/create-yaml.js
CHANGED
|
@@ -70,13 +70,14 @@ export const ACTIVELY_REMOVE = [
|
|
|
70
70
|
|
|
71
71
|
const INDENT = 2;
|
|
72
72
|
|
|
73
|
-
export function createYamlWithOptions(schemas, type, data, options) {
|
|
73
|
+
export function createYamlWithOptions(schemas, type, data, options, commentFieldsOptions) {
|
|
74
74
|
return createYaml(
|
|
75
75
|
schemas,
|
|
76
76
|
type,
|
|
77
77
|
data,
|
|
78
78
|
true, 0, '', null,
|
|
79
|
-
options
|
|
79
|
+
options,
|
|
80
|
+
commentFieldsOptions
|
|
80
81
|
);
|
|
81
82
|
}
|
|
82
83
|
|
|
@@ -89,6 +90,7 @@ export function createYaml(
|
|
|
89
90
|
path = '',
|
|
90
91
|
rootType = null,
|
|
91
92
|
dataOptions = {},
|
|
93
|
+
commentFieldsOptions = null
|
|
92
94
|
) {
|
|
93
95
|
data = data || {};
|
|
94
96
|
|
|
@@ -133,6 +135,10 @@ export function createYaml(
|
|
|
133
135
|
|
|
134
136
|
const regularFields = [];
|
|
135
137
|
|
|
138
|
+
if ( !commentFieldsOptions ) {
|
|
139
|
+
commentFieldsOptions = data?.commentFieldsOptions;
|
|
140
|
+
}
|
|
141
|
+
|
|
136
142
|
if (processAlwaysAdd) {
|
|
137
143
|
// Add all the parents of each key so that spec.template.foo.blah
|
|
138
144
|
// causes 'spec', 'template' and 'foo' keys to be created
|
|
@@ -230,6 +236,18 @@ export function createYaml(
|
|
|
230
236
|
out = 'type:';
|
|
231
237
|
}
|
|
232
238
|
|
|
239
|
+
commentFieldsOptions = addCommentSubFieldsOptions(commentFieldsOptions, data, path, key);
|
|
240
|
+
|
|
241
|
+
// If commentFieldOptions is defined on the model and the currentPath matches the path and key
|
|
242
|
+
// defined in one of the options, then comment out that line.
|
|
243
|
+
if ( Array.isArray(commentFieldsOptions) && commentFieldsOptions.length ) {
|
|
244
|
+
const currentPath = path ? `${ path }.${ key }` : key;
|
|
245
|
+
|
|
246
|
+
if ( commentFieldsOptions.some((option) => `${ option.path }.${ option.key }` === currentPath) ) {
|
|
247
|
+
out = `#${ out }`;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
233
251
|
// if a key on data is not listed in the schema's resourceFields, just convert it to yaml, add indents where needed, and return
|
|
234
252
|
if ( !field ) {
|
|
235
253
|
if (data[key]) {
|
|
@@ -275,7 +293,7 @@ export function createYaml(
|
|
|
275
293
|
out += `# key: ${ mapOf }`;
|
|
276
294
|
} else {
|
|
277
295
|
// If not a simple type ie some sort of object/array, recursively build out commented fields (note data = null here) per the type's (mapOf's) schema
|
|
278
|
-
const chunk = createYaml(schemas, mapOf, null, processAlwaysAdd, depth + 1, (path ? `${ path }.${ key }` : key), rootType, dataOptions);
|
|
296
|
+
const chunk = createYaml(schemas, mapOf, null, processAlwaysAdd, depth + 1, (path ? `${ path }.${ key }` : key), rootType, dataOptions, commentFieldsOptions);
|
|
279
297
|
let indented = indent(chunk);
|
|
280
298
|
|
|
281
299
|
// convert "# foo" to "#foo"
|
|
@@ -296,7 +314,34 @@ export function createYaml(
|
|
|
296
314
|
if ( cleaned?.[key] ) {
|
|
297
315
|
const parsedData = jsyaml.dump(cleaned[key]);
|
|
298
316
|
|
|
299
|
-
|
|
317
|
+
let chunk;
|
|
318
|
+
|
|
319
|
+
// If commentFieldOptions is defined on the model and the array has the property (`key`)
|
|
320
|
+
// defined in one of the options, then comment out that line.
|
|
321
|
+
if ( Array.isArray(commentFieldsOptions) && commentFieldsOptions.length ) {
|
|
322
|
+
let lines = parsedData.split('\n');
|
|
323
|
+
|
|
324
|
+
commentFieldsOptions.forEach((option) => {
|
|
325
|
+
// Assuming the path for the current array matches the option's path
|
|
326
|
+
// and the specific key to comment out exists in the array
|
|
327
|
+
if ( `${ path }.${ key }` === option.path && data[key][option.key] !== undefined ) {
|
|
328
|
+
// Comment out the line containing the target line
|
|
329
|
+
lines = lines.map((line, i) => {
|
|
330
|
+
if ( i === Number(option.key) ) {
|
|
331
|
+
return `#${ line }`;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return line;
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
chunk = lines.join('\n').trim();
|
|
340
|
+
} else {
|
|
341
|
+
chunk = parsedData.trim();
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
out += `\n${ indent(chunk) }`;
|
|
300
345
|
}
|
|
301
346
|
} catch (e) {
|
|
302
347
|
console.error(`Error: Unable to parse array data for yaml of type: ${ type }`, e); // eslint-disable-line no-console
|
|
@@ -306,7 +351,7 @@ export function createYaml(
|
|
|
306
351
|
if ( SIMPLE_TYPES.includes(arrayOf) ) {
|
|
307
352
|
out += `\n# - ${ arrayOf }`;
|
|
308
353
|
} else {
|
|
309
|
-
const chunk = createYaml(schemas, arrayOf, null, false, depth + 1, (path ? `${ path }.${ key }` : key), rootType, dataOptions);
|
|
354
|
+
const chunk = createYaml(schemas, arrayOf, null, false, depth + 1, (path ? `${ path }.${ key }` : key), rootType, dataOptions, commentFieldsOptions);
|
|
310
355
|
let indented = indent(chunk, 2);
|
|
311
356
|
|
|
312
357
|
// turn "# foo" into "# - foo"
|
|
@@ -357,19 +402,45 @@ export function createYaml(
|
|
|
357
402
|
|
|
358
403
|
const subDef = schemaDefinitions?.[type] || findBy(schemas, 'id', type);
|
|
359
404
|
|
|
360
|
-
if ( subDef) {
|
|
405
|
+
if ( subDef ) {
|
|
361
406
|
let chunk;
|
|
362
407
|
|
|
363
408
|
if (subDef?.resourceFields && !isEmpty(subDef?.resourceFields)) {
|
|
364
|
-
chunk = createYaml(schemas, type, data[key], processAlwaysAdd, depth + 1, (path ? `${ path }.${ key }` : key), rootType, dataOptions);
|
|
409
|
+
chunk = createYaml(schemas, type, data[key], processAlwaysAdd, depth + 1, (path ? `${ path }.${ key }` : key), rootType, dataOptions, commentFieldsOptions);
|
|
365
410
|
} else if (data[key]) {
|
|
366
411
|
// if there are no fields defined on the schema but there are in the data, just format data as yaml and add to output yaml
|
|
367
412
|
try {
|
|
368
413
|
const parsed = jsyaml.dump(data[key]);
|
|
369
414
|
|
|
370
|
-
|
|
415
|
+
// If commentFieldOptions is defined on the model and `data[key]` has the property (`key`)
|
|
416
|
+
// defined in one of the options, then comment out that line.
|
|
417
|
+
if ( Array.isArray(commentFieldsOptions) && commentFieldsOptions.length ) {
|
|
418
|
+
let lines = parsed.split('\n');
|
|
419
|
+
|
|
420
|
+
commentFieldsOptions.forEach((option) => {
|
|
421
|
+
// Assuming the path for the current data[key] matches the option's path
|
|
422
|
+
// and the specific key to comment out exists in the data[key]
|
|
423
|
+
if ( `${ path }.${ key }` === option.path && data[key][option.key] !== undefined ) {
|
|
424
|
+
const targetKeyString = `${ option.key }:`;
|
|
425
|
+
|
|
426
|
+
// Comment out the line containing the target key
|
|
427
|
+
lines = lines.map((line) => {
|
|
428
|
+
if ( line.trim().startsWith(targetKeyString) ) {
|
|
429
|
+
return `# ${ line }`;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return line;
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
chunk = lines.join('\n').trim();
|
|
438
|
+
} else {
|
|
439
|
+
// If commentFieldsOptions do not exist, use the original `parsed` string
|
|
440
|
+
chunk = parsed.trim();
|
|
441
|
+
}
|
|
371
442
|
} catch (e) {
|
|
372
|
-
console.error(`Error:
|
|
443
|
+
console.error(`Error: Unable to parse data for yaml of type: ${ type }`, e); // eslint-disable-line no-console
|
|
373
444
|
}
|
|
374
445
|
}
|
|
375
446
|
|
|
@@ -380,6 +451,29 @@ export function createYaml(
|
|
|
380
451
|
|
|
381
452
|
return out;
|
|
382
453
|
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Extends original commentFieldsOptions to cover nested objects
|
|
457
|
+
*/
|
|
458
|
+
function addCommentSubFieldsOptions(options, data, path, key) {
|
|
459
|
+
if (!!options) {
|
|
460
|
+
if ( Array.isArray(options) && options.length ) {
|
|
461
|
+
const currentPath = path ? `${ path }.${ key }` : key;
|
|
462
|
+
|
|
463
|
+
if ( options.some((option) => `${ option.path }.${ option.key }` === currentPath) ) {
|
|
464
|
+
options = [
|
|
465
|
+
...options,
|
|
466
|
+
...Object.keys(data[key]).map((k) => ({
|
|
467
|
+
path: `${ path }.${ key }`,
|
|
468
|
+
key: k
|
|
469
|
+
}))
|
|
470
|
+
];
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return options;
|
|
476
|
+
}
|
|
383
477
|
}
|
|
384
478
|
|
|
385
479
|
function comment(lines) {
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for string encryption and decryption
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// We just use a static salt
|
|
6
|
+
const SALT = new TextEncoder().encode('rancher-dashboard');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Type for the result of encryption
|
|
10
|
+
*/
|
|
11
|
+
export type EncryptedString = {
|
|
12
|
+
cipher: string;
|
|
13
|
+
iv: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Generate an encryption key from a password
|
|
18
|
+
*
|
|
19
|
+
* @param password Password to use for the key
|
|
20
|
+
* @returns Encryption key
|
|
21
|
+
*/
|
|
22
|
+
export async function deriveKey(password: string): Promise<CryptoKey> {
|
|
23
|
+
const passwordBytes = stringToBytes(password);
|
|
24
|
+
|
|
25
|
+
const initialKey = await crypto.subtle.importKey(
|
|
26
|
+
'raw',
|
|
27
|
+
passwordBytes,
|
|
28
|
+
{ name: 'PBKDF2' },
|
|
29
|
+
false,
|
|
30
|
+
['deriveKey']
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return await crypto.subtle.deriveKey(
|
|
34
|
+
{
|
|
35
|
+
name: 'PBKDF2',
|
|
36
|
+
salt: SALT,
|
|
37
|
+
iterations: 100000,
|
|
38
|
+
hash: 'SHA-256'
|
|
39
|
+
},
|
|
40
|
+
initialKey,
|
|
41
|
+
{
|
|
42
|
+
name: 'AES-GCM',
|
|
43
|
+
length: 256
|
|
44
|
+
},
|
|
45
|
+
false,
|
|
46
|
+
[
|
|
47
|
+
'encrypt',
|
|
48
|
+
'decrypt'
|
|
49
|
+
]
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Encrypt data
|
|
55
|
+
*
|
|
56
|
+
* @param content String to be encrypted
|
|
57
|
+
* @param key Encryption key
|
|
58
|
+
* @returns Encrypted data
|
|
59
|
+
*/
|
|
60
|
+
export async function encrypt(content: string, key: CryptoKey): Promise<EncryptedString> {
|
|
61
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
62
|
+
const contentBytes = stringToBytes(content);
|
|
63
|
+
const cipher = new Uint8Array(
|
|
64
|
+
await crypto.subtle.encrypt({ name: 'AES-GCM', iv }, key, contentBytes)
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
iv: bytesToBase64(iv),
|
|
69
|
+
cipher: bytesToBase64(cipher),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Decrypt encrypted data
|
|
75
|
+
* @param encryptedData Encrypted data with `cipher` and `iv` field
|
|
76
|
+
* @param key Key to use for decryption
|
|
77
|
+
* @returns Decrypted value as a string
|
|
78
|
+
*/
|
|
79
|
+
export async function decrypt(encryptedData: EncryptedString, key: CryptoKey): Promise<string> {
|
|
80
|
+
const iv = base64ToBytes(encryptedData.iv);
|
|
81
|
+
const cipher = base64ToBytes(encryptedData.cipher);
|
|
82
|
+
const contentBytes = new Uint8Array(
|
|
83
|
+
await crypto.subtle.decrypt({ name: 'AES-GCM', iv }, key, cipher)
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return bytesToString(contentBytes);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function bytesToString(bytes: any): string {
|
|
90
|
+
return new TextDecoder().decode(bytes);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function stringToBytes(str: string): Uint8Array {
|
|
94
|
+
return new TextEncoder().encode(str);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function bytesToBase64(arr: Uint8Array) {
|
|
98
|
+
return btoa(Array.from(arr, (b: number) => String.fromCharCode(b)).join(''));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function base64ToBytes(base64: string): Uint8Array {
|
|
102
|
+
return Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
|
|
103
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// For testing these could be changed to something like...
|
|
2
|
+
|
|
3
|
+
import { CATALOG } from '@shell/config/types';
|
|
4
|
+
import { FilterArgs, PaginationFilterField, PaginationParamFilter } from '@shell/types/store/pagination.types';
|
|
5
|
+
import { VuexStore } from '@shell/types/store/vuex';
|
|
6
|
+
|
|
7
|
+
const CSP_ADAPTER_APPS = ['rancher-csp-adapter', 'rancher-csp-billing-adapter'];
|
|
8
|
+
// For testing above line could be replaced with below line...
|
|
9
|
+
// const cspAdaptorApp = ['rancher-webhooka', 'rancher-webhook'];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Helpers in order to
|
|
13
|
+
*/
|
|
14
|
+
class CspAdapterUtils {
|
|
15
|
+
static canPagination($store: VuexStore): boolean {
|
|
16
|
+
return $store.getters[`management/paginationEnabled`]({ id: CATALOG.APP, context: 'branding' });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static fetchCspAdaptorApp($store: VuexStore): Promise<any> {
|
|
20
|
+
// For the login page, the schemas won't be loaded - we don't need the apps in this case
|
|
21
|
+
if ($store.getters['management/canList'](CATALOG.APP)) {
|
|
22
|
+
if (CspAdapterUtils.canPagination($store)) {
|
|
23
|
+
// Restrict the amount of apps we need to fetch
|
|
24
|
+
return $store.dispatch('management/findPage', {
|
|
25
|
+
type: CATALOG.APP,
|
|
26
|
+
opt: { // Of type ActionFindPageArgs
|
|
27
|
+
pagination: new FilterArgs({
|
|
28
|
+
filters: PaginationParamFilter.createMultipleFields(CSP_ADAPTER_APPS.map(
|
|
29
|
+
(t) => new PaginationFilterField({
|
|
30
|
+
field: 'metadata.name',
|
|
31
|
+
value: t,
|
|
32
|
+
})
|
|
33
|
+
)),
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return $store.dispatch('management/findAll', { type: CATALOG.APP });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return Promise.resolve([]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static hasCspAdapter({ $store, apps }: { $store: VuexStore, apps: any[]}): Object {
|
|
46
|
+
// In theory this should contain the filtered apps when pagination is on, and all apps when off. Keep filtering though in both cases just in case
|
|
47
|
+
return apps?.find((a) => CSP_ADAPTER_APPS.includes(a.metadata?.name));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default CspAdapterUtils;
|