@knime/hub-features 1.27.0 → 1.29.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 +32 -0
- package/package.json +4 -4
- package/src/analytics/analytics.ts +39 -13
- package/src/analytics/schema/cloudhome-event-functions.ts +245 -0
- package/src/analytics/schema/code-generator.js +17 -8
- package/src/analytics/schema/{event-functions.ts → editor-event-functions.ts} +7 -9
- package/src/analytics/schema/schema.d.ts +133 -7
- package/src/analytics/schema/schema.json +833 -157
- package/src/analytics/types.ts +4 -1
- package/src/httpClient/constants.ts +1 -0
- package/src/{common/ofetchClient.ts → httpClient/createHttpClient.ts} +6 -5
- package/src/httpClient/index.ts +2 -0
- package/src/index.ts +1 -0
- package/src/useDownloadArtifact/useDownloadArtifact.ts +2 -2
- package/src/useFileUpload/useFileUpload.ts +2 -2
- package/src/common/constants.ts +0 -1
- package/src/components/versions/components/CreateVersionForm.vue +0 -155
- package/src/components/versions/components/CurrentState.vue +0 -258
- package/src/components/versions/components/LabelList.vue +0 -253
- package/src/components/versions/components/ManageVersions.vue +0 -191
- package/src/components/versions/components/NoVersionItem.vue +0 -23
- package/src/components/versions/components/VersionHistory.vue +0 -138
- package/src/components/versions/components/VersionItem.vue +0 -278
- package/src/components/versions/components/VersionLimitInfo.vue +0 -37
- package/src/components/versions/composables/useVersionsApi.ts +0 -254
- package/src/components/versions/constants.ts +0 -3
- package/src/components/versions/index.ts +0 -7
- package/src/components/versions/types.ts +0 -77
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, ref } from "vue";
|
|
3
|
-
import { compact } from "lodash-es"; // eslint-disable-line depend/ban-dependencies
|
|
4
|
-
|
|
5
|
-
import { LocalDateTime, SubMenu, Tooltip } from "@knime/components";
|
|
6
|
-
import MenuIcon from "@knime/styles/img/icons/menu-options.svg";
|
|
7
|
-
import { truncateString } from "@knime/utils";
|
|
8
|
-
|
|
9
|
-
import HubAvatar from "../../avatars/HubAvatar.vue";
|
|
10
|
-
import type { NamedItemVersion, WithAvatar, WithLabels } from "../types";
|
|
11
|
-
|
|
12
|
-
import LabelList from "./LabelList.vue";
|
|
13
|
-
|
|
14
|
-
const DESCRIPTION_TRUNCATE_LENGTH = 120;
|
|
15
|
-
|
|
16
|
-
const props = defineProps<{
|
|
17
|
-
version: NamedItemVersion & WithAvatar & WithLabels;
|
|
18
|
-
isSelected: boolean;
|
|
19
|
-
hasAdminRights: boolean;
|
|
20
|
-
hasEditCapability: boolean;
|
|
21
|
-
}>();
|
|
22
|
-
|
|
23
|
-
const emit = defineEmits<{
|
|
24
|
-
select: [selectionStatus: boolean];
|
|
25
|
-
delete: [];
|
|
26
|
-
restore: [];
|
|
27
|
-
}>();
|
|
28
|
-
|
|
29
|
-
const hideTooltip = ref(false);
|
|
30
|
-
const tooltipText = computed(() => {
|
|
31
|
-
if (hideTooltip.value) {
|
|
32
|
-
return "";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (props.isSelected) {
|
|
36
|
-
return "Deselect to go back to latest";
|
|
37
|
-
} else {
|
|
38
|
-
return "Show version";
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const truncatedDescription = computed(() => {
|
|
43
|
-
return truncateString(props.version.description, DESCRIPTION_TRUNCATE_LENGTH);
|
|
44
|
-
});
|
|
45
|
-
const isDescriptionTruncated = computed(
|
|
46
|
-
() =>
|
|
47
|
-
props.version.description &&
|
|
48
|
-
props.version.description.length !== truncatedDescription.value.length,
|
|
49
|
-
);
|
|
50
|
-
const isDescriptionExpanded = ref(false);
|
|
51
|
-
|
|
52
|
-
const toggleVersionSelection = () => {
|
|
53
|
-
emit("select", !props.isSelected);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const menuItems = computed(() =>
|
|
57
|
-
compact([
|
|
58
|
-
props.hasEditCapability && {
|
|
59
|
-
text: props.isSelected ? "Deselect this version" : "Show this version",
|
|
60
|
-
action: toggleVersionSelection,
|
|
61
|
-
},
|
|
62
|
-
props.hasEditCapability && {
|
|
63
|
-
text: "Restore this version",
|
|
64
|
-
action: () => emit("restore"),
|
|
65
|
-
},
|
|
66
|
-
props.hasAdminRights && {
|
|
67
|
-
text: "Delete this version",
|
|
68
|
-
action: () => emit("delete"),
|
|
69
|
-
},
|
|
70
|
-
]),
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const onMenuItemClick = (_: Event, item: (typeof menuItems.value)[number]) => {
|
|
74
|
-
item.action();
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const onExpandDescription = () => {
|
|
78
|
-
isDescriptionExpanded.value = true;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const onLabelOver = () => {
|
|
82
|
-
hideTooltip.value = true;
|
|
83
|
-
};
|
|
84
|
-
const onLabelLeave = () => {
|
|
85
|
-
hideTooltip.value = false;
|
|
86
|
-
};
|
|
87
|
-
</script>
|
|
88
|
-
|
|
89
|
-
<template>
|
|
90
|
-
<div>
|
|
91
|
-
<div
|
|
92
|
-
:class="['version-item-container', isSelected && 'selected']"
|
|
93
|
-
@click="toggleVersionSelection"
|
|
94
|
-
>
|
|
95
|
-
<Tooltip ref="tooltip" class="tooltip" :text="tooltipText">
|
|
96
|
-
<div class="left">
|
|
97
|
-
<h6>
|
|
98
|
-
{{ version.title }}
|
|
99
|
-
</h6>
|
|
100
|
-
|
|
101
|
-
<div class="labels">
|
|
102
|
-
<LabelList
|
|
103
|
-
:labels="version.labels"
|
|
104
|
-
@label-over="onLabelOver"
|
|
105
|
-
@label-leave="onLabelLeave"
|
|
106
|
-
/>
|
|
107
|
-
</div>
|
|
108
|
-
|
|
109
|
-
<p v-if="isDescriptionTruncated && !isDescriptionExpanded">
|
|
110
|
-
{{ truncatedDescription }}
|
|
111
|
-
<button class="show-more-button" @click.stop="onExpandDescription">
|
|
112
|
-
Show more
|
|
113
|
-
</button>
|
|
114
|
-
</p>
|
|
115
|
-
<p v-else-if="version.description">{{ version.description }}</p>
|
|
116
|
-
<span class="footer-info">
|
|
117
|
-
Created on <LocalDateTime show-time :date="version.createdOn" /> –
|
|
118
|
-
Version {{ version.version }}
|
|
119
|
-
</span>
|
|
120
|
-
</div>
|
|
121
|
-
<div class="right">
|
|
122
|
-
<HubAvatar class="profile-picture" v-bind="version.avatar" />
|
|
123
|
-
<div v-if="menuItems.length" class="controls">
|
|
124
|
-
<nav>
|
|
125
|
-
<SubMenu
|
|
126
|
-
:items="menuItems"
|
|
127
|
-
button-title="Options"
|
|
128
|
-
@item-click="onMenuItemClick"
|
|
129
|
-
>
|
|
130
|
-
<MenuIcon class="open-icon" />
|
|
131
|
-
</SubMenu>
|
|
132
|
-
</nav>
|
|
133
|
-
</div>
|
|
134
|
-
</div>
|
|
135
|
-
</Tooltip>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
</template>
|
|
139
|
-
|
|
140
|
-
<style lang="postcss" scoped>
|
|
141
|
-
.version-item-container {
|
|
142
|
-
position: relative;
|
|
143
|
-
display: flex;
|
|
144
|
-
gap: 15px;
|
|
145
|
-
align-items: center;
|
|
146
|
-
align-items: stretch;
|
|
147
|
-
padding: 10px;
|
|
148
|
-
background-color: var(--knime-white);
|
|
149
|
-
transition: background-color 0.25s ease;
|
|
150
|
-
|
|
151
|
-
& .tooltip {
|
|
152
|
-
display: flex;
|
|
153
|
-
justify-content: space-between;
|
|
154
|
-
width: 100%;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
& p {
|
|
158
|
-
margin: 10px 0;
|
|
159
|
-
font-size: 11px;
|
|
160
|
-
line-height: 1.5;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
& button {
|
|
164
|
-
all: unset;
|
|
165
|
-
font-size: 11px;
|
|
166
|
-
font-weight: 500;
|
|
167
|
-
color: var(--knime-dove-gray);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
& .left {
|
|
171
|
-
display: flex;
|
|
172
|
-
flex-direction: column;
|
|
173
|
-
gap: 3px;
|
|
174
|
-
word-break: normal;
|
|
175
|
-
overflow-wrap: break-word;
|
|
176
|
-
|
|
177
|
-
& h6 {
|
|
178
|
-
display: block;
|
|
179
|
-
margin: 0;
|
|
180
|
-
font-size: 13px;
|
|
181
|
-
font-weight: 700;
|
|
182
|
-
line-height: 18px;
|
|
183
|
-
transition: color 0.25s ease;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
& .footer-info {
|
|
187
|
-
margin: 0;
|
|
188
|
-
font-size: 11px;
|
|
189
|
-
font-weight: 300;
|
|
190
|
-
line-height: 1.5;
|
|
191
|
-
transition: color 0.25s ease;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
& .right {
|
|
196
|
-
display: flex;
|
|
197
|
-
gap: 8px;
|
|
198
|
-
align-items: stretch;
|
|
199
|
-
justify-content: flex-end;
|
|
200
|
-
width: 100px;
|
|
201
|
-
|
|
202
|
-
& .controls {
|
|
203
|
-
display: flex;
|
|
204
|
-
flex-direction: column;
|
|
205
|
-
justify-content: center;
|
|
206
|
-
padding-left: 5px;
|
|
207
|
-
margin-right: -4px;
|
|
208
|
-
border-left: 1px solid var(--knime-silver-sand);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
&::before {
|
|
213
|
-
position: absolute;
|
|
214
|
-
top: 12px;
|
|
215
|
-
left: -6px;
|
|
216
|
-
width: 12px;
|
|
217
|
-
height: 12px;
|
|
218
|
-
content: "";
|
|
219
|
-
background-color: var(--knime-white);
|
|
220
|
-
transform: rotateZ(45deg);
|
|
221
|
-
transition: background-color 0.25s ease;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
&::after {
|
|
225
|
-
position: absolute;
|
|
226
|
-
top: 15px;
|
|
227
|
-
left: -24px;
|
|
228
|
-
width: 6px;
|
|
229
|
-
height: 6px;
|
|
230
|
-
content: "";
|
|
231
|
-
background-color: var(--knime-masala);
|
|
232
|
-
border-radius: 100%;
|
|
233
|
-
box-shadow: 0 0 0 0 transparent;
|
|
234
|
-
transition:
|
|
235
|
-
background-color 0.25s ease,
|
|
236
|
-
box-shadow 0.25s ease;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
&:hover {
|
|
240
|
-
cursor: pointer;
|
|
241
|
-
box-shadow: 0 2px 10px 0 var(--knime-gray-dark-semi);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
&.selected {
|
|
245
|
-
background-color: var(--knime-cornflower-semi);
|
|
246
|
-
|
|
247
|
-
& .left {
|
|
248
|
-
& h6,
|
|
249
|
-
& .date {
|
|
250
|
-
color: var(--knime-cornflower-dark);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
& .controls {
|
|
255
|
-
border-left: 1px solid var(--knime-cornflower-light);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
& .footer-info {
|
|
259
|
-
color: var(--knime-cornflower-dark);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
&::before {
|
|
263
|
-
background-color: var(--knime-cornflower-semi);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
&::after {
|
|
267
|
-
background-color: var(--knime-cornflower);
|
|
268
|
-
box-shadow:
|
|
269
|
-
0 0 0 3px var(--knime-porcelain),
|
|
270
|
-
0 0 0 5px var(--knime-cornflower);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
@media only screen and (width <= 900px) {
|
|
275
|
-
width: calc(100vw - 100px);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
</style>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed } from "vue";
|
|
3
|
-
|
|
4
|
-
import { InlineMessage } from "@knime/components";
|
|
5
|
-
|
|
6
|
-
import type { VersionLimit } from "../types";
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
versionLimit,
|
|
10
|
-
upgradeUrl = undefined,
|
|
11
|
-
isPrivate = false,
|
|
12
|
-
} = defineProps<{
|
|
13
|
-
versionLimit: Required<VersionLimit>;
|
|
14
|
-
upgradeUrl?: string;
|
|
15
|
-
isPrivate?: boolean;
|
|
16
|
-
}>();
|
|
17
|
-
|
|
18
|
-
const isLimitReached = computed(
|
|
19
|
-
() => versionLimit.currentUsage >= versionLimit.limit,
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
const title = computed(() => {
|
|
23
|
-
if (isLimitReached.value) {
|
|
24
|
-
return `You've reached the maximum of ${versionLimit.limit} versions.`;
|
|
25
|
-
} else {
|
|
26
|
-
return `Using ${versionLimit.currentUsage} of ${versionLimit.limit} versions.`;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<template>
|
|
32
|
-
<InlineMessage variant="info" :title>
|
|
33
|
-
<template v-if="upgradeUrl"><a :href="upgradeUrl">Upgrade</a></template>
|
|
34
|
-
<template v-else>Upgrade</template>
|
|
35
|
-
to use unlimited versions{{ isPrivate ? " for private items." : "." }}
|
|
36
|
-
</InlineMessage>
|
|
37
|
-
</template>
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { type FetchOptions } from "ofetch";
|
|
2
|
-
|
|
3
|
-
import { type HubAvatarData, rfcErrors } from "@knime/hub-features";
|
|
4
|
-
import { VERSION_DEFAULT_LIMIT } from "@knime/hub-features/versions";
|
|
5
|
-
import type {
|
|
6
|
-
AssignedLabel,
|
|
7
|
-
ItemPermission,
|
|
8
|
-
ItemSavepoint,
|
|
9
|
-
NamedItemVersion,
|
|
10
|
-
RepositoryItem,
|
|
11
|
-
VersionLimit,
|
|
12
|
-
WithAvatar,
|
|
13
|
-
WithLabels,
|
|
14
|
-
} from "@knime/hub-features/versions";
|
|
15
|
-
|
|
16
|
-
import { getFetchClient } from "../../../common/ofetchClient";
|
|
17
|
-
|
|
18
|
-
type UseVersionsApiOptions = {
|
|
19
|
-
customFetchClientOptions?: FetchOptions;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const useVersionsApi = ({
|
|
23
|
-
customFetchClientOptions,
|
|
24
|
-
}: UseVersionsApiOptions) => {
|
|
25
|
-
const $ofetch = getFetchClient(customFetchClientOptions);
|
|
26
|
-
|
|
27
|
-
const doHubRequest = async (path: string, fetchOptions?: FetchOptions) => {
|
|
28
|
-
const defaults: FetchOptions = {
|
|
29
|
-
method: "GET",
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
consola.trace("useVersionsApi::calling", {
|
|
34
|
-
path,
|
|
35
|
-
options: fetchOptions,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return await $ofetch(path, { ...defaults, ...fetchOptions });
|
|
39
|
-
} catch (error) {
|
|
40
|
-
throw rfcErrors.tryParse(error) ?? error;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const fetchRepositoryItem = ({ itemId }: { itemId: string }) => {
|
|
45
|
-
return doHubRequest(`/repository/${itemId}`) as Promise<RepositoryItem>;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const fetchVersionLimit = ({ itemId }: { itemId: string }) => {
|
|
49
|
-
return doHubRequest(
|
|
50
|
-
`/repository/limits/${itemId}/item-versions`,
|
|
51
|
-
) as Promise<VersionLimit>;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const fetchVersions = ({
|
|
55
|
-
itemId,
|
|
56
|
-
loadAll,
|
|
57
|
-
}: {
|
|
58
|
-
itemId: string;
|
|
59
|
-
loadAll: boolean;
|
|
60
|
-
}) => {
|
|
61
|
-
let path = `/repository/${itemId}/versions`;
|
|
62
|
-
|
|
63
|
-
if (loadAll) {
|
|
64
|
-
path += "?limit=-1";
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return doHubRequest(path) as Promise<{
|
|
68
|
-
totalCount: number;
|
|
69
|
-
versions: Array<NamedItemVersion>;
|
|
70
|
-
}>;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const fetchResourceLabels = async ({
|
|
74
|
-
resourceType,
|
|
75
|
-
resourceId,
|
|
76
|
-
}: {
|
|
77
|
-
resourceType: "savepoint";
|
|
78
|
-
resourceId: string;
|
|
79
|
-
}): Promise<{
|
|
80
|
-
assignedLabels: Array<AssignedLabel>;
|
|
81
|
-
}> => {
|
|
82
|
-
try {
|
|
83
|
-
return await doHubRequest(
|
|
84
|
-
`/validation/validation/resources/${resourceType}/${resourceId}/labels`,
|
|
85
|
-
);
|
|
86
|
-
} catch (error) {
|
|
87
|
-
consola.error("useVersionsApi::Failed to fetch resource labels", {
|
|
88
|
-
resourceId,
|
|
89
|
-
resourceType,
|
|
90
|
-
error,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return { assignedLabels: [] };
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const deleteVersion = ({
|
|
98
|
-
itemId,
|
|
99
|
-
version,
|
|
100
|
-
}: {
|
|
101
|
-
itemId: string;
|
|
102
|
-
version: NamedItemVersion["version"];
|
|
103
|
-
}) => {
|
|
104
|
-
return doHubRequest(`/repository/${itemId}/versions/${version}`, {
|
|
105
|
-
method: "DELETE",
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const restoreVersion = ({
|
|
110
|
-
itemId,
|
|
111
|
-
version,
|
|
112
|
-
}: {
|
|
113
|
-
itemId: string;
|
|
114
|
-
version: NamedItemVersion["version"];
|
|
115
|
-
}) => {
|
|
116
|
-
return doHubRequest(
|
|
117
|
-
`/repository/${itemId}/workingArea?fromVersion=${version}`,
|
|
118
|
-
{
|
|
119
|
-
method: "POST",
|
|
120
|
-
},
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const discardUnversionedChanges = ({ itemId }: { itemId: string }) => {
|
|
125
|
-
return doHubRequest(`/repository/${itemId}/workingArea`, {
|
|
126
|
-
method: "DELETE",
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const createVersion = ({
|
|
131
|
-
itemId,
|
|
132
|
-
title,
|
|
133
|
-
description,
|
|
134
|
-
}: {
|
|
135
|
-
itemId: string;
|
|
136
|
-
title: string;
|
|
137
|
-
description: string;
|
|
138
|
-
}): Promise<NamedItemVersion> => {
|
|
139
|
-
return doHubRequest(`/repository/${itemId}/versions`, {
|
|
140
|
-
method: "POST",
|
|
141
|
-
body: JSON.stringify({
|
|
142
|
-
title,
|
|
143
|
-
description,
|
|
144
|
-
}),
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const getAvatar = async ({
|
|
149
|
-
accountName,
|
|
150
|
-
}: {
|
|
151
|
-
accountName: string;
|
|
152
|
-
}): Promise<HubAvatarData> => {
|
|
153
|
-
try {
|
|
154
|
-
const accountInfo = await doHubRequest(`/accounts/name/${accountName}`, {
|
|
155
|
-
headers: {
|
|
156
|
-
Prefer: "representation=minimal",
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
kind: accountInfo.type === "TEAM" ? "group" : "account",
|
|
162
|
-
name: accountInfo.name,
|
|
163
|
-
image: {
|
|
164
|
-
url: accountInfo.avatarUrl,
|
|
165
|
-
altText: `${accountInfo.realName ?? accountInfo.name} profile image`,
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
} catch (error) {
|
|
169
|
-
consola.error("useVersionsApi::Failed to fetch user avatar", {
|
|
170
|
-
accountName,
|
|
171
|
-
error,
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
return {
|
|
175
|
-
kind: "account",
|
|
176
|
-
name: "?",
|
|
177
|
-
tooltip: "unknown",
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const loadSavepointMetadata = async (
|
|
183
|
-
savepoint: ItemSavepoint,
|
|
184
|
-
): Promise<WithAvatar & WithLabels> => {
|
|
185
|
-
const avatar = await getAvatar({
|
|
186
|
-
accountName: savepoint.version?.author ?? savepoint.author,
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
const labels = savepoint.itemVersionId
|
|
190
|
-
? await fetchResourceLabels({
|
|
191
|
-
resourceType: "savepoint",
|
|
192
|
-
resourceId: savepoint.itemVersionId,
|
|
193
|
-
}).then((response) => response.assignedLabels)
|
|
194
|
-
: [];
|
|
195
|
-
|
|
196
|
-
return { avatar, labels };
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
const fetchItemSavepoints = ({
|
|
200
|
-
itemId,
|
|
201
|
-
limit,
|
|
202
|
-
}: {
|
|
203
|
-
itemId: string;
|
|
204
|
-
limit?: number;
|
|
205
|
-
}) => {
|
|
206
|
-
return doHubRequest(
|
|
207
|
-
`/repository/${itemId}/savepoints?limit=${
|
|
208
|
-
limit ?? VERSION_DEFAULT_LIMIT
|
|
209
|
-
}`,
|
|
210
|
-
) as Promise<{
|
|
211
|
-
totalCount: number;
|
|
212
|
-
savepoints: Array<ItemSavepoint>;
|
|
213
|
-
}>;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
const fetchPermissions = async ({
|
|
217
|
-
itemId,
|
|
218
|
-
}: {
|
|
219
|
-
itemId: string;
|
|
220
|
-
}): Promise<ItemPermission[]> => {
|
|
221
|
-
const masonControlsMap = {
|
|
222
|
-
"knime:delete": "DELETE",
|
|
223
|
-
edit: "EDIT",
|
|
224
|
-
"knime:configuration": "CONFIGURATION",
|
|
225
|
-
"knime:move": "MOVE",
|
|
226
|
-
"knime:copy": "COPY",
|
|
227
|
-
} as const;
|
|
228
|
-
|
|
229
|
-
const repositoryItem = await fetchRepositoryItem({
|
|
230
|
-
itemId,
|
|
231
|
-
});
|
|
232
|
-
return Object.keys(repositoryItem["@controls"])
|
|
233
|
-
.filter((control) => control in masonControlsMap)
|
|
234
|
-
.map(
|
|
235
|
-
(control) => masonControlsMap[control as keyof typeof masonControlsMap],
|
|
236
|
-
);
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
fetchVersions,
|
|
241
|
-
fetchVersionLimit,
|
|
242
|
-
fetchResourceLabels,
|
|
243
|
-
fetchItemSavepoints,
|
|
244
|
-
fetchPermissions,
|
|
245
|
-
loadSavepointMetadata,
|
|
246
|
-
deleteVersion,
|
|
247
|
-
restoreVersion,
|
|
248
|
-
discardUnversionedChanges,
|
|
249
|
-
createVersion,
|
|
250
|
-
getAvatar,
|
|
251
|
-
};
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
export type VersionsAPI = ReturnType<typeof useVersionsApi>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import CreateVersionForm from "./components/CreateVersionForm.vue";
|
|
2
|
-
import ManageVersions from "./components/ManageVersions.vue";
|
|
3
|
-
|
|
4
|
-
export { CreateVersionForm, ManageVersions };
|
|
5
|
-
export type * from "./types";
|
|
6
|
-
export * from "./constants";
|
|
7
|
-
export * from "./composables/useVersionsApi";
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { HubAvatarData } from "../avatars/HubAvatar.vue";
|
|
2
|
-
|
|
3
|
-
import type { CURRENT_STATE_VERSION, MOST_RECENT_VERSION } from "./constants";
|
|
4
|
-
|
|
5
|
-
// TODO: Generate from OpenAPI spec
|
|
6
|
-
export type NamedItemVersion = {
|
|
7
|
-
version: number | typeof CURRENT_STATE_VERSION | typeof MOST_RECENT_VERSION;
|
|
8
|
-
title: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
author: string;
|
|
11
|
-
authorAccountId?: string;
|
|
12
|
-
createdOn: string;
|
|
13
|
-
};
|
|
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
|
-
|
|
35
|
-
export type AssignedLabel = {
|
|
36
|
-
labelId: string;
|
|
37
|
-
message?: string;
|
|
38
|
-
createdAt?: string;
|
|
39
|
-
createdBy?: string; // UUID
|
|
40
|
-
label: {
|
|
41
|
-
name?: string;
|
|
42
|
-
description?: string;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type WithAvatar = { avatar: HubAvatarData };
|
|
47
|
-
export type WithLabels = { labels: Array<AssignedLabel> };
|
|
48
|
-
|
|
49
|
-
type ItemChange = {
|
|
50
|
-
author: string;
|
|
51
|
-
createdOn: string;
|
|
52
|
-
eventActionType: "ADDED" | "UPDATED" | "MOVED" | "RENAMED";
|
|
53
|
-
message: string;
|
|
54
|
-
authorAccountId?: string;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export type ItemSavepoint = {
|
|
58
|
-
author: string;
|
|
59
|
-
authorAccountId?: string;
|
|
60
|
-
lastEditedOn: string;
|
|
61
|
-
savepointNumber: number;
|
|
62
|
-
version?: NamedItemVersion;
|
|
63
|
-
itemVersionId?: string; // UUID
|
|
64
|
-
changes: Array<ItemChange>;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export type ItemPermission =
|
|
68
|
-
| "DELETE"
|
|
69
|
-
| "EDIT"
|
|
70
|
-
| "CONFIGURATION"
|
|
71
|
-
| "MOVE"
|
|
72
|
-
| "COPY";
|
|
73
|
-
|
|
74
|
-
export type VersionLimit = {
|
|
75
|
-
currentUsage: number;
|
|
76
|
-
limit?: number;
|
|
77
|
-
};
|