@rancher/shell 0.5.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.DS_Store +0 -0
- package/assets/images/providers/aks-black.svg +28 -0
- package/assets/images/providers/aks.svg +31 -0
- package/assets/styles/global/_labeled-input.scss +1 -0
- package/assets/styles/global/_layout.scss +0 -99
- package/assets/translations/en-us.yaml +77 -71
- package/assets/translations/zh-hans.yaml +25 -23
- package/babel.config.js +1 -7
- package/chart/gatekeeper.vue +11 -2
- package/chart/istio.vue +10 -1
- package/chart/logging/index.vue +11 -2
- package/chart/monitoring/alerting/index.vue +21 -7
- package/chart/monitoring/grafana/index.vue +2 -57
- package/chart/monitoring/index.vue +26 -52
- package/chart/monitoring/prometheus/index.vue +43 -37
- package/chart/rancher-backup/index.vue +10 -3
- package/cloud-credential/azure.vue +17 -4
- package/components/AsyncButton.vue +0 -9
- package/components/Carousel.vue +0 -1
- package/components/ChartPsp.vue +76 -0
- package/components/CodeMirror.vue +21 -19
- package/components/CopyCode.vue +2 -6
- package/components/CopyToClipboard.vue +1 -2
- package/components/CopyToClipboardText.vue +9 -14
- package/components/CruResource.vue +0 -1
- package/components/EtcdInfoBanner.vue +5 -5
- package/components/ExplorerProjectsNamespaces.vue +1 -25
- package/components/IconOrSvg.vue +1 -1
- package/components/Markdown.vue +12 -16
- package/components/Questions/index.vue +1 -1
- package/components/ResourceDetail/Masthead.vue +9 -25
- package/components/ResourceList/Masthead.vue +18 -1
- package/components/ResourceTable.vue +2 -14
- package/components/ResourceYaml.vue +0 -5
- package/components/SideNav.vue +1 -1
- package/components/SortableTable/THead.vue +9 -7
- package/components/SortableTable/index.vue +3 -2
- package/components/StatusTable.vue +1 -5
- package/components/TabTitle.vue +84 -0
- package/components/Tabbed/index.vue +0 -12
- package/components/__tests__/ChartPsp.test.ts +75 -0
- package/components/__tests__/CopyCode.test.ts +4 -5
- package/components/fleet/FleetBundles.vue +11 -5
- package/components/fleet/FleetRepos.vue +27 -62
- package/components/fleet/FleetResources.vue +1 -6
- package/components/fleet/FleetStatus.vue +3 -3
- package/components/fleet/FleetSummary.vue +30 -35
- package/components/form/ArrayList.vue +8 -1
- package/components/form/ArrayListSelect.vue +9 -9
- package/components/form/KeyValue.vue +0 -1
- package/components/form/LabeledSelect.vue +0 -4
- package/components/form/Password.vue +1 -3
- package/components/form/Select.vue +1 -1
- package/components/form/SelectOrCreateAuthSecret.vue +4 -4
- package/components/form/__tests__/KeyValue.test.ts +1 -1
- package/components/formatter/Checked.vue +3 -11
- package/components/formatter/ClusterProvider.vue +18 -1
- package/components/formatter/FleetSummaryGraph.vue +11 -23
- package/components/formatter/LiveDate.vue +16 -0
- package/components/formatter/LiveDuration.vue +1 -1
- package/components/formatter/PercentageBar.vue +1 -1
- package/components/formatter/__tests__/ClusterProvider.test.ts +28 -0
- package/components/nav/Group.vue +2 -2
- package/components/nav/Header.vue +2 -1
- package/components/nav/TopLevelMenu.vue +3 -29
- package/components/nav/Type.vue +3 -1
- package/components/nav/WindowManager/ContainerLogs.vue +19 -120
- package/components/nav/WindowManager/ContainerShell.vue +1 -6
- package/components/nav/WindowManager/index.vue +10 -11
- package/components/nav/__tests__/TopLevelMenu.test.ts +0 -33
- package/components/nav/__tests__/Type.test.ts +1 -1
- package/components/nuxt/nuxt-child.js +78 -14
- package/components/nuxt/nuxt.js +1 -1
- package/components/user.retention/user-retention-header.vue +34 -0
- package/composables/useI18n.ts +26 -0
- package/composables/useStore.ts +16 -0
- package/config/harvester-manager-types.js +0 -2
- package/config/home-links.js +32 -2
- package/config/private-label.js +0 -22
- package/config/product/explorer.js +4 -4
- package/config/product/fleet.js +1 -6
- package/config/product/legacy.js +1 -84
- package/config/product/manager.js +15 -8
- package/config/query-params.js +0 -1
- package/config/router.js +368 -385
- package/config/settings.ts +9 -2
- package/config/store.js +1 -1
- package/config/system-namespaces.js +0 -3
- package/config/table-headers.js +27 -47
- package/config/types.js +5 -0
- package/config/uiplugins.js +1 -1
- package/core/plugin-helpers.js +5 -3
- package/core/plugin-routes.ts +114 -56
- package/core/plugin.ts +10 -16
- package/core/plugins-loader.js +9 -7
- package/core/plugins.js +3 -0
- package/core/types-provisioning.ts +0 -7
- package/creators/app/init +0 -19
- package/detail/fleet.cattle.io.cluster.vue +1 -11
- package/detail/node.vue +0 -42
- package/detail/pod.vue +1 -68
- package/detail/provisioning.cattle.io.cluster.vue +4 -6
- package/detail/workload/index.vue +1 -15
- package/dialog/ScaleMachineDownDialog.vue +17 -34
- package/edit/auth/googleoauth.vue +5 -1
- package/edit/catalog.cattle.io.clusterrepo.vue +7 -20
- package/edit/cloudcredential.vue +0 -2
- package/edit/fleet.cattle.io.gitrepo.vue +4 -3
- package/edit/management.cattle.io.project.vue +52 -1
- package/edit/management.cattle.io.setting.vue +2 -31
- package/edit/monitoring.coreos.com.prometheusrule/AlertingRule.vue +3 -12
- package/edit/monitoring.coreos.com.prometheusrule/GroupRules.vue +1 -2
- package/edit/networking.k8s.io.networkpolicy/__tests__/PolicyRuleTarget.spec.ts +1 -1
- package/edit/provisioning.cattle.io.cluster/{tabs/Basics.vue → Basics.vue} +126 -109
- package/edit/provisioning.cattle.io.cluster/{tabs/MachinePool.vue → MachinePool.vue} +7 -1
- package/edit/provisioning.cattle.io.cluster/{tabs/registries/RegistryConfigs.vue → RegistryConfigs.vue} +3 -1
- package/edit/provisioning.cattle.io.cluster/SelectCredential.vue +7 -15
- package/edit/provisioning.cattle.io.cluster/__tests__/Basics.tests.ts +237 -0
- package/edit/provisioning.cattle.io.cluster/__tests__/{CustomCommand.test.ts → CustomCommand.tests.ts} +0 -6
- package/edit/provisioning.cattle.io.cluster/__tests__/DrainOptions.test.ts +1 -1
- package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +1 -7
- package/edit/provisioning.cattle.io.cluster/import.vue +2 -2
- package/edit/provisioning.cattle.io.cluster/index.vue +37 -99
- package/edit/provisioning.cattle.io.cluster/rke2.vue +690 -181
- package/edit/service.vue +0 -12
- package/edit/workload/Upgrading.vue +2 -3
- package/edit/workload/index.vue +1 -2
- package/edit/workload/mixins/workload.js +1 -1
- package/initialize/App.js +71 -25
- package/initialize/client.js +162 -21
- package/initialize/index.js +124 -47
- package/initialize/layouts.ts +26 -0
- package/{components/templates → layouts}/blank.vue +1 -1
- package/{components/templates → layouts}/default.vue +98 -8
- package/{components/templates → layouts}/error.vue +19 -10
- package/{components/templates → layouts}/home.vue +1 -4
- package/{components/templates → layouts}/plain.vue +1 -4
- package/{components/templates → layouts}/standalone.vue +1 -1
- package/{components/templates → layouts}/unauthenticated.vue +1 -1
- package/list/management.cattle.io.feature.vue +7 -1
- package/list/management.cattle.io.user.vue +25 -1
- package/list/node.vue +0 -1
- package/machine-config/__tests__/vmwarevsphere.test.ts +161 -56
- package/machine-config/amazonec2.vue +1 -0
- package/machine-config/azure.vue +37 -21
- package/machine-config/vmwarevsphere.vue +47 -42
- package/middleware/authenticated.js +19 -14
- package/mixins/auth-config.js +7 -2
- package/mixins/brand.js +41 -29
- package/mixins/fetch.server.js +73 -0
- package/mixins/labeled-form-element.ts +1 -6
- package/models/__tests__/management.cattle.io.node.ts +0 -85
- package/models/__tests__/namespace.test.ts +9 -49
- package/models/cluster/node.js +4 -4
- package/models/cluster.x-k8s.io.machine.js +1 -1
- package/models/cluster.x-k8s.io.machinedeployment.js +0 -14
- package/models/fleet.cattle.io.cluster.js +0 -4
- package/models/fleet.cattle.io.gitrepo.js +13 -56
- package/models/management.cattle.io.cluster.js +3 -11
- package/models/management.cattle.io.kontainerdriver.js +0 -1
- package/models/management.cattle.io.node.js +14 -18
- package/models/management.cattle.io.nodepool.js +0 -17
- package/models/management.cattle.io.project.js +36 -0
- package/models/management.cattle.io.setting.js +7 -11
- package/models/management.cattle.io.user.js +65 -0
- package/models/namespace.js +1 -1
- package/models/pod.js +0 -20
- package/models/provisioning.cattle.io.cluster.js +8 -55
- package/models/secret.js +18 -117
- package/models/workload.js +0 -16
- package/models/workload.service.js +0 -18
- package/package.json +10 -12
- package/pages/about.vue +1 -0
- package/pages/account/create-key.vue +1 -0
- package/pages/account/index.vue +1 -0
- package/pages/auth/login.vue +1 -0
- package/pages/auth/logout.vue +2 -0
- package/pages/auth/setup.vue +4 -37
- package/pages/auth/verify.vue +8 -14
- package/pages/c/_cluster/apps/charts/__tests__/install.helper.test.ts +17 -2
- package/pages/c/_cluster/apps/charts/index.vue +58 -64
- package/pages/c/_cluster/apps/charts/install.helpers.js +13 -2
- package/pages/c/_cluster/apps/charts/install.vue +5 -5
- package/pages/c/_cluster/apps/index.vue +2 -0
- package/pages/c/_cluster/auth/index.vue +2 -0
- package/pages/c/_cluster/auth/user.retention/index.vue +384 -0
- package/pages/c/_cluster/ecm/index.vue +2 -0
- package/pages/c/_cluster/explorer/index.vue +53 -56
- package/pages/c/_cluster/explorer/tools/index.vue +3 -171
- package/pages/c/_cluster/fleet/index.vue +1 -1
- package/pages/c/_cluster/index.vue +2 -0
- package/pages/c/_cluster/manager/pages/_page.vue +5 -4
- package/pages/c/_cluster/monitoring/index.vue +1 -17
- package/pages/c/_cluster/settings/DefaultLinksEditor.vue +1 -0
- package/pages/c/_cluster/settings/banners.vue +2 -0
- package/pages/c/_cluster/settings/brand.vue +2 -0
- package/pages/c/_cluster/settings/index.vue +2 -0
- package/pages/c/_cluster/settings/links.vue +3 -2
- package/pages/c/_cluster/settings/performance.vue +1 -0
- package/pages/c/_cluster/uiplugins/AddExtensionRepos.vue +4 -4
- package/pages/c/_cluster/uiplugins/CatalogList/CatalogLoadDialog.vue +1 -2
- package/pages/c/_cluster/uiplugins/CatalogList/index.vue +46 -10
- package/pages/c/_cluster/uiplugins/SetupUIPlugins.vue +5 -2
- package/pages/c/_cluster/uiplugins/__tests__/AddExtensionRepos.test.ts +96 -0
- package/pages/c/_cluster/uiplugins/__tests__/SetupUIPlugins.test.ts +128 -0
- package/pages/c/_cluster/uiplugins/index.vue +2 -0
- package/pages/c/index.vue +9 -0
- package/pages/diagnostic.vue +2 -1
- package/pages/fail-whale.vue +1 -0
- package/pages/prefs.vue +1 -0
- package/pages/rio/mesh.vue +508 -0
- package/pages/support/index.vue +8 -2
- package/pkg/auto-import.js +1 -1
- package/plugins/axios.js +36 -0
- package/plugins/back-button.js +5 -3
- package/plugins/clean-html-directive.js +19 -1
- package/plugins/clean-tooltip-directive.js +1 -1
- package/plugins/codemirror-loader.js +1 -1
- package/plugins/codemirror.js +0 -41
- package/plugins/dashboard-store/__tests__/actions.spec.ts +250 -0
- package/plugins/dashboard-store/__tests__/{mutations.test.ts → mutations.spec.ts} +1 -1
- package/plugins/dashboard-store/actions.js +21 -22
- package/plugins/dashboard-store/classify.js +18 -1
- package/plugins/dashboard-store/getters.js +5 -10
- package/plugins/dashboard-store/index.js +12 -0
- package/plugins/dashboard-store/mutations.js +4 -0
- package/plugins/dashboard-store/resource-class.js +18 -59
- package/plugins/i18n.js +1 -1
- package/plugins/steve/__tests__/getters.spec.ts +56 -24
- package/plugins/steve/__tests__/subscribe.spec.ts +106 -0
- package/plugins/steve/getters.js +30 -7
- package/plugins/steve/mutations.js +5 -2
- package/plugins/steve/norman-class.js +0 -19
- package/plugins/steve/steve-class.js +0 -22
- package/plugins/steve/subscribe.js +34 -13
- package/plugins/transitions.js +4 -0
- package/plugins/vue-clipboard2.js +4 -0
- package/rancher-components/Accordion/Accordion.vue +3 -2
- package/rancher-components/BadgeState/BadgeState.vue +3 -3
- package/rancher-components/Banner/Banner.test.ts +1 -5
- package/rancher-components/Banner/Banner.vue +2 -2
- package/rancher-components/Card/Card.vue +4 -4
- package/rancher-components/Form/Checkbox/Checkbox.vue +4 -3
- package/rancher-components/Form/LabeledInput/LabeledInput.test.ts +1 -1
- package/rancher-components/Form/LabeledInput/LabeledInput.vue +55 -24
- package/rancher-components/Form/Radio/RadioButton.test.ts +1 -3
- package/rancher-components/Form/Radio/RadioButton.vue +13 -7
- package/rancher-components/Form/Radio/RadioGroup.vue +4 -3
- package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +7 -5
- package/rancher-components/Form/ToggleSwitch/ToggleSwitch.vue +7 -4
- package/rancher-components/LabeledTooltip/LabeledTooltip.vue +9 -4
- package/rancher-components/StringList/StringList.vue +8 -8
- package/rancher-components/components/Accordion/Accordion.vue +3 -2
- package/rancher-components/components/BadgeState/BadgeState.test.ts +12 -0
- package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +2 -19
- package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +14 -11
- package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +1 -1
- package/rancher-components/components/StringList/StringList.test.ts +0 -270
- package/rancher-components/components/StringList/StringList.vue +18 -57
- package/scripts/extension/bundle +7 -19
- package/scripts/extension/helm/scripts/package +3 -11
- package/scripts/extension/parse-tag-name +4 -4
- package/scripts/extension/publish +9 -20
- package/scripts/publish-shell.sh +1 -11
- package/scripts/test-plugins-build.sh +9 -85
- package/store/catalog.js +1 -1
- package/store/features.js +0 -1
- package/store/i18n.js +0 -11
- package/store/index.js +11 -8
- package/store/prefs.js +38 -33
- package/store/type-map.js +8 -13
- package/tsconfig.default.json +46 -0
- package/tsconfig.json +9 -35
- package/types/shell/index.d.ts +404 -463
- package/utils/__tests__/create-yaml.test.ts +10 -0
- package/utils/axios.js +19 -0
- package/utils/create-yaml.js +6 -6
- package/utils/custom-validators.js +2 -0
- package/utils/error.js +1 -16
- package/utils/monitoring.js +2 -37
- package/utils/nuxt.js +39 -18
- package/utils/object.js +0 -14
- package/utils/router.scrollBehavior.js +14 -12
- package/utils/socket.js +1 -0
- package/utils/time.js +1 -1
- package/utils/title.ts +3 -0
- package/utils/url.ts +1 -1
- package/utils/validators/formRules/__tests__/index.test.ts +4 -49
- package/utils/validators/formRules/index.ts +9 -12
- package/utils/validators/setting.js +10 -6
- package/vue.config.js +3 -24
- package/chart/monitoring/steps/uninstall-v1.vue +0 -135
- package/components/Certificates.vue +0 -164
- package/components/fleet/__tests__/FleetSummary.test.ts +0 -316
- package/components/formatter/FleetClusterSummaryGraph.vue +0 -27
- package/components/formatter/__tests__/Checked.test.ts +0 -19
- package/components/nav/WindowManager/__tests__/ContainerLogs.test.ts +0 -186
- package/composables/useCompactInput.ts +0 -20
- package/composables/useLabeledFormElement.ts +0 -138
- package/creators/app/files/.gitlab-ci.yml +0 -14
- package/edit/__tests__/service.test.ts +0 -89
- package/edit/provisioning.cattle.io.cluster/__tests__/Advanced.test.ts +0 -112
- package/edit/provisioning.cattle.io.cluster/__tests__/Basics.test.ts +0 -473
- package/edit/provisioning.cattle.io.cluster/__tests__/index.test.ts +0 -73
- package/edit/provisioning.cattle.io.cluster/__tests__/utils/cluster.ts +0 -386
- package/edit/provisioning.cattle.io.cluster/tabs/AddOnConfig.vue +0 -137
- package/edit/provisioning.cattle.io.cluster/tabs/Advanced.vue +0 -157
- package/edit/provisioning.cattle.io.cluster/tabs/etcd/index.vue +0 -135
- package/edit/provisioning.cattle.io.cluster/tabs/networking/index.vue +0 -189
- package/edit/provisioning.cattle.io.cluster/tabs/registries/index.vue +0 -144
- package/edit/provisioning.cattle.io.cluster/tabs/upgrade/index.vue +0 -76
- package/mixins/v1-workload-metrics.js +0 -43
- package/models/__tests__/management.cattle.io.cluster.test.ts +0 -23
- package/models/__tests__/management.cattle.io.nodepool.ts +0 -83
- package/models/__tests__/provisioning.cattle.io.cluster.test.ts +0 -90
- package/models/__tests__/workload.test.ts +0 -91
- package/plugins/clean-html.js +0 -53
- package/plugins/dashboard-store/__tests__/actions.test.ts +0 -165
- package/plugins/dashboard-store/__tests__/resource-class.test.ts +0 -49
- package/plugins/dashboard-store/__tests__/utils/store-mocks.ts +0 -7
- package/plugins/index.js +0 -11
- package/plugins/steve/__tests__/steve-class.spec.ts +0 -59
- package/plugins/steve/__tests__/utils/steve-mocks.ts +0 -31
- package/scripts/.gitlab/workflows/build-extension-catalog.gitlab-ci.yml +0 -50
- package/server/har-file.js +0 -183
- package/tsconfig.paths.json +0 -18
- package/utils/azure.js +0 -24
- package/utils/clipboard.js +0 -5
- /package/components/form/__tests__/{NameNsDescription.test.ts → NameNsDescription.ts} +0 -0
- /package/edit/networking.k8s.io.networkpolicy/__tests__/utils/{selectors.test.ts → selectors.ts} +0 -0
- /package/edit/provisioning.cattle.io.cluster/{tabs/networking/ACE.vue → ACE.vue} +0 -0
- /package/edit/provisioning.cattle.io.cluster/{tabs/AgentConfiguration.vue → AgentConfiguration.vue} +0 -0
- /package/edit/provisioning.cattle.io.cluster/{tabs/upgrade/DrainOptions.vue → DrainOptions.vue} +0 -0
- /package/edit/provisioning.cattle.io.cluster/{tabs/MemberRoles.vue → MemberRoles.vue} +0 -0
- /package/edit/provisioning.cattle.io.cluster/{tabs/registries/RegistryMirrors.vue → RegistryMirrors.vue} +0 -0
- /package/edit/provisioning.cattle.io.cluster/{tabs/etcd/S3Config.vue → S3Config.vue} +0 -0
- /package/plugins/dashboard-store/__tests__/{getters.test.ts → getters.spec.ts} +0 -0
- /package/rancher-components/BadgeState/{BadgeState.spec.ts → BadgeState.test.ts} +0 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import _actions from '@shell/plugins/dashboard-store/actions';
|
|
2
|
+
|
|
3
|
+
const { findAll, findMatching } = _actions;
|
|
4
|
+
|
|
5
|
+
describe('dashboard-store: actions', () => {
|
|
6
|
+
describe('findAll', () => {
|
|
7
|
+
// Note - there are TS errors alll over this describe and should not have merged with them in.
|
|
8
|
+
const setupContext = () => {
|
|
9
|
+
const commit = jest.fn();
|
|
10
|
+
const dispatch = jest.fn((...args) => {
|
|
11
|
+
switch (args[0]) {
|
|
12
|
+
case 'request':
|
|
13
|
+
return { data: ['requestData'] };
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const state = { config: { namespace: 'unitTest' } };
|
|
17
|
+
const getters = {
|
|
18
|
+
normalizeType: jest.fn(() => 'getters.normalizeType'),
|
|
19
|
+
typeRegistered: jest.fn(() => false),
|
|
20
|
+
haveAll: jest.fn(() => false),
|
|
21
|
+
haveAllNamespace: jest.fn(() => false),
|
|
22
|
+
all: jest.fn(() => 'getters.all'),
|
|
23
|
+
urlFor: jest.fn(() => 'getters.urlFor'), // we're not testing the urlFor getter so we don't need to do anything with opt here
|
|
24
|
+
};
|
|
25
|
+
const rootGetters = {
|
|
26
|
+
'type-map/optionsFor': jest.fn(),
|
|
27
|
+
'auth/fromHeader': 'foo'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// we're not testing function output based off of state or getter inputs here since they are dependencies and should be tested independently
|
|
31
|
+
return {
|
|
32
|
+
state,
|
|
33
|
+
getters,
|
|
34
|
+
rootGetters,
|
|
35
|
+
commit,
|
|
36
|
+
dispatch
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const standardAssertions = {
|
|
41
|
+
returnsPromise: {
|
|
42
|
+
assertionLabel: 'returns a promise',
|
|
43
|
+
valueGetter: ({ findAllPromise }) => typeof findAllPromise.then,
|
|
44
|
+
valueExpected: 'function'
|
|
45
|
+
},
|
|
46
|
+
callsAll: {
|
|
47
|
+
assertionLabel: 'calls the "all" getter with the normalizedType',
|
|
48
|
+
valueGetter: ({ getters }) => getters.all.mock.calls[0][0],
|
|
49
|
+
valueExpected: 'getters.normalizeType'
|
|
50
|
+
},
|
|
51
|
+
returnsFromAll: {
|
|
52
|
+
assertionLabel: 'returns the value expected from the "all" getter',
|
|
53
|
+
valueGetter: ({ findAllReturnValue }) => findAllReturnValue,
|
|
54
|
+
valueExpected: 'getters.all'
|
|
55
|
+
},
|
|
56
|
+
firstDispatchAction: {
|
|
57
|
+
assertionLabel: 'first dispatch should be the "request" action',
|
|
58
|
+
valueGetter: ({ dispatch }) => dispatch.mock.calls[0][0],
|
|
59
|
+
valueExpected: 'request'
|
|
60
|
+
},
|
|
61
|
+
firstDispatchParams: {
|
|
62
|
+
assertionLabel: 'first dispatch parameters should be provided a normalized type and a url, streaming, and "metadata.managedFields" excluded under opt',
|
|
63
|
+
valueGetter: ({ dispatch }) => dispatch.mock.calls[0][1],
|
|
64
|
+
valueExpected: {
|
|
65
|
+
type: 'getters.normalizeType',
|
|
66
|
+
opt: {
|
|
67
|
+
url: 'getters.urlFor',
|
|
68
|
+
stream: true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
assertionMethod: 'toMatchObject'
|
|
72
|
+
},
|
|
73
|
+
secondDispatchAction: {
|
|
74
|
+
assertionLabel: 'second dispatch should be the "watch" action',
|
|
75
|
+
valueGetter: ({ dispatch }) => dispatch.mock.calls[1][0],
|
|
76
|
+
valueExpected: 'watch'
|
|
77
|
+
},
|
|
78
|
+
secondDispatchParams: {
|
|
79
|
+
assertionLabel: 'second dispatch parameters should have a normalized type and force set to false',
|
|
80
|
+
valueGetter: ({ dispatch }) => dispatch.mock.calls[1][1],
|
|
81
|
+
valueExpected: { type: 'getters.normalizeType', force: false },
|
|
82
|
+
assertionMethod: 'toMatchObject'
|
|
83
|
+
},
|
|
84
|
+
countDispatches: {
|
|
85
|
+
assertionLabel: 'should only make two dispatches',
|
|
86
|
+
valueGetter: ({ dispatch }) => dispatch.mock.calls,
|
|
87
|
+
valueExpected: 2,
|
|
88
|
+
assertionMethod: 'toHaveLength'
|
|
89
|
+
},
|
|
90
|
+
firstCommitMutation: {
|
|
91
|
+
assertionLabel: 'first commit should be the "registerType" mutation',
|
|
92
|
+
valueGetter: ({ commit }) => commit.mock.calls[0][0],
|
|
93
|
+
valueExpected: 'registerType'
|
|
94
|
+
},
|
|
95
|
+
firstCommitParams: {
|
|
96
|
+
assertionLabel: 'first commit parameter should be a normalized type',
|
|
97
|
+
valueGetter: ({ commit }) => commit.mock.calls[0][1],
|
|
98
|
+
valueExpected: 'getters.normalizeType'
|
|
99
|
+
},
|
|
100
|
+
secondCommitMutation: {
|
|
101
|
+
assertionLabel: 'second commit should be the "loadAll" mutation',
|
|
102
|
+
valueGetter: ({ commit }) => commit.mock.calls[1][0],
|
|
103
|
+
valueExpected: 'loadAll'
|
|
104
|
+
},
|
|
105
|
+
secondCommitParams: {
|
|
106
|
+
assertionLabel: 'second commit parameters should have a normalized type, ctx.state.config.namespace, data returned by request, and skipHaveAll set to false',
|
|
107
|
+
valueGetter: ({ commit }) => commit.mock.calls[1][1],
|
|
108
|
+
valueExpected: {
|
|
109
|
+
type: 'getters.normalizeType',
|
|
110
|
+
ctx: { state: { config: { namespace: 'unitTest' } } },
|
|
111
|
+
data: ['requestData'],
|
|
112
|
+
skipHaveAll: false,
|
|
113
|
+
},
|
|
114
|
+
assertionMethod: 'toMatchObject'
|
|
115
|
+
},
|
|
116
|
+
countCommits: {
|
|
117
|
+
assertionLabel: 'should only make two commits',
|
|
118
|
+
valueGetter: ({ commit }) => commit.mock.calls,
|
|
119
|
+
valueExpected: 2,
|
|
120
|
+
assertionMethod: 'toHaveLength'
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
describe('called without a cache for the type in the second param', () => {
|
|
126
|
+
const {
|
|
127
|
+
dispatch, commit, getters, rootGetters, state
|
|
128
|
+
} = setupContext();
|
|
129
|
+
|
|
130
|
+
const findAllPromise = findAll(
|
|
131
|
+
{
|
|
132
|
+
dispatch, commit, getters, rootGetters, state
|
|
133
|
+
},
|
|
134
|
+
{ type: 'type' }
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const assertionChain = [
|
|
138
|
+
standardAssertions.returnsPromise,
|
|
139
|
+
standardAssertions.callsAll,
|
|
140
|
+
standardAssertions.returnsFromAll,
|
|
141
|
+
standardAssertions.firstDispatchAction,
|
|
142
|
+
standardAssertions.firstDispatchParams,
|
|
143
|
+
standardAssertions.secondDispatchAction,
|
|
144
|
+
standardAssertions.secondDispatchParams,
|
|
145
|
+
standardAssertions.countDispatches,
|
|
146
|
+
standardAssertions.firstCommitMutation,
|
|
147
|
+
standardAssertions.firstCommitParams,
|
|
148
|
+
standardAssertions.secondCommitMutation,
|
|
149
|
+
standardAssertions.secondCommitParams,
|
|
150
|
+
standardAssertions.countCommits
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
it.each(assertionChain)(
|
|
154
|
+
'$assertionLabel',
|
|
155
|
+
async({ valueGetter, valueExpected, assertionMethod = 'toBe' }) => {
|
|
156
|
+
const findAllReturnValue = await findAllPromise;
|
|
157
|
+
|
|
158
|
+
expect(valueGetter({
|
|
159
|
+
findAllPromise, findAllReturnValue, getters, dispatch, commit
|
|
160
|
+
}))[assertionMethod](valueExpected);
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe('findMatching', () => {
|
|
167
|
+
const setupContext = () => {
|
|
168
|
+
const commit = jest.fn();
|
|
169
|
+
const dispatch = jest.fn(() => 'dispatch');
|
|
170
|
+
|
|
171
|
+
const state = { config: { namespace: 'unitTest' } };
|
|
172
|
+
const getters = {
|
|
173
|
+
normalizeType: jest.fn((type) => type),
|
|
174
|
+
typeRegistered: jest.fn(() => true),
|
|
175
|
+
haveSelector: jest.fn(() => false),
|
|
176
|
+
matching: jest.fn(() => 'getters.all'),
|
|
177
|
+
urlFor: jest.fn(() => 'getters.urlFor'),
|
|
178
|
+
urlOptions: jest.fn(() => 'getters.urlOptions')
|
|
179
|
+
};
|
|
180
|
+
const rootGetters = { 'type-map/optionsFor': jest.fn() };
|
|
181
|
+
|
|
182
|
+
// we're not testing function output based off of state or getter inputs here since they are dependencies and should be tested independently
|
|
183
|
+
return {
|
|
184
|
+
state,
|
|
185
|
+
getters,
|
|
186
|
+
rootGetters,
|
|
187
|
+
commit,
|
|
188
|
+
dispatch
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
const genericType = 'services';
|
|
192
|
+
const genericSelector = 'a=b';
|
|
193
|
+
const genericOpt = {};
|
|
194
|
+
|
|
195
|
+
const assertionChain = [{
|
|
196
|
+
assertionLabel: 'Basic Selector',
|
|
197
|
+
input: {
|
|
198
|
+
type: genericType,
|
|
199
|
+
selector: genericSelector,
|
|
200
|
+
opt: { ...genericOpt },
|
|
201
|
+
namespace: undefined
|
|
202
|
+
},
|
|
203
|
+
output: {
|
|
204
|
+
getters: {
|
|
205
|
+
urlFor: [
|
|
206
|
+
genericType,
|
|
207
|
+
null,
|
|
208
|
+
{
|
|
209
|
+
...genericOpt,
|
|
210
|
+
depaginate: undefined,
|
|
211
|
+
labelSelector: genericSelector,
|
|
212
|
+
url: 'getters.urlFor',
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
actions: {
|
|
217
|
+
request: {
|
|
218
|
+
opt: {},
|
|
219
|
+
type: genericType
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}];
|
|
224
|
+
|
|
225
|
+
const {
|
|
226
|
+
dispatch,
|
|
227
|
+
commit,
|
|
228
|
+
getters,
|
|
229
|
+
rootGetters,
|
|
230
|
+
state
|
|
231
|
+
} = setupContext();
|
|
232
|
+
|
|
233
|
+
it.each(assertionChain)(
|
|
234
|
+
'$assertionLabel',
|
|
235
|
+
async({ input, output }) => {
|
|
236
|
+
await findMatching(
|
|
237
|
+
{
|
|
238
|
+
dispatch,
|
|
239
|
+
getters,
|
|
240
|
+
rootGetters,
|
|
241
|
+
state,
|
|
242
|
+
commit,
|
|
243
|
+
},
|
|
244
|
+
input
|
|
245
|
+
);
|
|
246
|
+
expect(getters.urlFor).toHaveBeenCalledWith(...output.getters.urlFor);
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
});
|
|
250
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { batchChanges } from '@shell/plugins/dashboard-store/mutations
|
|
1
|
+
import { batchChanges } from '@shell/plugins/dashboard-store/mutations';
|
|
2
2
|
import { POD, WORKLOAD_TYPES } from '@shell/config/types';
|
|
3
3
|
import Resource from '@shell/plugins/dashboard-store/resource-class';
|
|
4
4
|
|
|
@@ -7,6 +7,7 @@ import { classify } from '@shell/plugins/dashboard-store/classify';
|
|
|
7
7
|
import { normalizeType } from './normalize';
|
|
8
8
|
import garbageCollect from '@shell/utils/gc/gc';
|
|
9
9
|
import { addSchemaIndexFields } from '@shell/plugins/steve/schema.utils';
|
|
10
|
+
import { addParam } from '@shell/utils/url';
|
|
10
11
|
|
|
11
12
|
export const _ALL = 'all';
|
|
12
13
|
export const _MERGE = 'merge';
|
|
@@ -71,10 +72,6 @@ export async function loadSchemas(ctx, watch = true) {
|
|
|
71
72
|
return all;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
const findAllGetter = (getters, type, opt) => {
|
|
75
|
-
return opt.namespaced ? getters.matching(type, null, opt.namespaced, { skipSelector: true }) : getters.all(type);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
75
|
export default {
|
|
79
76
|
request() {
|
|
80
77
|
throw new Error('Not Implemented');
|
|
@@ -156,19 +153,19 @@ export default {
|
|
|
156
153
|
|
|
157
154
|
// No need to request the resources if we have them already
|
|
158
155
|
if ( opt.force !== true && (getters['haveAll'](type) || getters['haveAllNamespace'](type, opt.namespaced))) {
|
|
159
|
-
const args = {
|
|
160
|
-
type,
|
|
161
|
-
revision: '',
|
|
162
|
-
// watchNamespace - used sometimes when we haven't fetched the results of a single namespace
|
|
163
|
-
// namespaced - used when we have fetched the result of a single namespace (see https://github.com/rancher/dashboard/pull/7329/files)
|
|
164
|
-
namespace: opt.watchNamespace || opt.namespaced
|
|
165
|
-
};
|
|
166
|
-
|
|
167
156
|
if (opt.watch !== false ) {
|
|
157
|
+
const args = {
|
|
158
|
+
type,
|
|
159
|
+
revision: '',
|
|
160
|
+
// watchNamespace - used sometimes when we haven't fetched the results of a single namespace
|
|
161
|
+
// namespaced - used when we have fetched the result of a single namespace (see https://github.com/rancher/dashboard/pull/7329/files)
|
|
162
|
+
namespace: opt.watchNamespace || opt.namespaced
|
|
163
|
+
};
|
|
164
|
+
|
|
168
165
|
dispatch('watch', args);
|
|
169
166
|
}
|
|
170
167
|
|
|
171
|
-
return
|
|
168
|
+
return getters.all(type);
|
|
172
169
|
}
|
|
173
170
|
|
|
174
171
|
let load = (opt.load === undefined ? _ALL : opt.load);
|
|
@@ -208,12 +205,12 @@ export default {
|
|
|
208
205
|
|
|
209
206
|
const pageFetchOpts = {
|
|
210
207
|
...opt,
|
|
211
|
-
url:
|
|
208
|
+
url: addParam(opt.url, 'limit', `${ opt.incremental }`),
|
|
212
209
|
};
|
|
213
210
|
|
|
214
211
|
// this is where we "hijack" the limit for the dispatch('request') some lines below
|
|
215
212
|
// and therefore have 2 initial requests in parallel
|
|
216
|
-
opt.url =
|
|
213
|
+
opt.url = addParam(opt.url, 'limit', '100');
|
|
217
214
|
skipHaveAll = true;
|
|
218
215
|
|
|
219
216
|
// since we are forcing a request, clear the haveAll
|
|
@@ -333,7 +330,7 @@ export default {
|
|
|
333
330
|
dispatch('watch', args);
|
|
334
331
|
}
|
|
335
332
|
|
|
336
|
-
const all =
|
|
333
|
+
const all = getters.all(type);
|
|
337
334
|
|
|
338
335
|
if (!opt.incremental && opt.hasManualRefresh) {
|
|
339
336
|
dispatch('resource-fetch/updateManualRefreshIsLoading', false, { root: true });
|
|
@@ -368,10 +365,7 @@ export default {
|
|
|
368
365
|
const typeOptions = rootGetters['type-map/optionsFor'](type);
|
|
369
366
|
|
|
370
367
|
opt = opt || {};
|
|
371
|
-
|
|
372
|
-
opt.filter = opt.filter || {};
|
|
373
|
-
opt.filter['labelSelector'] = selector;
|
|
374
|
-
|
|
368
|
+
opt.labelSelector = selector;
|
|
375
369
|
opt.url = getters.urlFor(type, null, opt);
|
|
376
370
|
opt.depaginate = typeOptions?.depaginate;
|
|
377
371
|
|
|
@@ -445,8 +439,13 @@ export default {
|
|
|
445
439
|
const watchMsg = {
|
|
446
440
|
type,
|
|
447
441
|
id,
|
|
448
|
-
|
|
449
|
-
|
|
442
|
+
// Although not used by sockets, we need this for when resyncWatch calls find.... which needs namespace to construct the url
|
|
443
|
+
namespace: opt.namespaced,
|
|
444
|
+
// Override the revision. Used in cases where we need to avoid using the resource's own revision which would be `too old`.
|
|
445
|
+
// For the above case opt.revision will be `null`. If left as `undefined` the subscribe mechanism will try to determine a revision
|
|
446
|
+
// from resources in store (which would be this one, with the too old revision)
|
|
447
|
+
revision: typeof opt.revision !== 'undefined' ? opt.revision : res?.metadata?.resourceVersion,
|
|
448
|
+
force: opt.forceWatch === true,
|
|
450
449
|
};
|
|
451
450
|
|
|
452
451
|
const idx = id.indexOf('/');
|
|
@@ -12,7 +12,24 @@ export function classify(ctx, obj, isClone = false) {
|
|
|
12
12
|
|
|
13
13
|
const customModel = ctx.getters['classify'](obj);
|
|
14
14
|
|
|
15
|
-
const out = new customModel(obj, ctx, null, isClone);
|
|
15
|
+
const out = new customModel(obj, ctx, (process.server ? ctx.state.config.namespace : null), isClone);
|
|
16
|
+
|
|
17
|
+
if ( process.server ) {
|
|
18
|
+
Object.defineProperty(obj, '__rehydrate', {
|
|
19
|
+
value: ctx.state.config.namespace,
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if ( isClone ) {
|
|
25
|
+
Object.defineProperty(obj, '__clone', {
|
|
26
|
+
value: true,
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
16
33
|
|
|
17
34
|
return out;
|
|
18
35
|
}
|
|
@@ -64,24 +64,19 @@ export default {
|
|
|
64
64
|
return state.types[type].list;
|
|
65
65
|
},
|
|
66
66
|
|
|
67
|
-
matching: (state, getters, rootState) => (type, selector, namespace
|
|
68
|
-
let
|
|
67
|
+
matching: (state, getters, rootState) => (type, selector, namespace) => {
|
|
68
|
+
let all = getters['all'](type);
|
|
69
69
|
|
|
70
70
|
// Filter first by namespace if one is provided, since this is efficient
|
|
71
|
-
if (namespace
|
|
72
|
-
|
|
71
|
+
if (namespace) {
|
|
72
|
+
all = all.filter((obj) => obj.namespace === namespace);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
garbageCollect.gcUpdateLastAccessed({
|
|
76
76
|
state, getters, rootState
|
|
77
77
|
}, type);
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
if (config.skipSelector) {
|
|
81
|
-
return matching;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return matching.filter((obj) => {
|
|
79
|
+
return all.filter((obj) => {
|
|
85
80
|
return matches(obj, selector);
|
|
86
81
|
});
|
|
87
82
|
},
|
|
@@ -33,9 +33,21 @@ export default (vuexModule, config, init) => {
|
|
|
33
33
|
const namespace = config.namespace || '';
|
|
34
34
|
|
|
35
35
|
return function(store) {
|
|
36
|
+
// const inst = SteveFactory(namespace, config.baseUrl);
|
|
37
|
+
|
|
36
38
|
store.registerModule(namespace, vuexModule);
|
|
37
39
|
store.commit(`${ namespace }/applyConfig`, config);
|
|
38
40
|
|
|
41
|
+
if ( !process.client ) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// store.subscribe(({ type }, state) => {
|
|
46
|
+
// if ( type === 'auth/loggedOut' ) {
|
|
47
|
+
// store.dispatch(`${ namespace }/unsubscribe`);
|
|
48
|
+
// }
|
|
49
|
+
// });
|
|
50
|
+
|
|
39
51
|
const module = store._modules.root._children[namespace];
|
|
40
52
|
const fromServer = window.__NUXT__;
|
|
41
53
|
|
|
@@ -23,6 +23,10 @@ function registerType(state, type) {
|
|
|
23
23
|
// Not enumerable so they don't get sent back to the client for SSR
|
|
24
24
|
Object.defineProperty(cache, 'map', { value: new Map() });
|
|
25
25
|
|
|
26
|
+
if ( process.server && !cache.list.__rehydrateAll ) {
|
|
27
|
+
Object.defineProperty(cache.list, '__rehydrateAll', { value: `${ state.config.namespace }/${ type }`, enumerable: true });
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
Vue.set(state.types, type, cache);
|
|
27
31
|
}
|
|
28
32
|
|
|
@@ -105,7 +105,6 @@ export const STATES_ENUM = {
|
|
|
105
105
|
ERRORING: 'erroring',
|
|
106
106
|
ERRORS: 'errors',
|
|
107
107
|
EXPIRED: 'expired',
|
|
108
|
-
EXPIRING: 'expiring',
|
|
109
108
|
FAIL: 'fail',
|
|
110
109
|
FAILED: 'failed',
|
|
111
110
|
HEALTHY: 'healthy',
|
|
@@ -168,13 +167,6 @@ export const STATES_ENUM = {
|
|
|
168
167
|
WARNING: 'warning',
|
|
169
168
|
};
|
|
170
169
|
|
|
171
|
-
export function mapStateToEnum(statusString) {
|
|
172
|
-
// e.g. in fleet Status is Capitalized. This function will map it to the enum
|
|
173
|
-
return Object.values(STATES_ENUM).find((val) => {
|
|
174
|
-
return val.toLowerCase() === statusString.toLocaleLowerCase();
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
170
|
export const STATES = {
|
|
179
171
|
[STATES_ENUM.IN_USE]: {
|
|
180
172
|
color: 'success', icon: 'dot-open', label: 'In Use', compoundIcon: 'checkmark'
|
|
@@ -261,10 +253,7 @@ export const STATES = {
|
|
|
261
253
|
color: 'error', icon: 'error', label: 'Errors', compoundIcon: 'error'
|
|
262
254
|
},
|
|
263
255
|
[STATES_ENUM.EXPIRED]: {
|
|
264
|
-
color: '
|
|
265
|
-
},
|
|
266
|
-
[STATES_ENUM.EXPIRING]: {
|
|
267
|
-
color: 'warning', icon: 'error', label: 'Expiring', compoundIcon: 'error'
|
|
256
|
+
color: 'warning', icon: 'error', label: 'Expired', compoundIcon: 'warning'
|
|
268
257
|
},
|
|
269
258
|
[STATES_ENUM.FAIL]: {
|
|
270
259
|
color: 'error', icon: 'error', label: 'Fail', compoundIcon: 'error'
|
|
@@ -523,28 +512,6 @@ export function stateDisplay(state) {
|
|
|
523
512
|
return key.split(/-/).map(ucFirst).join('-');
|
|
524
513
|
}
|
|
525
514
|
|
|
526
|
-
export function primaryDisplayStatusFromCount(status) {
|
|
527
|
-
const statusOrder = [
|
|
528
|
-
STATES_ENUM.ERROR,
|
|
529
|
-
STATES_ENUM.FAILED,
|
|
530
|
-
STATES_ENUM.WARNING,
|
|
531
|
-
STATES_ENUM.MODIFIED,
|
|
532
|
-
STATES_ENUM.WAIT_APPLIED,
|
|
533
|
-
STATES_ENUM.ORPHANED,
|
|
534
|
-
STATES_ENUM.MISSING,
|
|
535
|
-
STATES_ENUM.UNKNOWN,
|
|
536
|
-
STATES_ENUM.NOT_READY,
|
|
537
|
-
STATES_ENUM.READY,
|
|
538
|
-
];
|
|
539
|
-
|
|
540
|
-
// sort status by order of statusOrder
|
|
541
|
-
const existingStatuses = Object.keys(status).filter((key) => {
|
|
542
|
-
return status[key] > 0 && statusOrder.includes(key.toLowerCase());
|
|
543
|
-
}).sort((a, b) => statusOrder.indexOf(a.toLowerCase()) - statusOrder.indexOf(b.toLowerCase()));
|
|
544
|
-
|
|
545
|
-
return existingStatuses[0] ? existingStatuses[0] : STATES_ENUM.UNKNOWN;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
515
|
export function stateSort(color, display) {
|
|
549
516
|
color = color.replace(/^(text|bg)-/, '');
|
|
550
517
|
|
|
@@ -1122,16 +1089,6 @@ export default class Resource {
|
|
|
1122
1089
|
return this._save(...arguments);
|
|
1123
1090
|
}
|
|
1124
1091
|
|
|
1125
|
-
/**
|
|
1126
|
-
* Remove any unwanted properties from the object that will be saved
|
|
1127
|
-
*/
|
|
1128
|
-
cleanForSave(data, forNew) {
|
|
1129
|
-
delete data.__rehydrate;
|
|
1130
|
-
delete data.__clone;
|
|
1131
|
-
|
|
1132
|
-
return data;
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
1092
|
/**
|
|
1136
1093
|
* Allow to handle the response of the save request
|
|
1137
1094
|
* @param {*} res Full request response
|
|
@@ -1139,6 +1096,9 @@ export default class Resource {
|
|
|
1139
1096
|
processSaveResponse(res) { }
|
|
1140
1097
|
|
|
1141
1098
|
async _save(opt = {}) {
|
|
1099
|
+
delete this.__rehydrate;
|
|
1100
|
+
delete this.__clone;
|
|
1101
|
+
|
|
1142
1102
|
const forNew = !this.id;
|
|
1143
1103
|
|
|
1144
1104
|
const errors = await this.validationErrors(this, opt.ignoreFields);
|
|
@@ -1185,24 +1145,22 @@ export default class Resource {
|
|
|
1185
1145
|
// @TODO remove this once the API maps steve _type <-> k8s type in both directions
|
|
1186
1146
|
opt.data = this.toSave() || { ...this };
|
|
1187
1147
|
|
|
1188
|
-
if (opt
|
|
1148
|
+
if (opt?.data._type) {
|
|
1189
1149
|
opt.data.type = opt.data._type;
|
|
1190
1150
|
}
|
|
1191
1151
|
|
|
1192
|
-
if (opt
|
|
1152
|
+
if (opt?.data._name) {
|
|
1193
1153
|
opt.data.name = opt.data._name;
|
|
1194
1154
|
}
|
|
1195
1155
|
|
|
1196
|
-
if (opt
|
|
1156
|
+
if (opt?.data._labels) {
|
|
1197
1157
|
opt.data.labels = opt.data._labels;
|
|
1198
1158
|
}
|
|
1199
1159
|
|
|
1200
|
-
if (opt
|
|
1160
|
+
if (opt?.data._annotations) {
|
|
1201
1161
|
opt.data.annotations = opt.data._annotations;
|
|
1202
1162
|
}
|
|
1203
1163
|
|
|
1204
|
-
opt.data = this.cleanForSave(opt.data, forNew);
|
|
1205
|
-
|
|
1206
1164
|
// handle "replace" opt as a query param _replace=true for norman PUT requests
|
|
1207
1165
|
if (opt?.replace && opt.method === 'put') {
|
|
1208
1166
|
const argParam = opt.url.includes('?') ? '&' : '?';
|
|
@@ -1260,11 +1218,19 @@ export default class Resource {
|
|
|
1260
1218
|
// ------------------------------------------------------------------
|
|
1261
1219
|
|
|
1262
1220
|
currentRoute() {
|
|
1263
|
-
|
|
1221
|
+
if ( process.server ) {
|
|
1222
|
+
return this.$rootState.$route;
|
|
1223
|
+
} else {
|
|
1224
|
+
return window.$nuxt.$route;
|
|
1225
|
+
}
|
|
1264
1226
|
}
|
|
1265
1227
|
|
|
1266
1228
|
currentRouter() {
|
|
1267
|
-
|
|
1229
|
+
if ( process.server ) {
|
|
1230
|
+
return this.$rootState.$router;
|
|
1231
|
+
} else {
|
|
1232
|
+
return window.$nuxt.$router;
|
|
1233
|
+
}
|
|
1268
1234
|
}
|
|
1269
1235
|
|
|
1270
1236
|
get listLocation() {
|
|
@@ -1965,11 +1931,4 @@ export default class Resource {
|
|
|
1965
1931
|
get creationTimestamp() {
|
|
1966
1932
|
return this.metadata?.creationTimestamp;
|
|
1967
1933
|
}
|
|
1968
|
-
|
|
1969
|
-
/**
|
|
1970
|
-
* Allows model to specify JSON Paths that should be folded in the YAML editor by default
|
|
1971
|
-
*/
|
|
1972
|
-
get yamlFolding() {
|
|
1973
|
-
return [];
|
|
1974
|
-
}
|
|
1975
1934
|
}
|
package/plugins/i18n.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Vue from 'vue';
|
|
2
2
|
import { escapeHtml } from '../utils/string';
|
|
3
3
|
|
|
4
|
-
function stringFor(store, key, args, raw = false, escapehtml = true) {
|
|
4
|
+
export function stringFor(store, key, args, raw = false, escapehtml = true) {
|
|
5
5
|
const translation = store.getters['i18n/t'](key, args);
|
|
6
6
|
|
|
7
7
|
let out;
|