@red-hat-developer-hub/backstage-plugin-lightspeed 2.1.0 → 2.2.1

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/alpha.d.ts +32 -0
  3. package/dist/api/NotebooksApiClient.esm.js +88 -17
  4. package/dist/api/NotebooksApiClient.esm.js.map +1 -1
  5. package/dist/api/notebooksApi.esm.js.map +1 -1
  6. package/dist/components/LightSpeedChat.esm.js +76 -17
  7. package/dist/components/LightSpeedChat.esm.js.map +1 -1
  8. package/dist/components/LightspeedChatContainer.esm.js +17 -2
  9. package/dist/components/LightspeedChatContainer.esm.js.map +1 -1
  10. package/dist/components/LightspeedChatModelsState.esm.js +198 -0
  11. package/dist/components/LightspeedChatModelsState.esm.js.map +1 -0
  12. package/dist/components/LightspeedDrawerProvider.esm.js +2 -1
  13. package/dist/components/LightspeedDrawerProvider.esm.js.map +1 -1
  14. package/dist/components/Router.esm.js +2 -1
  15. package/dist/components/Router.esm.js.map +1 -1
  16. package/dist/components/notebooks/AddDocumentModal.esm.js +170 -0
  17. package/dist/components/notebooks/AddDocumentModal.esm.js.map +1 -0
  18. package/dist/components/notebooks/DocumentSidebar.esm.js +154 -0
  19. package/dist/components/notebooks/DocumentSidebar.esm.js.map +1 -0
  20. package/dist/components/notebooks/FileTypeIcon.esm.js +59 -0
  21. package/dist/components/notebooks/FileTypeIcon.esm.js.map +1 -0
  22. package/dist/components/notebooks/NotebookCard.esm.js +86 -75
  23. package/dist/components/notebooks/NotebookCard.esm.js.map +1 -1
  24. package/dist/components/notebooks/NotebookView.esm.js +376 -0
  25. package/dist/components/notebooks/NotebookView.esm.js.map +1 -0
  26. package/dist/components/notebooks/NotebooksTab.esm.js +15 -5
  27. package/dist/components/notebooks/NotebooksTab.esm.js.map +1 -1
  28. package/dist/components/notebooks/OverwriteConfirmModal.esm.js +141 -0
  29. package/dist/components/notebooks/OverwriteConfirmModal.esm.js.map +1 -0
  30. package/dist/components/notebooks/SidebarCollapseIcon.esm.js +47 -0
  31. package/dist/components/notebooks/SidebarCollapseIcon.esm.js.map +1 -0
  32. package/dist/components/notebooks/UploadResourceScreen.esm.js +58 -0
  33. package/dist/components/notebooks/UploadResourceScreen.esm.js.map +1 -0
  34. package/dist/const.esm.js +26 -1
  35. package/dist/const.esm.js.map +1 -1
  36. package/dist/hooks/notebooks/useCreateNotebook.esm.js +19 -0
  37. package/dist/hooks/notebooks/useCreateNotebook.esm.js.map +1 -0
  38. package/dist/hooks/notebooks/useDocumentStatusPolling.esm.js +39 -0
  39. package/dist/hooks/notebooks/useDocumentStatusPolling.esm.js.map +1 -0
  40. package/dist/hooks/notebooks/useNotebookDocuments.esm.js +18 -0
  41. package/dist/hooks/notebooks/useNotebookDocuments.esm.js.map +1 -0
  42. package/dist/hooks/notebooks/useUploadDocument.esm.js +28 -0
  43. package/dist/hooks/notebooks/useUploadDocument.esm.js.map +1 -0
  44. package/dist/hooks/useLightspeedProviderState.esm.js +13 -6
  45. package/dist/hooks/useLightspeedProviderState.esm.js.map +1 -1
  46. package/dist/index.d.ts +1 -0
  47. package/dist/plugin.esm.js +3 -2
  48. package/dist/plugin.esm.js.map +1 -1
  49. package/dist/routes.esm.js +6 -1
  50. package/dist/routes.esm.js.map +1 -1
  51. package/dist/translations/de.esm.js +35 -0
  52. package/dist/translations/de.esm.js.map +1 -1
  53. package/dist/translations/es.esm.js +35 -0
  54. package/dist/translations/es.esm.js.map +1 -1
  55. package/dist/translations/fr.esm.js +35 -0
  56. package/dist/translations/fr.esm.js.map +1 -1
  57. package/dist/translations/it.esm.js +35 -0
  58. package/dist/translations/it.esm.js.map +1 -1
  59. package/dist/translations/ja.esm.js +35 -0
  60. package/dist/translations/ja.esm.js.map +1 -1
  61. package/dist/translations/ref.esm.js +36 -0
  62. package/dist/translations/ref.esm.js.map +1 -1
  63. package/dist/types.esm.js.map +1 -1
  64. package/dist/utils/notebook-upload-utils.esm.js +48 -0
  65. package/dist/utils/notebook-upload-utils.esm.js.map +1 -0
  66. package/package.json +2 -2
@@ -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;AAAA,GACb;AAAA,EACA,WAAa,EAAA;AAAA,IACX,OAAS,EAAA,MAAA;AAAA,IACT,aAAe,EAAA,QAAA;AAAA,IACf,UAAY,EAAA,QAAA;AAAA,IACZ,UAAA,EAAY,KAAM,CAAA,OAAA,CAAQ,GAAG,CAAA;AAAA,IAC7B,GAAA,EAAK,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IACpB,WAAa,EAAA;AAAA,GACf;AAAA,EACA,aAAe,EAAA;AAAA,IACb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;AAAA;AAAA,mBAClD;AAAA,kCACC,GAAA,CAAA,eAAA,EAAA,EAAgB,KAAO,EAAA,CAAA,CAAE,uBAAuB,CAAG,EAAA;AAAA,iBACtD,EAAA;AAAA,eACF,EAAA;AAAA,aAAA,EACF,CACF,EAAA;AAAA;AAAA;AACF;AAAA,KACF;AAAA,oBAEA,GAAA;AAAA,MAAC,gBAAA;AAAA,MAAA;AAAA,QACC,MAAQ,EAAA,iBAAA;AAAA,QACR,OAAS,EAAA,sBAAA;AAAA,QACT,SAAA;AAAA,QACA,qBAAuB,EAAA,SAAA,CAAU,GAAI,CAAA,CAAA,CAAA,KAAK,EAAE,KAAK,CAAA;AAAA,QACjD,gBAAkB,EAAA,oBAAA;AAAA,QAClB,eAAiB,EAAA,mBAAA;AAAA,QACjB,cAAgB,EAAA,kBAAA;AAAA,QAChB,iBAAmB,EAAA;AAAA;AAAA,KACrB;AAAA,oBAEA,GAAA;AAAA,MAAC,qBAAA;AAAA,MAAA;AAAA,QACC,MAAQ,EAAA,oBAAA;AAAA,QACR,OAAS,EAAA,qBAAA;AAAA,QACT,SAAW,EAAA,sBAAA;AAAA,QACX,SAAW,EAAA,gBAAA,CAAiB,GAAI,CAAA,CAAA,CAAA,KAAK,EAAE,IAAI;AAAA;AAAA;AAC7C,GACF,EAAA,CAAA;AAEJ;;;;"}
@@ -11,10 +11,11 @@ const NotebooksTab = ({
11
11
  classes,
12
12
  openNotebookMenuId,
13
13
  setOpenNotebookMenuId,
14
+ onSelectNotebook,
14
15
  onRename,
15
16
  onDelete,
16
- t,
17
- getDocumentsCount
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(Button, { variant: "primary", className: classes.notebooksActionEmpty, children: t("notebooks.empty.action") })
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 getDocumentsCount: (documentIds?: string[]) => number;\n};\n\nexport const NotebooksTab = ({\n notebooks,\n hasNotebooks,\n classes,\n openNotebookMenuId,\n setOpenNotebookMenuId,\n onRename,\n onDelete,\n t,\n getDocumentsCount,\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 >\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 variant=\"primary\" className={classes.notebooksActionEmpty}>\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 onRename={onRename}\n onDelete={onDelete}\n t={t}\n getDocumentsCount={getDocumentsCount}\n />\n ))}\n </div>\n )}\n </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WAAW,OAAQ,CAAA,oBAAA;AAAA,QAElB,YAAE,6BAA6B;AAAA;AAAA,KAClC;AAAA,oBACA,GAAA,CAAC,UAAO,OAAQ,EAAA,SAAA,EAAU,WAAW,OAAQ,CAAA,oBAAA,EAC1C,QAAE,EAAA,CAAA,CAAA,wBAAwB,CAC7B,EAAA;AAAA,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,QAAA;AAAA,MACA,QAAA;AAAA,MACA,CAAA;AAAA,MACA;AAAA,KAAA;AAAA,IARK,QAAS,CAAA;AAAA,GAUjB,CACH,EAAA;AAAA,CAEJ,EAAA;;;;"}
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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;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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OverwriteConfirmModal.esm.js","sources":["../../../src/components/notebooks/OverwriteConfirmModal.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 { makeStyles } from '@material-ui/core/styles';\nimport CloseIcon from '@mui/icons-material/Close';\nimport Alert from '@mui/material/Alert';\nimport Button from '@mui/material/Button';\nimport Dialog from '@mui/material/Dialog';\nimport DialogActions from '@mui/material/DialogActions';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport IconButton from '@mui/material/IconButton';\nimport Typography from '@mui/material/Typography';\n\nimport { useTranslation } from '../../hooks/useTranslation';\nimport { FileTypeIcon } from './FileTypeIcon';\n\nconst useStyles = makeStyles(theme => ({\n dialogPaper: {\n borderRadius: 24,\n maxWidth: 578,\n },\n dialogTitle: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n padding: '24px 24px 16px',\n },\n titleText: {\n fontWeight: 500,\n fontSize: '1.25rem',\n lineHeight: '1.625rem',\n letterSpacing: '-0.25px',\n },\n closeButton: {\n color: theme.palette.grey[700],\n },\n dialogContent: {\n padding: '0 24px 24px',\n },\n fileList: {\n margin: 0,\n padding: 0,\n listStyle: 'none',\n },\n fileItem: {\n display: 'flex',\n alignItems: 'center',\n gap: theme.spacing(1),\n padding: `${theme.spacing(2)}px 0`,\n borderBottom:\n '1px solid var(--pf-t--global--border--color--default, #c7c7c7)',\n },\n fileName: {\n flex: 1,\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n fontSize: '0.875rem',\n lineHeight: '1.25rem',\n },\n dialogActions: {\n justifyContent: 'left',\n padding: theme.spacing(2.5),\n gap: theme.spacing(1),\n },\n overwriteButton: {\n textTransform: 'none',\n borderRadius: 999,\n },\n cancelButton: {\n textTransform: 'none',\n borderRadius: 999,\n },\n warningAlert: {\n borderRadius: '6px',\n },\n}));\n\ntype OverwriteConfirmModalProps = {\n isOpen: boolean;\n onClose: () => void;\n onConfirm: () => void;\n fileNames: string[];\n};\n\nexport const OverwriteConfirmModal = ({\n isOpen,\n onClose,\n onConfirm,\n fileNames,\n}: OverwriteConfirmModalProps) => {\n const classes = useStyles();\n const { t } = useTranslation();\n\n return (\n <Dialog\n open={isOpen}\n onClose={onClose}\n aria-labelledby=\"overwrite-confirm-modal-title\"\n PaperProps={{\n className: classes.dialogPaper,\n }}\n >\n <DialogTitle className={classes.dialogTitle}>\n <Typography component=\"h2\" className={classes.titleText}>\n {t('notebook.overwrite.modal.title')}\n </Typography>\n <IconButton\n aria-label={t('common.close')}\n onClick={onClose}\n className={classes.closeButton}\n size=\"small\"\n >\n <CloseIcon />\n </IconButton>\n </DialogTitle>\n\n <DialogContent className={classes.dialogContent}>\n <Alert severity=\"warning\" className={classes.warningAlert}>\n {t('notebook.overwrite.modal.description')}\n </Alert>\n\n <ul className={classes.fileList}>\n {fileNames.map(name => (\n <li key={name} className={classes.fileItem}>\n <FileTypeIcon fileName={name} />\n <Typography className={classes.fileName}>{name}</Typography>\n </li>\n ))}\n </ul>\n </DialogContent>\n\n <DialogActions className={classes.dialogActions}>\n <Button\n variant=\"contained\"\n color=\"error\"\n className={classes.overwriteButton}\n onClick={onConfirm}\n >\n {t('notebook.overwrite.modal.action')}\n </Button>\n <Button\n variant=\"outlined\"\n className={classes.cancelButton}\n onClick={onClose}\n >\n {t('common.cancel')}\n </Button>\n </DialogActions>\n </Dialog>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,WAAa,EAAA;AAAA,IACX,YAAc,EAAA,EAAA;AAAA,IACd,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,WAAa,EAAA;AAAA,IACX,OAAS,EAAA,MAAA;AAAA,IACT,UAAY,EAAA,QAAA;AAAA,IACZ,cAAgB,EAAA,eAAA;AAAA,IAChB,OAAS,EAAA;AAAA,GACX;AAAA,EACA,SAAW,EAAA;AAAA,IACT,UAAY,EAAA,GAAA;AAAA,IACZ,QAAU,EAAA,SAAA;A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A,EAAG,SAAW,EAAA,OAAA,CAAQ,QACpB,EAAA,QAAA,EAAA,SAAA,CAAU,GAAI,CAAA,CAAA,IAAA,qBACZ,IAAA,CAAA,IAAA,EAAA,EAAc,SAAW,EAAA,OAAA,CAAQ,QAChC,EAAA,QAAA,EAAA;AAAA,4BAAC,GAAA,CAAA,YAAA,EAAA,EAAa,UAAU,IAAM,EAAA,CAAA;AAAA,4BAC7B,GAAA,CAAA,UAAA,EAAA,EAAW,SAAW,EAAA,OAAA,CAAQ,UAAW,QAAK,EAAA,IAAA,EAAA;AAAA,WAFxC,EAAA,EAAA,IAGT,CACD,CACH,EAAA;AAAA,SACF,EAAA,CAAA;AAAA,wBAEC,IAAA,CAAA,aAAA,EAAA,EAAc,SAAW,EAAA,OAAA,CAAQ,aAChC,EAAA,QAAA,EAAA;AAAA,0BAAA,GAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACC,OAAQ,EAAA,WAAA;AAAA,cACR,KAAM,EAAA,OAAA;AAAA,cACN,WAAW,OAAQ,CAAA,eAAA;AAAA,cACnB,OAAS,EAAA,SAAA;AAAA,cAER,YAAE,iCAAiC;AAAA;AAAA,WACtC;AAAA,0BACA,GAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACC,OAAQ,EAAA,UAAA;AAAA,cACR,WAAW,OAAQ,CAAA,YAAA;AAAA,cACnB,OAAS,EAAA,OAAA;AAAA,cAER,YAAE,eAAe;AAAA;AAAA;AACpB,SACF,EAAA;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
@@ -0,0 +1,47 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ const SidebarCollapseIcon = ({ className }) => /* @__PURE__ */ jsx(
4
+ "svg",
5
+ {
6
+ className,
7
+ width: "24",
8
+ height: "24",
9
+ viewBox: "0 0 24 24",
10
+ fill: "none",
11
+ xmlns: "http://www.w3.org/2000/svg",
12
+ children: /* @__PURE__ */ jsx("path", { d: "M16 21V3H14V21H16ZM12 17V7L7 12L12 17Z", fill: "currentColor" })
13
+ }
14
+ );
15
+ const SidebarExpandIcon = ({ className }) => /* @__PURE__ */ jsx(
16
+ "svg",
17
+ {
18
+ className,
19
+ width: "24",
20
+ height: "24",
21
+ viewBox: "0 0 24 24",
22
+ fill: "none",
23
+ xmlns: "http://www.w3.org/2000/svg",
24
+ children: /* @__PURE__ */ jsx("path", { d: "M9 21V3H11V21H9ZM13 17V7L18 12L13 17Z", fill: "currentColor" })
25
+ }
26
+ );
27
+ const AddCircleFilledIcon = ({ className }) => /* @__PURE__ */ jsx(
28
+ "svg",
29
+ {
30
+ className,
31
+ width: "16",
32
+ height: "16",
33
+ viewBox: "0 0 16 16",
34
+ fill: "none",
35
+ xmlns: "http://www.w3.org/2000/svg",
36
+ children: /* @__PURE__ */ jsx(
37
+ "path",
38
+ {
39
+ d: "M7.75 0C12.0312 1.02089e-05 15.5 3.46877 15.5 7.75C15.5 12.0312 12.0312 15.5 7.75 15.5C3.46877 15.5 1.02086e-05 12.0312 0 7.75C0 3.46876 3.46876 0 7.75 0ZM6.875 3.25C6.66876 3.25 6.5 3.41876 6.5 3.625V6.5H3.625C3.41876 6.5 3.25 6.66876 3.25 6.875V8.625C3.25001 8.83123 3.41877 9 3.625 9H6.5V11.875C6.50002 12.0812 6.66877 12.25 6.875 12.25H8.625C8.83122 12.25 8.99998 12.0812 9 11.875V9H11.875C12.0812 8.99998 12.25 8.83122 12.25 8.625V6.875C12.25 6.66877 12.0812 6.50002 11.875 6.5H9V3.625C9 3.41877 8.83123 3.25001 8.625 3.25H6.875Z",
40
+ fill: "#0066CC"
41
+ }
42
+ )
43
+ }
44
+ );
45
+
46
+ export { AddCircleFilledIcon, SidebarCollapseIcon, SidebarExpandIcon };
47
+ //# sourceMappingURL=SidebarCollapseIcon.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidebarCollapseIcon.esm.js","sources":["../../../src/components/notebooks/SidebarCollapseIcon.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\ntype IconProps = {\n className?: string;\n};\n\nexport const SidebarCollapseIcon = ({ className }: IconProps) => (\n <svg\n className={className}\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path d=\"M16 21V3H14V21H16ZM12 17V7L7 12L12 17Z\" fill=\"currentColor\" />\n </svg>\n);\n\nexport const SidebarExpandIcon = ({ className }: IconProps) => (\n <svg\n className={className}\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path d=\"M9 21V3H11V21H9ZM13 17V7L18 12L13 17Z\" fill=\"currentColor\" />\n </svg>\n);\n\nexport const AddCircleFilledIcon = ({ className }: IconProps) => (\n <svg\n className={className}\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M7.75 0C12.0312 1.02089e-05 15.5 3.46877 15.5 7.75C15.5 12.0312 12.0312 15.5 7.75 15.5C3.46877 15.5 1.02086e-05 12.0312 0 7.75C0 3.46876 3.46876 0 7.75 0ZM6.875 3.25C6.66876 3.25 6.5 3.41876 6.5 3.625V6.5H3.625C3.41876 6.5 3.25 6.66876 3.25 6.875V8.625C3.25001 8.83123 3.41877 9 3.625 9H6.5V11.875C6.50002 12.0812 6.66877 12.25 6.875 12.25H8.625C8.83122 12.25 8.99998 12.0812 9 11.875V9H11.875C12.0812 8.99998 12.25 8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AAA;AAAA,QACF,IAAK,EAAA;AAAA;AAAA;AACP;AACF;;;;"}
@@ -0,0 +1,58 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { makeStyles, Typography } from '@material-ui/core';
3
+ import { Button } from '@patternfly/react-core';
4
+ import { AddCircleOIcon } from '@patternfly/react-icons';
5
+ import { CatalogIcon } from '@patternfly/react-icons/dist/esm/icons';
6
+ import { useTranslation } from '../../hooks/useTranslation.esm.js';
7
+
8
+ const useStyles = makeStyles((theme) => ({
9
+ container: {
10
+ display: "flex",
11
+ flexDirection: "column",
12
+ alignItems: "center",
13
+ justifyContent: "center",
14
+ flex: 1,
15
+ textAlign: "center",
16
+ gap: theme.spacing(2)
17
+ },
18
+ icon: {
19
+ fontSize: 48,
20
+ color: "var(--pf-t--global--icon--color--subtle)"
21
+ },
22
+ heading: {
23
+ fontWeight: 500,
24
+ fontSize: "1.5rem",
25
+ lineHeight: "2rem",
26
+ letterSpacing: "-0.25px"
27
+ },
28
+ uploadButton: {
29
+ textTransform: "none",
30
+ borderRadius: 999,
31
+ paddingLeft: theme.spacing(3),
32
+ paddingRight: theme.spacing(3)
33
+ }
34
+ }));
35
+ const UploadResourceScreen = ({
36
+ onUploadClick
37
+ }) => {
38
+ const classes = useStyles();
39
+ const { t } = useTranslation();
40
+ return /* @__PURE__ */ jsxs("div", { className: classes.container, children: [
41
+ /* @__PURE__ */ jsx(CatalogIcon, { className: classes.icon }),
42
+ /* @__PURE__ */ jsx(Typography, { className: classes.heading, children: t("notebook.view.upload.heading") }),
43
+ /* @__PURE__ */ jsx(
44
+ Button,
45
+ {
46
+ variant: "secondary",
47
+ className: classes.uploadButton,
48
+ icon: /* @__PURE__ */ jsx(AddCircleOIcon, {}),
49
+ iconPosition: "end",
50
+ onClick: onUploadClick,
51
+ children: t("notebook.view.upload.action")
52
+ }
53
+ )
54
+ ] });
55
+ };
56
+
57
+ export { UploadResourceScreen };
58
+ //# sourceMappingURL=UploadResourceScreen.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UploadResourceScreen.esm.js","sources":["../../../src/components/notebooks/UploadResourceScreen.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 { makeStyles, Typography } from '@material-ui/core';\nimport { Button } from '@patternfly/react-core';\nimport { AddCircleOIcon } from '@patternfly/react-icons';\nimport { CatalogIcon } from '@patternfly/react-icons/dist/esm/icons';\n\nimport { useTranslation } from '../../hooks/useTranslation';\n\nconst useStyles = makeStyles(theme => ({\n container: {\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n flex: 1,\n textAlign: 'center',\n gap: theme.spacing(2),\n },\n icon: {\n fontSize: 48,\n color: 'var(--pf-t--global--icon--color--subtle)',\n },\n heading: {\n fontWeight: 500,\n fontSize: '1.5rem',\n lineHeight: '2rem',\n letterSpacing: '-0.25px',\n },\n uploadButton: {\n textTransform: 'none',\n borderRadius: 999,\n paddingLeft: theme.spacing(3),\n paddingRight: theme.spacing(3),\n },\n}));\n\ntype UploadResourceScreenProps = {\n onUploadClick: () => void;\n};\n\nexport const UploadResourceScreen = ({\n onUploadClick,\n}: UploadResourceScreenProps) => {\n const classes = useStyles();\n const { t } = useTranslation();\n\n return (\n <div className={classes.container}>\n <CatalogIcon className={classes.icon} />\n <Typography className={classes.heading}>\n {t('notebook.view.upload.heading')}\n </Typography>\n <Button\n variant=\"secondary\"\n className={classes.uploadButton}\n icon={<AddCircleOIcon />}\n iconPosition=\"end\"\n onClick={onUploadClick}\n >\n {t('notebook.view.upload.action')}\n </Button>\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,CAAE,8BAA8B,CACnC,EAAA,CAAA;AAAA,oBACA,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,WAAA;AAAA,QACR,WAAW,OAAQ,CAAA,YAAA;AAAA,QACnB,IAAA,sBAAO,cAAe,EAAA,EAAA,CAAA;AAAA,QACtB,YAAa,EAAA,KAAA;AAAA,QACb,OAAS,EAAA,aAAA;AAAA,QAER,YAAE,6BAA6B;AAAA;AAAA;AAClC,GACF,EAAA,CAAA;AAEJ;;;;"}
package/dist/const.esm.js CHANGED
@@ -8,6 +8,31 @@ const supportedFileTypes = {
8
8
  "application/json": [".json"],
9
9
  "application/yaml": [".yaml", ".yml"]
10
10
  };
11
+ const NOTEBOOK_MAX_FILES = 10;
12
+ const NOTEBOOK_MAX_FILE_SIZE_BYTES = 25 * 1024 * 1024;
13
+ const UNTITLED_NOTEBOOK_NAME = "Untitled Notebook";
14
+ const NOTEBOOK_ALLOWED_EXTENSIONS = {
15
+ "text/plain": [".txt", ".log"],
16
+ "text/markdown": [".md"],
17
+ "application/pdf": [".pdf"],
18
+ "application/json": [".json"],
19
+ "application/x-yaml": [".yaml", ".yml"],
20
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [
21
+ ".docx"
22
+ ],
23
+ "application/vnd.oasis.opendocument.text": [".odt"]
24
+ };
25
+ const NOTEBOOK_EXTENSION_TO_FILE_TYPE = {
26
+ ".txt": "txt",
27
+ ".md": "md",
28
+ ".pdf": "pdf",
29
+ ".json": "json",
30
+ ".yaml": "yaml",
31
+ ".yml": "yaml",
32
+ ".log": "log",
33
+ ".docx": "txt",
34
+ ".odt": "txt"
35
+ };
11
36
  const DEFAULT_SAMPLE_PROMPTS = [
12
37
  createPrompt(
13
38
  "prompts.codeReadability.title",
@@ -44,5 +69,5 @@ const VALID_TOPIC_RESTRICTION_PROVIDER_IDS = [
44
69
  ];
45
70
  const DOCKED_CONTENT_OFFSET = "calc(var(--docked-drawer-width, 500px) + 1.5em)";
46
71
 
47
- export { DEFAULT_SAMPLE_PROMPTS, DOCKED_CONTENT_OFFSET, LIGHTSPEED_APP_DRAWER_ID, RHDH_SAMPLE_PROMPTS, TEMP_CONVERSATION_ID, VALID_TOPIC_RESTRICTION_PROVIDER_IDS, supportedFileTypes };
72
+ export { DEFAULT_SAMPLE_PROMPTS, DOCKED_CONTENT_OFFSET, LIGHTSPEED_APP_DRAWER_ID, NOTEBOOK_ALLOWED_EXTENSIONS, NOTEBOOK_EXTENSION_TO_FILE_TYPE, NOTEBOOK_MAX_FILES, NOTEBOOK_MAX_FILE_SIZE_BYTES, RHDH_SAMPLE_PROMPTS, TEMP_CONVERSATION_ID, UNTITLED_NOTEBOOK_NAME, VALID_TOPIC_RESTRICTION_PROVIDER_IDS, supportedFileTypes };
48
73
  //# sourceMappingURL=const.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"const.esm.js","sources":["../src/const.ts"],"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 { SamplePrompts } from './types';\n\nexport const TEMP_CONVERSATION_ID = 'temp-conversation-id';\n\nexport const LIGHTSPEED_APP_DRAWER_ID = 'lightspeed';\n\n// Translation keys for disclaimers\nexport const FUNCTION_DISCLAIMER_WITHOUT_QUESTION_VALIDATION_KEY =\n 'disclaimer.withoutValidation';\nexport const FUNCTION_DISCLAIMER_KEY = 'disclaimer.withValidation';\n\nconst createPrompt = (titleKey: string, messageKey: string) => {\n return { titleKey, messageKey };\n};\n\nexport const supportedFileTypes = {\n 'text/plain': ['.txt'],\n 'application/json': ['.json'],\n 'application/yaml': ['.yaml', '.yml'],\n};\n\nexport const DEFAULT_SAMPLE_PROMPTS: SamplePrompts = [\n createPrompt(\n 'prompts.codeReadability.title',\n 'prompts.codeReadability.message',\n ),\n createPrompt('prompts.debugging.title', 'prompts.debugging.message'),\n createPrompt(\n 'prompts.developmentConcept.title',\n 'prompts.developmentConcept.message',\n ),\n createPrompt(\n 'prompts.codeOptimization.title',\n 'prompts.codeOptimization.message',\n ),\n createPrompt('prompts.documentation.title', 'prompts.documentation.message'),\n createPrompt('prompts.gitWorkflows.title', 'prompts.gitWorkflows.message'),\n createPrompt(\n 'prompts.testingStrategies.title',\n 'prompts.testingStrategies.message',\n ),\n createPrompt(\n 'prompts.sortingAlgorithms.title',\n 'prompts.sortingAlgorithms.message',\n ),\n createPrompt('prompts.eventDriven.title', 'prompts.eventDriven.message'),\n];\n\nexport const RHDH_SAMPLE_PROMPTS: SamplePrompts = [\n createPrompt('prompts.tekton.title', 'prompts.tekton.message'),\n createPrompt('prompts.openshift.title', 'prompts.openshift.message'),\n createPrompt('prompts.rhdh.title', 'prompts.rhdh.message'),\n];\n\n// Topic restriction valid provider IDs\nexport const VALID_TOPIC_RESTRICTION_PROVIDER_IDS = [\n 'lightspeed_question_validity-shield',\n];\n\n// Matches app shell margin on main when ApplicationDrawer is docked (e.g. Root.tsx).\nexport const DOCKED_CONTENT_OFFSET =\n 'calc(var(--docked-drawer-width, 500px) + 1.5em)';\n"],"names":[],"mappings":"AAkBO,MAAM,oBAAuB,GAAA;AAE7B,MAAM,wBAA2B,GAAA;AAOxC,MAAM,YAAA,GAAe,CAAC,QAAA,EAAkB,UAAuB,KAAA;AAC7D,EAAO,OAAA,EAAE,UAAU,UAAW,EAAA;AAChC,CAAA;AAEO,MAAM,kBAAqB,GAAA;AAAA,EAChC,YAAA,EAAc,CAAC,MAAM,CAAA;AAAA,EACrB,kBAAA,EAAoB,CAAC,OAAO,CAAA;AAAA,EAC5B,kBAAA,EAAoB,CAAC,OAAA,EAAS,MAAM;AACtC;AAEO,MAAM,sBAAwC,GAAA;AAAA,EACnD,YAAA;AAAA,IACE,+BAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,YAAA,CAAa,2BAA2B,2BAA2B,CAAA;AAAA,EACnE,YAAA;AAAA,IACE,kCAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,YAAA;AAAA,IACE,gCAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,YAAA,CAAa,+BAA+B,+BAA+B,CAAA;AAAA,EAC3E,YAAA,CAAa,8BAA8B,8BAA8B,CAAA;AAAA,EACzE,YAAA;AAAA,IACE,iCAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,YAAA;AAAA,IACE,iCAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,YAAA,CAAa,6BAA6B,6BAA6B;AACzE;AAEO,MAAM,mBAAqC,GAAA;AAAA,EAChD,YAAA,CAAa,wBAAwB,wBAAwB,CAAA;AAAA,EAC7D,YAAA,CAAa,2BAA2B,2BAA2B,CAAA;AAAA,EACnE,YAAA,CAAa,sBAAsB,sBAAsB;AAC3D;AAGO,MAAM,oCAAuC,GAAA;AAAA,EAClD;AACF;AAGO,MAAM,qBACX,GAAA;;;;"}
1
+ {"version":3,"file":"const.esm.js","sources":["../src/const.ts"],"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 { SamplePrompts } from './types';\n\nexport const TEMP_CONVERSATION_ID = 'temp-conversation-id';\n\nexport const LIGHTSPEED_APP_DRAWER_ID = 'lightspeed';\n\n// Translation keys for disclaimers\nexport const FUNCTION_DISCLAIMER_WITHOUT_QUESTION_VALIDATION_KEY =\n 'disclaimer.withoutValidation';\nexport const FUNCTION_DISCLAIMER_KEY = 'disclaimer.withValidation';\n\nconst createPrompt = (titleKey: string, messageKey: string) => {\n return { titleKey, messageKey };\n};\n\nexport const supportedFileTypes = {\n 'text/plain': ['.txt'],\n 'application/json': ['.json'],\n 'application/yaml': ['.yaml', '.yml'],\n};\n\nexport const NOTEBOOK_MAX_FILES = 10;\nexport const NOTEBOOK_MAX_FILE_SIZE_BYTES = 25 * 1024 * 1024; // 25 MB\nexport const UNTITLED_NOTEBOOK_NAME = 'Untitled Notebook';\n\nexport const NOTEBOOK_ALLOWED_EXTENSIONS: Record<string, string[]> = {\n 'text/plain': ['.txt', '.log'],\n 'text/markdown': ['.md'],\n 'application/pdf': ['.pdf'],\n 'application/json': ['.json'],\n 'application/x-yaml': ['.yaml', '.yml'],\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': [\n '.docx',\n ],\n 'application/vnd.oasis.opendocument.text': ['.odt'],\n};\n\nexport const NOTEBOOK_EXTENSION_TO_FILE_TYPE: Record<string, string> = {\n '.txt': 'txt',\n '.md': 'md',\n '.pdf': 'pdf',\n '.json': 'json',\n '.yaml': 'yaml',\n '.yml': 'yaml',\n '.log': 'log',\n '.docx': 'txt',\n '.odt': 'txt',\n};\n\nexport const DEFAULT_SAMPLE_PROMPTS: SamplePrompts = [\n createPrompt(\n 'prompts.codeReadability.title',\n 'prompts.codeReadability.message',\n ),\n createPrompt('prompts.debugging.title', 'prompts.debugging.message'),\n createPrompt(\n 'prompts.developmentConcept.title',\n 'prompts.developmentConcept.message',\n ),\n createPrompt(\n 'prompts.codeOptimization.title',\n 'prompts.codeOptimization.message',\n ),\n createPrompt('prompts.documentation.title', 'prompts.documentation.message'),\n createPrompt('prompts.gitWorkflows.title', 'prompts.gitWorkflows.message'),\n createPrompt(\n 'prompts.testingStrategies.title',\n 'prompts.testingStrategies.message',\n ),\n createPrompt(\n 'prompts.sortingAlgorithms.title',\n 'prompts.sortingAlgorithms.message',\n ),\n createPrompt('prompts.eventDriven.title', 'prompts.eventDriven.message'),\n];\n\nexport const RHDH_SAMPLE_PROMPTS: SamplePrompts = [\n createPrompt('prompts.tekton.title', 'prompts.tekton.message'),\n createPrompt('prompts.openshift.title', 'prompts.openshift.message'),\n createPrompt('prompts.rhdh.title', 'prompts.rhdh.message'),\n];\n\n// Topic restriction valid provider IDs\nexport const VALID_TOPIC_RESTRICTION_PROVIDER_IDS = [\n 'lightspeed_question_validity-shield',\n];\n\n// Matches app shell margin on main when ApplicationDrawer is docked (e.g. Root.tsx).\nexport const DOCKED_CONTENT_OFFSET =\n 'calc(var(--docked-drawer-width, 500px) + 1.5em)';\n"],"names":[],"mappings":"AAkBO,MAAM,oBAAuB,GAAA;AAE7B,MAAM,wBAA2B,GAAA;AAOxC,MAAM,YAAA,GAAe,CAAC,QAAA,EAAkB,UAAuB,KAAA;AAC7D,EAAO,OAAA,EAAE,UAAU,UAAW,EAAA;AAChC,CAAA;AAEO,MAAM,kBAAqB,GAAA;AAAA,EAChC,YAAA,EAAc,CAAC,MAAM,CAAA;AAAA,EACrB,kBAAA,EAAoB,CAAC,OAAO,CAAA;AAAA,EAC5B,kBAAA,EAAoB,CAAC,OAAA,EAAS,MAAM;AACtC;AAEO,MAAM,kBAAqB,GAAA;AACrB,MAAA,4BAAA,GAA+B,KAAK,IAAO,GAAA;AACjD,MAAM,sBAAyB,GAAA;AAE/B,MAAM,2BAAwD,GAAA;AAAA,EACnE,YAAA,EAAc,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,EAC7B,eAAA,EAAiB,CAAC,KAAK,CAAA;AAAA,EACvB,iBAAA,EAAmB,CAAC,MAAM,CAAA;AAAA,EAC1B,kBAAA,EAAoB,CAAC,OAAO,CAAA;AAAA,EAC5B,oBAAA,EAAsB,CAAC,OAAA,EAAS,MAAM,CAAA;AAAA,EACtC,yEAA2E,EAAA;AAAA,IACzE;AAAA,GACF;AAAA,EACA,yCAAA,EAA2C,CAAC,MAAM;AACpD;AAEO,MAAM,+BAA0D,GAAA;AAAA,EACrE,MAAQ,EAAA,KAAA;AAAA,EACR,KAAO,EAAA,IAAA;AAAA,EACP,MAAQ,EAAA,KAAA;AAAA,EACR,OAAS,EAAA,MAAA;AAAA,EACT,OAAS,EAAA,MAAA;AAAA,EACT,MAAQ,EAAA,MAAA;AAAA,EACR,MAAQ,EAAA,KAAA;AAAA,EACR,OAAS,EAAA,KAAA;AAAA,EACT,MAAQ,EAAA;AACV;AAEO,MAAM,sBAAwC,GAAA;AAAA,EACnD,YAAA;AAAA,IACE,+BAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,YAAA,CAAa,2BAA2B,2BAA2B,CAAA;AAAA,EACnE,YAAA;AAAA,IACE,kCAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,YAAA;AAAA,IACE,gCAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,YAAA,CAAa,+BAA+B,+BAA+B,CAAA;AAAA,EAC3E,YAAA,CAAa,8BAA8B,8BAA8B,CAAA;AAAA,EACzE,YAAA;AAAA,IACE,iCAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,YAAA;AAAA,IACE,iCAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,YAAA,CAAa,6BAA6B,6BAA6B;AACzE;AAEO,MAAM,mBAAqC,GAAA;AAAA,EAChD,YAAA,CAAa,wBAAwB,wBAAwB,CAAA;AAAA,EAC7D,YAAA,CAAa,2BAA2B,2BAA2B,CAAA;AAAA,EACnE,YAAA,CAAa,sBAAsB,sBAAsB;AAC3D;AAGO,MAAM,oCAAuC,GAAA;AAAA,EAClD;AACF;AAGO,MAAM,qBACX,GAAA;;;;"}
@@ -0,0 +1,19 @@
1
+ import { useApi } from '@backstage/core-plugin-api';
2
+ import { useQueryClient, useMutation } from '@tanstack/react-query';
3
+ import { notebooksApiRef } from '../../api/notebooksApi.esm.js';
4
+
5
+ const useCreateNotebook = () => {
6
+ const notebooksApi = useApi(notebooksApiRef);
7
+ const queryClient = useQueryClient();
8
+ return useMutation({
9
+ mutationFn: async ({ name, description }) => {
10
+ return notebooksApi.createSession(name, description);
11
+ },
12
+ onSuccess: () => {
13
+ queryClient.invalidateQueries({ queryKey: ["notebooks", "sessions"] });
14
+ }
15
+ });
16
+ };
17
+
18
+ export { useCreateNotebook };
19
+ //# sourceMappingURL=useCreateNotebook.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCreateNotebook.esm.js","sources":["../../../src/hooks/notebooks/useCreateNotebook.ts"],"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 { useApi } from '@backstage/core-plugin-api';\n\nimport {\n useMutation,\n useQueryClient,\n type UseMutationResult,\n} from '@tanstack/react-query';\n\nimport { notebooksApiRef } from '../../api/notebooksApi';\nimport { NotebookSession } from '../../types';\n\ntype CreateNotebookParams = {\n name: string;\n description?: string;\n};\n\nexport const useCreateNotebook = (): UseMutationResult<\n NotebookSession,\n unknown,\n CreateNotebookParams\n> => {\n const notebooksApi = useApi(notebooksApiRef);\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ name, description }: CreateNotebookParams) => {\n return notebooksApi.createSession(name, description);\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['notebooks', 'sessions'] });\n },\n });\n};\n"],"names":[],"mappings":";;;;AAgCO,MAAM,oBAAoB,MAI5B;AACH,EAAM,MAAA,YAAA,GAAe,OAAO,eAAe,CAAA;AAC3C,EAAA,MAAM,cAAc,cAAe,EAAA;AAEnC,EAAA,OAAO,WAAY,CAAA;AAAA,IACjB,UAAY,EAAA,OAAO,EAAE,IAAA,EAAM,aAAwC,KAAA;AACjE,MAAO,OAAA,YAAA,CAAa,aAAc,CAAA,IAAA,EAAM,WAAW,CAAA;AAAA,KACrD;AAAA,IACA,WAAW,MAAM;AACf,MAAA,WAAA,CAAY,kBAAkB,EAAE,QAAA,EAAU,CAAC,WAAa,EAAA,UAAU,GAAG,CAAA;AAAA;AACvE,GACD,CAAA;AACH;;;;"}
@@ -0,0 +1,39 @@
1
+ import { useApi } from '@backstage/core-plugin-api';
2
+ import { useQueries } from '@tanstack/react-query';
3
+ import { notebooksApiRef } from '../../api/notebooksApi.esm.js';
4
+
5
+ const POLL_INTERVAL_MS = 5e3;
6
+ const useDocumentStatusPolling = (sessionId, pendingUploads) => {
7
+ const notebooksApi = useApi(notebooksApiRef);
8
+ const results = useQueries({
9
+ queries: pendingUploads.map((upload) => ({
10
+ queryKey: ["notebooks", "documentStatus", sessionId, upload.documentId],
11
+ queryFn: () => notebooksApi.getDocumentStatus(sessionId, upload.documentId),
12
+ refetchInterval: (query) => {
13
+ if (query.state.status === "error") {
14
+ return false;
15
+ }
16
+ const status = query.state.data?.status;
17
+ if (status === "completed" || status === "failed" || status === "cancelled") {
18
+ return false;
19
+ }
20
+ return POLL_INTERVAL_MS;
21
+ },
22
+ retry: 10,
23
+ enabled: Boolean(upload.documentId)
24
+ }))
25
+ });
26
+ return pendingUploads.map((upload, index) => {
27
+ const result = results[index];
28
+ const dataStatus = result?.data?.status;
29
+ const isQueryError = result?.isError;
30
+ return {
31
+ fileName: upload.fileName,
32
+ documentId: upload.documentId,
33
+ status: isQueryError ? "failed" : dataStatus ?? "polling"
34
+ };
35
+ });
36
+ };
37
+
38
+ export { useDocumentStatusPolling };
39
+ //# sourceMappingURL=useDocumentStatusPolling.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDocumentStatusPolling.esm.js","sources":["../../../src/hooks/notebooks/useDocumentStatusPolling.ts"],"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 { useApi } from '@backstage/core-plugin-api';\n\nimport { useQueries } from '@tanstack/react-query';\n\nimport { notebooksApiRef } from '../../api/notebooksApi';\nimport { DocumentStatus } from '../../types';\n\nexport type PendingUpload = {\n fileName: string;\n documentId: string;\n};\n\nexport type DocumentPollingResult = {\n fileName: string;\n documentId: string;\n status: DocumentStatus['status'] | 'polling';\n};\n\nconst POLL_INTERVAL_MS = 5000;\n\nexport const useDocumentStatusPolling = (\n sessionId: string,\n pendingUploads: PendingUpload[],\n): DocumentPollingResult[] => {\n const notebooksApi = useApi(notebooksApiRef);\n\n const results = useQueries({\n queries: pendingUploads.map(upload => ({\n queryKey: ['notebooks', 'documentStatus', sessionId, upload.documentId],\n queryFn: () =>\n notebooksApi.getDocumentStatus(sessionId, upload.documentId),\n refetchInterval: (query: {\n state: { data?: DocumentStatus; status: string };\n }) => {\n if (query.state.status === 'error') {\n return false;\n }\n const status = query.state.data?.status;\n if (\n status === 'completed' ||\n status === 'failed' ||\n status === 'cancelled'\n ) {\n return false;\n }\n return POLL_INTERVAL_MS;\n },\n retry: 10,\n enabled: Boolean(upload.documentId),\n })),\n });\n\n return pendingUploads.map((upload, index) => {\n const result = results[index];\n const dataStatus = result?.data?.status;\n const isQueryError = result?.isError;\n return {\n fileName: upload.fileName,\n documentId: upload.documentId,\n status: isQueryError ? 'failed' : (dataStatus ?? 'polling'),\n };\n });\n};\n"],"names":[],"mappings":";;;;AAkCA,MAAM,gBAAmB,GAAA,GAAA;AAEZ,MAAA,wBAAA,GA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;"}
@@ -0,0 +1,18 @@
1
+ import { useApi } from '@backstage/core-plugin-api';
2
+ import { useQuery } from '@tanstack/react-query';
3
+ import { notebooksApiRef } from '../../api/notebooksApi.esm.js';
4
+
5
+ const useNotebookDocuments = (sessionId) => {
6
+ const notebooksApi = useApi(notebooksApiRef);
7
+ return useQuery({
8
+ queryKey: ["notebooks", "documents", sessionId],
9
+ queryFn: async () => {
10
+ return await notebooksApi.listDocuments(sessionId);
11
+ },
12
+ enabled: Boolean(sessionId),
13
+ staleTime: 1e3 * 60
14
+ });
15
+ };
16
+
17
+ export { useNotebookDocuments };
18
+ //# sourceMappingURL=useNotebookDocuments.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotebookDocuments.esm.js","sources":["../../../src/hooks/notebooks/useNotebookDocuments.ts"],"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 { useApi } from '@backstage/core-plugin-api';\n\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\nimport { notebooksApiRef } from '../../api/notebooksApi';\nimport { SessionDocument } from '../../types';\n\nexport const useNotebookDocuments = (\n sessionId?: string,\n): UseQueryResult<SessionDocument[], Error> => {\n const notebooksApi = useApi(notebooksApiRef);\n return useQuery({\n queryKey: ['notebooks', 'documents', sessionId],\n queryFn: async () => {\n return await notebooksApi.listDocuments(sessionId!);\n },\n enabled: Boolean(sessionId),\n staleTime: 1000 * 60,\n });\n};\n"],"names":[],"mappings":";;;;AAuBa,MAAA,oBAAA,GAAuB,CAClC,SAC6C,KAAA;AAC7C,EAAM,MAAA,YAAA,GAAe,OAAO,eAAe,CAAA;AAC3C,EAAA,OAAO,QAAS,CAAA;AAAA,IACd,QAAU,EAAA,CAAC,WAAa,EAAA,WAAA,EAAa,SAAS,CAAA;AAAA,IAC9C,SAAS,YAAY;AACnB,MAAO,OAAA,MAAM,YAAa,CAAA,aAAA,CAAc,SAAU,CAAA;AAAA,KACpD;AAAA,IACA,OAAA,EAAS,QAAQ,SAAS,CAAA;AAAA,IAC1B,WAAW,GAAO,GAAA;AAAA,GACnB,CAAA;AACH;;;;"}
@@ -0,0 +1,28 @@
1
+ import { useApi } from '@backstage/core-plugin-api';
2
+ import { useQueryClient, useMutation } from '@tanstack/react-query';
3
+ import { notebooksApiRef } from '../../api/notebooksApi.esm.js';
4
+ import { NOTEBOOK_EXTENSION_TO_FILE_TYPE } from '../../const.esm.js';
5
+
6
+ const getFileType = (fileName) => {
7
+ const lastDot = fileName.lastIndexOf(".");
8
+ const ext = lastDot >= 0 ? fileName.slice(lastDot).toLowerCase() : "";
9
+ return NOTEBOOK_EXTENSION_TO_FILE_TYPE[ext] ?? "txt";
10
+ };
11
+ const useUploadDocument = () => {
12
+ const notebooksApi = useApi(notebooksApiRef);
13
+ const queryClient = useQueryClient();
14
+ return useMutation({
15
+ mutationFn: async ({ sessionId, file }) => {
16
+ const fileType = getFileType(file.name);
17
+ return notebooksApi.uploadDocument(sessionId, file, fileType, file.name);
18
+ },
19
+ onSuccess: (_data, variables) => {
20
+ queryClient.invalidateQueries({
21
+ queryKey: ["notebooks", "documents", variables.sessionId]
22
+ });
23
+ }
24
+ });
25
+ };
26
+
27
+ export { useUploadDocument };
28
+ //# sourceMappingURL=useUploadDocument.esm.js.map