@rancher/shell 3.0.12-rc.5 → 3.0.12-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/apis/intf/resources-api/resource-base.ts +42 -2
- package/apis/intf/resources-api/resource-instance.ts +101 -0
- package/apis/intf/resources-api/resources-api.ts +177 -23
- package/apis/intf/resources.ts +8 -6
- package/apis/intf/shell-api/slide-in.ts +46 -17
- package/apis/resources/__tests__/resources-api-class.test.ts +309 -28
- package/apis/resources/resources-api-class.ts +232 -43
- package/apis/shell/__tests__/slide-in.test.ts +83 -2
- package/apis/shell/slide-in.ts +20 -0
- package/assets/images/providers/traefik.png +0 -0
- package/assets/translations/en-us.yaml +10 -4
- package/chart/__tests__/rancher-monitoring-dashboards-index.test.ts +269 -0
- package/chart/rancher-monitoring-dashboards/index.vue +155 -0
- package/cloud-credential/__tests__/generic.test.ts +132 -0
- package/cloud-credential/generic.vue +33 -3
- package/components/EtcdInfoBanner.vue +2 -12
- package/components/ExplorerProjectsNamespaces.vue +2 -2
- package/components/GrafanaDashboard.vue +2 -8
- package/components/Resource/Detail/Masthead/__tests__/index.test.ts +68 -14
- package/components/Resource/Detail/Masthead/index.vue +8 -3
- package/components/Resource/Detail/Metadata/IdentifyingInformation/__tests__/identifying-fields.test.ts +9 -0
- package/components/Resource/Detail/Metadata/IdentifyingInformation/identifying-fields.ts +5 -1
- package/components/SlideInPanelManager.vue +103 -25
- package/components/__tests__/SlideInPanelManager.spec.ts +153 -10
- package/components/auth/AuthBanner.vue +1 -1
- package/components/form/Security.vue +1 -1
- package/components/formatter/Translate.vue +22 -1
- package/components/nav/Group.vue +5 -10
- package/components/nav/TopLevelMenu.vue +1 -30
- package/components/nav/__tests__/Group.test.ts +61 -0
- package/config/labels-annotations.js +1 -0
- package/config/table-headers.js +5 -2
- package/core/__tests__/plugin-products-apply.test.ts +787 -0
- package/core/__tests__/plugin-products-extend.test.ts +189 -0
- package/core/__tests__/plugin-products-helpers.test.ts +81 -78
- package/core/__tests__/plugin-products-new.test.ts +389 -0
- package/core/__tests__/plugin-products-scenarios.test.ts +980 -0
- package/core/__tests__/plugin-products-side-menu.test.ts +1935 -0
- package/core/plugin-products-base.ts +201 -93
- package/core/plugin-products-extending.ts +1 -1
- package/core/plugin-products-external.ts +380 -0
- package/core/plugin-products-helpers.ts +28 -24
- package/core/plugin-products-internal.ts +207 -0
- package/core/plugin-products-top-level.ts +10 -5
- package/core/plugin-products-type-guards.ts +17 -6
- package/core/plugin-products.ts +5 -7
- package/core/plugin-types.ts +1 -389
- package/core/plugin.ts +10 -11
- package/core/plugins-loader.js +2 -0
- package/core/types.ts +6 -202
- package/detail/__tests__/provisioning.cattle.io.cluster.test.ts +52 -0
- package/detail/pod.vue +1 -1
- package/detail/provisioning.cattle.io.cluster.vue +0 -2
- package/edit/auth/AuthProviderWarningBanners.vue +12 -0
- package/edit/auth/__tests__/AuthProviderWarningBanners.test.ts +10 -1
- package/edit/auth/__tests__/azuread.test.ts +1 -0
- package/edit/auth/__tests__/github.test.ts +1 -0
- package/edit/auth/__tests__/oidc.test.ts +1 -0
- package/edit/auth/__tests__/saml.test.ts +1 -0
- package/edit/auth/ldap/__tests__/index.test.ts +1 -0
- package/edit/provisioning.cattle.io.cluster/index.vue +1 -1
- package/edit/provisioning.cattle.io.cluster/rke2.vue +1 -1
- package/edit/provisioning.cattle.io.cluster/tabs/networking/index.vue +2 -2
- package/list/management.cattle.io.user.vue +24 -5
- package/list/utils/management.cattle.io.cluster.utils.ts +1 -1
- package/machine-config/__tests__/generic.test.ts +163 -0
- package/machine-config/components/EC2Networking.vue +31 -7
- package/machine-config/components/__tests__/EC2Networking.test.ts +38 -15
- package/machine-config/generic.vue +32 -5
- package/mixins/resource-fetch.js +1 -1
- package/models/__tests__/namespace.test.ts +133 -8
- package/models/__tests__/provisioning.cattle.io.cluster.test.ts +57 -1
- package/models/__tests__/rke-machine.cattle.io.vmwarevspheremachinetemplate.test.ts +22 -0
- package/models/namespace.js +34 -2
- package/models/pod.js +12 -10
- package/models/provisioning.cattle.io.cluster.js +20 -13
- package/models/rke-machine.cattle.io.vmwarevspheremachinetemplate.js +9 -0
- package/package.json +1 -1
- package/pages/auth/login.vue +1 -1
- package/pages/c/_cluster/apps/charts/__tests__/install.test.ts +110 -0
- package/pages/c/_cluster/apps/charts/install.vue +29 -0
- package/pages/c/_cluster/auth/config/index.vue +11 -4
- package/pages/c/_cluster/explorer/workload-dashboard/__tests__/composable.test.ts +136 -1
- package/pages/c/_cluster/explorer/workload-dashboard/composable.ts +69 -1
- package/pages/c/_cluster/fleet/index.vue +5 -9
- package/pages/c/_cluster/monitoring/index.vue +6 -1
- package/pkg/vue.config.js +4 -3
- package/plugins/codemirror.js +2 -0
- package/plugins/dashboard-store/resource-class.js +13 -9
- package/plugins/steve/__tests__/steve-class-resource-api.test.ts +147 -0
- package/plugins/steve/steve-class.js +43 -0
- package/plugins/steve/subscribe.js +11 -0
- package/rancher-components/Form/LabeledInput/LabeledInput.test.ts +115 -0
- package/rancher-components/Form/LabeledInput/LabeledInput.vue +83 -3
- package/store/__tests__/action-menu.test.ts +622 -0
- package/store/__tests__/auth.test.ts +18 -0
- package/store/__tests__/notifications.test.ts +466 -1
- package/store/__tests__/slideInPanel.test.ts +143 -43
- package/store/__tests__/ui-context.test.ts +255 -0
- package/store/__tests__/wm.test.ts +503 -0
- package/store/auth.js +11 -1
- package/store/aws.js +19 -4
- package/store/features.js +1 -0
- package/store/plugins.js +6 -0
- package/store/slideInPanel.ts +15 -3
- package/types/rancher/steve.api.ts +2 -2
- package/types/shell/index.d.ts +84 -2
- package/types/store/dashboard-store.types.ts +2 -2
- package/types/store/type-map.ts +262 -1
- package/utils/__tests__/fleet-appco.test.ts +23 -0
- package/utils/async.ts +2 -0
- package/utils/fleet-appco.ts +6 -1
- package/utils/grafana.js +2 -17
- package/utils/monitoring.js +38 -1
- package/utils/sort.js +1 -1
- package/core/__tests__/plugin-products.test.ts +0 -4694
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ResourceType, FindMethodOptions, FindAllMethodOptions, FindFilteredPageOptions, FindFilteredLabelSelectorOptions,
|
|
3
|
-
FindFilteredPageResponse, FindFilteredLabelSelectorResponse
|
|
2
|
+
ResourceType, CreateResourceData, FindMethodOptions, FindAllMethodOptions, FindFilteredPageOptions, FindFilteredLabelSelectorOptions,
|
|
3
|
+
FindFilteredPageResponse, FindFilteredLabelSelectorResponse, SteveResource,
|
|
4
|
+
FindFilteredPageOptionsTransient,
|
|
4
5
|
} from '@shell/apis/intf/resources-api/resource-base';
|
|
6
|
+
import { ResourceInstance } from '@shell/apis/intf/resources-api/resource-instance';
|
|
5
7
|
import { ResourcesApi } from '@shell/apis/intf/resources-api/resources-api';
|
|
6
|
-
import {
|
|
8
|
+
import { ActionFindPageTransientResponse } from '@shell/types/store/dashboard-store.types';
|
|
7
9
|
import { Store } from 'vuex';
|
|
8
10
|
|
|
9
11
|
export class ResourcesApiClassImpl implements ResourcesApi {
|
|
@@ -11,11 +13,32 @@ export class ResourcesApiClassImpl implements ResourcesApi {
|
|
|
11
13
|
|
|
12
14
|
private storeType: 'cluster' | 'management' | string;
|
|
13
15
|
|
|
16
|
+
private createLogMessage(message: string, level: 'error' | 'warning' = 'error') {
|
|
17
|
+
return `Resource API ${ level } - ${ this.storeType } - ${ message }`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private surfaceWarning(message: string, e?: any): void {
|
|
21
|
+
console.warn(this.createLogMessage(message, 'warning'), e); // eslint-disable-line no-console
|
|
22
|
+
}
|
|
23
|
+
|
|
14
24
|
private surfaceError(message: string, e?: any): never {
|
|
15
|
-
console.error(
|
|
25
|
+
console.error(this.createLogMessage(message), e); // eslint-disable-line no-console
|
|
26
|
+
|
|
16
27
|
throw new Error(`Resource API error - ${ this.storeType } - ${ message }`, { cause: e });
|
|
17
28
|
}
|
|
18
29
|
|
|
30
|
+
private resourceUrl(resourceType: ResourceType, resourceId?: string): string {
|
|
31
|
+
if (this.isNamespaced(resourceType) && resourceId && !resourceId.includes('/')) {
|
|
32
|
+
if (!resourceId) {
|
|
33
|
+
this.surfaceError(`Resource "${ resourceType }" is namespaced`);
|
|
34
|
+
} else {
|
|
35
|
+
this.surfaceError(`Resource "${ resourceType }" is namespaced. The resourceId must be in "namespace/name" format, but received "${ resourceId }"`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return this.store.getters[`${ this.storeType }/urlFor`](resourceType, resourceId);
|
|
40
|
+
}
|
|
41
|
+
|
|
19
42
|
private isNamespaced(resourceType: ResourceType): boolean {
|
|
20
43
|
const schema = this.store.getters[`${ this.storeType }/schemaFor`]?.(resourceType);
|
|
21
44
|
|
|
@@ -30,8 +53,9 @@ export class ResourcesApiClassImpl implements ResourcesApi {
|
|
|
30
53
|
/**
|
|
31
54
|
* Finds a specific resource by its type and ID.
|
|
32
55
|
*
|
|
33
|
-
* @template T -
|
|
34
|
-
* @
|
|
56
|
+
* @template T - Your specific resource type. Rancher will supplement the response with additional properties and methods
|
|
57
|
+
* @template I - An override for the response type. By default this uses T and supplements the response, or by supplying a value ignores T
|
|
58
|
+
* @param resourceType - The type of the resource to find (examples in **{@link K8S}**). See also {@link ResourceType}.
|
|
35
59
|
* @param resourceId - The unique identifier of the resource to find. If the resource is namespaced, this should be in the format `namespace/name`.
|
|
36
60
|
* @param options - Optional find arguments
|
|
37
61
|
* @returns The found resource item or null if not found.
|
|
@@ -49,11 +73,11 @@ export class ResourcesApiClassImpl implements ResourcesApi {
|
|
|
49
73
|
* const node = await resources.cluster.find(K8S.NODE, 'worker-1');
|
|
50
74
|
* ```
|
|
51
75
|
*/
|
|
52
|
-
async find<T =
|
|
76
|
+
async find<T = Record<string, any>, I = ResourceInstance<T>>(
|
|
53
77
|
resourceType: ResourceType,
|
|
54
78
|
resourceId: string,
|
|
55
79
|
options?: FindMethodOptions
|
|
56
|
-
): Promise<
|
|
80
|
+
): Promise<I | null> {
|
|
57
81
|
if (this.isNamespaced(resourceType) && !resourceId.includes('/')) {
|
|
58
82
|
this.surfaceError(`Resource "${ resourceType }" is namespaced. The resourceId must be in "namespace/name" format, but received "${ resourceId }"`);
|
|
59
83
|
}
|
|
@@ -65,8 +89,14 @@ export class ResourcesApiClassImpl implements ResourcesApi {
|
|
|
65
89
|
opt: options || {}
|
|
66
90
|
});
|
|
67
91
|
|
|
68
|
-
return
|
|
92
|
+
return resource as I;
|
|
69
93
|
} catch (e: unknown) {
|
|
94
|
+
if ((e as any)?.status === 404) {
|
|
95
|
+
this.surfaceWarning(`Failed to find resource ${ resourceType }/${ resourceId }: ${ (e as Error).message }`, e);
|
|
96
|
+
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
70
100
|
this.surfaceError(`Failed to find resource ${ resourceType }/${ resourceId }: ${ (e as Error).message }`, e);
|
|
71
101
|
}
|
|
72
102
|
}
|
|
@@ -74,18 +104,40 @@ export class ResourcesApiClassImpl implements ResourcesApi {
|
|
|
74
104
|
/**
|
|
75
105
|
* Finds resources using pagination mode with server-side filtering, sorting, and pagination.
|
|
76
106
|
*
|
|
107
|
+
* The response is not cached
|
|
108
|
+
*
|
|
109
|
+
* Requires `ui-sql-cache` to be enabled.
|
|
110
|
+
*
|
|
111
|
+
* @template T - Your specific resource type. Rancher will supplement the response with additional properties and methods
|
|
112
|
+
* @template I - An override for the response type. By default this uses T and supplements the response, or by supplying a value ignores T
|
|
113
|
+
* @param resourceType - The type of the resources to find (examples in **{@link K8S}**). See also {@link ResourceType}.
|
|
114
|
+
* @param options - Pagination options with server-side filtering and sorting via the Steve API's pagination cache. See {@link FindFilteredPageOptions}.
|
|
115
|
+
* @returns Response containing resource items
|
|
116
|
+
* @throws Error if pagination mode is requested but `ui-sql-cache` is not enabled.
|
|
117
|
+
*/
|
|
118
|
+
findFiltered<T = Record<string, any>, I = ActionFindPageTransientResponse<ResourceInstance<T>>>(
|
|
119
|
+
resourceType: ResourceType,
|
|
120
|
+
options: FindFilteredPageOptionsTransient
|
|
121
|
+
): Promise<I>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Finds resources using pagination mode with server-side filtering, sorting, and pagination.
|
|
125
|
+
*
|
|
126
|
+
* The response is cached.
|
|
127
|
+
*
|
|
77
128
|
* Requires `ui-sql-cache` to be enabled.
|
|
78
129
|
*
|
|
79
|
-
* @template T -
|
|
80
|
-
* @
|
|
81
|
-
* @param
|
|
82
|
-
* @
|
|
83
|
-
* @
|
|
130
|
+
* @template T - Your specific resource type. Rancher will supplement the response with additional properties and methods
|
|
131
|
+
* @template I - An override for the response type. By default this uses T and supplements the response, or by supplying a value ignores T
|
|
132
|
+
* @param resourceType - The type of the resources to find (examples in **{@link K8S}**). See also {@link ResourceType}.
|
|
133
|
+
* @param options - Pagination options with server-side filtering and sorting via the Steve API's pagination cache. See {@link FindFilteredPageOptions}.
|
|
134
|
+
* @returns Response containing resource items
|
|
135
|
+
* @throws Error if pagination mode is requested but `ui-sql-cache` is not enabled.
|
|
84
136
|
*/
|
|
85
|
-
findFiltered<T =
|
|
137
|
+
findFiltered<T = Record<string, any>, I = ResourceInstance<T>>(
|
|
86
138
|
resourceType: ResourceType,
|
|
87
139
|
options: FindFilteredPageOptions
|
|
88
|
-
): Promise<
|
|
140
|
+
): Promise<I[]>;
|
|
89
141
|
|
|
90
142
|
/**
|
|
91
143
|
* Finds resources using label selector matching.
|
|
@@ -94,23 +146,25 @@ export class ResourcesApiClassImpl implements ResourcesApi {
|
|
|
94
146
|
* - If `ui-sql-cache` is enabled: uses server-side pagination
|
|
95
147
|
* - Otherwise: uses native Kubernetes API pagination
|
|
96
148
|
*
|
|
97
|
-
* @template T -
|
|
98
|
-
* @
|
|
99
|
-
* @param
|
|
100
|
-
* @
|
|
149
|
+
* @template T - Your specific resource type. Rancher will supplement the response with additional properties and methods
|
|
150
|
+
* @template I - An override for the response type. By default this uses T and supplements the response, or by supplying a value ignores T
|
|
151
|
+
* @param resourceType - The type of the resources to find (examples in **{@link K8S}**). See also {@link ResourceType}.
|
|
152
|
+
* @param options - Label selector options for filtering. See {@link FindFilteredLabelSelectorOptions}.
|
|
153
|
+
* @returns Response containing resource items.
|
|
154
|
+
*
|
|
101
155
|
*/
|
|
102
|
-
findFiltered<T =
|
|
156
|
+
findFiltered<T = Record<string, any>, I = FindFilteredLabelSelectorResponse<ResourceInstance<T>>>(
|
|
103
157
|
resourceType: ResourceType,
|
|
104
158
|
options: FindFilteredLabelSelectorOptions
|
|
105
|
-
): Promise<
|
|
159
|
+
): Promise<I>;
|
|
106
160
|
|
|
107
161
|
/**
|
|
108
162
|
* @internal Implementation - use one of the overloads above
|
|
109
163
|
*/
|
|
110
|
-
async findFiltered<T =
|
|
164
|
+
async findFiltered<T = Record<string, any>, I = ResourceInstance<T>>(
|
|
111
165
|
resourceType: ResourceType,
|
|
112
|
-
options: FindFilteredPageOptions | FindFilteredLabelSelectorOptions
|
|
113
|
-
): Promise<
|
|
166
|
+
options: FindFilteredPageOptions | FindFilteredPageOptionsTransient | FindFilteredLabelSelectorOptions
|
|
167
|
+
): Promise<I[] | ResourceInstance<T>[] | ActionFindPageTransientResponse<ResourceInstance<T>>> {
|
|
114
168
|
try {
|
|
115
169
|
if ('pagination' in options) { // pagination mode
|
|
116
170
|
const canPaginate = this.store.getters[`${ this.storeType }/paginationEnabled`]?.(resourceType);
|
|
@@ -125,7 +179,11 @@ export class ResourcesApiClassImpl implements ResourcesApi {
|
|
|
125
179
|
opt: safeOption
|
|
126
180
|
});
|
|
127
181
|
|
|
128
|
-
|
|
182
|
+
if (options.transient) {
|
|
183
|
+
return response as ResourceInstance<T>[];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return response as FindFilteredPageResponse<ResourceInstance<T>>;
|
|
129
187
|
} else if ('labelSelector' in options) { // label selector mode
|
|
130
188
|
const safeOption = options as FindFilteredLabelSelectorOptions;
|
|
131
189
|
const { labelSelector, namespaced, ...rest } = safeOption;
|
|
@@ -138,7 +196,7 @@ export class ResourcesApiClassImpl implements ResourcesApi {
|
|
|
138
196
|
opt: rest
|
|
139
197
|
});
|
|
140
198
|
|
|
141
|
-
return resources as FindFilteredLabelSelectorResponse<T
|
|
199
|
+
return resources as FindFilteredLabelSelectorResponse<ResourceInstance<T>>;
|
|
142
200
|
} else {
|
|
143
201
|
return this.surfaceError('findFiltered request was made with unknown options');
|
|
144
202
|
}
|
|
@@ -151,37 +209,168 @@ export class ResourcesApiClassImpl implements ResourcesApi {
|
|
|
151
209
|
* Fetches all resources of a specific type with advanced options.
|
|
152
210
|
* This method provides additional capabilities like incremental loading and namespace filtering.
|
|
153
211
|
*
|
|
154
|
-
* @template T -
|
|
155
|
-
* @
|
|
212
|
+
* @template T - Your specific resource type. Rancher will supplement the response with additional properties and methods
|
|
213
|
+
* @template I - An override for the response type. By default this uses T and supplements the response, or by supplying a value ignores T
|
|
214
|
+
* @param resourceType - The type of the resources to find (examples in **{@link K8S}**). See also {@link ResourceType}.
|
|
156
215
|
* @param options - Optional advanced fetch options (incremental loading, namespace filtering, etc.)
|
|
157
216
|
* @returns An array of resource items or an empty array if none are found.
|
|
217
|
+
*/
|
|
218
|
+
async findAll<T = Record<string, any>, I = ResourceInstance<T>>(
|
|
219
|
+
resourceType: ResourceType,
|
|
220
|
+
options?: FindAllMethodOptions
|
|
221
|
+
): Promise<I[]> {
|
|
222
|
+
try {
|
|
223
|
+
const resources = await this.store.dispatch(`${ this.storeType }/findAll`, {
|
|
224
|
+
type: resourceType,
|
|
225
|
+
opt: options || {}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
return (resources || []) as I[];
|
|
229
|
+
} catch (e: unknown) {
|
|
230
|
+
this.surfaceError(`Failed to find all resources ${ resourceType }: ${ (e as Error).message }`, e);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Creates a new resource.
|
|
236
|
+
*
|
|
237
|
+
* The `data` object must include a `type` property identifying the resource type.
|
|
238
|
+
* This is a raw HTTP operation — it does not check permissions or update the store cache.
|
|
239
|
+
*
|
|
240
|
+
* @template T - Your specific resource type. Rancher will supplement the response with additional properties and methods
|
|
241
|
+
* @template I - An override for the response type. By default this uses T and supplements the response, or by supplying a value ignores T
|
|
242
|
+
* @param data - The resource data to create. Must include a `type` property (examples in **{@link K8S}**). See also {@link CreateResourceData}.
|
|
243
|
+
* @returns The created resource instance.
|
|
244
|
+
*/
|
|
245
|
+
async create<T = Record<string, any>, I = SteveResource<T>>(
|
|
246
|
+
data: CreateResourceData
|
|
247
|
+
): Promise<I> {
|
|
248
|
+
try {
|
|
249
|
+
if (!data.type) {
|
|
250
|
+
return this.surfaceError('Resource data must include a "type" property');
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const url = this.resourceUrl(data.type);
|
|
254
|
+
|
|
255
|
+
const res = await this.store.dispatch(`${ this.storeType }/request`, {
|
|
256
|
+
opt: {
|
|
257
|
+
url,
|
|
258
|
+
method: 'POST',
|
|
259
|
+
headers: { 'content-type': 'application/json' },
|
|
260
|
+
data,
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
return res as I;
|
|
265
|
+
} catch (e: unknown) {
|
|
266
|
+
this.surfaceError(`Failed to create resource of type "${ data.type }": ${ (e as Error).message }`, e);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Applies a partial update to a resource using HTTP PATCH (merge-patch).
|
|
272
|
+
*
|
|
273
|
+
* Only the fields provided in `data` are sent to the server.
|
|
274
|
+
* This is a raw HTTP operation — it does not check permissions or update the store cache.
|
|
275
|
+
*
|
|
276
|
+
* @template T - Your specific resource type. Rancher will supplement the response with additional properties and methods
|
|
277
|
+
* @template I - An override for the response type. By default this uses T and supplements the response, or by supplying a value ignores T
|
|
278
|
+
* @param resourceType - The type of the resource (examples in **{@link K8S}**). See also {@link ResourceType}.
|
|
279
|
+
* @param resourceId - The unique identifier. If namespaced, use `namespace/name` format.
|
|
280
|
+
* @param data - An object containing only the fields to update.
|
|
281
|
+
* @returns The server response.
|
|
282
|
+
*/
|
|
283
|
+
async update<T = Record<string, any>, I = SteveResource<T>>(
|
|
284
|
+
resourceType: ResourceType,
|
|
285
|
+
resourceId: string,
|
|
286
|
+
data: Record<string, any>
|
|
287
|
+
): Promise<I> {
|
|
288
|
+
try {
|
|
289
|
+
const url = this.resourceUrl(resourceType, resourceId);
|
|
290
|
+
const res = await this.store.dispatch(`${ this.storeType }/request`, {
|
|
291
|
+
opt: {
|
|
292
|
+
url,
|
|
293
|
+
method: 'patch',
|
|
294
|
+
headers: { 'content-type': 'application/strategic-merge-patch+json' },
|
|
295
|
+
data,
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
return res as I;
|
|
300
|
+
} catch (e: unknown) {
|
|
301
|
+
this.surfaceError(`Failed to update resource ${ resourceType }/${ resourceId }: ${ (e as Error).message }`, e);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Performs a full replacement update of a resource using HTTP PUT.
|
|
307
|
+
*
|
|
308
|
+
* Runs `cleanForSave` on the data before sending.
|
|
309
|
+
* This is a raw HTTP operation — it does not check permissions or update the store cache.
|
|
310
|
+
*
|
|
311
|
+
* @template T - Your specific resource type. Rancher will supplement the response with additional properties and methods
|
|
312
|
+
* @template I - An override for the response type. By default this uses T and supplements the response, or by supplying a value ignores T
|
|
313
|
+
* @param resourceType - The type of the resource (examples in **{@link K8S}**). See also {@link ResourceType}.
|
|
314
|
+
* @param resourceId - The unique identifier. If namespaced, use `namespace/name` format.
|
|
315
|
+
* @param data - The complete resource data to send as the replacement.
|
|
316
|
+
* @returns The server response.
|
|
317
|
+
*/
|
|
318
|
+
async replace<T = Record<string, any>, I = SteveResource<T>>(
|
|
319
|
+
resourceType: ResourceType,
|
|
320
|
+
resourceId: string,
|
|
321
|
+
data: Record<string, any>
|
|
322
|
+
): Promise<I> {
|
|
323
|
+
try {
|
|
324
|
+
const url = this.resourceUrl(resourceType, resourceId);
|
|
325
|
+
const model = await this.store.dispatch(`${ this.storeType }/create`, data);
|
|
326
|
+
const cleanData = model.cleanForSave({ ...data });
|
|
327
|
+
const res = await this.store.dispatch(`${ this.storeType }/request`, {
|
|
328
|
+
opt: {
|
|
329
|
+
url,
|
|
330
|
+
method: 'put',
|
|
331
|
+
headers: { 'content-type': 'application/json' },
|
|
332
|
+
data: cleanData,
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
return res as I;
|
|
337
|
+
} catch (e: unknown) {
|
|
338
|
+
this.surfaceError(`Failed to update resource ${ resourceType }/${ resourceId }: ${ (e as Error).message }`, e);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Deletes a resource by type and ID using HTTP DELETE.
|
|
344
|
+
*
|
|
345
|
+
* This is a raw HTTP operation — it does not check permissions or update the store cache.
|
|
346
|
+
*
|
|
347
|
+
* @param resourceType - The type of the resource (examples in **{@link K8S}**). See also {@link ResourceType}.
|
|
348
|
+
* @param resourceId - The unique identifier. If namespaced, use `namespace/name` format.
|
|
158
349
|
*
|
|
159
350
|
* @example
|
|
160
351
|
* ```ts
|
|
161
352
|
* import { useResources, K8S } from '@shell/apis';
|
|
162
|
-
* import type { Pod } from '@shell/types/resources';
|
|
163
353
|
*
|
|
164
354
|
* const resources = useResources();
|
|
165
355
|
*
|
|
166
|
-
*
|
|
167
|
-
* const pods = await resources.cluster.findAll<Pod>(K8S.POD, {
|
|
168
|
-
* namespaced: ['default', 'kube-system']
|
|
169
|
-
* });
|
|
356
|
+
* await resources.cluster.delete(K8S.CONFIG_MAP, 'default/my-config');
|
|
170
357
|
* ```
|
|
171
358
|
*/
|
|
172
|
-
async
|
|
359
|
+
async delete(
|
|
173
360
|
resourceType: ResourceType,
|
|
174
|
-
|
|
175
|
-
): Promise<
|
|
361
|
+
resourceId: string
|
|
362
|
+
): Promise<void> {
|
|
176
363
|
try {
|
|
177
|
-
const
|
|
178
|
-
type: resourceType,
|
|
179
|
-
opt: options || {}
|
|
180
|
-
});
|
|
364
|
+
const url = this.resourceUrl(resourceType, resourceId);
|
|
181
365
|
|
|
182
|
-
|
|
366
|
+
await this.store.dispatch(`${ this.storeType }/request`, {
|
|
367
|
+
opt: {
|
|
368
|
+
url,
|
|
369
|
+
method: 'delete',
|
|
370
|
+
}
|
|
371
|
+
});
|
|
183
372
|
} catch (e: unknown) {
|
|
184
|
-
this.surfaceError(`Failed to
|
|
373
|
+
this.surfaceError(`Failed to delete resource ${ resourceType }/${ resourceId }: ${ (e as Error).message }`, e);
|
|
185
374
|
}
|
|
186
375
|
}
|
|
187
376
|
}
|
|
@@ -38,7 +38,7 @@ describe('slideInApiImpl', () => {
|
|
|
38
38
|
it('should open a slide-in panel with a config', () => {
|
|
39
39
|
const config = {
|
|
40
40
|
title: 'Test Panel',
|
|
41
|
-
width: '
|
|
41
|
+
width: 'default' as const,
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
// 3. Act
|
|
@@ -48,7 +48,7 @@ describe('slideInApiImpl', () => {
|
|
|
48
48
|
expect(mockCommit).toHaveBeenCalledTimes(1);
|
|
49
49
|
expect(mockCommit).toHaveBeenCalledWith('slideInPanel/open', {
|
|
50
50
|
component: MockComponent,
|
|
51
|
-
componentProps: {
|
|
51
|
+
componentProps: { title: 'Test Panel', width: 'default' },
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -87,4 +87,85 @@ describe('slideInApiImpl', () => {
|
|
|
87
87
|
},
|
|
88
88
|
});
|
|
89
89
|
});
|
|
90
|
+
|
|
91
|
+
it('should open with preset properties', () => {
|
|
92
|
+
const config = {
|
|
93
|
+
title: 'Preset Panel',
|
|
94
|
+
width: 'wide' as const,
|
|
95
|
+
height: 'full' as const,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
slideInApi.open(MockComponent, config);
|
|
99
|
+
|
|
100
|
+
expect(mockCommit).toHaveBeenCalledTimes(1);
|
|
101
|
+
expect(mockCommit).toHaveBeenCalledWith('slideInPanel/open', {
|
|
102
|
+
component: MockComponent,
|
|
103
|
+
componentProps: {
|
|
104
|
+
title: 'Preset Panel',
|
|
105
|
+
width: 'wide',
|
|
106
|
+
height: 'full',
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('should open with disableFocusTrap option', () => {
|
|
112
|
+
const config = {
|
|
113
|
+
width: 'wide' as const,
|
|
114
|
+
height: 'full' as const,
|
|
115
|
+
disableFocusTrap: true,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
slideInApi.open(MockComponent, config);
|
|
119
|
+
|
|
120
|
+
expect(mockCommit).toHaveBeenCalledTimes(1);
|
|
121
|
+
expect(mockCommit).toHaveBeenCalledWith('slideInPanel/open', {
|
|
122
|
+
component: MockComponent,
|
|
123
|
+
componentProps: {
|
|
124
|
+
width: 'wide',
|
|
125
|
+
height: 'full',
|
|
126
|
+
disableFocusTrap: true,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
describe('deprecation warnings', () => {
|
|
132
|
+
const originalEnv = process.env.dev;
|
|
133
|
+
let warnSpy: jest.SpyInstance;
|
|
134
|
+
|
|
135
|
+
beforeEach(() => {
|
|
136
|
+
process.env.dev = 'true';
|
|
137
|
+
warnSpy = jest.spyOn(console, 'warn').mockImplementation();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
afterEach(() => {
|
|
141
|
+
process.env.dev = originalEnv;
|
|
142
|
+
warnSpy.mockRestore();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('warns when deprecated "top" is used', () => {
|
|
146
|
+
slideInApi.open(MockComponent, { top: '0' });
|
|
147
|
+
|
|
148
|
+
expect(warnSpy).toHaveBeenCalledWith(
|
|
149
|
+
expect.stringContaining('"top" is deprecated')
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('warns when deprecated "showHeader" is used', () => {
|
|
154
|
+
slideInApi.open(MockComponent, { showHeader: false });
|
|
155
|
+
|
|
156
|
+
expect(warnSpy).toHaveBeenCalledWith(
|
|
157
|
+
expect.stringContaining('"showHeader" is deprecated')
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('does not warn when using preset properties', () => {
|
|
162
|
+
slideInApi.open(MockComponent, {
|
|
163
|
+
title: 'Test',
|
|
164
|
+
width: 'wide' as const,
|
|
165
|
+
height: 'full' as const,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
169
|
+
});
|
|
170
|
+
});
|
|
90
171
|
});
|
package/apis/shell/slide-in.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { Component } from 'vue';
|
|
|
2
2
|
import { SlideInApi, SlideInConfig } from '@shell/apis/intf/shell';
|
|
3
3
|
import { Store } from 'vuex';
|
|
4
4
|
|
|
5
|
+
const DEPRECATION_PREFIX = '[SlideIn API]';
|
|
6
|
+
|
|
5
7
|
export class SlideInApiImpl implements SlideInApi {
|
|
6
8
|
private store: Store<any>;
|
|
7
9
|
|
|
@@ -9,6 +11,20 @@ export class SlideInApiImpl implements SlideInApi {
|
|
|
9
11
|
this.store = store;
|
|
10
12
|
}
|
|
11
13
|
|
|
14
|
+
private warnDeprecated(config: SlideInConfig): void {
|
|
15
|
+
if (!process.env.dev) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (config.top !== undefined) {
|
|
20
|
+
console.warn(`${ DEPRECATION_PREFIX } "top" is deprecated. It is now automatically managed based on "panelHeight". Full deprecation expected in Rancher 2.17.`); // eslint-disable-line no-console
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (config.showHeader !== undefined) {
|
|
24
|
+
console.warn(`${ DEPRECATION_PREFIX } "showHeader" is deprecated. Header visibility is now inferred from the presence of "title". Full deprecation expected in Rancher 2.17.`); // eslint-disable-line no-console
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
12
28
|
/**
|
|
13
29
|
* Opens a slide in panel in Rancher UI
|
|
14
30
|
*
|
|
@@ -30,6 +46,10 @@ export class SlideInApiImpl implements SlideInApi {
|
|
|
30
46
|
public open(component: Component, config?: SlideInConfig): void {
|
|
31
47
|
const props = config?.props || {};
|
|
32
48
|
|
|
49
|
+
if (config) {
|
|
50
|
+
this.warnDeprecated(config);
|
|
51
|
+
}
|
|
52
|
+
|
|
33
53
|
delete config?.props;
|
|
34
54
|
|
|
35
55
|
this.store.commit('slideInPanel/open', {
|
|
Binary file
|
|
@@ -504,6 +504,7 @@ authConfig:
|
|
|
504
504
|
allowedPrincipalIds:
|
|
505
505
|
title: Authorized Users & Groups
|
|
506
506
|
associatedWarning: 'The {provider} account that is used to enable the external provider will be granted permissions equal to the currently logged in Rancher user. See <a href="{docsBase}/how-to-guides/new-user-guides/authentication-permissions-and-global-configuration/authentication-config#external-authentication-configuration-and-principal-users" target="_blank" rel="noopener noreferrer nofollow">External Authentication Configuration and Principal Users</a> to understand why.'
|
|
507
|
+
bannerEnableAuthProvider: "The \"Disable Local Authentication\" setting is enabled. Enabling an Authentication Provider will prevent users from logging in with local credentials. In the event of a Provider failure no user will be able to log in. Ensure you have continued API or CLI access to Rancher to disable the feature and regain access."
|
|
507
508
|
githubapp:
|
|
508
509
|
clientId:
|
|
509
510
|
label: Client ID
|
|
@@ -1366,6 +1367,8 @@ catalog:
|
|
|
1366
1367
|
generatedNewImagePullSecret: "A new Image Pull Secret <b>{ imagePullSecretName }</b> will be generated"
|
|
1367
1368
|
generatedImagePullSecretBannerFromPreviousAuth: "A new Image Pull Secret <b>{ imagePullSecretName }</b> will be generated from the Repository secret <b>{ repoAuthenticationName }</b>."
|
|
1368
1369
|
usePreviouslyGeneratedImagePullSecretBanner: "Image Pull Secret <b>{ imagePullSecretName }</b> was already created previously from the Repository secret <b>{ repoAuthenticationName }</b> and will be used."
|
|
1370
|
+
oldMonitoringChartWarning: "From v2.15.0 this chart is deprecated, instead please use the new Rancher Monitoring Dashboard chart."
|
|
1371
|
+
newMonitoringChartWarning: "Before installing the new Rancher Monitoring Dashboard chart please make sure any applications using the old Rancher Monitoring Chart have been uninstalled and dependencies such as Prometheus have been installed."
|
|
1369
1372
|
clusterTplVersion:
|
|
1370
1373
|
label: Version
|
|
1371
1374
|
subtext: Select a version of the template
|
|
@@ -2172,7 +2175,8 @@ cluster:
|
|
|
2172
2175
|
label: Enable IPv6
|
|
2173
2176
|
httpProtocolIpv6:
|
|
2174
2177
|
label: Enable IPv6 endpoint for instance metadata service
|
|
2175
|
-
|
|
2178
|
+
dualStackValidationWarning: When one pool enables dual-stack subnet/vpc, all pools must use the same networking configuration.
|
|
2179
|
+
ipv6ValidationWarning: When one pool enables IPv6 subnet/vpc, all pools must use the same networking configuration.
|
|
2176
2180
|
pnap:
|
|
2177
2181
|
serverLocation:
|
|
2178
2182
|
label: Location
|
|
@@ -2450,7 +2454,7 @@ cluster:
|
|
|
2450
2454
|
aws: Amazon
|
|
2451
2455
|
azure: Azure
|
|
2452
2456
|
azureaks: Azure AKS
|
|
2453
|
-
aks:
|
|
2457
|
+
aks: AKS
|
|
2454
2458
|
azurekubernetesservice: Azure AKS (Unsupported Kev1)
|
|
2455
2459
|
baiducloudcontainerengine: Baidu CCE
|
|
2456
2460
|
baidu: Baidu CCE
|
|
@@ -2459,13 +2463,13 @@ cluster:
|
|
|
2459
2463
|
custom: Custom
|
|
2460
2464
|
digitalocean: DigitalOcean
|
|
2461
2465
|
docker: Docker
|
|
2462
|
-
eks:
|
|
2466
|
+
eks: EKS
|
|
2463
2467
|
exoscale: Exoscale
|
|
2464
2468
|
sks: Exoscale SKS
|
|
2465
2469
|
gcp: Google
|
|
2466
2470
|
google: Google GCE
|
|
2467
2471
|
googlegke: Google GKE
|
|
2468
|
-
gke:
|
|
2472
|
+
gke: GKE
|
|
2469
2473
|
googlekubernetesengine: Google GKE (Unsupported Kev1)
|
|
2470
2474
|
harvester: Harvester
|
|
2471
2475
|
huaweicce: Huawei CCE
|
|
@@ -9044,6 +9048,8 @@ advancedSettings:
|
|
|
9044
9048
|
header: Cluster Provisioning
|
|
9045
9049
|
|
|
9046
9050
|
featureFlags:
|
|
9051
|
+
description:
|
|
9052
|
+
'hide-local-auth-provider': Activating this feature and enabling an Authentication Provider will prevent users from logging in with local credentials. In the event of a Provider failure no user will be able to log in. Ensure you have continued API or CLI access to Rancher to disable the feature and regain access
|
|
9047
9053
|
label: Feature Flags
|
|
9048
9054
|
title: "Are you sure?"
|
|
9049
9055
|
warning: |-
|