@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,59 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { makeStyles } from '@material-ui/core';
3
+
4
+ const FILE_TYPE_COLORS = {
5
+ pdf: "#C9190B",
6
+ yaml: "#F0AB00",
7
+ yml: "#F0AB00",
8
+ json: "#F0AB00",
9
+ csv: "#3E8635",
10
+ txt: "#6A6E73",
11
+ md: "#0066CC",
12
+ log: "#6A6E73",
13
+ docx: "#004B95",
14
+ odt: "#009596",
15
+ html: "#EC7A08",
16
+ xml: "#0066CC",
17
+ rtf: "#8476D1",
18
+ pptx: "#C9190B"
19
+ };
20
+ const DEFAULT_COLOR = "#6A6E73";
21
+ const useStyles = makeStyles(() => ({
22
+ badge: {
23
+ display: "inline-flex",
24
+ alignItems: "center",
25
+ justifyContent: "center",
26
+ minWidth: 28,
27
+ height: 22,
28
+ padding: "0 4px",
29
+ borderRadius: 4,
30
+ border: "1.5px solid",
31
+ fontSize: "0.625rem",
32
+ fontWeight: 700,
33
+ textTransform: "uppercase",
34
+ lineHeight: 1,
35
+ flexShrink: 0
36
+ }
37
+ }));
38
+ const getExtension = (fileName) => {
39
+ if (!fileName) return "";
40
+ const lastDot = fileName.lastIndexOf(".");
41
+ return lastDot >= 0 ? fileName.slice(lastDot + 1).toLowerCase() : "";
42
+ };
43
+ const FileTypeIcon = ({ fileName, className }) => {
44
+ const classes = useStyles();
45
+ const ext = getExtension(fileName);
46
+ const color = FILE_TYPE_COLORS[ext] ?? DEFAULT_COLOR;
47
+ const label = ext || "?";
48
+ return /* @__PURE__ */ jsx(
49
+ "span",
50
+ {
51
+ className: `${classes.badge}${className ? ` ${className}` : ""}`,
52
+ style: { borderColor: color, color },
53
+ children: label
54
+ }
55
+ );
56
+ };
57
+
58
+ export { FileTypeIcon };
59
+ //# sourceMappingURL=FileTypeIcon.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileTypeIcon.esm.js","sources":["../../../src/components/notebooks/FileTypeIcon.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';\n\nconst FILE_TYPE_COLORS: Record<string, string> = {\n pdf: '#C9190B',\n yaml: '#F0AB00',\n yml: '#F0AB00',\n json: '#F0AB00',\n csv: '#3E8635',\n txt: '#6A6E73',\n md: '#0066CC',\n log: '#6A6E73',\n docx: '#004B95',\n odt: '#009596',\n html: '#EC7A08',\n xml: '#0066CC',\n rtf: '#8476D1',\n pptx: '#C9190B',\n};\n\nconst DEFAULT_COLOR = '#6A6E73';\n\nconst useStyles = makeStyles(() => ({\n badge: {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n minWidth: 28,\n height: 22,\n padding: '0 4px',\n borderRadius: 4,\n border: '1.5px solid',\n fontSize: '0.625rem',\n fontWeight: 700,\n textTransform: 'uppercase',\n lineHeight: 1,\n flexShrink: 0,\n },\n}));\n\ntype FileTypeIconProps = {\n fileName: string;\n className?: string;\n};\n\nconst getExtension = (fileName: string): string => {\n if (!fileName) return '';\n const lastDot = fileName.lastIndexOf('.');\n return lastDot >= 0 ? fileName.slice(lastDot + 1).toLowerCase() : '';\n};\n\nexport const FileTypeIcon = ({ fileName, className }: FileTypeIconProps) => {\n const classes = useStyles();\n const ext = getExtension(fileName);\n const color = FILE_TYPE_COLORS[ext] ?? DEFAULT_COLOR;\n const label = ext || '?';\n\n return (\n <span\n className={`${classes.badge}${className ? ` ${className}` : ''}`}\n style={{ borderColor: color, color }}\n >\n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AA;AACpE,CAAA;AAEO,MAAM,YAAe,GAAA,CAAC,EAAE,QAAA,EAAU,WAAmC,KAAA;AAC1E,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAM,MAAA,GAAA,GAAM,aAAa,QAAQ,CAAA;AACjC,EAAM,MAAA,KAAA,GAAQ,gBAAiB,CAAA,GAAG,CAAK,IAAA,aAAA;AACvC,EAAA,MAAM,QAAQ,GAAO,IAAA,GAAA;AAErB,EACE,uBAAA,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,GAAG,OAAQ,CAAA,KAAK,GAAG,SAAY,GAAA,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA;AAAA,MAC9D,KAAO,EAAA,EAAE,WAAa,EAAA,KAAA,EAAO,KAAM,EAAA;AAAA,MAElC,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ;;;;"}
@@ -10,87 +10,98 @@ const NotebookCard = ({
10
10
  classes,
11
11
  openNotebookMenuId,
12
12
  setOpenNotebookMenuId,
13
+ onClick,
13
14
  onRename,
14
15
  onDelete,
15
- t,
16
- getDocumentsCount
17
- }) => /* @__PURE__ */ jsxs(Card, { className: classes.notebookCard, isSelectable: true, children: [
18
- /* @__PURE__ */ jsx(
19
- CardHeader,
20
- {
21
- className: classes.notebookCardHeader,
22
- actions: {
23
- actions: /* @__PURE__ */ jsx(
24
- Dropdown,
25
- {
26
- className: classes.notebookDropdownMenu,
27
- isOpen: openNotebookMenuId === notebook.session_id,
28
- popperProps: {
29
- position: "end",
30
- preventOverflow: true
31
- },
32
- onOpenChange: (isOpen) => setOpenNotebookMenuId(isOpen ? notebook.session_id : null),
33
- toggle: (toggleRef) => /* @__PURE__ */ jsx(
34
- MenuToggle,
16
+ t
17
+ }) => /* @__PURE__ */ jsxs(
18
+ Card,
19
+ {
20
+ className: classes.notebookCard,
21
+ isSelectable: true,
22
+ isClickable: true,
23
+ onClick: () => onClick(notebook),
24
+ children: [
25
+ /* @__PURE__ */ jsx(
26
+ CardHeader,
27
+ {
28
+ className: classes.notebookCardHeader,
29
+ actions: {
30
+ actions: /* @__PURE__ */ jsx(
31
+ Dropdown,
35
32
  {
36
- ref: toggleRef,
37
- variant: "plain",
38
- className: classes.notebookMenuButton,
39
- "aria-label": t("aria.options.label"),
40
- isExpanded: openNotebookMenuId === notebook.session_id,
41
- onClick: (event) => {
42
- event.stopPropagation();
43
- setOpenNotebookMenuId(
44
- (current) => current === notebook.session_id ? null : notebook.session_id
45
- );
33
+ className: classes.notebookDropdownMenu,
34
+ isOpen: openNotebookMenuId === notebook.session_id,
35
+ popperProps: {
36
+ position: "end",
37
+ preventOverflow: true
46
38
  },
47
- children: /* @__PURE__ */ jsx(EllipsisVIcon, {})
39
+ onOpenChange: (isOpen) => setOpenNotebookMenuId(isOpen ? notebook.session_id : null),
40
+ toggle: (toggleRef) => /* @__PURE__ */ jsx(
41
+ MenuToggle,
42
+ {
43
+ ref: toggleRef,
44
+ variant: "plain",
45
+ className: classes.notebookMenuButton,
46
+ "aria-label": t("aria.options.label"),
47
+ isExpanded: openNotebookMenuId === notebook.session_id,
48
+ onClick: (event) => {
49
+ event.stopPropagation();
50
+ setOpenNotebookMenuId(
51
+ (current) => current === notebook.session_id ? null : notebook.session_id
52
+ );
53
+ },
54
+ children: /* @__PURE__ */ jsx(EllipsisVIcon, {})
55
+ }
56
+ ),
57
+ children: /* @__PURE__ */ jsxs(DropdownList, { className: classes.notebookDropdownList, children: [
58
+ /* @__PURE__ */ jsx(
59
+ DropdownItem,
60
+ {
61
+ className: classes.notebookDropdownItem,
62
+ onClick: (event) => {
63
+ event.stopPropagation();
64
+ onRename(notebook.session_id);
65
+ setOpenNotebookMenuId(null);
66
+ },
67
+ children: t("notebooks.actions.rename")
68
+ }
69
+ ),
70
+ /* @__PURE__ */ jsx(
71
+ DropdownItem,
72
+ {
73
+ className: classes.notebookDropdownItem,
74
+ onClick: (event) => {
75
+ event.stopPropagation();
76
+ onDelete(notebook.session_id);
77
+ setOpenNotebookMenuId(null);
78
+ },
79
+ children: t("notebooks.actions.delete")
80
+ }
81
+ )
82
+ ] })
48
83
  }
49
84
  ),
50
- children: /* @__PURE__ */ jsxs(DropdownList, { className: classes.notebookDropdownList, children: [
51
- /* @__PURE__ */ jsx(
52
- DropdownItem,
53
- {
54
- className: classes.notebookDropdownItem,
55
- onClick: () => {
56
- onRename(notebook.session_id);
57
- setOpenNotebookMenuId(null);
58
- },
59
- children: t("notebooks.actions.rename")
60
- }
61
- ),
62
- /* @__PURE__ */ jsx(
63
- DropdownItem,
64
- {
65
- className: classes.notebookDropdownItem,
66
- onClick: () => {
67
- onDelete(notebook.session_id);
68
- setOpenNotebookMenuId(null);
69
- },
70
- children: t("notebooks.actions.delete")
71
- }
72
- )
73
- ] })
74
- }
75
- ),
76
- className: classes.notebookCardHeaderActions
77
- },
78
- children: /* @__PURE__ */ jsxs(CardTitle, { className: classes.notebookTitle, children: [
79
- /* @__PURE__ */ jsx(CatalogIcon, {}),
80
- /* @__PURE__ */ jsx(Typography, { component: "span", className: classes.notebookTitleText, children: notebook.name })
81
- ] })
82
- }
83
- ),
84
- /* @__PURE__ */ jsx("div", { className: classes.notebookCardDivider }),
85
- /* @__PURE__ */ jsx(CardBody, { className: classes.notebookCardBody, children: /* @__PURE__ */ jsxs("div", { children: [
86
- /* @__PURE__ */ jsx("div", { className: classes.notebookDocuments, children: /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
87
- getDocumentsCount(notebook.metadata?.document_ids),
88
- " ",
89
- t("notebooks.documents")
90
- ] }) }),
91
- /* @__PURE__ */ jsx("div", { className: classes.notebookUpdated, children: /* @__PURE__ */ jsx(Typography, { variant: "caption", children: formatUpdatedLabel(notebook.updated_at, t) }) })
92
- ] }) })
93
- ] });
85
+ className: classes.notebookCardHeaderActions
86
+ },
87
+ children: /* @__PURE__ */ jsxs(CardTitle, { className: classes.notebookTitle, children: [
88
+ /* @__PURE__ */ jsx(CatalogIcon, {}),
89
+ /* @__PURE__ */ jsx(Typography, { component: "span", className: classes.notebookTitleText, children: notebook.name })
90
+ ] })
91
+ }
92
+ ),
93
+ /* @__PURE__ */ jsx("div", { className: classes.notebookCardDivider }),
94
+ /* @__PURE__ */ jsx(CardBody, { className: classes.notebookCardBody, children: /* @__PURE__ */ jsxs("div", { children: [
95
+ /* @__PURE__ */ jsx("div", { className: classes.notebookDocuments, children: /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
96
+ notebook.document_count ?? 0,
97
+ " ",
98
+ t("notebooks.documents")
99
+ ] }) }),
100
+ /* @__PURE__ */ jsx("div", { className: classes.notebookUpdated, children: /* @__PURE__ */ jsx(Typography, { variant: "caption", children: formatUpdatedLabel(notebook.updated_at, t) }) })
101
+ ] }) })
102
+ ]
103
+ }
104
+ );
94
105
 
95
106
  export { NotebookCard };
96
107
  //# sourceMappingURL=NotebookCard.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotebookCard.esm.js","sources":["../../../src/components/notebooks/NotebookCard.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 '@mui/material/Typography';\nimport {\n Card,\n CardBody,\n CardHeader,\n CardTitle,\n Dropdown,\n DropdownItem,\n DropdownList,\n MenuToggle,\n} from '@patternfly/react-core';\nimport { EllipsisVIcon } from '@patternfly/react-icons';\nimport { CatalogIcon } from '@patternfly/react-icons/dist/esm/icons';\n\nimport { lightspeedTranslationRef } from '../../translations/ref';\nimport { NotebookSession } from '../../types';\nimport { formatUpdatedLabel } from '../../utils/notebooks-utils';\n\ntype NotebookCardProps = {\n notebook: NotebookSession;\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 NotebookCard = ({\n notebook,\n classes,\n openNotebookMenuId,\n setOpenNotebookMenuId,\n onRename,\n onDelete,\n t,\n getDocumentsCount,\n}: NotebookCardProps) => (\n <Card className={classes.notebookCard} isSelectable>\n <CardHeader\n className={classes.notebookCardHeader}\n actions={{\n actions: (\n <Dropdown\n className={classes.notebookDropdownMenu}\n isOpen={openNotebookMenuId === notebook.session_id}\n popperProps={{\n position: 'end',\n preventOverflow: true,\n }}\n onOpenChange={isOpen =>\n setOpenNotebookMenuId(isOpen ? notebook.session_id : null)\n }\n toggle={toggleRef => (\n <MenuToggle\n ref={toggleRef}\n variant=\"plain\"\n className={classes.notebookMenuButton}\n aria-label={t('aria.options.label')}\n isExpanded={openNotebookMenuId === notebook.session_id}\n onClick={event => {\n event.stopPropagation();\n setOpenNotebookMenuId(current =>\n current === notebook.session_id\n ? null\n : notebook.session_id,\n );\n }}\n >\n <EllipsisVIcon />\n </MenuToggle>\n )}\n >\n <DropdownList className={classes.notebookDropdownList}>\n <DropdownItem\n className={classes.notebookDropdownItem}\n onClick={() => {\n onRename(notebook.session_id);\n setOpenNotebookMenuId(null);\n }}\n >\n {t('notebooks.actions.rename')}\n </DropdownItem>\n <DropdownItem\n className={classes.notebookDropdownItem}\n onClick={() => {\n onDelete(notebook.session_id);\n setOpenNotebookMenuId(null);\n }}\n >\n {t('notebooks.actions.delete')}\n </DropdownItem>\n </DropdownList>\n </Dropdown>\n ),\n className: classes.notebookCardHeaderActions,\n }}\n >\n <CardTitle className={classes.notebookTitle}>\n <CatalogIcon />\n <Typography component=\"span\" className={classes.notebookTitleText}>\n {notebook.name}\n </Typography>\n </CardTitle>\n </CardHeader>\n <div className={classes.notebookCardDivider} />\n <CardBody className={classes.notebookCardBody}>\n <div>\n <div className={classes.notebookDocuments}>\n <Typography variant=\"body2\">\n {getDocumentsCount(notebook.metadata?.document_ids)}{' '}\n {t('notebooks.documents')}\n </Typography>\n </div>\n <div className={classes.notebookUpdated}>\n <Typography variant=\"caption\">\n {formatUpdatedLabel(notebook.updated_at, t)}\n </Typography>\n </div>\n </div>\n </CardBody>\n </Card>\n);\n"],"names":[],"mappings":";;;;;;;AA+CO,MAAM,eAAe,CAAC;AAAA,EAC3B,QAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AAAA,EACA,qBAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,CAAA;AAAA,EACA;AACF,CAAA,0BACG,IAAK,EAAA,EAAA,SAAA,EAAW,OAAQ,CAAA,YAAA,EAAc,cAAY,IACjD,EAAA,QAAA,EAAA;AAAA,kBAAA,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,WAAW,OAAQ,CAAA,kBAAA;AAAA,MACnB,OAAS,EAAA;AAAA,QACP,OACE,kBAAA,GAAA;AAAA,UAAC,QAAA;AAAA,UAAA;AAAA,YACC,WAAW,OAAQ,CAAA,oBAAA;AAAA,YACnB,MAAA,EAAQ,uBAAuB,QAAS,CAAA,UAAA;AAAA,YACxC,WAAa,EAAA;AAAA,cACX,QAAU,EAAA,KAAA;AAAA,cACV,eAAiB,EAAA;AAAA,aACnB;AAAA,YACA,cAAc,CACZ,MAAA,KAAA,qBAAA,CAAsB,MAAS,GAAA,QAAA,CAAS,aAAa,IAAI,CAAA;AAAA,YAE3D,QAAQ,CACN,SAAA,qBAAA,GAAA;AAAA,cAAC,UAAA;AAAA,cAAA;AAAA,gBACC,GAAK,EAAA,SAAA;AAAA,gBACL,OAAQ,EAAA,OAAA;AAAA,gBACR,WAAW,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;AAAA,wBACb,GAAA,CAAC,cAAW,SAAU,EAAA,MAAA,EAAO,WAAW,OAAQ,CAAA,iBAAA,EAC7C,mBAAS,IACZ,EAAA;AAAA,OACF,EAAA;AAAA;AAAA,GACF;AAAA,kBACC,GAAA,CAAA,KAAA,EAAA,EAAI,SAAW,EAAA,OAAA,CAAQ,mBAAqB,EAAA,CAAA;AAAA,sBAC5C,QAAS,EAAA,EAAA,SAAA,EAAW,OAAQ,CAAA,gBAAA,EAC3B,+BAAC,KACC,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,SAAI,SAAW,EAAA,OAAA,CAAQ,mBACtB,QAAC,kBAAA,IAAA,CAAA,UAAA,EAAA,EAAW,SAAQ,OACjB,EAAA,QAAA,EAAA;AAAA,MAAkB,iBAAA,CAAA,QAAA,CAAS,UAAU,YAAY,CAAA;AAAA,MAAG,GAAA;AAAA,MACpD,EAAE,qBAAqB;AAAA,KAAA,EAC1B,CACF,EAAA,CAAA;AAAA,oBACC,GAAA,CAAA,KAAA,EAAA,EAAI,SAAW,EAAA,OAAA,CAAQ,iBACtB,QAAC,kBAAA,GAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,SAAA,EACjB,QAAmB,EAAA,kBAAA,CAAA,QAAA,CAAS,UAAY,EAAA,CAAC,GAC5C,CACF,EAAA;AAAA,GAAA,EACF,CACF,EAAA;AAAA,CACF,EAAA;;;;"}
1
+ {"version":3,"file":"NotebookCard.esm.js","sources":["../../../src/components/notebooks/NotebookCard.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 '@mui/material/Typography';\nimport {\n Card,\n CardBody,\n CardHeader,\n CardTitle,\n Dropdown,\n DropdownItem,\n DropdownList,\n MenuToggle,\n} from '@patternfly/react-core';\nimport { EllipsisVIcon } from '@patternfly/react-icons';\nimport { CatalogIcon } from '@patternfly/react-icons/dist/esm/icons';\n\nimport { lightspeedTranslationRef } from '../../translations/ref';\nimport { NotebookSession } from '../../types';\nimport { formatUpdatedLabel } from '../../utils/notebooks-utils';\n\ntype NotebookCardProps = {\n notebook: NotebookSession;\n classes: Record<string, string>;\n openNotebookMenuId: string | null;\n setOpenNotebookMenuId: React.Dispatch<React.SetStateAction<string | null>>;\n onClick: (notebook: NotebookSession) => void;\n onRename: (sessionId: string) => void;\n onDelete: (sessionId: string) => void;\n t: TranslationFunction<typeof lightspeedTranslationRef.T>;\n};\n\nexport const NotebookCard = ({\n notebook,\n classes,\n openNotebookMenuId,\n setOpenNotebookMenuId,\n onClick,\n onRename,\n onDelete,\n t,\n}: NotebookCardProps) => (\n <Card\n className={classes.notebookCard}\n isSelectable\n isClickable\n onClick={() => onClick(notebook)}\n >\n <CardHeader\n className={classes.notebookCardHeader}\n actions={{\n actions: (\n <Dropdown\n className={classes.notebookDropdownMenu}\n isOpen={openNotebookMenuId === notebook.session_id}\n popperProps={{\n position: 'end',\n preventOverflow: true,\n }}\n onOpenChange={isOpen =>\n setOpenNotebookMenuId(isOpen ? notebook.session_id : null)\n }\n toggle={toggleRef => (\n <MenuToggle\n ref={toggleRef}\n variant=\"plain\"\n className={classes.notebookMenuButton}\n aria-label={t('aria.options.label')}\n isExpanded={openNotebookMenuId === notebook.session_id}\n onClick={event => {\n event.stopPropagation();\n setOpenNotebookMenuId(current =>\n current === notebook.session_id\n ? null\n : notebook.session_id,\n );\n }}\n >\n <EllipsisVIcon />\n </MenuToggle>\n )}\n >\n <DropdownList className={classes.notebookDropdownList}>\n <DropdownItem\n className={classes.notebookDropdownItem}\n onClick={event => {\n event.stopPropagation();\n onRename(notebook.session_id);\n setOpenNotebookMenuId(null);\n }}\n >\n {t('notebooks.actions.rename')}\n </DropdownItem>\n <DropdownItem\n className={classes.notebookDropdownItem}\n onClick={event => {\n event.stopPropagation();\n onDelete(notebook.session_id);\n setOpenNotebookMenuId(null);\n }}\n >\n {t('notebooks.actions.delete')}\n </DropdownItem>\n </DropdownList>\n </Dropdown>\n ),\n className: classes.notebookCardHeaderActions,\n }}\n >\n <CardTitle className={classes.notebookTitle}>\n <CatalogIcon />\n <Typography component=\"span\" className={classes.notebookTitleText}>\n {notebook.name}\n </Typography>\n </CardTitle>\n </CardHeader>\n <div className={classes.notebookCardDivider} />\n <CardBody className={classes.notebookCardBody}>\n <div>\n <div className={classes.notebookDocuments}>\n <Typography variant=\"body2\">\n {notebook.document_count ?? 0} {t('notebooks.documents')}\n </Typography>\n </div>\n <div className={classes.notebookUpdated}>\n <Typography variant=\"caption\">\n {formatUpdatedLabel(notebook.updated_at, t)}\n </Typography>\n </div>\n </div>\n </CardBody>\n </Card>\n);\n"],"names":[],"mappings":";;;;;;;AA+CO,MAAM,eAAe,CAAC;AAAA,EAC3B,QAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AAAA,EACA,qBAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CACE,qBAAA,IAAA;AAAA,EAAC,IAAA;AAAA,EAAA;AAAA,IACC,WAAW,OAAQ,CAAA,YAAA;AAAA,IACnB,YAAY,EAAA,IAAA;AAAA,IACZ,WAAW,EAAA,IAAA;AAAA,IACX,OAAA,EAAS,MAAM,OAAA,CAAQ,QAAQ,CAAA;AAAA,IAE/B,QAAA,EAAA;AAAA,sBAAA,GAAA;AAAA,QAAC,UAAA;AAAA,QAAA;AAAA,UACC,WAAW,OAAQ,CAAA,kBAAA;AAAA,UACnB,OAAS,EAAA;AAAA,YACP,OACE,kBAAA,GAAA;A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CAAQ,iBACtB,QAAC,kBAAA,GAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,SAAA,EACjB,QAAmB,EAAA,kBAAA,CAAA,QAAA,CAAS,UAAY,EAAA,CAAC,GAC5C,CACF,EAAA;AAAA,OAAA,EACF,CACF,EAAA;AAAA;AAAA;AACF;;;;"}
@@ -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