@knime/hub-features 1.11.4 → 1.11.6
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 +13 -0
- package/package.json +2 -2
- package/src/rfcErrors/RFCErrorToastTemplate.vue +42 -18
- package/src/rfcErrors/index.ts +9 -3
- package/src/rfcErrors/types.ts +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @knime/hub-features
|
|
2
2
|
|
|
3
|
+
## 1.11.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- dc12ac4: Adjust payload for RFC error utils
|
|
8
|
+
|
|
9
|
+
## 1.11.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [e7d2020]
|
|
14
|
+
- @knime/components@1.33.1
|
|
15
|
+
|
|
3
16
|
## 1.11.4
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knime/hub-features",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.6",
|
|
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)",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"lodash-es": "4.17.21",
|
|
32
32
|
"ofetch": "^1.4.1",
|
|
33
33
|
"typescript": "^5.4.5",
|
|
34
|
-
"@knime/components": "1.33.
|
|
34
|
+
"@knime/components": "1.33.1",
|
|
35
35
|
"@knime/styles": "1.10.0",
|
|
36
36
|
"@knime/utils": "1.5.3"
|
|
37
37
|
},
|
|
@@ -9,14 +9,22 @@ import CopyIcon from "@knime/styles/img/icons/copy.svg";
|
|
|
9
9
|
interface Props {
|
|
10
10
|
headline: string; // toast headline, will not be displayed here but needed when copying to clipboard
|
|
11
11
|
title: string;
|
|
12
|
+
status?: number;
|
|
13
|
+
date?: Date;
|
|
12
14
|
details?: string[];
|
|
13
|
-
|
|
14
|
-
date: Date;
|
|
15
|
-
requestId: string;
|
|
15
|
+
requestId?: string;
|
|
16
16
|
errorId?: string;
|
|
17
|
+
canCopyToClipboard?: boolean;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
const props = defineProps<Props>()
|
|
20
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
21
|
+
status: undefined,
|
|
22
|
+
date: undefined,
|
|
23
|
+
details: () => [],
|
|
24
|
+
requestId: undefined,
|
|
25
|
+
errorId: undefined,
|
|
26
|
+
canCopyToClipboard: true,
|
|
27
|
+
});
|
|
20
28
|
const emits = defineEmits(["showMore"]);
|
|
21
29
|
|
|
22
30
|
const { copy, copied } = useClipboard({
|
|
@@ -57,16 +65,29 @@ const errorForClipboard = computed(() => {
|
|
|
57
65
|
errorText += `${props.title}\n\n`;
|
|
58
66
|
errorText += details ? `Details: ${details}\n\n` : "";
|
|
59
67
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
if (props.status !== undefined) {
|
|
69
|
+
errorText += `Status: ${props.status}\n`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (props.date) {
|
|
73
|
+
errorText += `Date: ${formattedDate.value}\n`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (props.requestId) {
|
|
77
|
+
errorText += `Request Id: ${props.requestId}\n`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (props.errorId) {
|
|
81
|
+
errorText += props.errorId ? `Error Id: ${props.errorId}\n` : "";
|
|
82
|
+
}
|
|
64
83
|
|
|
65
84
|
return errorText;
|
|
66
85
|
});
|
|
67
86
|
|
|
68
87
|
const copyToClipboard = () => {
|
|
69
|
-
copy(errorForClipboard.value)
|
|
88
|
+
copy(errorForClipboard.value).catch((error) => {
|
|
89
|
+
consola.error("Failed to copy to clipboard", { error });
|
|
90
|
+
});
|
|
70
91
|
};
|
|
71
92
|
|
|
72
93
|
const onShowDetailsClicked = () => {
|
|
@@ -95,17 +116,20 @@ const onShowDetailsClicked = () => {
|
|
|
95
116
|
</ul>
|
|
96
117
|
</template>
|
|
97
118
|
</div>
|
|
98
|
-
|
|
99
|
-
<div
|
|
100
|
-
|
|
119
|
+
|
|
120
|
+
<div v-if="status !== undefined">
|
|
121
|
+
<strong>Status: </strong>{{ status }}
|
|
122
|
+
</div>
|
|
123
|
+
<div v-if="date"><strong>Date: </strong>{{ formattedDate }}</div>
|
|
124
|
+
<div v-if="requestId"><strong>Request id: </strong>{{ requestId }}</div>
|
|
101
125
|
<div v-if="errorId"><strong>Error id: </strong>{{ errorId }}</div>
|
|
102
|
-
<div class="copy-button-wrapper">
|
|
126
|
+
<div v-if="canCopyToClipboard" class="copy-button-wrapper">
|
|
103
127
|
<Button @click="copyToClipboard">
|
|
104
|
-
<template v-if="copied"
|
|
105
|
-
|
|
106
|
-
>
|
|
107
|
-
<template v-else
|
|
108
|
-
|
|
128
|
+
<template v-if="copied">
|
|
129
|
+
<CheckIcon class="copy-icon" />Error was copied
|
|
130
|
+
</template>
|
|
131
|
+
<template v-else>
|
|
132
|
+
<CopyIcon class="copy-icon" />Copy error to clipboard
|
|
109
133
|
</template>
|
|
110
134
|
</Button>
|
|
111
135
|
</div>
|
package/src/rfcErrors/index.ts
CHANGED
|
@@ -12,13 +12,19 @@ import { RFCError, type RFCErrorData } from "./types";
|
|
|
12
12
|
const toToast = ({
|
|
13
13
|
headline,
|
|
14
14
|
rfcError,
|
|
15
|
+
canCopyToClipboard = true,
|
|
15
16
|
}: {
|
|
16
17
|
headline: string;
|
|
17
18
|
rfcError: RFCError;
|
|
19
|
+
canCopyToClipboard?: boolean;
|
|
18
20
|
}): Toast => {
|
|
19
21
|
const { data } = rfcError;
|
|
20
22
|
|
|
21
|
-
const rfcErrorToastContent = h(RFCErrorToastTemplate, {
|
|
23
|
+
const rfcErrorToastContent = h(RFCErrorToastTemplate, {
|
|
24
|
+
headline,
|
|
25
|
+
...data,
|
|
26
|
+
canCopyToClipboard,
|
|
27
|
+
});
|
|
22
28
|
|
|
23
29
|
return {
|
|
24
30
|
type: "error",
|
|
@@ -39,14 +45,14 @@ const tryParse = (error: FetchError): RFCError | FetchError => {
|
|
|
39
45
|
|
|
40
46
|
const responseDate = error.response.headers.get("date")
|
|
41
47
|
? new Date(error.response.headers.get("date")!)
|
|
42
|
-
:
|
|
48
|
+
: undefined;
|
|
43
49
|
|
|
44
50
|
const rfcErrorData: RFCErrorData = {
|
|
45
51
|
title: error.data.title as string,
|
|
46
52
|
details: error.data.details as string[] | undefined,
|
|
47
53
|
status: error.statusCode as number,
|
|
48
54
|
date: responseDate,
|
|
49
|
-
requestId: error.response.headers.get("x-request-id") ??
|
|
55
|
+
requestId: error.response.headers.get("x-request-id") ?? undefined,
|
|
50
56
|
errorId: error.response.headers.get("x-error-id") ?? undefined,
|
|
51
57
|
};
|
|
52
58
|
|
package/src/rfcErrors/types.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type based on an RFC-9457 error standard (https://www.rfc-editor.org/rfc/rfc9457)
|
|
3
|
+
* Also see:
|
|
4
|
+
* https://knime-com.atlassian.net/wiki/spaces/SPECS/pages/4126769212/API+Errors+Problem+Details
|
|
3
5
|
*/
|
|
4
6
|
export type RFCErrorData = {
|
|
5
7
|
title: string;
|
|
8
|
+
status?: number;
|
|
9
|
+
date?: Date;
|
|
6
10
|
details?: string[];
|
|
7
|
-
|
|
8
|
-
date: Date;
|
|
9
|
-
requestId: string;
|
|
11
|
+
requestId?: string;
|
|
10
12
|
errorId?: string;
|
|
11
13
|
};
|
|
12
14
|
|