@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,198 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { CircularProgress, Box, Typography, Button, Link } from '@material-ui/core';
3
+ import { makeStyles, createStyles } from '@material-ui/core/styles';
4
+ import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
5
+ import OpenInNewIcon from '@mui/icons-material/OpenInNew';
6
+ import SmartToyOutlinedIcon from '@mui/icons-material/SmartToyOutlined';
7
+ import { useTranslation } from '../hooks/useTranslation.esm.js';
8
+
9
+ const LLAMA_STACK_CONFIGURE_DOCS_URL = "https://docs.redhat.com/en/documentation/red_hat_developer_hub/latest/html/interacting_with_red_hat_developer_lightspeed_for_red_hat_developer_hub/developer-lightspeed#proc-installing-and-configuring-lightspeed_developer-lightspeed";
10
+ const LIGHTSPEED_BACKEND_README_URL = "https://github.com/redhat-developer/rhdh-plugins/blob/main/workspaces/lightspeed/plugins/lightspeed-backend/README.md";
11
+ const useStyles = makeStyles(
12
+ (theme) => createStyles({
13
+ root: {
14
+ display: "flex",
15
+ flexDirection: "column",
16
+ boxSizing: "border-box",
17
+ width: "100%",
18
+ maxWidth: "100%",
19
+ minWidth: 0,
20
+ minHeight: "100%",
21
+ height: "100%",
22
+ flex: "1 1 auto",
23
+ alignItems: "center",
24
+ justifyContent: "center",
25
+ padding: theme.spacing(4, 2),
26
+ backgroundColor: theme.palette.background.default
27
+ },
28
+ panel: {
29
+ display: "flex",
30
+ flexDirection: "column",
31
+ alignItems: "center",
32
+ textAlign: "center",
33
+ width: "100%",
34
+ maxWidth: 440,
35
+ gap: theme.spacing(2)
36
+ },
37
+ emptyStateIcon: {
38
+ fontSize: 64,
39
+ color: theme.palette.text.secondary
40
+ },
41
+ errorIcon: {
42
+ fontSize: 64,
43
+ color: theme.palette.warning.main
44
+ },
45
+ description: {
46
+ lineHeight: 1.5,
47
+ color: theme.palette.text.secondary
48
+ },
49
+ actions: {
50
+ display: "flex",
51
+ flexDirection: "column",
52
+ alignItems: "center",
53
+ gap: theme.spacing(1.5),
54
+ marginTop: theme.spacing(1)
55
+ },
56
+ backendLink: {
57
+ display: "inline-flex",
58
+ alignItems: "center",
59
+ gap: theme.spacing(0.5),
60
+ fontSize: theme.typography.body1.fontSize,
61
+ fontWeight: 500
62
+ }
63
+ })
64
+ );
65
+ const LightspeedChatModelsLoading = () => {
66
+ const classes = useStyles();
67
+ const { t } = useTranslation();
68
+ return /* @__PURE__ */ jsx(
69
+ "div",
70
+ {
71
+ className: classes.root,
72
+ "data-testid": "lightspeed-models-loading",
73
+ role: "status",
74
+ "aria-busy": "true",
75
+ "aria-label": t("common.loading"),
76
+ children: /* @__PURE__ */ jsx(CircularProgress, { "aria-hidden": true })
77
+ }
78
+ );
79
+ };
80
+ const LcoreNotConfiguredEmptyState = () => {
81
+ const classes = useStyles();
82
+ const { t } = useTranslation();
83
+ return /* @__PURE__ */ jsx("div", { className: classes.root, "data-testid": "lightspeed-lcore-not-configured", children: /* @__PURE__ */ jsxs(
84
+ Box,
85
+ {
86
+ className: classes.panel,
87
+ component: "section",
88
+ "aria-labelledby": "lightspeed-lcore-empty-title",
89
+ children: [
90
+ /* @__PURE__ */ jsx(
91
+ SmartToyOutlinedIcon,
92
+ {
93
+ className: classes.emptyStateIcon,
94
+ "aria-hidden": true,
95
+ focusable: false
96
+ }
97
+ ),
98
+ /* @__PURE__ */ jsx(
99
+ Typography,
100
+ {
101
+ id: "lightspeed-lcore-empty-title",
102
+ variant: "h5",
103
+ component: "h2",
104
+ children: t("lcore.notConfigured.title")
105
+ }
106
+ ),
107
+ /* @__PURE__ */ jsx(
108
+ Typography,
109
+ {
110
+ variant: "body1",
111
+ component: "p",
112
+ className: classes.description,
113
+ children: t("lcore.notConfigured.description")
114
+ }
115
+ ),
116
+ /* @__PURE__ */ jsxs(Box, { className: classes.actions, children: [
117
+ /* @__PURE__ */ jsxs(
118
+ Button,
119
+ {
120
+ variant: "contained",
121
+ color: "primary",
122
+ target: "_blank",
123
+ rel: "noopener noreferrer",
124
+ href: LLAMA_STACK_CONFIGURE_DOCS_URL,
125
+ children: [
126
+ t("lcore.notConfigured.developerLightspeedDocs"),
127
+ " \xA0",
128
+ " ",
129
+ /* @__PURE__ */ jsx(OpenInNewIcon, { fontSize: "small", "aria-hidden": true })
130
+ ]
131
+ }
132
+ ),
133
+ /* @__PURE__ */ jsxs(
134
+ Link,
135
+ {
136
+ className: classes.backendLink,
137
+ component: "a",
138
+ color: "primary",
139
+ href: LIGHTSPEED_BACKEND_README_URL,
140
+ target: "_blank",
141
+ rel: "noopener noreferrer",
142
+ children: [
143
+ t("lcore.notConfigured.backendDocs"),
144
+ /* @__PURE__ */ jsx(OpenInNewIcon, { fontSize: "small", "aria-hidden": true })
145
+ ]
146
+ }
147
+ )
148
+ ] })
149
+ ]
150
+ }
151
+ ) });
152
+ };
153
+ const ModelsLoadErrorEmptyState = ({
154
+ onRetry
155
+ }) => {
156
+ const classes = useStyles();
157
+ const { t } = useTranslation();
158
+ return /* @__PURE__ */ jsx("div", { className: classes.root, "data-testid": "lightspeed-models-load-error", children: /* @__PURE__ */ jsxs(
159
+ Box,
160
+ {
161
+ className: classes.panel,
162
+ component: "section",
163
+ "aria-labelledby": "lightspeed-models-error-title",
164
+ children: [
165
+ /* @__PURE__ */ jsx(
166
+ ErrorOutlineIcon,
167
+ {
168
+ className: classes.errorIcon,
169
+ "aria-hidden": true,
170
+ focusable: false
171
+ }
172
+ ),
173
+ /* @__PURE__ */ jsx(
174
+ Typography,
175
+ {
176
+ id: "lightspeed-models-error-title",
177
+ variant: "h5",
178
+ component: "h2",
179
+ children: t("lcore.loadError.title")
180
+ }
181
+ ),
182
+ /* @__PURE__ */ jsx(
183
+ Typography,
184
+ {
185
+ variant: "body1",
186
+ component: "p",
187
+ className: classes.description,
188
+ children: t("lcore.loadError.description")
189
+ }
190
+ ),
191
+ /* @__PURE__ */ jsx(Box, { className: classes.actions, children: /* @__PURE__ */ jsx(Button, { variant: "contained", color: "primary", onClick: () => onRetry(), children: t("common.retry") }) })
192
+ ]
193
+ }
194
+ ) });
195
+ };
196
+
197
+ export { LcoreNotConfiguredEmptyState, LightspeedChatModelsLoading, ModelsLoadErrorEmptyState };
198
+ //# sourceMappingURL=LightspeedChatModelsState.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LightspeedChatModelsState.esm.js","sources":["../../src/components/LightspeedChatModelsState.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 {\n Box,\n Button,\n CircularProgress,\n Link,\n Typography,\n} from '@material-ui/core';\nimport { createStyles, makeStyles } from '@material-ui/core/styles';\nimport ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';\nimport OpenInNewIcon from '@mui/icons-material/OpenInNew';\nimport SmartToyOutlinedIcon from '@mui/icons-material/SmartToyOutlined';\n\nimport { useTranslation } from '../hooks/useTranslation';\n\nconst LLAMA_STACK_CONFIGURE_DOCS_URL =\n 'https://docs.redhat.com/en/documentation/red_hat_developer_hub/latest/html/interacting_with_red_hat_developer_lightspeed_for_red_hat_developer_hub/developer-lightspeed#proc-installing-and-configuring-lightspeed_developer-lightspeed';\nconst LIGHTSPEED_BACKEND_README_URL =\n 'https://github.com/redhat-developer/rhdh-plugins/blob/main/workspaces/lightspeed/plugins/lightspeed-backend/README.md';\n\nconst useStyles = makeStyles(theme =>\n createStyles({\n root: {\n display: 'flex',\n flexDirection: 'column',\n boxSizing: 'border-box',\n width: '100%',\n maxWidth: '100%',\n minWidth: 0,\n minHeight: '100%',\n height: '100%',\n flex: '1 1 auto',\n alignItems: 'center',\n justifyContent: 'center',\n padding: theme.spacing(4, 2),\n backgroundColor: theme.palette.background.default,\n },\n panel: {\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n textAlign: 'center',\n width: '100%',\n maxWidth: 440,\n gap: theme.spacing(2),\n },\n emptyStateIcon: {\n fontSize: 64,\n color: theme.palette.text.secondary,\n },\n errorIcon: {\n fontSize: 64,\n color: theme.palette.warning.main,\n },\n description: {\n lineHeight: 1.5,\n color: theme.palette.text.secondary,\n },\n actions: {\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n gap: theme.spacing(1.5),\n marginTop: theme.spacing(1),\n },\n backendLink: {\n display: 'inline-flex',\n alignItems: 'center',\n gap: theme.spacing(0.5),\n fontSize: theme.typography.body1.fontSize,\n fontWeight: 500,\n },\n }),\n);\n\n/**\n * Shown while the models list is loading for an authorized user.\n */\nexport const LightspeedChatModelsLoading = () => {\n const classes = useStyles();\n const { t } = useTranslation();\n return (\n <div\n className={classes.root}\n data-testid=\"lightspeed-models-loading\"\n role=\"status\"\n aria-busy=\"true\"\n aria-label={t('common.loading')}\n >\n <CircularProgress aria-hidden />\n </div>\n );\n};\n\n/**\n * Shown when LCORE / Llama Stack is up but no LLM models are registered.\n */\nexport const LcoreNotConfiguredEmptyState = () => {\n const classes = useStyles();\n const { t } = useTranslation();\n\n return (\n <div className={classes.root} data-testid=\"lightspeed-lcore-not-configured\">\n <Box\n className={classes.panel}\n component=\"section\"\n aria-labelledby=\"lightspeed-lcore-empty-title\"\n >\n <SmartToyOutlinedIcon\n className={classes.emptyStateIcon}\n aria-hidden\n focusable={false}\n />\n <Typography\n id=\"lightspeed-lcore-empty-title\"\n variant=\"h5\"\n component=\"h2\"\n >\n {t('lcore.notConfigured.title')}\n </Typography>\n <Typography\n variant=\"body1\"\n component=\"p\"\n className={classes.description}\n >\n {t('lcore.notConfigured.description')}\n </Typography>\n <Box className={classes.actions}>\n <Button\n variant=\"contained\"\n color=\"primary\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={LLAMA_STACK_CONFIGURE_DOCS_URL}\n >\n {t('lcore.notConfigured.developerLightspeedDocs')} &nbsp;{' '}\n <OpenInNewIcon fontSize=\"small\" aria-hidden />\n </Button>\n <Link\n className={classes.backendLink}\n component=\"a\"\n color=\"primary\"\n href={LIGHTSPEED_BACKEND_README_URL}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {t('lcore.notConfigured.backendDocs')}\n <OpenInNewIcon fontSize=\"small\" aria-hidden />\n </Link>\n </Box>\n </Box>\n </div>\n );\n};\n\ntype ModelsLoadErrorEmptyStateProps = {\n onRetry: () => void;\n};\n\n/**\n * Shown when the models API fails (distinct from “no models configured”).\n */\nexport const ModelsLoadErrorEmptyState = ({\n onRetry,\n}: ModelsLoadErrorEmptyStateProps) => {\n const classes = useStyles();\n const { t } = useTranslation();\n\n return (\n <div className={classes.root} data-testid=\"lightspeed-models-load-error\">\n <Box\n className={classes.panel}\n component=\"section\"\n aria-labelledby=\"lightspeed-models-error-title\"\n >\n <ErrorOutlineIcon\n className={classes.errorIcon}\n aria-hidden\n focusable={false}\n />\n <Typography\n id=\"lightspeed-models-error-title\"\n variant=\"h5\"\n component=\"h2\"\n >\n {t('lcore.loadError.title')}\n </Typography>\n <Typography\n variant=\"body1\"\n component=\"p\"\n className={classes.description}\n >\n {t('lcore.loadError.description')}\n </Typography>\n <Box className={classes.actions}>\n <Button variant=\"contained\" color=\"primary\" onClick={() => onRetry()}>\n {t('common.retry')}\n </Button>\n </Box>\n </Box>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA8BA,MAAM,8BACJ,GAAA,yOAAA;AACF,MAAM,6BACJ,GAAA,uHAAA;AAEF,MAAM,SAAY,GAAA,UAAA;AAAA,EAAW,WAC3B,YAAa,CAAA;AAAA,IACX,IAAM,EAAA;AAAA,MACJ,OAAS,EAAA,MAAA;AAAA,MACT,aAAe,EA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AAQ,EAAA,WAAA,EAAY,KAAM,EAAA,SAAA,EAAU,SAAS,MAAM,OAAA,IACxD,QAAE,EAAA,CAAA,CAAA,cAAc,GACnB,CACF,EAAA;AAAA;AAAA;AAAA,GAEJ,EAAA,CAAA;AAEJ;;;;"}
@@ -29,7 +29,8 @@ const LightspeedDrawerProvider = ({ children }) => {
29
29
  {
30
30
  isOpen: true,
31
31
  displayMode: contextValue.displayMode,
32
- onClose: closeChatbot,
32
+ disableFocusTrap: true,
33
+ onEscapePress: () => closeChatbot(),
33
34
  ouiaId: "LightspeedChatbotModal",
34
35
  "aria-labelledby": "lightspeed-chatpopup-modal",
35
36
  className: classes.chatbotModal,
@@ -1 +1 @@
1
- {"version":3,"file":"LightspeedDrawerProvider.esm.js","sources":["../../src/components/LightspeedDrawerProvider.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 { PropsWithChildren } from 'react';\n\nimport { makeStyles } from '@mui/styles';\nimport { ChatbotModal } from '@patternfly/chatbot';\n\nimport { DOCKED_CONTENT_OFFSET } from '../const';\nimport { useLightspeedProviderState } from '../hooks/useLightspeedProviderState';\nimport { LightspeedChatContainer } from './LightspeedChatContainer';\nimport { LightspeedDrawerContext } from './LightspeedDrawerContext';\n\nconst useStyles = makeStyles(theme => ({\n chatbotModal: {\n boxShadow:\n '0 14px 20px -7px rgba(0, 0, 0, 0.22), 0 32px 50px 6px rgba(0, 0, 0, 0.16), 0 12px 60px 12px rgba(0, 0, 0, 0.14) !important',\n bottom: `calc(${theme?.spacing?.(2) ?? '16px'} + 5em)`,\n right: `calc(${theme?.spacing?.(2) ?? '16px'} + 1.5em)`,\n maxWidth: 'min(30rem, calc(100vw - 32px)) !important',\n overflowX: 'hidden' as const,\n transition: 'margin-right 0.3s ease',\n 'body.docked-drawer-open &': {\n marginRight: DOCKED_CONTENT_OFFSET,\n },\n },\n}));\n\n/**\n * @public\n */\nexport const LightspeedDrawerProvider = ({ children }: PropsWithChildren) => {\n const classes = useStyles();\n const { contextValue, shouldRenderOverlayModal, closeChatbot } =\n useLightspeedProviderState();\n\n return (\n <LightspeedDrawerContext.Provider value={contextValue}>\n {children}\n {shouldRenderOverlayModal && (\n <ChatbotModal\n isOpen\n displayMode={contextValue.displayMode}\n onClose={closeChatbot}\n ouiaId=\"LightspeedChatbotModal\"\n aria-labelledby=\"lightspeed-chatpopup-modal\"\n className={classes.chatbotModal}\n >\n <LightspeedChatContainer />\n </ChatbotModal>\n )}\n </LightspeedDrawerContext.Provider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA0BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,YAAc,EAAA;AAAA,IACZ,SACE,EAAA,4HAAA;AAAA,IACF,QAAQ,CAAQ,KAAA,EAAA,KAAA,EAAO,OAAU,GAAA,CAAC,KAAK,MAAM,CAAA,OAAA,CAAA;AAAA,IAC7C,OAAO,CAAQ,KAAA,EAAA,KAAA,EAAO,OAAU,GAAA,CAAC,KAAK,MAAM,CAAA,SAAA,CAAA;AAAA,IAC5C,QAAU,EAAA,2CAAA;AAAA,IACV,SAAW,EAAA,QAAA;AAAA,IACX,UAAY,EAAA,wBAAA;AAAA,IACZ,2BAA6B,EAAA;AAAA,MAC3B,WAAa,EAAA;AAAA;AACf;AAEJ,CAAE,CAAA,CAAA;AAKK,MAAM,wBAA2B,GAAA,CAAC,EAAE,QAAA,EAAkC,KAAA;AAC3E,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAA,MAAM,EAAE,YAAA,EAAc,wBAA0B,EAAA,YAAA,KAC9C,0BAA2B,EAAA;AAE7B,EAAA,uBACG,IAAA,CAAA,uBAAA,CAAwB,QAAxB,EAAA,EAAiC,OAAO,YACtC,EAAA,QAAA,EAAA;AAAA,IAAA,QAAA;AAAA,IACA,wBACC,oBAAA,GAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,MAAM,EAAA,IAAA;AAAA,QACN,aAAa,YAAa,CAAA,WAAA;AAAA,QAC1B,OAAS,EAAA,YAAA;AAAA,QACT,MAAO,EAAA,wBAAA;AAAA,QACP,iBAAgB,EAAA,4BAAA;AAAA,QAChB,WAAW,OAAQ,CAAA,YAAA;AAAA,QAEnB,8BAAC,uBAAwB,EAAA,EAAA;AAAA;AAAA;AAC3B,GAEJ,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"LightspeedDrawerProvider.esm.js","sources":["../../src/components/LightspeedDrawerProvider.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 { PropsWithChildren } from 'react';\n\nimport { makeStyles } from '@mui/styles';\nimport { ChatbotModal } from '@patternfly/chatbot';\n\nimport { DOCKED_CONTENT_OFFSET } from '../const';\nimport { useLightspeedProviderState } from '../hooks/useLightspeedProviderState';\nimport { LightspeedChatContainer } from './LightspeedChatContainer';\nimport { LightspeedDrawerContext } from './LightspeedDrawerContext';\n\nconst useStyles = makeStyles(theme => ({\n chatbotModal: {\n boxShadow:\n '0 14px 20px -7px rgba(0, 0, 0, 0.22), 0 32px 50px 6px rgba(0, 0, 0, 0.16), 0 12px 60px 12px rgba(0, 0, 0, 0.14) !important',\n bottom: `calc(${theme?.spacing?.(2) ?? '16px'} + 5em)`,\n right: `calc(${theme?.spacing?.(2) ?? '16px'} + 1.5em)`,\n maxWidth: 'min(30rem, calc(100vw - 32px)) !important',\n overflowX: 'hidden' as const,\n transition: 'margin-right 0.3s ease',\n 'body.docked-drawer-open &': {\n marginRight: DOCKED_CONTENT_OFFSET,\n },\n },\n}));\n\n/**\n * @public\n */\nexport const LightspeedDrawerProvider = ({ children }: PropsWithChildren) => {\n const classes = useStyles();\n const { contextValue, shouldRenderOverlayModal, closeChatbot } =\n useLightspeedProviderState();\n\n return (\n <LightspeedDrawerContext.Provider value={contextValue}>\n {children}\n {shouldRenderOverlayModal && (\n <ChatbotModal\n isOpen\n displayMode={contextValue.displayMode}\n disableFocusTrap\n onEscapePress={() => closeChatbot()}\n ouiaId=\"LightspeedChatbotModal\"\n aria-labelledby=\"lightspeed-chatpopup-modal\"\n className={classes.chatbotModal}\n >\n <LightspeedChatContainer />\n </ChatbotModal>\n )}\n </LightspeedDrawerContext.Provider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA0BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,YAAc,EAAA;AAAA,IACZ,SACE,EAAA,4HAAA;AAAA,IACF,QAAQ,CAAQ,KAAA,EAAA,KAAA,EAAO,OAAU,GAAA,CAAC,KAAK,MAAM,CAAA,OAAA,CAAA;AAAA,IAC7C,OAAO,CAAQ,KAAA,EAAA,KAAA,EAAO,OAAU,GAAA,CAAC,KAAK,MAAM,CAAA,SAAA,CAAA;AAAA,IAC5C,QAAU,EAAA,2CAAA;AAAA,IACV,SAAW,EAAA,QAAA;AAAA,IACX,UAAY,EAAA,wBAAA;AAAA,IACZ,2BAA6B,EAAA;AAAA,MAC3B,WAAa,EAAA;AAAA;AACf;AAEJ,CAAE,CAAA,CAAA;AAKK,MAAM,wBAA2B,GAAA,CAAC,EAAE,QAAA,EAAkC,KAAA;AAC3E,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAA,MAAM,EAAE,YAAA,EAAc,wBAA0B,EAAA,YAAA,KAC9C,0BAA2B,EAAA;AAE7B,EAAA,uBACG,IAAA,CAAA,uBAAA,CAAwB,QAAxB,EAAA,EAAiC,OAAO,YACtC,EAAA,QAAA,EAAA;AAAA,IAAA,QAAA;AAAA,IACA,wBACC,oBAAA,GAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,MAAM,EAAA,IAAA;AAAA,QACN,aAAa,YAAa,CAAA,WAAA;AAAA,QAC1B,gBAAgB,EAAA,IAAA;AAAA,QAChB,aAAA,EAAe,MAAM,YAAa,EAAA;AAAA,QAClC,MAAO,EAAA,wBAAA;AAAA,QACP,iBAAgB,EAAA,4BAAA;AAAA,QAChB,WAAW,OAAQ,CAAA,YAAA;AAAA,QAEnB,8BAAC,uBAAwB,EAAA,EAAA;AAAA;AAAA;AAC3B,GAEJ,EAAA,CAAA;AAEJ;;;;"}
@@ -11,7 +11,8 @@ const Router = () => {
11
11
  path: "/conversation/:conversationId",
12
12
  element: /* @__PURE__ */ jsx(LightspeedPage, {})
13
13
  }
14
- )
14
+ ),
15
+ /* @__PURE__ */ jsx(Route, { path: "/notebooks", element: /* @__PURE__ */ jsx(LightspeedPage, {}) })
15
16
  ] });
16
17
  };
17
18
 
@@ -1 +1 @@
1
- {"version":3,"file":"Router.esm.js","sources":["../../src/components/Router.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 { Route, Routes } from 'react-router-dom';\n\nimport { LightspeedPage } from './LightspeedPage';\n\n/**\n * @public\n */\nexport const Router = () => {\n return (\n <Routes>\n <Route path=\"/\" element={<LightspeedPage />} />\n <Route\n path=\"/conversation/:conversationId\"\n element={<LightspeedPage />}\n />\n </Routes>\n );\n};\n"],"names":[],"mappings":";;;;AAuBO,MAAM,SAAS,MAAM;AAC1B,EAAA,4BACG,MACC,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,SAAM,IAAK,EAAA,GAAA,EAAI,OAAS,kBAAA,GAAA,CAAC,kBAAe,CAAI,EAAA,CAAA;AAAA,oBAC7C,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,IAAK,EAAA,+BAAA;AAAA,QACL,OAAA,sBAAU,cAAe,EAAA,EAAA;AAAA;AAAA;AAC3B,GACF,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"Router.esm.js","sources":["../../src/components/Router.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 { Route, Routes } from 'react-router-dom';\n\nimport { LightspeedPage } from './LightspeedPage';\n\n/**\n * @public\n */\nexport const Router = () => {\n return (\n <Routes>\n <Route path=\"/\" element={<LightspeedPage />} />\n <Route\n path=\"/conversation/:conversationId\"\n element={<LightspeedPage />}\n />\n <Route path=\"/notebooks\" element={<LightspeedPage />} />\n </Routes>\n );\n};\n"],"names":[],"mappings":";;;;AAuBO,MAAM,SAAS,MAAM;AAC1B,EAAA,4BACG,MACC,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,SAAM,IAAK,EAAA,GAAA,EAAI,OAAS,kBAAA,GAAA,CAAC,kBAAe,CAAI,EAAA,CAAA;AAAA,oBAC7C,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,IAAK,EAAA,+BAAA;AAAA,QACL,OAAA,sBAAU,cAAe,EAAA,EAAA;AAAA;AAAA,KAC3B;AAAA,wBACC,KAAM,EAAA,EAAA,IAAA,EAAK,cAAa,OAAS,kBAAA,GAAA,CAAC,kBAAe,CAAI,EAAA;AAAA,GACxD,EAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,170 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useState } from 'react';
3
+ import { makeStyles } from '@material-ui/core/styles';
4
+ import CloseIcon from '@mui/icons-material/Close';
5
+ import Alert from '@mui/material/Alert';
6
+ import Dialog from '@mui/material/Dialog';
7
+ import DialogContent from '@mui/material/DialogContent';
8
+ import DialogTitle from '@mui/material/DialogTitle';
9
+ import IconButton from '@mui/material/IconButton';
10
+ import Typography from '@mui/material/Typography';
11
+ import { MultipleFileUpload, MultipleFileUploadMain } from '@patternfly/react-core';
12
+ import { UploadIcon } from '@patternfly/react-icons';
13
+ import { NOTEBOOK_MAX_FILES } from '../../const.esm.js';
14
+ import { useUploadDocument } from '../../hooks/notebooks/useUploadDocument.esm.js';
15
+ import { useTranslation } from '../../hooks/useTranslation.esm.js';
16
+ import { getNotebookAcceptedFileTypes, validateFiles } from '../../utils/notebook-upload-utils.esm.js';
17
+
18
+ const useStyles = makeStyles((theme) => ({
19
+ dialogPaper: {
20
+ borderRadius: 24,
21
+ maxWidth: 578
22
+ },
23
+ dialogTitle: {
24
+ display: "flex",
25
+ alignItems: "center",
26
+ justifyContent: "space-between",
27
+ padding: "24px 24px 16px"
28
+ },
29
+ titleText: {
30
+ fontWeight: 500,
31
+ fontSize: "1.25rem",
32
+ lineHeight: "1.625rem",
33
+ letterSpacing: "-0.25px"
34
+ },
35
+ closeButton: {
36
+ color: theme.palette.grey[700]
37
+ },
38
+ dialogContent: {
39
+ padding: "0 24px 24px"
40
+ },
41
+ errorAlert: {
42
+ marginBottom: theme.spacing(2)
43
+ },
44
+ dropzone: {
45
+ "& .pf-v6-c-multiple-file-upload__main": {
46
+ borderColor: "var(--pf-t--global--border--color--brand--default)",
47
+ transition: "background-color 0.2s ease",
48
+ cursor: "pointer"
49
+ },
50
+ "& .pf-v6-c-multiple-file-upload__main:hover": {
51
+ backgroundColor: "color-mix(in srgb, var(--pf-t--global--color--brand--default) 10%, transparent)"
52
+ }
53
+ }
54
+ }));
55
+ const AddDocumentModal = ({
56
+ isOpen,
57
+ onClose,
58
+ sessionId,
59
+ existingDocumentNames,
60
+ onFilesUploading,
61
+ onUploadStarted,
62
+ onUploadFailed,
63
+ onDuplicatesFound
64
+ }) => {
65
+ const classes = useStyles();
66
+ const { t } = useTranslation();
67
+ const uploadMutation = useUploadDocument();
68
+ const [validationErrors, setValidationErrors] = useState([]);
69
+ const handleFileDrop = (_event, files) => {
70
+ setValidationErrors([]);
71
+ const { valid, errors } = validateFiles(
72
+ files,
73
+ existingDocumentNames.length
74
+ );
75
+ if (errors.length > 0) {
76
+ setValidationErrors(errors);
77
+ return;
78
+ }
79
+ if (valid.length === 0) return;
80
+ const existingNamesSet = new Set(existingDocumentNames);
81
+ const newFiles = valid.filter((f) => !existingNamesSet.has(f.name));
82
+ const duplicateFiles = valid.filter((f) => existingNamesSet.has(f.name));
83
+ if (newFiles.length > 0) {
84
+ onFilesUploading?.(newFiles);
85
+ for (const file of newFiles) {
86
+ uploadMutation.mutateAsync({ sessionId, file }).then((data) => {
87
+ onUploadStarted?.({
88
+ fileName: file.name,
89
+ documentId: data.document_id
90
+ });
91
+ }).catch(() => {
92
+ onUploadFailed?.(file.name);
93
+ });
94
+ }
95
+ }
96
+ if (duplicateFiles.length > 0) {
97
+ onDuplicatesFound?.(duplicateFiles);
98
+ }
99
+ setValidationErrors([]);
100
+ onClose();
101
+ };
102
+ const handleDropRejected = (rejections) => {
103
+ const hasInvalidType = rejections.some(
104
+ (r) => r.errors.some((e) => e.code === "file-invalid-type")
105
+ );
106
+ if (hasInvalidType) {
107
+ setValidationErrors(["notebook.upload.error.unsupportedType"]);
108
+ }
109
+ };
110
+ const handleClose = () => {
111
+ setValidationErrors([]);
112
+ onClose();
113
+ };
114
+ return /* @__PURE__ */ jsxs(
115
+ Dialog,
116
+ {
117
+ open: isOpen,
118
+ onClose: handleClose,
119
+ "aria-labelledby": "add-document-modal-title",
120
+ PaperProps: {
121
+ className: classes.dialogPaper
122
+ },
123
+ children: [
124
+ /* @__PURE__ */ jsxs(DialogTitle, { className: classes.dialogTitle, children: [
125
+ /* @__PURE__ */ jsx(Typography, { component: "h2", className: classes.titleText, children: t("notebook.upload.modal.title") }),
126
+ /* @__PURE__ */ jsx(
127
+ IconButton,
128
+ {
129
+ "aria-label": t("common.close"),
130
+ onClick: handleClose,
131
+ className: classes.closeButton,
132
+ size: "small",
133
+ children: /* @__PURE__ */ jsx(CloseIcon, {})
134
+ }
135
+ )
136
+ ] }),
137
+ /* @__PURE__ */ jsxs(DialogContent, { className: classes.dialogContent, children: [
138
+ validationErrors.length > 0 && /* @__PURE__ */ jsx(Alert, { severity: "error", className: classes.errorAlert, children: validationErrors.map((errorKey) => {
139
+ const message = t(errorKey);
140
+ return errorKey === "notebook.upload.error.tooManyFiles" ? message.replace("{{max}}", String(NOTEBOOK_MAX_FILES)) : message;
141
+ }).join("\n") }),
142
+ /* @__PURE__ */ jsx(
143
+ MultipleFileUpload,
144
+ {
145
+ className: classes.dropzone,
146
+ dropzoneProps: {
147
+ accept: getNotebookAcceptedFileTypes(),
148
+ onDropRejected: handleDropRejected
149
+ },
150
+ onFileDrop: handleFileDrop,
151
+ children: /* @__PURE__ */ jsx(
152
+ MultipleFileUploadMain,
153
+ {
154
+ titleIcon: /* @__PURE__ */ jsx(UploadIcon, {}),
155
+ titleText: t("notebook.upload.modal.dragDropTitle"),
156
+ titleTextSeparator: t("notebook.upload.modal.separator"),
157
+ infoText: t("notebook.upload.modal.infoText"),
158
+ browseButtonText: t("notebook.upload.modal.browseButton")
159
+ }
160
+ )
161
+ }
162
+ )
163
+ ] })
164
+ ]
165
+ }
166
+ );
167
+ };
168
+
169
+ export { AddDocumentModal };
170
+ //# sourceMappingURL=AddDocumentModal.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AddDocumentModal.esm.js","sources":["../../../src/components/notebooks/AddDocumentModal.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 { useState } from 'react';\nimport { FileRejection } from 'react-dropzone';\n\nimport { makeStyles } from '@material-ui/core/styles';\nimport CloseIcon from '@mui/icons-material/Close';\nimport Alert from '@mui/material/Alert';\nimport Dialog from '@mui/material/Dialog';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport IconButton from '@mui/material/IconButton';\nimport Typography from '@mui/material/Typography';\nimport {\n MultipleFileUpload,\n MultipleFileUploadMain,\n} from '@patternfly/react-core';\nimport { UploadIcon } from '@patternfly/react-icons';\n\nimport { NOTEBOOK_MAX_FILES } from '../../const';\nimport { useUploadDocument } from '../../hooks/notebooks/useUploadDocument';\nimport { useTranslation } from '../../hooks/useTranslation';\nimport {\n getNotebookAcceptedFileTypes,\n validateFiles,\n} from '../../utils/notebook-upload-utils';\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 errorAlert: {\n marginBottom: theme.spacing(2),\n },\n dropzone: {\n '& .pf-v6-c-multiple-file-upload__main': {\n borderColor: 'var(--pf-t--global--border--color--brand--default)',\n transition: 'background-color 0.2s ease',\n cursor: 'pointer',\n },\n '& .pf-v6-c-multiple-file-upload__main:hover': {\n backgroundColor:\n 'color-mix(in srgb, var(--pf-t--global--color--brand--default) 10%, transparent)',\n },\n },\n}));\n\ntype AddDocumentModalProps = {\n isOpen: boolean;\n onClose: () => void;\n sessionId: string;\n existingDocumentNames: string[];\n onFilesUploading?: (files: File[]) => void;\n onUploadStarted?: (info: { fileName: string; documentId: string }) => void;\n onUploadFailed?: (fileName: string) => void;\n onDuplicatesFound?: (files: File[]) => void;\n};\n\nexport const AddDocumentModal = ({\n isOpen,\n onClose,\n sessionId,\n existingDocumentNames,\n onFilesUploading,\n onUploadStarted,\n onUploadFailed,\n onDuplicatesFound,\n}: AddDocumentModalProps) => {\n const classes = useStyles();\n const { t } = useTranslation();\n const uploadMutation = useUploadDocument();\n const [validationErrors, setValidationErrors] = useState<string[]>([]);\n\n const handleFileDrop = (_event: unknown, files: File[]) => {\n setValidationErrors([]);\n\n const { valid, errors } = validateFiles(\n files,\n existingDocumentNames.length,\n );\n\n if (errors.length > 0) {\n setValidationErrors(errors);\n return;\n }\n\n if (valid.length === 0) return;\n\n const existingNamesSet = new Set(existingDocumentNames);\n const newFiles = valid.filter(f => !existingNamesSet.has(f.name));\n const duplicateFiles = valid.filter(f => existingNamesSet.has(f.name));\n\n if (newFiles.length > 0) {\n onFilesUploading?.(newFiles);\n for (const file of newFiles) {\n uploadMutation\n .mutateAsync({ sessionId, file })\n .then(data => {\n onUploadStarted?.({\n fileName: file.name,\n documentId: data.document_id,\n });\n })\n .catch(() => {\n onUploadFailed?.(file.name);\n });\n }\n }\n\n if (duplicateFiles.length > 0) {\n onDuplicatesFound?.(duplicateFiles);\n }\n\n setValidationErrors([]);\n onClose();\n };\n\n const handleDropRejected = (rejections: FileRejection[]) => {\n const hasInvalidType = rejections.some(r =>\n r.errors.some(e => e.code === 'file-invalid-type'),\n );\n if (hasInvalidType) {\n setValidationErrors(['notebook.upload.error.unsupportedType']);\n }\n };\n\n const handleClose = () => {\n setValidationErrors([]);\n onClose();\n };\n\n return (\n <Dialog\n open={isOpen}\n onClose={handleClose}\n aria-labelledby=\"add-document-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.upload.modal.title')}\n </Typography>\n <IconButton\n aria-label={t('common.close')}\n onClick={handleClose}\n className={classes.closeButton}\n size=\"small\"\n >\n <CloseIcon />\n </IconButton>\n </DialogTitle>\n\n <DialogContent className={classes.dialogContent}>\n {validationErrors.length > 0 && (\n <Alert severity=\"error\" className={classes.errorAlert}>\n {validationErrors\n .map(errorKey => {\n const message = (t as Function)(errorKey) as string;\n return errorKey === 'notebook.upload.error.tooManyFiles'\n ? message.replace('{{max}}', String(NOTEBOOK_MAX_FILES))\n : message;\n })\n .join('\\n')}\n </Alert>\n )}\n\n <MultipleFileUpload\n className={classes.dropzone}\n dropzoneProps={{\n accept: getNotebookAcceptedFileTypes(),\n onDropRejected: handleDropRejected,\n }}\n onFileDrop={handleFileDrop}\n >\n <MultipleFileUploadMain\n titleIcon={<UploadIcon />}\n titleText={t('notebook.upload.modal.dragDropTitle')}\n titleTextSeparator={t('notebook.upload.modal.separator')}\n infoText={t('notebook.upload.modal.infoText')}\n browseButtonText={t('notebook.upload.modal.browseButton')}\n />\n </MultipleFileUpload>\n </DialogContent>\n </Dialog>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAyCA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,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,wBAEC,IAAA,CAAA,aAAA,EAAA,EAAc,SAAW,EAAA,OAAA,CAAQ,aAC/B,EAAA,QAAA,EAAA;AAAA,UAAiB,gBAAA,CAAA,MAAA,GAAS,CACzB,oBAAA,GAAA,CAAC,KAAM,EAAA,EAAA,QAAA,EAAS,OAAQ,EAAA,SAAA,EAAW,OAAQ,CAAA,UAAA,EACxC,QACE,EAAA,gBAAA,CAAA,GAAA,CAAI,CAAY,QAAA,KAAA;AACf,YAAM,MAAA,OAAA,GAAW,EAAe,QAAQ,CAAA;AACxC,YAAO,OAAA,QAAA,KAAa,uCAChB,OAAQ,CAAA,OAAA,CAAQ,WAAW,MAAO,CAAA,kBAAkB,CAAC,CACrD,GAAA,OAAA;AAAA,WACL,CAAA,CACA,IAAK,CAAA,IAAI,CACd,EAAA,CAAA;AAAA,0BAGF,GAAA;AAAA,YAAC,kBAAA;AAAA,YAAA;AAAA,cACC,WAAW,OAAQ,CAAA,QAAA;AAAA,cACnB,aAAe,EAAA;AAAA,gBACb,QAAQ,4BAA6B,EAAA;AAAA,gBACrC,cAAgB,EAAA;AAAA,eAClB;AAAA,cACA,UAAY,EAAA,cAAA;AAAA,cAEZ,QAAA,kBAAA,GAAA;AAAA,gBAAC,sBAAA;AAAA,gBAAA;AAAA,kBACC,SAAA,sBAAY,UAAW,EAAA,EAAA,CAAA;AAAA,kBACvB,SAAA,EAAW,EAAE,qCAAqC,CAAA;AAAA,kBAClD,kBAAA,EAAoB,EAAE,iCAAiC,CAAA;AAAA,kBACvD,QAAA,EAAU,EAAE,gCAAgC,CAAA;AAAA,kBAC5C,gBAAA,EAAkB,EAAE,oCAAoC;AAAA;AAAA;AAC1D;AAAA;AACF,SACF,EAAA;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
@@ -0,0 +1,154 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { makeStyles, Typography } from '@material-ui/core';
3
+ import { Tooltip, Button, Spinner } from '@patternfly/react-core';
4
+ import { PlusCircleIcon } from '@patternfly/react-icons';
5
+ import { useTranslation } from '../../hooks/useTranslation.esm.js';
6
+ import { FileTypeIcon } from './FileTypeIcon.esm.js';
7
+ import { SidebarCollapseIcon } from './SidebarCollapseIcon.esm.js';
8
+
9
+ const useStyles = makeStyles((theme) => ({
10
+ sidebar: {
11
+ display: "flex",
12
+ flexDirection: "column",
13
+ width: "100%",
14
+ height: "100%",
15
+ padding: theme.spacing(2),
16
+ overflow: "hidden"
17
+ },
18
+ titleRow: {
19
+ display: "flex",
20
+ alignItems: "center",
21
+ justifyContent: "space-between",
22
+ marginBottom: theme.spacing(2),
23
+ gap: theme.spacing(1)
24
+ },
25
+ title: {
26
+ fontWeight: 500,
27
+ fontSize: "1.25rem",
28
+ lineHeight: "2rem",
29
+ letterSpacing: "-0.25px",
30
+ overflow: "hidden",
31
+ textOverflow: "ellipsis",
32
+ whiteSpace: "nowrap",
33
+ flex: 1,
34
+ minWidth: 0
35
+ },
36
+ collapseButton: {
37
+ flexShrink: 0
38
+ },
39
+ documentsRow: {
40
+ display: "flex",
41
+ alignItems: "center",
42
+ justifyContent: "space-between"
43
+ },
44
+ documentCount: {
45
+ fontWeight: 700,
46
+ fontSize: "1.125rem",
47
+ lineHeight: "2rem"
48
+ },
49
+ addButton: {
50
+ textTransform: "none"
51
+ },
52
+ documentsList: {
53
+ marginTop: theme.spacing(2),
54
+ display: "flex",
55
+ flexDirection: "column",
56
+ gap: theme.spacing(0.5),
57
+ overflowY: "auto",
58
+ flex: 1
59
+ },
60
+ documentItem: {
61
+ display: "flex",
62
+ alignItems: "center",
63
+ gap: theme.spacing(1),
64
+ padding: `${theme.spacing(1)}px ${theme.spacing(0.5)}px`,
65
+ borderRadius: 4
66
+ },
67
+ fileIcon: {
68
+ flexShrink: 0,
69
+ color: theme.palette.grey[500],
70
+ fontSize: "1rem"
71
+ },
72
+ fileName: {
73
+ flex: 1,
74
+ minWidth: 0,
75
+ overflow: "hidden",
76
+ textOverflow: "ellipsis",
77
+ whiteSpace: "nowrap",
78
+ fontSize: "0.875rem",
79
+ lineHeight: "1.25rem"
80
+ },
81
+ spinnerContainer: {
82
+ flexShrink: 0
83
+ }
84
+ }));
85
+ const DocumentSidebar = ({
86
+ notebookName,
87
+ documents,
88
+ uploadingFileNames,
89
+ completedFileNames,
90
+ collapsed,
91
+ onToggleCollapse,
92
+ onAddDocument
93
+ }) => {
94
+ const classes = useStyles();
95
+ const { t } = useTranslation();
96
+ if (collapsed) {
97
+ return null;
98
+ }
99
+ const uploadedNames = new Set(documents.map((d) => d.title));
100
+ const activePending = uploadingFileNames.filter(
101
+ (name) => !uploadedNames.has(name)
102
+ );
103
+ const totalCount = documents.length + activePending.length;
104
+ return /* @__PURE__ */ jsxs("div", { className: classes.sidebar, children: [
105
+ /* @__PURE__ */ jsxs("div", { className: classes.titleRow, children: [
106
+ /* @__PURE__ */ jsx(Typography, { className: classes.title, children: notebookName }),
107
+ /* @__PURE__ */ jsx(Tooltip, { content: t("notebook.view.sidebar.collapse"), position: "right", children: /* @__PURE__ */ jsx(
108
+ Button,
109
+ {
110
+ variant: "plain",
111
+ className: classes.collapseButton,
112
+ onClick: onToggleCollapse,
113
+ "aria-label": t("notebook.view.sidebar.collapse"),
114
+ children: /* @__PURE__ */ jsx(SidebarCollapseIcon, {})
115
+ }
116
+ ) })
117
+ ] }),
118
+ /* @__PURE__ */ jsxs("div", { className: classes.documentsRow, children: [
119
+ /* @__PURE__ */ jsx(Typography, { className: classes.documentCount, children: t("notebook.view.documents.count", {
120
+ count: totalCount
121
+ }) }),
122
+ /* @__PURE__ */ jsx(
123
+ Button,
124
+ {
125
+ variant: "link",
126
+ className: classes.addButton,
127
+ icon: /* @__PURE__ */ jsx(PlusCircleIcon, {}),
128
+ onClick: onAddDocument,
129
+ children: t("notebook.view.documents.add")
130
+ }
131
+ )
132
+ ] }),
133
+ (documents.length > 0 || activePending.length > 0) && /* @__PURE__ */ jsxs("div", { className: classes.documentsList, children: [
134
+ documents.map((doc) => /* @__PURE__ */ jsxs("div", { className: classes.documentItem, children: [
135
+ /* @__PURE__ */ jsx(FileTypeIcon, { fileName: doc.title }),
136
+ /* @__PURE__ */ jsx(Typography, { className: classes.fileName, children: doc.title })
137
+ ] }, doc.document_id)),
138
+ activePending.map((fileName) => /* @__PURE__ */ jsxs("div", { className: classes.documentItem, children: [
139
+ /* @__PURE__ */ jsx(FileTypeIcon, { fileName }),
140
+ /* @__PURE__ */ jsx(Typography, { className: classes.fileName, children: fileName }),
141
+ !completedFileNames?.has(fileName) && /* @__PURE__ */ jsx("div", { className: classes.spinnerContainer, children: /* @__PURE__ */ jsx(
142
+ Spinner,
143
+ {
144
+ size: "md",
145
+ "aria-label": t("notebook.view.documents.uploading")
146
+ }
147
+ ) })
148
+ ] }, `pending-${fileName}`))
149
+ ] })
150
+ ] });
151
+ };
152
+
153
+ export { DocumentSidebar };
154
+ //# sourceMappingURL=DocumentSidebar.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentSidebar.esm.js","sources":["../../../src/components/notebooks/DocumentSidebar.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, Spinner, Tooltip } from '@patternfly/react-core';\nimport { PlusCircleIcon } from '@patternfly/react-icons';\n\nimport { useTranslation } from '../../hooks/useTranslation';\nimport { SessionDocument } from '../../types';\nimport { FileTypeIcon } from './FileTypeIcon';\nimport { SidebarCollapseIcon } from './SidebarCollapseIcon';\n\nconst useStyles = makeStyles(theme => ({\n sidebar: {\n display: 'flex',\n flexDirection: 'column',\n width: '100%',\n height: '100%',\n padding: theme.spacing(2),\n overflow: 'hidden',\n },\n titleRow: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n marginBottom: theme.spacing(2),\n gap: theme.spacing(1),\n },\n title: {\n fontWeight: 500,\n fontSize: '1.25rem',\n lineHeight: '2rem',\n letterSpacing: '-0.25px',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n flex: 1,\n minWidth: 0,\n },\n collapseButton: {\n flexShrink: 0,\n },\n documentsRow: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n documentCount: {\n fontWeight: 700,\n fontSize: '1.125rem',\n lineHeight: '2rem',\n },\n addButton: {\n textTransform: 'none',\n },\n documentsList: {\n marginTop: theme.spacing(2),\n display: 'flex',\n flexDirection: 'column',\n gap: theme.spacing(0.5),\n overflowY: 'auto',\n flex: 1,\n },\n documentItem: {\n display: 'flex',\n alignItems: 'center',\n gap: theme.spacing(1),\n padding: `${theme.spacing(1)}px ${theme.spacing(0.5)}px`,\n borderRadius: 4,\n },\n fileIcon: {\n flexShrink: 0,\n color: theme.palette.grey[500],\n fontSize: '1rem',\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 spinnerContainer: {\n flexShrink: 0,\n },\n}));\n\ntype DocumentSidebarProps = {\n notebookName: string;\n documents: SessionDocument[];\n uploadingFileNames: string[];\n completedFileNames?: Set<string>;\n collapsed: boolean;\n onToggleCollapse: () => void;\n onAddDocument: () => void;\n};\n\nexport const DocumentSidebar = ({\n notebookName,\n documents,\n uploadingFileNames,\n completedFileNames,\n collapsed,\n onToggleCollapse,\n onAddDocument,\n}: DocumentSidebarProps) => {\n const classes = useStyles();\n const { t } = useTranslation();\n\n if (collapsed) {\n return null;\n }\n\n const uploadedNames = new Set(documents.map(d => d.title));\n const activePending = uploadingFileNames.filter(\n name => !uploadedNames.has(name),\n );\n const totalCount = documents.length + activePending.length;\n\n return (\n <div className={classes.sidebar}>\n <div className={classes.titleRow}>\n <Typography className={classes.title}>{notebookName}</Typography>\n <Tooltip content={t('notebook.view.sidebar.collapse')} position=\"right\">\n <Button\n variant=\"plain\"\n className={classes.collapseButton}\n onClick={onToggleCollapse}\n aria-label={t('notebook.view.sidebar.collapse')}\n >\n <SidebarCollapseIcon />\n </Button>\n </Tooltip>\n </div>\n\n <div className={classes.documentsRow}>\n <Typography className={classes.documentCount}>\n {t('notebook.view.documents.count', {\n count: totalCount,\n } as any)}\n </Typography>\n <Button\n variant=\"link\"\n className={classes.addButton}\n icon={<PlusCircleIcon />}\n onClick={onAddDocument}\n >\n {t('notebook.view.documents.add')}\n </Button>\n </div>\n\n {(documents.length > 0 || activePending.length > 0) && (\n <div className={classes.documentsList}>\n {documents.map(doc => (\n <div key={doc.document_id} className={classes.documentItem}>\n <FileTypeIcon fileName={doc.title} />\n <Typography className={classes.fileName}>{doc.title}</Typography>\n </div>\n ))}\n {activePending.map(fileName => (\n <div key={`pending-${fileName}`} className={classes.documentItem}>\n <FileTypeIcon fileName={fileName} />\n <Typography className={classes.fileName}>{fileName}</Typography>\n {!completedFileNames?.has(fileName) && (\n <div className={classes.spinnerContainer}>\n <Spinner\n size=\"md\"\n aria-label={t('notebook.view.documents.uploading')}\n />\n </div>\n )}\n </div>\n ))}\n </div>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAyBA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,OAAS,EAAA;AAAA,IACP,OAAS,EAAA,MAAA;AAAA,IACT,aAAe,EAAA,QAAA;AAAA,IACf,KAAO,EAAA,MAAA;AAAA,IACP,MAAQ,EAAA,MAAA;AAAA,IACR,OAAA,EAAS,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IACxB,QAAU,EAAA;AAAA,GACZ;AA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