@red-hat-developer-hub/backstage-plugin-lightspeed 2.1.0 → 2.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 +10 -0
- package/dist/alpha.d.ts +24 -0
- package/dist/api/NotebooksApiClient.esm.js +88 -17
- package/dist/api/NotebooksApiClient.esm.js.map +1 -1
- package/dist/api/notebooksApi.esm.js.map +1 -1
- package/dist/components/LightSpeedChat.esm.js +68 -17
- package/dist/components/LightSpeedChat.esm.js.map +1 -1
- package/dist/components/Router.esm.js +2 -1
- package/dist/components/Router.esm.js.map +1 -1
- package/dist/components/notebooks/AddDocumentModal.esm.js +170 -0
- package/dist/components/notebooks/AddDocumentModal.esm.js.map +1 -0
- package/dist/components/notebooks/DocumentSidebar.esm.js +154 -0
- package/dist/components/notebooks/DocumentSidebar.esm.js.map +1 -0
- package/dist/components/notebooks/FileTypeIcon.esm.js +59 -0
- package/dist/components/notebooks/FileTypeIcon.esm.js.map +1 -0
- package/dist/components/notebooks/NotebookCard.esm.js +86 -75
- package/dist/components/notebooks/NotebookCard.esm.js.map +1 -1
- package/dist/components/notebooks/NotebookView.esm.js +376 -0
- package/dist/components/notebooks/NotebookView.esm.js.map +1 -0
- package/dist/components/notebooks/NotebooksTab.esm.js +15 -5
- package/dist/components/notebooks/NotebooksTab.esm.js.map +1 -1
- package/dist/components/notebooks/OverwriteConfirmModal.esm.js +141 -0
- package/dist/components/notebooks/OverwriteConfirmModal.esm.js.map +1 -0
- package/dist/components/notebooks/SidebarCollapseIcon.esm.js +47 -0
- package/dist/components/notebooks/SidebarCollapseIcon.esm.js.map +1 -0
- package/dist/components/notebooks/UploadResourceScreen.esm.js +58 -0
- package/dist/components/notebooks/UploadResourceScreen.esm.js.map +1 -0
- package/dist/const.esm.js +26 -1
- package/dist/const.esm.js.map +1 -1
- package/dist/hooks/notebooks/useCreateNotebook.esm.js +19 -0
- package/dist/hooks/notebooks/useCreateNotebook.esm.js.map +1 -0
- package/dist/hooks/notebooks/useDocumentStatusPolling.esm.js +39 -0
- package/dist/hooks/notebooks/useDocumentStatusPolling.esm.js.map +1 -0
- package/dist/hooks/notebooks/useNotebookDocuments.esm.js +18 -0
- package/dist/hooks/notebooks/useNotebookDocuments.esm.js.map +1 -0
- package/dist/hooks/notebooks/useUploadDocument.esm.js +28 -0
- package/dist/hooks/notebooks/useUploadDocument.esm.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/plugin.esm.js +3 -2
- package/dist/plugin.esm.js.map +1 -1
- package/dist/routes.esm.js +6 -1
- package/dist/routes.esm.js.map +1 -1
- package/dist/translations/de.esm.js +27 -0
- package/dist/translations/de.esm.js.map +1 -1
- package/dist/translations/es.esm.js +27 -0
- package/dist/translations/es.esm.js.map +1 -1
- package/dist/translations/fr.esm.js +27 -0
- package/dist/translations/fr.esm.js.map +1 -1
- package/dist/translations/it.esm.js +27 -0
- package/dist/translations/it.esm.js.map +1 -1
- package/dist/translations/ja.esm.js +27 -0
- package/dist/translations/ja.esm.js.map +1 -1
- package/dist/translations/ref.esm.js +27 -0
- package/dist/translations/ref.esm.js.map +1 -1
- package/dist/types.esm.js.map +1 -1
- package/dist/utils/notebook-upload-utils.esm.js +48 -0
- package/dist/utils/notebook-upload-utils.esm.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useRef, useEffect } from 'react';
|
|
3
|
+
import { makeStyles } from '@material-ui/core';
|
|
4
|
+
import { ChatbotFooter, MessageBar, ChatbotFootnote } from '@patternfly/chatbot';
|
|
5
|
+
import { DrawerPanelContent, AlertGroup, Alert, AlertVariant, AlertActionCloseButton, Drawer, DrawerContent, DrawerContentBody, Tooltip, Button } from '@patternfly/react-core';
|
|
6
|
+
import { TimesIcon } from '@patternfly/react-icons';
|
|
7
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
8
|
+
import { UNTITLED_NOTEBOOK_NAME } from '../../const.esm.js';
|
|
9
|
+
import { useDocumentStatusPolling } from '../../hooks/notebooks/useDocumentStatusPolling.esm.js';
|
|
10
|
+
import { useUploadDocument } from '../../hooks/notebooks/useUploadDocument.esm.js';
|
|
11
|
+
import { useTranslation } from '../../hooks/useTranslation.esm.js';
|
|
12
|
+
import { AddDocumentModal } from './AddDocumentModal.esm.js';
|
|
13
|
+
import { DocumentSidebar } from './DocumentSidebar.esm.js';
|
|
14
|
+
import { OverwriteConfirmModal } from './OverwriteConfirmModal.esm.js';
|
|
15
|
+
import { SidebarExpandIcon, AddCircleFilledIcon } from './SidebarCollapseIcon.esm.js';
|
|
16
|
+
import { UploadResourceScreen } from './UploadResourceScreen.esm.js';
|
|
17
|
+
|
|
18
|
+
const useStyles = makeStyles((theme) => ({
|
|
19
|
+
root: {
|
|
20
|
+
display: "flex",
|
|
21
|
+
flexDirection: "column",
|
|
22
|
+
height: "100%",
|
|
23
|
+
backgroundColor: "var(--pf-t--global--background--color--primary--default)"
|
|
24
|
+
},
|
|
25
|
+
drawerContainer: {
|
|
26
|
+
flex: 1,
|
|
27
|
+
minHeight: 0
|
|
28
|
+
},
|
|
29
|
+
expandStrip: {
|
|
30
|
+
display: "flex",
|
|
31
|
+
flexDirection: "column",
|
|
32
|
+
alignItems: "center",
|
|
33
|
+
paddingTop: theme.spacing(1.5),
|
|
34
|
+
gap: theme.spacing(1),
|
|
35
|
+
borderRight: "1px solid var(--pf-t--global--border--color--default)"
|
|
36
|
+
},
|
|
37
|
+
addIconButton: {
|
|
38
|
+
padding: 0,
|
|
39
|
+
minWidth: 0,
|
|
40
|
+
lineHeight: 1
|
|
41
|
+
},
|
|
42
|
+
mainArea: {
|
|
43
|
+
display: "flex",
|
|
44
|
+
flexDirection: "row",
|
|
45
|
+
height: "100%",
|
|
46
|
+
minWidth: 0
|
|
47
|
+
},
|
|
48
|
+
topBar: {
|
|
49
|
+
display: "flex",
|
|
50
|
+
justifyContent: "flex-end",
|
|
51
|
+
padding: `${theme.spacing(1.5)}px ${theme.spacing(2)}px`
|
|
52
|
+
},
|
|
53
|
+
closeButton: {
|
|
54
|
+
textTransform: "none"
|
|
55
|
+
},
|
|
56
|
+
mainContent: {
|
|
57
|
+
display: "flex",
|
|
58
|
+
flexDirection: "column",
|
|
59
|
+
flex: 1,
|
|
60
|
+
minHeight: 0
|
|
61
|
+
},
|
|
62
|
+
drawerContentBody: {
|
|
63
|
+
backgroundColor: "var(--pf-t--global--background--color--secondary--default)"
|
|
64
|
+
},
|
|
65
|
+
contentColumn: {
|
|
66
|
+
display: "flex",
|
|
67
|
+
flexDirection: "column",
|
|
68
|
+
flex: 1,
|
|
69
|
+
minWidth: 0
|
|
70
|
+
},
|
|
71
|
+
alertContainer: {
|
|
72
|
+
width: "100%",
|
|
73
|
+
maxWidth: 816,
|
|
74
|
+
margin: "0 auto",
|
|
75
|
+
padding: `0 ${theme.spacing(3)}px ${theme.spacing(1)}px`
|
|
76
|
+
},
|
|
77
|
+
toastAlertGroup: {
|
|
78
|
+
"--pf-v6-c-alert-group--m-toast--InsetInlineEnd": `${theme.spacing(2.5)}px`,
|
|
79
|
+
"--pf-v6-c-alert-group--m-toast--InsetBlockStart": `${theme.spacing(2.5)}px`,
|
|
80
|
+
"--pf-v6-c-alert-group--m-toast--MaxWidth": "350px"
|
|
81
|
+
},
|
|
82
|
+
toastAlert: {
|
|
83
|
+
maxWidth: "350px",
|
|
84
|
+
"& .pf-v6-c-alert__title": {
|
|
85
|
+
margin: 0
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}));
|
|
89
|
+
const NotebookView = ({
|
|
90
|
+
sessionId,
|
|
91
|
+
notebookName = UNTITLED_NOTEBOOK_NAME,
|
|
92
|
+
documents = [],
|
|
93
|
+
onClose
|
|
94
|
+
}) => {
|
|
95
|
+
const classes = useStyles();
|
|
96
|
+
const { t } = useTranslation();
|
|
97
|
+
const queryClient = useQueryClient();
|
|
98
|
+
const uploadMutation = useUploadDocument();
|
|
99
|
+
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
|
|
100
|
+
const [isUploadModalOpen, setIsUploadModalOpen] = useState(false);
|
|
101
|
+
const [uploadingFileNames, setUploadingFileNames] = useState([]);
|
|
102
|
+
const [pendingUploads, setPendingUploads] = useState([]);
|
|
103
|
+
const [toastAlerts, setToastAlerts] = useState([]);
|
|
104
|
+
const processedIds = useRef(/* @__PURE__ */ new Set());
|
|
105
|
+
const [completedFileNames, setCompletedFileNames] = useState(
|
|
106
|
+
/* @__PURE__ */ new Set()
|
|
107
|
+
);
|
|
108
|
+
const [filesToOverwrite, setFilesToOverwrite] = useState([]);
|
|
109
|
+
const [isOverwriteModalOpen, setIsOverwriteModalOpen] = useState(false);
|
|
110
|
+
const handleOpenUploadModal = () => setIsUploadModalOpen(true);
|
|
111
|
+
const handleCloseUploadModal = () => setIsUploadModalOpen(false);
|
|
112
|
+
const handleFilesUploading = (files) => {
|
|
113
|
+
setUploadingFileNames((prev) => [...prev, ...files.map((f) => f.name)]);
|
|
114
|
+
};
|
|
115
|
+
const handleUploadStarted = (info) => {
|
|
116
|
+
processedIds.current.delete(info.documentId);
|
|
117
|
+
setPendingUploads((prev) => [
|
|
118
|
+
...prev,
|
|
119
|
+
{ fileName: info.fileName, documentId: info.documentId }
|
|
120
|
+
]);
|
|
121
|
+
};
|
|
122
|
+
const handleUploadFailed = (fileName) => {
|
|
123
|
+
setUploadingFileNames((prev) => prev.filter((n) => n !== fileName));
|
|
124
|
+
setToastAlerts((prev) => [
|
|
125
|
+
{
|
|
126
|
+
key: Date.now() + fileName,
|
|
127
|
+
title: t("notebook.upload.failed", {
|
|
128
|
+
fileName
|
|
129
|
+
}),
|
|
130
|
+
variant: "danger"
|
|
131
|
+
},
|
|
132
|
+
...prev
|
|
133
|
+
]);
|
|
134
|
+
};
|
|
135
|
+
const handleDuplicatesFound = (files) => {
|
|
136
|
+
setFilesToOverwrite(files);
|
|
137
|
+
setIsOverwriteModalOpen(true);
|
|
138
|
+
};
|
|
139
|
+
const handleOverwriteConfirm = () => {
|
|
140
|
+
const files = filesToOverwrite;
|
|
141
|
+
setIsOverwriteModalOpen(false);
|
|
142
|
+
setFilesToOverwrite([]);
|
|
143
|
+
if (files.length === 0) return;
|
|
144
|
+
setUploadingFileNames((prev) => [...prev, ...files.map((f) => f.name)]);
|
|
145
|
+
for (const file of files) {
|
|
146
|
+
uploadMutation.mutateAsync({ sessionId, file }).then((data) => {
|
|
147
|
+
handleUploadStarted({
|
|
148
|
+
fileName: file.name,
|
|
149
|
+
documentId: data.document_id
|
|
150
|
+
});
|
|
151
|
+
}).catch(() => {
|
|
152
|
+
handleUploadFailed(file.name);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const handleOverwriteCancel = () => {
|
|
157
|
+
setIsOverwriteModalOpen(false);
|
|
158
|
+
setFilesToOverwrite([]);
|
|
159
|
+
};
|
|
160
|
+
const pollingResults = useDocumentStatusPolling(sessionId, pendingUploads);
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
const completedOrFailed = pollingResults.filter(
|
|
163
|
+
(r) => (r.status === "completed" || r.status === "failed" || r.status === "cancelled") && !processedIds.current.has(r.documentId)
|
|
164
|
+
);
|
|
165
|
+
if (completedOrFailed.length === 0) return;
|
|
166
|
+
const idsToRemove = /* @__PURE__ */ new Set();
|
|
167
|
+
const namesToRemove = /* @__PURE__ */ new Set();
|
|
168
|
+
const newAlerts = [];
|
|
169
|
+
const newCompletedNames = /* @__PURE__ */ new Set();
|
|
170
|
+
for (const result of completedOrFailed) {
|
|
171
|
+
processedIds.current.add(result.documentId);
|
|
172
|
+
idsToRemove.add(result.documentId);
|
|
173
|
+
if (result.status !== "completed") {
|
|
174
|
+
namesToRemove.add(result.fileName);
|
|
175
|
+
} else {
|
|
176
|
+
newCompletedNames.add(result.fileName);
|
|
177
|
+
}
|
|
178
|
+
if (result.status === "completed") {
|
|
179
|
+
newAlerts.push({
|
|
180
|
+
key: Date.now() + result.documentId,
|
|
181
|
+
title: t("notebook.upload.success", {
|
|
182
|
+
fileName: result.fileName
|
|
183
|
+
}),
|
|
184
|
+
variant: "success"
|
|
185
|
+
});
|
|
186
|
+
} else {
|
|
187
|
+
newAlerts.push({
|
|
188
|
+
key: Date.now() + result.documentId,
|
|
189
|
+
title: t("notebook.upload.failed", {
|
|
190
|
+
fileName: result.fileName
|
|
191
|
+
}),
|
|
192
|
+
variant: "danger"
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
setPendingUploads((prev) => prev.filter((u) => !idsToRemove.has(u.documentId)));
|
|
197
|
+
setUploadingFileNames(
|
|
198
|
+
(prev) => prev.filter((name) => !namesToRemove.has(name))
|
|
199
|
+
);
|
|
200
|
+
if (newCompletedNames.size > 0) {
|
|
201
|
+
setCompletedFileNames((prev) => /* @__PURE__ */ new Set([...prev, ...newCompletedNames]));
|
|
202
|
+
queryClient.invalidateQueries({
|
|
203
|
+
queryKey: ["notebooks", "documents", sessionId]
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
setToastAlerts((prev) => [...newAlerts, ...prev]);
|
|
207
|
+
}, [pollingResults, t, queryClient, sessionId]);
|
|
208
|
+
const handleRemoveToastAlert = (key) => {
|
|
209
|
+
setToastAlerts((prev) => prev.filter((a) => a.key !== key));
|
|
210
|
+
};
|
|
211
|
+
const hasDocuments = documents.length > 0 || uploadingFileNames.length > 0;
|
|
212
|
+
const panelContent = /* @__PURE__ */ jsx(
|
|
213
|
+
DrawerPanelContent,
|
|
214
|
+
{
|
|
215
|
+
isResizable: true,
|
|
216
|
+
defaultSize: "310px",
|
|
217
|
+
minSize: "232px",
|
|
218
|
+
maxSize: "50%",
|
|
219
|
+
resizeAriaLabel: t("notebook.view.sidebar.resize"),
|
|
220
|
+
children: /* @__PURE__ */ jsx(
|
|
221
|
+
DocumentSidebar,
|
|
222
|
+
{
|
|
223
|
+
notebookName,
|
|
224
|
+
documents,
|
|
225
|
+
uploadingFileNames,
|
|
226
|
+
completedFileNames,
|
|
227
|
+
collapsed: sidebarCollapsed,
|
|
228
|
+
onToggleCollapse: () => setSidebarCollapsed((prev) => !prev),
|
|
229
|
+
onAddDocument: handleOpenUploadModal
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
return /* @__PURE__ */ jsxs("div", { className: classes.root, children: [
|
|
235
|
+
toastAlerts.length > 0 && /* @__PURE__ */ jsx(
|
|
236
|
+
AlertGroup,
|
|
237
|
+
{
|
|
238
|
+
hasAnimations: true,
|
|
239
|
+
isToast: true,
|
|
240
|
+
isLiveRegion: true,
|
|
241
|
+
className: classes.toastAlertGroup,
|
|
242
|
+
children: toastAlerts.map(({ key, title, variant }) => /* @__PURE__ */ jsx(
|
|
243
|
+
Alert,
|
|
244
|
+
{
|
|
245
|
+
variant: AlertVariant[variant ?? "success"],
|
|
246
|
+
title,
|
|
247
|
+
className: classes.toastAlert,
|
|
248
|
+
timeout: 8e3,
|
|
249
|
+
onTimeout: () => handleRemoveToastAlert(key),
|
|
250
|
+
actionClose: /* @__PURE__ */ jsx(
|
|
251
|
+
AlertActionCloseButton,
|
|
252
|
+
{
|
|
253
|
+
title,
|
|
254
|
+
variantLabel: `${variant ?? "success"} alert`,
|
|
255
|
+
onClose: () => handleRemoveToastAlert(key)
|
|
256
|
+
}
|
|
257
|
+
)
|
|
258
|
+
},
|
|
259
|
+
key
|
|
260
|
+
))
|
|
261
|
+
}
|
|
262
|
+
),
|
|
263
|
+
/* @__PURE__ */ jsx(
|
|
264
|
+
Drawer,
|
|
265
|
+
{
|
|
266
|
+
isExpanded: !sidebarCollapsed,
|
|
267
|
+
isInline: true,
|
|
268
|
+
position: "start",
|
|
269
|
+
className: classes.drawerContainer,
|
|
270
|
+
children: /* @__PURE__ */ jsx(
|
|
271
|
+
DrawerContent,
|
|
272
|
+
{
|
|
273
|
+
panelContent: !sidebarCollapsed ? panelContent : undefined,
|
|
274
|
+
children: /* @__PURE__ */ jsx(DrawerContentBody, { className: classes.drawerContentBody, children: /* @__PURE__ */ jsxs("div", { className: classes.mainArea, children: [
|
|
275
|
+
sidebarCollapsed && /* @__PURE__ */ jsxs("div", { className: classes.expandStrip, children: [
|
|
276
|
+
/* @__PURE__ */ jsx(
|
|
277
|
+
Tooltip,
|
|
278
|
+
{
|
|
279
|
+
content: t("notebook.view.sidebar.expand"),
|
|
280
|
+
position: "right",
|
|
281
|
+
children: /* @__PURE__ */ jsx(
|
|
282
|
+
Button,
|
|
283
|
+
{
|
|
284
|
+
variant: "plain",
|
|
285
|
+
onClick: () => setSidebarCollapsed(false),
|
|
286
|
+
"aria-label": t("notebook.view.sidebar.expand"),
|
|
287
|
+
size: "sm",
|
|
288
|
+
children: /* @__PURE__ */ jsx(SidebarExpandIcon, {})
|
|
289
|
+
}
|
|
290
|
+
)
|
|
291
|
+
}
|
|
292
|
+
),
|
|
293
|
+
/* @__PURE__ */ jsx(
|
|
294
|
+
Tooltip,
|
|
295
|
+
{
|
|
296
|
+
content: t("notebook.view.documents.add"),
|
|
297
|
+
position: "right",
|
|
298
|
+
children: /* @__PURE__ */ jsx(
|
|
299
|
+
Button,
|
|
300
|
+
{
|
|
301
|
+
variant: "plain",
|
|
302
|
+
className: classes.addIconButton,
|
|
303
|
+
onClick: handleOpenUploadModal,
|
|
304
|
+
"aria-label": t("notebook.view.documents.add"),
|
|
305
|
+
children: /* @__PURE__ */ jsx(AddCircleFilledIcon, {})
|
|
306
|
+
}
|
|
307
|
+
)
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
] }),
|
|
311
|
+
/* @__PURE__ */ jsxs("div", { className: classes.contentColumn, children: [
|
|
312
|
+
/* @__PURE__ */ jsx("div", { className: classes.topBar, children: /* @__PURE__ */ jsx(
|
|
313
|
+
Button,
|
|
314
|
+
{
|
|
315
|
+
variant: "link",
|
|
316
|
+
className: classes.closeButton,
|
|
317
|
+
onClick: onClose,
|
|
318
|
+
icon: /* @__PURE__ */ jsx(TimesIcon, {}),
|
|
319
|
+
iconPosition: "end",
|
|
320
|
+
children: t("notebook.view.close")
|
|
321
|
+
}
|
|
322
|
+
) }),
|
|
323
|
+
/* @__PURE__ */ jsx("div", { className: classes.mainContent, children: !hasDocuments && /* @__PURE__ */ jsx(
|
|
324
|
+
UploadResourceScreen,
|
|
325
|
+
{
|
|
326
|
+
onUploadClick: handleOpenUploadModal
|
|
327
|
+
}
|
|
328
|
+
) }),
|
|
329
|
+
/* @__PURE__ */ jsx("div", { className: classes.alertContainer, children: /* @__PURE__ */ jsx(Alert, { isInline: true, variant: "info", title: t("aria.important"), children: t("disclaimer.withoutValidation") }) }),
|
|
330
|
+
/* @__PURE__ */ jsxs(ChatbotFooter, { children: [
|
|
331
|
+
/* @__PURE__ */ jsx(
|
|
332
|
+
MessageBar,
|
|
333
|
+
{
|
|
334
|
+
hasAttachButton: false,
|
|
335
|
+
hasMicrophoneButton: true,
|
|
336
|
+
hasStopButton: false,
|
|
337
|
+
onSendMessage: () => {
|
|
338
|
+
},
|
|
339
|
+
placeholder: t("notebook.view.input.placeholder")
|
|
340
|
+
}
|
|
341
|
+
),
|
|
342
|
+
/* @__PURE__ */ jsx(ChatbotFootnote, { label: t("footer.accuracy.label") })
|
|
343
|
+
] })
|
|
344
|
+
] })
|
|
345
|
+
] }) })
|
|
346
|
+
}
|
|
347
|
+
)
|
|
348
|
+
}
|
|
349
|
+
),
|
|
350
|
+
/* @__PURE__ */ jsx(
|
|
351
|
+
AddDocumentModal,
|
|
352
|
+
{
|
|
353
|
+
isOpen: isUploadModalOpen,
|
|
354
|
+
onClose: handleCloseUploadModal,
|
|
355
|
+
sessionId,
|
|
356
|
+
existingDocumentNames: documents.map((d) => d.title),
|
|
357
|
+
onFilesUploading: handleFilesUploading,
|
|
358
|
+
onUploadStarted: handleUploadStarted,
|
|
359
|
+
onUploadFailed: handleUploadFailed,
|
|
360
|
+
onDuplicatesFound: handleDuplicatesFound
|
|
361
|
+
}
|
|
362
|
+
),
|
|
363
|
+
/* @__PURE__ */ jsx(
|
|
364
|
+
OverwriteConfirmModal,
|
|
365
|
+
{
|
|
366
|
+
isOpen: isOverwriteModalOpen,
|
|
367
|
+
onClose: handleOverwriteCancel,
|
|
368
|
+
onConfirm: handleOverwriteConfirm,
|
|
369
|
+
fileNames: filesToOverwrite.map((f) => f.name)
|
|
370
|
+
}
|
|
371
|
+
)
|
|
372
|
+
] });
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
export { NotebookView };
|
|
376
|
+
//# sourceMappingURL=NotebookView.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotebookView.esm.js","sources":["../../../src/components/notebooks/NotebookView.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { makeStyles } from '@material-ui/core';\nimport {\n ChatbotFooter,\n ChatbotFootnote,\n MessageBar,\n} from '@patternfly/chatbot';\nimport {\n Alert,\n AlertActionCloseButton,\n AlertGroup,\n AlertVariant,\n Button,\n Drawer,\n DrawerContent,\n DrawerContentBody,\n DrawerPanelContent,\n Tooltip,\n type AlertProps,\n} from '@patternfly/react-core';\nimport { TimesIcon } from '@patternfly/react-icons';\nimport { useQueryClient } from '@tanstack/react-query';\n\nimport { UNTITLED_NOTEBOOK_NAME } from '../../const';\nimport {\n useDocumentStatusPolling,\n type PendingUpload,\n} from '../../hooks/notebooks/useDocumentStatusPolling';\nimport { useUploadDocument } from '../../hooks/notebooks/useUploadDocument';\nimport { useTranslation } from '../../hooks/useTranslation';\nimport { SessionDocument } from '../../types';\nimport { AddDocumentModal } from './AddDocumentModal';\nimport { DocumentSidebar } from './DocumentSidebar';\nimport { OverwriteConfirmModal } from './OverwriteConfirmModal';\nimport { AddCircleFilledIcon, SidebarExpandIcon } from './SidebarCollapseIcon';\nimport { UploadResourceScreen } from './UploadResourceScreen';\n\nconst useStyles = makeStyles(theme => ({\n root: {\n display: 'flex',\n flexDirection: 'column',\n height: '100%',\n backgroundColor: 'var(--pf-t--global--background--color--primary--default)',\n },\n drawerContainer: {\n flex: 1,\n minHeight: 0,\n },\n expandStrip: {\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n paddingTop: theme.spacing(1.5),\n gap: theme.spacing(1),\n borderRight: '1px solid var(--pf-t--global--border--color--default)',\n },\n addIconButton: {\n padding: 0,\n minWidth: 0,\n lineHeight: 1,\n },\n mainArea: {\n display: 'flex',\n flexDirection: 'row',\n height: '100%',\n minWidth: 0,\n },\n topBar: {\n display: 'flex',\n justifyContent: 'flex-end',\n padding: `${theme.spacing(1.5)}px ${theme.spacing(2)}px`,\n },\n closeButton: {\n textTransform: 'none',\n },\n mainContent: {\n display: 'flex',\n flexDirection: 'column',\n flex: 1,\n minHeight: 0,\n },\n drawerContentBody: {\n backgroundColor:\n 'var(--pf-t--global--background--color--secondary--default)',\n },\n contentColumn: {\n display: 'flex',\n flexDirection: 'column',\n flex: 1,\n minWidth: 0,\n },\n alertContainer: {\n width: '100%',\n maxWidth: 816,\n margin: '0 auto',\n padding: `0 ${theme.spacing(3)}px ${theme.spacing(1)}px`,\n },\n toastAlertGroup: {\n '--pf-v6-c-alert-group--m-toast--InsetInlineEnd': `${theme.spacing(2.5)}px`,\n '--pf-v6-c-alert-group--m-toast--InsetBlockStart': `${theme.spacing(2.5)}px`,\n '--pf-v6-c-alert-group--m-toast--MaxWidth': '350px',\n },\n toastAlert: {\n maxWidth: '350px',\n '& .pf-v6-c-alert__title': {\n margin: 0,\n },\n },\n}));\n\ntype NotebookViewProps = {\n sessionId: string;\n notebookName?: string;\n documents?: SessionDocument[];\n onClose: () => void;\n};\n\nexport const NotebookView = ({\n sessionId,\n notebookName = UNTITLED_NOTEBOOK_NAME,\n documents = [],\n onClose,\n}: NotebookViewProps) => {\n const classes = useStyles();\n const { t } = useTranslation();\n const queryClient = useQueryClient();\n const uploadMutation = useUploadDocument();\n const [sidebarCollapsed, setSidebarCollapsed] = useState(false);\n const [isUploadModalOpen, setIsUploadModalOpen] = useState(false);\n const [uploadingFileNames, setUploadingFileNames] = useState<string[]>([]);\n const [pendingUploads, setPendingUploads] = useState<PendingUpload[]>([]);\n const [toastAlerts, setToastAlerts] = useState<Partial<AlertProps>[]>([]);\n const processedIds = useRef<Set<string>>(new Set());\n const [completedFileNames, setCompletedFileNames] = useState<Set<string>>(\n new Set(),\n );\n const [filesToOverwrite, setFilesToOverwrite] = useState<File[]>([]);\n const [isOverwriteModalOpen, setIsOverwriteModalOpen] = useState(false);\n\n const handleOpenUploadModal = () => setIsUploadModalOpen(true);\n const handleCloseUploadModal = () => setIsUploadModalOpen(false);\n\n const handleFilesUploading = (files: File[]) => {\n setUploadingFileNames(prev => [...prev, ...files.map(f => f.name)]);\n };\n\n const handleUploadStarted = (info: {\n fileName: string;\n documentId: string;\n }) => {\n processedIds.current.delete(info.documentId);\n setPendingUploads(prev => [\n ...prev,\n { fileName: info.fileName, documentId: info.documentId },\n ]);\n };\n\n const handleUploadFailed = (fileName: string) => {\n setUploadingFileNames(prev => prev.filter(n => n !== fileName));\n setToastAlerts(prev => [\n {\n key: Date.now() + fileName,\n title: (t as Function)('notebook.upload.failed', {\n fileName,\n }) as string,\n variant: 'danger',\n },\n ...prev,\n ]);\n };\n\n const handleDuplicatesFound = (files: File[]) => {\n setFilesToOverwrite(files);\n setIsOverwriteModalOpen(true);\n };\n\n const handleOverwriteConfirm = () => {\n const files = filesToOverwrite;\n setIsOverwriteModalOpen(false);\n setFilesToOverwrite([]);\n\n if (files.length === 0) return;\n\n setUploadingFileNames(prev => [...prev, ...files.map(f => f.name)]);\n for (const file of files) {\n uploadMutation\n .mutateAsync({ sessionId, file })\n .then(data => {\n handleUploadStarted({\n fileName: file.name,\n documentId: data.document_id,\n });\n })\n .catch(() => {\n handleUploadFailed(file.name);\n });\n }\n };\n\n const handleOverwriteCancel = () => {\n setIsOverwriteModalOpen(false);\n setFilesToOverwrite([]);\n };\n\n const pollingResults = useDocumentStatusPolling(sessionId, pendingUploads);\n\n useEffect(() => {\n const completedOrFailed = pollingResults.filter(\n r =>\n (r.status === 'completed' ||\n r.status === 'failed' ||\n r.status === 'cancelled') &&\n !processedIds.current.has(r.documentId),\n );\n\n if (completedOrFailed.length === 0) return;\n\n const idsToRemove = new Set<string>();\n const namesToRemove = new Set<string>();\n const newAlerts: Partial<AlertProps>[] = [];\n\n const newCompletedNames = new Set<string>();\n\n for (const result of completedOrFailed) {\n processedIds.current.add(result.documentId);\n idsToRemove.add(result.documentId);\n if (result.status !== 'completed') {\n namesToRemove.add(result.fileName);\n } else {\n newCompletedNames.add(result.fileName);\n }\n\n if (result.status === 'completed') {\n newAlerts.push({\n key: Date.now() + result.documentId,\n title: (t as Function)('notebook.upload.success', {\n fileName: result.fileName,\n }) as string,\n variant: 'success',\n });\n } else {\n newAlerts.push({\n key: Date.now() + result.documentId,\n title: (t as Function)('notebook.upload.failed', {\n fileName: result.fileName,\n }) as string,\n variant: 'danger',\n });\n }\n }\n\n setPendingUploads(prev => prev.filter(u => !idsToRemove.has(u.documentId)));\n setUploadingFileNames(prev =>\n prev.filter(name => !namesToRemove.has(name)),\n );\n if (newCompletedNames.size > 0) {\n setCompletedFileNames(prev => new Set([...prev, ...newCompletedNames]));\n queryClient.invalidateQueries({\n queryKey: ['notebooks', 'documents', sessionId],\n });\n }\n setToastAlerts(prev => [...newAlerts, ...prev]);\n }, [pollingResults, t, queryClient, sessionId]);\n\n const handleRemoveToastAlert = (key: React.Key) => {\n setToastAlerts(prev => prev.filter(a => a.key !== key));\n };\n\n const hasDocuments = documents.length > 0 || uploadingFileNames.length > 0;\n\n const panelContent = (\n <DrawerPanelContent\n isResizable\n defaultSize=\"310px\"\n minSize=\"232px\"\n maxSize=\"50%\"\n resizeAriaLabel={t('notebook.view.sidebar.resize')}\n >\n <DocumentSidebar\n notebookName={notebookName}\n documents={documents}\n uploadingFileNames={uploadingFileNames}\n completedFileNames={completedFileNames}\n collapsed={sidebarCollapsed}\n onToggleCollapse={() => setSidebarCollapsed(prev => !prev)}\n onAddDocument={handleOpenUploadModal}\n />\n </DrawerPanelContent>\n );\n\n return (\n <div className={classes.root}>\n {toastAlerts.length > 0 && (\n <AlertGroup\n hasAnimations\n isToast\n isLiveRegion\n className={classes.toastAlertGroup}\n >\n {toastAlerts.map(({ key, title, variant }) => (\n <Alert\n key={key}\n variant={AlertVariant[variant ?? 'success']}\n title={title}\n className={classes.toastAlert}\n timeout={8000}\n onTimeout={() => handleRemoveToastAlert(key as React.Key)}\n actionClose={\n <AlertActionCloseButton\n title={title as string}\n variantLabel={`${variant ?? 'success'} alert`}\n onClose={() => handleRemoveToastAlert(key as React.Key)}\n />\n }\n />\n ))}\n </AlertGroup>\n )}\n <Drawer\n isExpanded={!sidebarCollapsed}\n isInline\n position=\"start\"\n className={classes.drawerContainer}\n >\n <DrawerContent\n panelContent={!sidebarCollapsed ? panelContent : undefined}\n >\n <DrawerContentBody className={classes.drawerContentBody}>\n <div className={classes.mainArea}>\n {sidebarCollapsed && (\n <div className={classes.expandStrip}>\n <Tooltip\n content={t('notebook.view.sidebar.expand')}\n position=\"right\"\n >\n <Button\n variant=\"plain\"\n onClick={() => setSidebarCollapsed(false)}\n aria-label={t('notebook.view.sidebar.expand')}\n size=\"sm\"\n >\n <SidebarExpandIcon />\n </Button>\n </Tooltip>\n <Tooltip\n content={t('notebook.view.documents.add')}\n position=\"right\"\n >\n <Button\n variant=\"plain\"\n className={classes.addIconButton}\n onClick={handleOpenUploadModal}\n aria-label={t('notebook.view.documents.add')}\n >\n <AddCircleFilledIcon />\n </Button>\n </Tooltip>\n </div>\n )}\n\n <div className={classes.contentColumn}>\n <div className={classes.topBar}>\n <Button\n variant=\"link\"\n className={classes.closeButton}\n onClick={onClose}\n icon={<TimesIcon />}\n iconPosition=\"end\"\n >\n {t('notebook.view.close')}\n </Button>\n </div>\n\n <div className={classes.mainContent}>\n {!hasDocuments && (\n <UploadResourceScreen\n onUploadClick={handleOpenUploadModal}\n />\n )}\n </div>\n\n <div className={classes.alertContainer}>\n <Alert isInline variant=\"info\" title={t('aria.important')}>\n {t('disclaimer.withoutValidation')}\n </Alert>\n </div>\n\n <ChatbotFooter>\n <MessageBar\n hasAttachButton={false}\n hasMicrophoneButton\n hasStopButton={false}\n onSendMessage={() => {}}\n placeholder={t('notebook.view.input.placeholder')}\n />\n <ChatbotFootnote label={t('footer.accuracy.label')} />\n </ChatbotFooter>\n </div>\n </div>\n </DrawerContentBody>\n </DrawerContent>\n </Drawer>\n\n <AddDocumentModal\n isOpen={isUploadModalOpen}\n onClose={handleCloseUploadModal}\n sessionId={sessionId}\n existingDocumentNames={documents.map(d => d.title)}\n onFilesUploading={handleFilesUploading}\n onUploadStarted={handleUploadStarted}\n onUploadFailed={handleUploadFailed}\n onDuplicatesFound={handleDuplicatesFound}\n />\n\n <OverwriteConfirmModal\n isOpen={isOverwriteModalOpen}\n onClose={handleOverwriteCancel}\n onConfirm={handleOverwriteConfirm}\n fileNames={filesToOverwrite.map(f => f.name)}\n />\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAsDA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,IAAM,EAAA;AAAA,IACJ,OAAS,EAAA,MAAA;AAAA,IACT,aAAe,EAAA,QAAA;AAAA,IACf,MAAQ,EAAA,MAAA;AAAA,IACR,eAAiB,EAAA;AAAA,GACnB;AAAA,EACA,eAAiB,EAAA;AAAA,IACf,IAAM,EAAA,CAAA;AAAA,IACN,SAAW,EAAA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13
|
setOpenNotebookMenuId,
|
|
14
|
+
onSelectNotebook,
|
|
14
15
|
onRename,
|
|
15
16
|
onDelete,
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
onCreateNotebook,
|
|
18
|
+
t
|
|
18
19
|
}) => /* @__PURE__ */ jsxs("div", { className: classes.notebooksContainer, children: [
|
|
19
20
|
/* @__PURE__ */ jsxs("div", { className: classes.notebooksHeader, children: [
|
|
20
21
|
/* @__PURE__ */ jsx(Typography, { variant: "h6", className: classes.notebooksHeading, children: t("notebooks.title") }),
|
|
@@ -24,6 +25,7 @@ const NotebooksTab = ({
|
|
|
24
25
|
variant: "primary",
|
|
25
26
|
className: classes.notebooksAction,
|
|
26
27
|
icon: /* @__PURE__ */ jsx(PlusCircleIcon, {}),
|
|
28
|
+
onClick: onCreateNotebook,
|
|
27
29
|
children: t("notebooks.empty.action")
|
|
28
30
|
}
|
|
29
31
|
)
|
|
@@ -40,7 +42,15 @@ const NotebooksTab = ({
|
|
|
40
42
|
children: t("notebooks.empty.description")
|
|
41
43
|
}
|
|
42
44
|
),
|
|
43
|
-
/* @__PURE__ */ jsx(
|
|
45
|
+
/* @__PURE__ */ jsx(
|
|
46
|
+
Button,
|
|
47
|
+
{
|
|
48
|
+
variant: "primary",
|
|
49
|
+
className: classes.notebooksActionEmpty,
|
|
50
|
+
onClick: onCreateNotebook,
|
|
51
|
+
children: t("notebooks.empty.action")
|
|
52
|
+
}
|
|
53
|
+
)
|
|
44
54
|
] }) : /* @__PURE__ */ jsx("div", { className: classes.notebooksGrid, children: notebooks.map((notebook) => /* @__PURE__ */ jsx(
|
|
45
55
|
NotebookCard,
|
|
46
56
|
{
|
|
@@ -48,10 +58,10 @@ const NotebooksTab = ({
|
|
|
48
58
|
classes,
|
|
49
59
|
openNotebookMenuId,
|
|
50
60
|
setOpenNotebookMenuId,
|
|
61
|
+
onClick: onSelectNotebook,
|
|
51
62
|
onRename,
|
|
52
63
|
onDelete,
|
|
53
|
-
t
|
|
54
|
-
getDocumentsCount
|
|
64
|
+
t
|
|
55
65
|
},
|
|
56
66
|
notebook.session_id
|
|
57
67
|
)) })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotebooksTab.esm.js","sources":["../../../src/components/notebooks/NotebooksTab.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TranslationFunction } from '@backstage/core-plugin-api/alpha';\n\nimport { Typography } from '@material-ui/core';\nimport { Button } from '@patternfly/react-core';\nimport { PlusCircleIcon } from '@patternfly/react-icons';\nimport { CatalogIcon } from '@patternfly/react-icons/dist/esm/icons';\n\nimport { lightspeedTranslationRef } from '../../translations/ref';\nimport { NotebookSession } from '../../types';\nimport { NotebookCard } from './NotebookCard';\n\ntype NotebooksTabProps = {\n notebooks: NotebookSession[];\n hasNotebooks: boolean;\n classes: Record<string, string>;\n openNotebookMenuId: string | null;\n setOpenNotebookMenuId: React.Dispatch<React.SetStateAction<string | null>>;\n onRename: (sessionId: string) => void;\n onDelete: (sessionId: string) => void;\n t: TranslationFunction<typeof lightspeedTranslationRef.T>;\n
|
|
1
|
+
{"version":3,"file":"NotebooksTab.esm.js","sources":["../../../src/components/notebooks/NotebooksTab.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TranslationFunction } from '@backstage/core-plugin-api/alpha';\n\nimport { Typography } from '@material-ui/core';\nimport { Button } from '@patternfly/react-core';\nimport { PlusCircleIcon } from '@patternfly/react-icons';\nimport { CatalogIcon } from '@patternfly/react-icons/dist/esm/icons';\n\nimport { lightspeedTranslationRef } from '../../translations/ref';\nimport { NotebookSession } from '../../types';\nimport { NotebookCard } from './NotebookCard';\n\ntype NotebooksTabProps = {\n notebooks: NotebookSession[];\n hasNotebooks: boolean;\n classes: Record<string, string>;\n openNotebookMenuId: string | null;\n setOpenNotebookMenuId: React.Dispatch<React.SetStateAction<string | null>>;\n onSelectNotebook: (notebook: NotebookSession) => void;\n onRename: (sessionId: string) => void;\n onDelete: (sessionId: string) => void;\n onCreateNotebook: () => void;\n t: TranslationFunction<typeof lightspeedTranslationRef.T>;\n};\n\nexport const NotebooksTab = ({\n notebooks,\n hasNotebooks,\n classes,\n openNotebookMenuId,\n setOpenNotebookMenuId,\n onSelectNotebook,\n onRename,\n onDelete,\n onCreateNotebook,\n t,\n}: NotebooksTabProps) => (\n <div className={classes.notebooksContainer}>\n <div className={classes.notebooksHeader}>\n <Typography variant=\"h6\" className={classes.notebooksHeading}>\n {t('notebooks.title')}\n </Typography>\n {hasNotebooks && (\n <Button\n variant=\"primary\"\n className={classes.notebooksAction}\n icon={<PlusCircleIcon />}\n onClick={onCreateNotebook}\n >\n {t('notebooks.empty.action')}\n </Button>\n )}\n </div>\n {!hasNotebooks ? (\n <div className={classes.notebooksEmptyState}>\n <CatalogIcon className={classes.notebooksIcon} />\n <Typography variant=\"h6\" className={classes.notebooksHeadingEmpty}>\n {t('notebooks.empty.title')}\n </Typography>\n <Typography\n variant=\"body2\"\n color=\"textSecondary\"\n className={classes.notebooksDescription}\n >\n {t('notebooks.empty.description')}\n </Typography>\n <Button\n variant=\"primary\"\n className={classes.notebooksActionEmpty}\n onClick={onCreateNotebook}\n >\n {t('notebooks.empty.action')}\n </Button>\n </div>\n ) : (\n <div className={classes.notebooksGrid}>\n {notebooks.map(notebook => (\n <NotebookCard\n key={notebook.session_id}\n notebook={notebook}\n classes={classes}\n openNotebookMenuId={openNotebookMenuId}\n setOpenNotebookMenuId={setOpenNotebookMenuId}\n onClick={onSelectNotebook}\n onRename={onRename}\n onDelete={onDelete}\n t={t}\n />\n ))}\n </div>\n )}\n </div>\n);\n"],"names":[],"mappings":";;;;;;;AAwCO,MAAM,eAAe,CAAC;AAAA,EAC3B,SAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AAAA,EACA,qBAAA;AAAA,EACA,gBAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF,CAAA,qBACG,IAAA,CAAA,KAAA,EAAA,EAAI,SAAW,EAAA,OAAA,CAAQ,kBACtB,EAAA,QAAA,EAAA;AAAA,kBAAC,IAAA,CAAA,KAAA,EAAA,EAAI,SAAW,EAAA,OAAA,CAAQ,eACtB,EAAA,QAAA,EAAA;AAAA,oBAAC,GAAA,CAAA,UAAA,EAAA,EAAW,SAAQ,IAAK,EAAA,SAAA,EAAW,QAAQ,gBACzC,EAAA,QAAA,EAAA,CAAA,CAAE,iBAAiB,CACtB,EAAA,CAAA;AAAA,IACC,YACC,oBAAA,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,SAAA;AAAA,QACR,WAAW,OAAQ,CAAA,eAAA;AAAA,QACnB,IAAA,sBAAO,cAAe,EAAA,EAAA,CAAA;AAAA,QACtB,OAAS,EAAA,gBAAA;AAAA,QAER,YAAE,wBAAwB;AAAA;AAAA;AAC7B,GAEJ,EAAA,CAAA;AAAA,EACC,CAAC,YACA,mBAAA,IAAA,CAAC,KAAI,EAAA,EAAA,SAAA,EAAW,QAAQ,mBACtB,EAAA,QAAA,EAAA;AAAA,oBAAC,GAAA,CAAA,WAAA,EAAA,EAAY,SAAW,EAAA,OAAA,CAAQ,aAAe,EAAA,CAAA;AAAA,oBAC/C,GAAA,CAAC,cAAW,OAAQ,EAAA,IAAA,EAAK,WAAW,OAAQ,CAAA,qBAAA,EACzC,QAAE,EAAA,CAAA,CAAA,uBAAuB,CAC5B,EAAA,CAAA;AAAA,oBACA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,OAAA;AAAA,QACR,KAAM,EAAA,eAAA;AAAA,QACN,WAAW,OAAQ,CAAA,oBAAA;AAAA,QAElB,YAAE,6BAA6B;AAAA;AAAA,KAClC;AAAA,oBACA,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,SAAA;AAAA,QACR,WAAW,OAAQ,CAAA,oBAAA;AAAA,QACnB,OAAS,EAAA,gBAAA;AAAA,QAER,YAAE,wBAAwB;AAAA;AAAA;AAC7B,GACF,EAAA,CAAA,uBAEC,KAAI,EAAA,EAAA,SAAA,EAAW,QAAQ,aACrB,EAAA,QAAA,EAAA,SAAA,CAAU,IAAI,CACb,QAAA,qBAAA,GAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MAEC,QAAA;AAAA,MACA,OAAA;AAAA,MACA,kBAAA;AAAA,MACA,qBAAA;AAAA,MACA,OAAS,EAAA,gBAAA;AAAA,MACT,QAAA;AAAA,MACA,QAAA;AAAA,MACA;AAAA,KAAA;AAAA,IARK,QAAS,CAAA;AAAA,GAUjB,CACH,EAAA;AAAA,CAEJ,EAAA;;;;"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
3
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
4
|
+
import Alert from '@mui/material/Alert';
|
|
5
|
+
import Button from '@mui/material/Button';
|
|
6
|
+
import Dialog from '@mui/material/Dialog';
|
|
7
|
+
import DialogActions from '@mui/material/DialogActions';
|
|
8
|
+
import DialogContent from '@mui/material/DialogContent';
|
|
9
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
|
10
|
+
import IconButton from '@mui/material/IconButton';
|
|
11
|
+
import Typography from '@mui/material/Typography';
|
|
12
|
+
import { useTranslation } from '../../hooks/useTranslation.esm.js';
|
|
13
|
+
import { FileTypeIcon } from './FileTypeIcon.esm.js';
|
|
14
|
+
|
|
15
|
+
const useStyles = makeStyles((theme) => ({
|
|
16
|
+
dialogPaper: {
|
|
17
|
+
borderRadius: 24,
|
|
18
|
+
maxWidth: 578
|
|
19
|
+
},
|
|
20
|
+
dialogTitle: {
|
|
21
|
+
display: "flex",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
justifyContent: "space-between",
|
|
24
|
+
padding: "24px 24px 16px"
|
|
25
|
+
},
|
|
26
|
+
titleText: {
|
|
27
|
+
fontWeight: 500,
|
|
28
|
+
fontSize: "1.25rem",
|
|
29
|
+
lineHeight: "1.625rem",
|
|
30
|
+
letterSpacing: "-0.25px"
|
|
31
|
+
},
|
|
32
|
+
closeButton: {
|
|
33
|
+
color: theme.palette.grey[700]
|
|
34
|
+
},
|
|
35
|
+
dialogContent: {
|
|
36
|
+
padding: "0 24px 24px"
|
|
37
|
+
},
|
|
38
|
+
fileList: {
|
|
39
|
+
margin: 0,
|
|
40
|
+
padding: 0,
|
|
41
|
+
listStyle: "none"
|
|
42
|
+
},
|
|
43
|
+
fileItem: {
|
|
44
|
+
display: "flex",
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
gap: theme.spacing(1),
|
|
47
|
+
padding: `${theme.spacing(2)}px 0`,
|
|
48
|
+
borderBottom: "1px solid var(--pf-t--global--border--color--default, #c7c7c7)"
|
|
49
|
+
},
|
|
50
|
+
fileName: {
|
|
51
|
+
flex: 1,
|
|
52
|
+
minWidth: 0,
|
|
53
|
+
overflow: "hidden",
|
|
54
|
+
textOverflow: "ellipsis",
|
|
55
|
+
whiteSpace: "nowrap",
|
|
56
|
+
fontSize: "0.875rem",
|
|
57
|
+
lineHeight: "1.25rem"
|
|
58
|
+
},
|
|
59
|
+
dialogActions: {
|
|
60
|
+
justifyContent: "left",
|
|
61
|
+
padding: theme.spacing(2.5),
|
|
62
|
+
gap: theme.spacing(1)
|
|
63
|
+
},
|
|
64
|
+
overwriteButton: {
|
|
65
|
+
textTransform: "none",
|
|
66
|
+
borderRadius: 999
|
|
67
|
+
},
|
|
68
|
+
cancelButton: {
|
|
69
|
+
textTransform: "none",
|
|
70
|
+
borderRadius: 999
|
|
71
|
+
},
|
|
72
|
+
warningAlert: {
|
|
73
|
+
borderRadius: "6px"
|
|
74
|
+
}
|
|
75
|
+
}));
|
|
76
|
+
const OverwriteConfirmModal = ({
|
|
77
|
+
isOpen,
|
|
78
|
+
onClose,
|
|
79
|
+
onConfirm,
|
|
80
|
+
fileNames
|
|
81
|
+
}) => {
|
|
82
|
+
const classes = useStyles();
|
|
83
|
+
const { t } = useTranslation();
|
|
84
|
+
return /* @__PURE__ */ jsxs(
|
|
85
|
+
Dialog,
|
|
86
|
+
{
|
|
87
|
+
open: isOpen,
|
|
88
|
+
onClose,
|
|
89
|
+
"aria-labelledby": "overwrite-confirm-modal-title",
|
|
90
|
+
PaperProps: {
|
|
91
|
+
className: classes.dialogPaper
|
|
92
|
+
},
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ jsxs(DialogTitle, { className: classes.dialogTitle, children: [
|
|
95
|
+
/* @__PURE__ */ jsx(Typography, { component: "h2", className: classes.titleText, children: t("notebook.overwrite.modal.title") }),
|
|
96
|
+
/* @__PURE__ */ jsx(
|
|
97
|
+
IconButton,
|
|
98
|
+
{
|
|
99
|
+
"aria-label": t("common.close"),
|
|
100
|
+
onClick: onClose,
|
|
101
|
+
className: classes.closeButton,
|
|
102
|
+
size: "small",
|
|
103
|
+
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] }),
|
|
107
|
+
/* @__PURE__ */ jsxs(DialogContent, { className: classes.dialogContent, children: [
|
|
108
|
+
/* @__PURE__ */ jsx(Alert, { severity: "warning", className: classes.warningAlert, children: t("notebook.overwrite.modal.description") }),
|
|
109
|
+
/* @__PURE__ */ jsx("ul", { className: classes.fileList, children: fileNames.map((name) => /* @__PURE__ */ jsxs("li", { className: classes.fileItem, children: [
|
|
110
|
+
/* @__PURE__ */ jsx(FileTypeIcon, { fileName: name }),
|
|
111
|
+
/* @__PURE__ */ jsx(Typography, { className: classes.fileName, children: name })
|
|
112
|
+
] }, name)) })
|
|
113
|
+
] }),
|
|
114
|
+
/* @__PURE__ */ jsxs(DialogActions, { className: classes.dialogActions, children: [
|
|
115
|
+
/* @__PURE__ */ jsx(
|
|
116
|
+
Button,
|
|
117
|
+
{
|
|
118
|
+
variant: "contained",
|
|
119
|
+
color: "error",
|
|
120
|
+
className: classes.overwriteButton,
|
|
121
|
+
onClick: onConfirm,
|
|
122
|
+
children: t("notebook.overwrite.modal.action")
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ jsx(
|
|
126
|
+
Button,
|
|
127
|
+
{
|
|
128
|
+
variant: "outlined",
|
|
129
|
+
className: classes.cancelButton,
|
|
130
|
+
onClick: onClose,
|
|
131
|
+
children: t("common.cancel")
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
] })
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export { OverwriteConfirmModal };
|
|
141
|
+
//# sourceMappingURL=OverwriteConfirmModal.esm.js.map
|