@rancher/shell 1.2.3 → 1.2.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.
- package/assets/translations/en-us.yaml +49 -18
- package/assets/translations/zh-hans.yaml +1 -0
- package/cloud-credential/__tests__/harvester.test.ts +18 -0
- package/cloud-credential/harvester.vue +9 -1
- package/components/AlertTable.vue +17 -7
- package/components/GrafanaDashboard.vue +6 -4
- package/components/nav/Header.vue +9 -5
- package/components/nav/TopLevelMenu.vue +1 -4
- package/config/product/explorer.js +11 -4
- package/config/settings.ts +9 -2
- package/config/types.js +1 -1
- package/config/uiplugins.js +2 -2
- package/detail/catalog.cattle.io.app.vue +17 -4
- package/edit/management.cattle.io.setting.vue +15 -2
- package/edit/provisioning.cattle.io.cluster/RegistryConfigs.vue +8 -2
- package/edit/provisioning.cattle.io.cluster/__tests__/RegistryConfigs.test.ts +61 -0
- package/edit/provisioning.cattle.io.cluster/__tests__/utils/cluster.ts +386 -0
- package/edit/provisioning.cattle.io.cluster/rke2.vue +73 -77
- package/edit/provisioning.cattle.io.cluster/tabs/AddOnAdditionalManifest.vue +45 -0
- package/edit/provisioning.cattle.io.cluster/tabs/AddOnConfig.vue +97 -0
- package/mixins/chart.js +6 -2
- package/models/catalog.cattle.io.app.js +112 -21
- package/models/management.cattle.io.cluster.js +18 -6
- package/package.json +1 -1
- package/pages/c/_cluster/apps/charts/install.vue +2 -1
- package/plugins/dashboard-store/actions.js +3 -2
- package/scripts/extension/bundle +1 -1
- package/scripts/publish-shell.sh +62 -55
- package/scripts/test-plugins-build.sh +111 -29
- package/scripts/typegen.sh +26 -23
- package/store/catalog.js +1 -1
- package/store/features.js +1 -0
- package/store/type-map.utils.ts +44 -0
- package/types/shell/index.d.ts +2 -0
- package/types/store/dashboard-store.types.ts +23 -0
- package/types/store/vuex.d.ts +9 -0
- package/utils/cluster.js +9 -0
- package/utils/v-sphere.ts +277 -0
- package/.DS_Store +0 -0
- package/creators/app/app.package.json +0 -13
- package/creators/app/files/.eslintignore +0 -18
- package/creators/app/files/.eslintrc.js +0 -173
- package/creators/app/files/.gitignore +0 -70
- package/creators/app/files/.vscode/settings.json +0 -22
- package/creators/app/files/babel.config.js +0 -1
- package/creators/app/files/tsconfig.json +0 -42
- package/creators/app/files/vue.config.js +0 -6
- package/creators/app/init +0 -101
- package/creators/app/package.json +0 -25
- package/creators/pkg/files/.github/workflows/build-extension-catalog.yml +0 -28
- package/creators/pkg/files/.github/workflows/build-extension-charts.yml +0 -26
- package/creators/pkg/files/babel.config.js +0 -1
- package/creators/pkg/files/index.ts +0 -14
- package/creators/pkg/files/tsconfig.json +0 -53
- package/creators/pkg/files/vue.config.js +0 -1
- package/creators/pkg/init +0 -254
- package/creators/pkg/package.json +0 -19
- package/creators/pkg/pkg.package.json +0 -21
- package/creators/pkg/vue-shim.ts +0 -4
- package/creators/update/init +0 -56
- package/creators/update/package.json +0 -20
- package/creators/update/upgrade +0 -56
|
@@ -7,6 +7,9 @@ echo "Checking plugin build"
|
|
|
7
7
|
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|
8
8
|
BASE_DIR="$( cd $SCRIPT_DIR && cd ../.. & pwd)"
|
|
9
9
|
SHELL_DIR=$BASE_DIR/shell/
|
|
10
|
+
SHELL_VERSION="99.99.99"
|
|
11
|
+
DEFAULT_NPM_REGISTRY="https://registry.npmjs.org/"
|
|
12
|
+
VERDACCIO_NPM_REGISTRY="http://localhost:4873"
|
|
10
13
|
|
|
11
14
|
echo ${SCRIPT_DIR}
|
|
12
15
|
|
|
@@ -66,29 +69,46 @@ else
|
|
|
66
69
|
rm -rf ~/.config/verdaccio/storage/@rancher/*
|
|
67
70
|
fi
|
|
68
71
|
|
|
69
|
-
export
|
|
72
|
+
export NPM_REGISTRY=$VERDACCIO_NPM_REGISTRY
|
|
70
73
|
export NUXT_TELEMETRY_DISABLED=1
|
|
71
74
|
|
|
72
75
|
# Remove test package from previous run, if present
|
|
73
|
-
|
|
76
|
+
if [ "${TEST_PERSIST_BUILD}" != "true" ]; then
|
|
77
|
+
echo "Removing folder ${BASE_DIR}/pkg/test-pkg"
|
|
78
|
+
rm -rf ${BASE_DIR}/pkg/test-pkg
|
|
79
|
+
fi
|
|
74
80
|
|
|
75
81
|
# We need to patch the version number of the shell, otherwise if we are running
|
|
76
82
|
# with the currently published version, things will fail as those versions
|
|
77
83
|
# are already published and Verdaccio will check, since it is a read-through cache
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
update_version_in_package_json() {
|
|
85
|
+
local package_json_path="$1"
|
|
86
|
+
local version="$2"
|
|
87
|
+
|
|
88
|
+
sed -i.bak -e "s/\"version\": \"[0-9]*.[0-9]*.[0-9]*\(-alpha\.[0-9]*\|-release[0-9]*.[0-9]*.[0-9]*\|-rc\.[0-9]*\)\{0,1\}\",/\"version\": \"${version}\",/g" "$package_json_path"
|
|
89
|
+
rm "${package_json_path}.bak"
|
|
90
|
+
}
|
|
80
91
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
92
|
+
update_version_in_package_json "${SHELL_DIR}/package.json" "${SHELL_VERSION}"
|
|
93
|
+
update_version_in_package_json "${BASE_DIR}/pkg/rancher-components/package.json" "${SHELL_VERSION}"
|
|
94
|
+
update_version_in_package_json "${BASE_DIR}/creators/extension/package.json" "${SHELL_VERSION}"
|
|
84
95
|
|
|
85
|
-
# Publish shell
|
|
86
|
-
echo "Publishing
|
|
96
|
+
# Publish shell pkg (tag is needed as publish-shell is optimized to work with release-shell-pkg workflow)
|
|
97
|
+
echo "Publishing Shell package to local registry"
|
|
87
98
|
yarn install
|
|
99
|
+
export TAG="shell-pkg-v${SHELL_VERSION}"
|
|
100
|
+
${SHELL_DIR}/scripts/publish-shell.sh
|
|
101
|
+
|
|
102
|
+
# Publish creators pkg (tag is needed as publish-shell is optimized to work with release-shell-pkg workflow)
|
|
103
|
+
echo "Publishing Creators package to local registry"
|
|
104
|
+
export TAG="creators-pkg-v${SHELL_VERSION}"
|
|
88
105
|
${SHELL_DIR}/scripts/publish-shell.sh
|
|
89
106
|
|
|
90
107
|
# Publish rancher components
|
|
91
108
|
yarn build:lib
|
|
109
|
+
|
|
110
|
+
npm set registry ${VERDACCIO_NPM_REGISTRY}
|
|
111
|
+
yarn config set registry ${VERDACCIO_NPM_REGISTRY}
|
|
92
112
|
yarn publish:lib
|
|
93
113
|
|
|
94
114
|
# We pipe into cat for cleaner logging - we need to set pipefail
|
|
@@ -101,25 +121,18 @@ if [ "${SKIP_STANDALONE}" == "false" ]; then
|
|
|
101
121
|
|
|
102
122
|
echo "Using temporary directory ${DIR}"
|
|
103
123
|
|
|
104
|
-
echo "Verifying
|
|
124
|
+
echo "Verifying extension creator"
|
|
105
125
|
|
|
106
|
-
yarn create @rancher/app test-app
|
|
107
|
-
pushd test-app
|
|
108
|
-
yarn install
|
|
109
|
-
|
|
110
|
-
echo "Building skeleton app"
|
|
111
|
-
FORCE_COLOR=true yarn build | cat
|
|
126
|
+
FORCE_COLOR=true yarn create @rancher/extension test-pkg --app-name test-app | cat
|
|
112
127
|
|
|
113
|
-
|
|
114
|
-
echo "Verifying package creator package"
|
|
115
|
-
yarn create @rancher/pkg test-pkg
|
|
128
|
+
pushd test-app > /dev/null
|
|
116
129
|
|
|
117
|
-
|
|
118
|
-
FORCE_COLOR=true yarn build
|
|
130
|
+
yarn install
|
|
131
|
+
FORCE_COLOR=true yarn build | cat
|
|
119
132
|
|
|
120
133
|
# Add test list component to the test package
|
|
121
134
|
# Validates rancher-components imports
|
|
122
|
-
mkdir pkg/test-pkg/list
|
|
135
|
+
mkdir -p pkg/test-pkg/list
|
|
123
136
|
cp ${SHELL_DIR}/list/catalog.cattle.io.clusterrepo.vue pkg/test-pkg/list
|
|
124
137
|
|
|
125
138
|
FORCE_COLOR=true yarn build-pkg test-pkg | cat
|
|
@@ -127,22 +140,91 @@ if [ "${SKIP_STANDALONE}" == "false" ]; then
|
|
|
127
140
|
echo "Cleaning temporary dir"
|
|
128
141
|
popd > /dev/null
|
|
129
142
|
|
|
130
|
-
|
|
143
|
+
if [ "${TEST_PERSIST_BUILD}" != "true" ]; then
|
|
144
|
+
echo "Removing folder ${DIR}"
|
|
145
|
+
rm -rf ${DIR}
|
|
146
|
+
fi
|
|
131
147
|
fi
|
|
132
148
|
|
|
133
149
|
pushd $BASE_DIR
|
|
134
|
-
pwd
|
|
135
|
-
ls
|
|
136
150
|
|
|
137
151
|
# Now try a plugin within the dashboard codebase
|
|
138
152
|
echo "Validating in-tree package"
|
|
139
153
|
|
|
140
154
|
yarn install
|
|
141
155
|
|
|
142
|
-
|
|
143
|
-
|
|
156
|
+
if [ "${TEST_PERSIST_BUILD}" != "true" ]; then
|
|
157
|
+
echo "Removing folder ./pkg/test-pkg"
|
|
158
|
+
rm -rf ./pkg/test-pkg
|
|
159
|
+
fi
|
|
160
|
+
|
|
161
|
+
yarn create @rancher/extension test-pkg -i
|
|
144
162
|
cp ${SHELL_DIR}/list/catalog.cattle.io.clusterrepo.vue ./pkg/test-pkg/list
|
|
145
163
|
FORCE_COLOR=true yarn build-pkg test-pkg | cat
|
|
146
|
-
rm -rf ./pkg/test-pkg
|
|
147
164
|
|
|
148
|
-
|
|
165
|
+
if [ "${TEST_PERSIST_BUILD}" != "true" ]; then
|
|
166
|
+
echo "Removing folder ./pkg/test-pkg"
|
|
167
|
+
rm -rf ./pkg/test-pkg
|
|
168
|
+
fi
|
|
169
|
+
|
|
170
|
+
# function to clone repos and install dependencies (including the newly published shell version)
|
|
171
|
+
function clone_repo_test_extension_build() {
|
|
172
|
+
REPO_NAME=$1
|
|
173
|
+
PKG_NAME=$2
|
|
174
|
+
|
|
175
|
+
echo -e "\nSetting up $REPO_NAME repository locally\n"
|
|
176
|
+
|
|
177
|
+
# set registry to default (to install all of the other dependencies)
|
|
178
|
+
yarn config set registry ${DEFAULT_NPM_REGISTRY}
|
|
179
|
+
|
|
180
|
+
if [ "${TEST_PERSIST_BUILD}" != "true" ]; then
|
|
181
|
+
echo "Removing folder ${BASE_DIR}/$REPO_NAME"
|
|
182
|
+
rm -rf ${BASE_DIR}/$REPO_NAME
|
|
183
|
+
fi
|
|
184
|
+
|
|
185
|
+
# cloning repo
|
|
186
|
+
git clone https://github.com/rancher/$REPO_NAME.git
|
|
187
|
+
pushd ${BASE_DIR}/$REPO_NAME
|
|
188
|
+
|
|
189
|
+
echo -e "\nInstalling dependencies for $REPO_NAME\n"
|
|
190
|
+
yarn install
|
|
191
|
+
|
|
192
|
+
# set registry to local verdaccio (to install new shell)
|
|
193
|
+
yarn config set registry ${VERDACCIO_NPM_REGISTRY}
|
|
194
|
+
|
|
195
|
+
# update package.json to use a specific version of shell
|
|
196
|
+
sed -i.bak -e "s/\"\@rancher\/shell\": \"[0-9]*.[0-9]*.[0-9]*\",/\"\@rancher\/shell\": \"${SHELL_VERSION}\",/g" package.json
|
|
197
|
+
rm package.json.bak
|
|
198
|
+
|
|
199
|
+
# we need to remove yarn.lock, otherwise it would install a version that we don't want
|
|
200
|
+
rm yarn.lock
|
|
201
|
+
|
|
202
|
+
echo -e "\nInstalling newly built shell version\n"
|
|
203
|
+
|
|
204
|
+
# installing new version of shell
|
|
205
|
+
yarn add @rancher/shell@${SHELL_VERSION}
|
|
206
|
+
|
|
207
|
+
# test build-pkg
|
|
208
|
+
FORCE_COLOR=true yarn build-pkg $PKG_NAME | cat
|
|
209
|
+
|
|
210
|
+
# # kubewarden has some unit tests and they should be quick to run... Let's check them as well
|
|
211
|
+
# if [ "${REPO_NAME}" == "kubewarden-ui" ]; then
|
|
212
|
+
# yarn test:ci
|
|
213
|
+
# fi
|
|
214
|
+
|
|
215
|
+
# return back to the base path
|
|
216
|
+
popd
|
|
217
|
+
|
|
218
|
+
# delete folder
|
|
219
|
+
echo "Removing folder ${BASE_DIR}/$REPO_NAME"
|
|
220
|
+
rm -rf ${BASE_DIR}/$REPO_NAME
|
|
221
|
+
yarn config set registry ${DEFAULT_NPM_REGISTRY}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
# Here we just add the extension that we want to include as a check (all our official extensions should be included here)
|
|
225
|
+
# Don't forget to add the unit tests exception to clone_repo_test_extension_build function if a new extension has those
|
|
226
|
+
# clone_repo_test_extension_build "kubewarden-ui" "kubewarden"
|
|
227
|
+
# clone_repo_test_extension_build "elemental-ui" "elemental"
|
|
228
|
+
# clone_repo_test_extension_build "capi-ui-extension" "capi"
|
|
229
|
+
|
|
230
|
+
echo "All done"
|
package/scripts/typegen.sh
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
|
|
3
3
|
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|
4
|
-
BASE_DIR="$(
|
|
4
|
+
BASE_DIR="$(git rev-parse --show-toplevel)"
|
|
5
5
|
SHELL_DIR=$BASE_DIR/shell
|
|
6
6
|
|
|
7
7
|
echo "Generating typescript definitions"
|
|
@@ -12,37 +12,40 @@ mkdir -p ${SHELL_DIR}/tmp
|
|
|
12
12
|
echo "Generating ..."
|
|
13
13
|
|
|
14
14
|
# utils
|
|
15
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
16
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
17
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
15
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/utils/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/utils > /dev/null
|
|
16
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/utils/validators/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/utils/validators > /dev/null
|
|
17
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/utils/crypto/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/utils/crypto > /dev/null
|
|
18
18
|
|
|
19
19
|
# config
|
|
20
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
21
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
22
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
23
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
20
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/config/query-params.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/config > /dev/null
|
|
21
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/config/table-headers.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/config > /dev/null
|
|
22
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/config/types.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/config > /dev/null
|
|
23
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/config/labels-annotations.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/config > /dev/null
|
|
24
24
|
|
|
25
|
-
# store
|
|
26
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
27
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
25
|
+
# # store
|
|
26
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/store/features.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/store > /dev/null
|
|
27
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/store/prefs.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/store > /dev/null
|
|
28
28
|
|
|
29
|
-
# plugins
|
|
30
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
31
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
32
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
33
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
29
|
+
# # plugins
|
|
30
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/plugins/dashboard-store/normalize.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
|
|
31
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/plugins/dashboard-store/resource-class.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
|
|
32
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/plugins/dashboard-store/classify.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
|
|
33
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/plugins/dashboard-store/actions.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
|
|
34
34
|
|
|
35
|
-
# mixins
|
|
36
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
35
|
+
# # mixins
|
|
36
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/mixins/create-edit-view/index.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/mixins/create-edit-view > /dev/null
|
|
37
37
|
|
|
38
|
-
# models
|
|
39
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
40
|
-
${BASE_DIR}/node_modules/.bin/tsc
|
|
38
|
+
# # models
|
|
39
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/models/namespace.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/models/ > /dev/null
|
|
40
|
+
${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/models/networking.k8s.io.ingress.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/models/ > /dev/null
|
|
41
41
|
|
|
42
|
-
#./node_modules/.bin/tsc
|
|
42
|
+
#./node_modules/.bin/tsc ${SHELL_DIR}/plugins/dashboard-store/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store
|
|
43
43
|
|
|
44
44
|
# Go through all of the folders and combine by wrapping with 'declare module'
|
|
45
45
|
|
|
46
|
+
echo "Contents of ${SHELL_DIR}/tmp after tsc commands:"
|
|
47
|
+
find ${SHELL_DIR}/tmp
|
|
48
|
+
|
|
46
49
|
echo "Combining type definitions ..."
|
|
47
50
|
|
|
48
51
|
DEST=${SHELL_DIR}/types/shell
|
|
@@ -90,4 +93,4 @@ function processDir() {
|
|
|
90
93
|
|
|
91
94
|
processDir ${SHELL_DIR}/tmp @shell
|
|
92
95
|
|
|
93
|
-
rm -rf ${SHELL_DIR}/tmp
|
|
96
|
+
rm -rf ${SHELL_DIR}/tmp
|
package/store/catalog.js
CHANGED
|
@@ -354,7 +354,7 @@ export const actions = {
|
|
|
354
354
|
|
|
355
355
|
// As per comment above, when there are no clusters this will be management. Store it such that it can be used for those cases
|
|
356
356
|
commit('setInStore', inStore);
|
|
357
|
-
hash.cluster = hash.cluster
|
|
357
|
+
hash.cluster = hash.cluster?.filter((repo) => !(repo?.metadata?.annotations?.[CATALOG_ANNOTATIONS.HIDDEN_REPO] === 'true'));
|
|
358
358
|
|
|
359
359
|
commit('setRepos', hash);
|
|
360
360
|
|
package/store/features.js
CHANGED
|
@@ -32,6 +32,7 @@ export const FLEET = create('continuous-delivery', true);
|
|
|
32
32
|
export const HARVESTER = create('harvester', true);
|
|
33
33
|
export const HARVESTER_CONTAINER = create('harvester-baremetal-container-workload', false);
|
|
34
34
|
export const FLEET_WORKSPACE_BACK = create('provisioningv2-fleet-workspace-back-population', false);
|
|
35
|
+
export const PROVISIONING_PRE_BOOTSTRAP = create('provisioningprebootstrap', false);
|
|
35
36
|
|
|
36
37
|
// Not currently used.. no point defining ones we don't use
|
|
37
38
|
// export const EMBEDDED_CLUSTER_API = create('embedded-cluster-api', true);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { VuexStoreGetters } from '@shell/types/store/vuex';
|
|
2
|
+
import { COUNT } from '@shell/config/types';
|
|
3
|
+
import { ActionFindAllArgs } from '@shell/types/store/dashboard-store.types';
|
|
4
|
+
|
|
5
|
+
type conditionalDepaginateArgs ={
|
|
6
|
+
ctx: { rootGetters: VuexStoreGetters},
|
|
7
|
+
args: { type: string, opt: ActionFindAllArgs},
|
|
8
|
+
};
|
|
9
|
+
type conditionalDepaginateFn = (args: conditionalDepaginateArgs) => boolean
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Conditionally determine if a resource should use naive kube pagination api to fetch all results
|
|
13
|
+
* (not just first page)
|
|
14
|
+
*/
|
|
15
|
+
export const conditionalDepaginate = (
|
|
16
|
+
depaginate?: conditionalDepaginateFn | boolean,
|
|
17
|
+
depaginateArgs?: conditionalDepaginateArgs
|
|
18
|
+
): boolean => {
|
|
19
|
+
if (typeof depaginate === 'function') {
|
|
20
|
+
return !!depaginateArgs ? depaginate(depaginateArgs) : false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return depaginate as boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Setup a function that will determine if a resource should use native kube pagination api to fetch all resources
|
|
28
|
+
* (not just the first page)
|
|
29
|
+
*/
|
|
30
|
+
export const configureConditionalDepaginate = (
|
|
31
|
+
{ maxResourceCount, isNorman = false }: { maxResourceCount: number, isNorman: boolean },
|
|
32
|
+
): conditionalDepaginateFn => {
|
|
33
|
+
return (fnArgs: conditionalDepaginateArgs ): boolean => {
|
|
34
|
+
const { rootGetters } = fnArgs.ctx;
|
|
35
|
+
const { type } = fnArgs.args;
|
|
36
|
+
const safeType = isNorman ? `management.cattle.io.${ type }` : type;
|
|
37
|
+
|
|
38
|
+
const inStore = rootGetters['currentStore'](safeType);
|
|
39
|
+
const resourceCounts = rootGetters[`${ inStore }/all`](COUNT)[0]?.counts[safeType];
|
|
40
|
+
const resourceCount = resourceCounts?.summary?.count;
|
|
41
|
+
|
|
42
|
+
return resourceCount !== undefined ? resourceCount < maxResourceCount : false;
|
|
43
|
+
};
|
|
44
|
+
};
|
package/types/shell/index.d.ts
CHANGED
|
@@ -2873,6 +2873,7 @@ export const FLEET: any;
|
|
|
2873
2873
|
export const HARVESTER: any;
|
|
2874
2874
|
export const HARVESTER_CONTAINER: any;
|
|
2875
2875
|
export const FLEET_WORKSPACE_BACK: any;
|
|
2876
|
+
export const PROVISIONING_PRE_BOOTSTRAP: any;
|
|
2876
2877
|
export namespace getters {
|
|
2877
2878
|
function get(state: any, getters: any, rootState: any, rootGetters: any): (name: any) => any;
|
|
2878
2879
|
}
|
|
@@ -3127,6 +3128,7 @@ export function filterHiddenLocalCluster(mgmtClusters: any, store: any): any;
|
|
|
3127
3128
|
* @example smallIdentifier('word-wide-web') => 'www'
|
|
3128
3129
|
*/
|
|
3129
3130
|
export function abbreviateClusterName(input: string): string;
|
|
3131
|
+
export function labelForAddon(name: any, configuration?: boolean): any;
|
|
3130
3132
|
}
|
|
3131
3133
|
|
|
3132
3134
|
// @shell/utils/color
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Properties on all findX actions
|
|
3
|
+
*/
|
|
4
|
+
export type ActionCoreFindArgs = {
|
|
5
|
+
force?: boolean,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Args used for findAll action
|
|
10
|
+
*/
|
|
11
|
+
export interface ActionFindAllArgs extends ActionCoreFindArgs {
|
|
12
|
+
watch?: boolean,
|
|
13
|
+
namespaced?: string[],
|
|
14
|
+
incremental?: boolean,
|
|
15
|
+
hasManualRefresh?: boolean,
|
|
16
|
+
limit?: number,
|
|
17
|
+
/**
|
|
18
|
+
* Iterate over all pages and return all resources.
|
|
19
|
+
*
|
|
20
|
+
* This is done via the native kube pagination api, not steve
|
|
21
|
+
*/
|
|
22
|
+
depaginate?: boolean,
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Unfortunately there's no current way to type the vuex store, however we have ts files that references it
|
|
2
|
+
// Until we bring that in, this file can contain the interfaces and types used by ts files in place of `any`
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generic interface for Vuex getters
|
|
6
|
+
*/
|
|
7
|
+
export interface VuexStoreGetters {
|
|
8
|
+
[name: string]: Function;
|
|
9
|
+
}
|
package/utils/cluster.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
|
+
import { camelToTitle } from '@shell/utils/string';
|
|
2
3
|
import { CAPI } from '@shell/config/labels-annotations';
|
|
3
4
|
import { MANAGEMENT, VIRTUAL_HARVESTER_PROVIDER } from '@shell/config/types';
|
|
4
5
|
import { SETTING } from '@shell/config/settings';
|
|
@@ -90,3 +91,11 @@ export function abbreviateClusterName(input) {
|
|
|
90
91
|
|
|
91
92
|
return result;
|
|
92
93
|
}
|
|
94
|
+
|
|
95
|
+
export function labelForAddon(name, configuration = true) {
|
|
96
|
+
const addon = camelToTitle(name.replace(/^(rke|rke2|rancher)-/, ''));
|
|
97
|
+
const fallback = `${ configuration ? '' : 'Add-on: ' }${ addon }`;
|
|
98
|
+
const key = `cluster.addonChart."${ name }"${ configuration ? '.configuration' : '.label' }`;
|
|
99
|
+
|
|
100
|
+
return this.$store.getters['i18n/withFallback'](key, null, fallback);
|
|
101
|
+
}
|