@knime/hub-features 1.6.9 → 1.7.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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knime/hub-features",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Vue components & composables for shared hub features",
|
|
5
5
|
"homepage": "https://knime.github.io/webapps-common/",
|
|
6
6
|
"license": "GPL 3 and Additional Permissions according to Sec. 7 (SEE the file LICENSE)",
|
|
@@ -12,6 +12,26 @@ export type NamedItemVersion = {
|
|
|
12
12
|
createdOn: string;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
interface MasonControl {
|
|
16
|
+
[key: string]: {
|
|
17
|
+
href: string;
|
|
18
|
+
method: string;
|
|
19
|
+
accept?: string[];
|
|
20
|
+
encoding?: string;
|
|
21
|
+
title?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type RepositoryItem = {
|
|
26
|
+
path: string;
|
|
27
|
+
id: string;
|
|
28
|
+
type: string;
|
|
29
|
+
owner: string;
|
|
30
|
+
author: string;
|
|
31
|
+
createdOn: string;
|
|
32
|
+
"@controls": Array<MasonControl>;
|
|
33
|
+
};
|
|
34
|
+
|
|
15
35
|
export type AssignedLabel = {
|
|
16
36
|
labelId: string;
|
|
17
37
|
message?: string;
|
|
@@ -43,3 +63,10 @@ export type ItemSavepoint = {
|
|
|
43
63
|
itemVersionId?: string; // UUID
|
|
44
64
|
changes: Array<ItemChange>;
|
|
45
65
|
};
|
|
66
|
+
|
|
67
|
+
export type ItemPermission =
|
|
68
|
+
| "DELETE"
|
|
69
|
+
| "EDIT"
|
|
70
|
+
| "CONFIGURATION"
|
|
71
|
+
| "MOVE"
|
|
72
|
+
| "COPY";
|
|
@@ -5,8 +5,10 @@ import type { HubAvatarData } from "@knime/hub-features";
|
|
|
5
5
|
import { VERSION_DEFAULT_LIMIT } from "@knime/hub-features/versions";
|
|
6
6
|
import type {
|
|
7
7
|
AssignedLabel,
|
|
8
|
+
ItemPermission,
|
|
8
9
|
ItemSavepoint,
|
|
9
10
|
NamedItemVersion,
|
|
11
|
+
RepositoryItem,
|
|
10
12
|
WithAvatar,
|
|
11
13
|
WithLabels,
|
|
12
14
|
} from "@knime/hub-features/versions";
|
|
@@ -40,6 +42,13 @@ export const useVersionsApi = ({ baseUrl }: UseVersionsApiOptions) => {
|
|
|
40
42
|
return response.json();
|
|
41
43
|
};
|
|
42
44
|
|
|
45
|
+
const fetchRepositoryItem = ({ itemId }: { itemId: string }) => {
|
|
46
|
+
return doHubRequestJson(
|
|
47
|
+
`/repository/${itemId}`,
|
|
48
|
+
{},
|
|
49
|
+
) as Promise<RepositoryItem>;
|
|
50
|
+
};
|
|
51
|
+
|
|
43
52
|
const fetchVersions = ({
|
|
44
53
|
itemId,
|
|
45
54
|
loadAll,
|
|
@@ -161,10 +170,34 @@ export const useVersionsApi = ({ baseUrl }: UseVersionsApiOptions) => {
|
|
|
161
170
|
}>;
|
|
162
171
|
};
|
|
163
172
|
|
|
173
|
+
const fetchPermissions = async ({
|
|
174
|
+
itemId,
|
|
175
|
+
}: {
|
|
176
|
+
itemId: string;
|
|
177
|
+
}): Promise<ItemPermission[]> => {
|
|
178
|
+
const masonControlsMap = {
|
|
179
|
+
"knime:delete": "DELETE",
|
|
180
|
+
edit: "EDIT",
|
|
181
|
+
"knime:configuration": "CONFIGURATION",
|
|
182
|
+
"knime:move": "MOVE",
|
|
183
|
+
"knime:copy": "COPY",
|
|
184
|
+
} as const;
|
|
185
|
+
|
|
186
|
+
const repositoryItem = await fetchRepositoryItem({
|
|
187
|
+
itemId,
|
|
188
|
+
});
|
|
189
|
+
return Object.keys(repositoryItem["@controls"])
|
|
190
|
+
.filter((control) => control in masonControlsMap)
|
|
191
|
+
.map(
|
|
192
|
+
(control) => masonControlsMap[control as keyof typeof masonControlsMap],
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
|
|
164
196
|
return {
|
|
165
197
|
fetchVersions,
|
|
166
198
|
fetchResourceLabels,
|
|
167
199
|
fetchItemSavepoints,
|
|
200
|
+
fetchPermissions,
|
|
168
201
|
loadSavepointMetadata,
|
|
169
202
|
deleteVersion,
|
|
170
203
|
createVersion,
|