@knime/hub-features 1.1.3 → 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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @knime/hub-features
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4f06376: Add hub-specific processing state for for uploads
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [4f06376]
12
+ - @knime/components@1.13.1
13
+ - @knime/utils@1.2.3
14
+
15
+ ## 1.1.4
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [1787fe5]
20
+ - @knime/components@1.13.0
21
+
3
22
  ## 1.1.3
4
23
 
5
24
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knime/hub-features",
3
- "version": "1.1.3",
3
+ "version": "1.2.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)",
@@ -27,9 +27,9 @@
27
27
  "consola": "3.2.3",
28
28
  "ofetch": "^1.4.1",
29
29
  "typescript": "^5.4.5",
30
- "@knime/components": "1.12.3",
30
+ "@knime/components": "1.13.1",
31
31
  "@knime/styles": "1.1.1",
32
- "@knime/utils": "1.2.2"
32
+ "@knime/utils": "1.2.3"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "vue": "3.x"
@@ -1,4 +1,4 @@
1
- import { computed, ref } from "vue";
1
+ import { computed, reactive, readonly, ref } from "vue";
2
2
  import { FetchError } from "ofetch";
3
3
 
4
4
  import { useUploadManager } from "@knime/components";
@@ -172,7 +172,32 @@ export const useFileUpload = (options: UseFileUploadOptions = {}) => {
172
172
  });
173
173
  };
174
174
 
175
- const useUploadManagerResult = useUploadManager({
175
+ // contains upload ids for files that have a processing step which was not finished yet
176
+ const unprocessedUploads = reactive<Set<string>>(new Set());
177
+ const isFileWithProcessing = (file: File) =>
178
+ knimeFileFormats.KNWF.matches(file);
179
+
180
+ let useUploadManagerResult: ReturnType<typeof useUploadManager> | null = null;
181
+
182
+ const setProcessingCompleted = ({ uploadId }: { uploadId: string }) => {
183
+ unprocessedUploads.delete(uploadId);
184
+ };
185
+
186
+ const setProcessingFailed = ({
187
+ uploadId,
188
+ error,
189
+ }: {
190
+ uploadId: string;
191
+ error?: Error;
192
+ }) => {
193
+ unprocessedUploads.delete(uploadId);
194
+ useUploadManagerResult?.setFailed(
195
+ uploadId,
196
+ error ?? new Error("An error occurred when processing the file"),
197
+ );
198
+ };
199
+
200
+ useUploadManagerResult = useUploadManager({
176
201
  resolveFilePartUploadURL,
177
202
 
178
203
  onFileUploadComplete: ({ uploadId, filePartIds }) => {
@@ -183,7 +208,7 @@ export const useFileUpload = (options: UseFileUploadOptions = {}) => {
183
208
  })
184
209
  .catch((error) => {
185
210
  consola.error("Error attempting to complete upload", { error });
186
- useUploadManagerResult.setFailed(uploadId, error as Error);
211
+ setProcessingFailed({ uploadId, error });
187
212
  });
188
213
  },
189
214
 
@@ -205,10 +230,27 @@ export const useFileUpload = (options: UseFileUploadOptions = {}) => {
205
230
  return files.slice(0, maxUploadQueueSize - totalPendingUploads.value);
206
231
  };
207
232
 
233
+ const { uploadState, ...uploadMangerResultRest } = useUploadManagerResult;
234
+
235
+ const uploadItems = computed(() => {
236
+ return Object.values(uploadState.value).map((uploadItem) => ({
237
+ ...uploadItem,
238
+ status:
239
+ uploadItem.status === "complete" &&
240
+ unprocessedUploads.has(uploadItem.id)
241
+ ? "processing"
242
+ : uploadItem.status,
243
+ }));
244
+ });
245
+
208
246
  const prepareQueueSize = ref(0);
209
247
 
210
248
  return {
211
- ...useUploadManagerResult,
249
+ ...uploadMangerResultRest,
250
+ uploadItems,
251
+ unprocessedUploads: readonly(unprocessedUploads),
252
+ setProcessingCompleted,
253
+ setProcessingFailed,
212
254
 
213
255
  isPreparingUpload: computed(() => prepareQueueSize.value > 0),
214
256
  totalFilesBeingPrepared: computed(() => prepareQueueSize.value),
@@ -230,6 +272,12 @@ export const useFileUpload = (options: UseFileUploadOptions = {}) => {
230
272
  retryDelayMS: DEFAULT_RETRY_DELAY_MS,
231
273
  });
232
274
 
275
+ uploadPayload.forEach(({ uploadId, file }) => {
276
+ if (isFileWithProcessing(file)) {
277
+ unprocessedUploads.add(uploadId);
278
+ }
279
+ });
280
+
233
281
  useUploadManagerResult.start(parentId, uploadPayload);
234
282
  } catch (error) {
235
283
  if (error instanceof FetchError) {