@malloy-publisher/sdk 0.0.382-dev → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/README.md +115 -95
  2. package/TREE_SHAKING.md +16 -11
  3. package/bunfig.toml +7 -0
  4. package/dist/ServerProvider-CTopDUWW.cjs.js +1 -0
  5. package/dist/ServerProvider-DUFPY6Rv.es.js +4072 -0
  6. package/dist/client/api.d.ts +3718 -1507
  7. package/dist/client/configuration.d.ts +1 -1
  8. package/dist/client/index.cjs.js +1 -1
  9. package/dist/client/index.d.ts +1 -1
  10. package/dist/client/index.es.js +85 -59
  11. package/dist/components/Connections/EditConnectionDialog.d.ts +2 -1
  12. package/dist/components/Connections/common.d.ts +8 -2
  13. package/dist/components/Dashboard/Dashboard.d.ts +49 -0
  14. package/dist/components/Dashboard/DashboardTile.d.ts +48 -0
  15. package/dist/components/Dashboard/index.d.ts +2 -0
  16. package/dist/components/DataAppViewer/DataAppViewer.d.ts +23 -0
  17. package/dist/components/DataAppViewer/index.d.ts +1 -0
  18. package/dist/components/Environment/Environment.d.ts +6 -0
  19. package/dist/components/Environment/index.d.ts +2 -0
  20. package/dist/components/Home/AddEnvironmentDialog.d.ts +1 -0
  21. package/dist/components/Home/DeleteEnvironmentDialog.d.ts +5 -0
  22. package/dist/components/Home/EditEnvironmentDialog.d.ts +7 -0
  23. package/dist/components/Home/Home.d.ts +2 -2
  24. package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +14 -0
  25. package/dist/components/Materializations/CreateMaterializationDialog.d.ts +10 -0
  26. package/dist/components/Materializations/DeleteMaterializationDialog.d.ts +7 -0
  27. package/dist/components/Materializations/EnvironmentMaterializations.d.ts +7 -0
  28. package/dist/components/Materializations/ManifestView.d.ts +13 -0
  29. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +9 -0
  30. package/dist/components/Materializations/MaterializationRunsList.d.ts +15 -0
  31. package/dist/components/Materializations/Materializations.d.ts +7 -0
  32. package/dist/components/Materializations/ScheduleCard.d.ts +20 -0
  33. package/dist/components/Materializations/SectionLabel.d.ts +10 -0
  34. package/dist/components/Materializations/SetScheduleDialog.d.ts +11 -0
  35. package/dist/components/Materializations/TriggerChip.d.ts +10 -0
  36. package/dist/components/Materializations/cron.d.ts +23 -0
  37. package/dist/components/Materializations/index.d.ts +2 -0
  38. package/dist/components/Materializations/utils.d.ts +46 -0
  39. package/dist/components/Notebook/Notebook.d.ts +47 -4
  40. package/dist/components/Notebook/NotebookCell.d.ts +37 -1
  41. package/dist/components/Notebook/runPlan.d.ts +29 -0
  42. package/dist/components/Notebook/types.d.ts +10 -0
  43. package/dist/components/Package/ContentTypeIcon.d.ts +31 -0
  44. package/dist/components/Package/Package.d.ts +1 -4
  45. package/dist/components/RenderedResult/RenderedResult.d.ts +7 -1
  46. package/dist/components/RenderedResult/ResultContainer.d.ts +5 -1
  47. package/dist/components/RenderedResult/renderLogs.d.ts +6 -0
  48. package/dist/components/ResultsDialog.d.ts +6 -1
  49. package/dist/components/ServerProvider.d.ts +28 -4
  50. package/dist/components/click_helper.d.ts +10 -1
  51. package/dist/components/drill/index.d.ts +3 -0
  52. package/dist/components/drill/markDrillableCells.d.ts +55 -0
  53. package/dist/components/drill/resolveDrill.d.ts +139 -0
  54. package/dist/components/drill/useDrill.d.ts +63 -0
  55. package/dist/components/given/GivenInput.d.ts +52 -0
  56. package/dist/components/given/GivensPanel.d.ts +47 -0
  57. package/dist/components/given/filterValue.d.ts +97 -0
  58. package/dist/components/given/index.d.ts +2 -0
  59. package/dist/components/given/paramCodec.d.ts +60 -0
  60. package/dist/components/given/utils.d.ts +17 -0
  61. package/dist/components/highlighter.d.ts +6 -1
  62. package/dist/components/index.d.ts +7 -2
  63. package/dist/components/styles.d.ts +47 -0
  64. package/dist/constants/docLinks.d.ts +12 -0
  65. package/dist/{core-YNpOLuB1.cjs.js → core-hLahnv0W.cjs.js} +1 -1
  66. package/dist/{core-CjeTkq8O.es.js → core-lb28vQkR.es.js} +1 -1
  67. package/dist/github-dark-BKL9xNgN.cjs.js +1 -0
  68. package/dist/github-dark-DenFmJkN.es.js +4 -0
  69. package/dist/hooks/givenValue.d.ts +10 -0
  70. package/dist/hooks/index.d.ts +4 -0
  71. package/dist/hooks/useDimensionFiltersFromSpec.d.ts +3 -3
  72. package/dist/hooks/useDimensionFiltersQuery.d.ts +3 -3
  73. package/dist/hooks/useDimensionalFilterRangeData.d.ts +4 -4
  74. package/dist/hooks/useGivensState.d.ts +64 -0
  75. package/dist/hooks/useModelGivens.d.ts +10 -0
  76. package/dist/hooks/useSuggestOptions.d.ts +78 -0
  77. package/dist/index-DvEanVgc.cjs.js +339 -0
  78. package/dist/{index-DRDu9kIV.es.js → index-txw04ZbN.es.js} +40531 -27964
  79. package/dist/index.cjs.js +1 -1
  80. package/dist/index.d.ts +4 -1
  81. package/dist/index.es.js +79 -48
  82. package/dist/malloy-explorer.css +12 -1
  83. package/dist/sdk.css +1 -1
  84. package/dist/theme/ThemeContext.d.ts +45 -0
  85. package/dist/theme/buildMalloyExplicitTheme.d.ts +34 -0
  86. package/dist/theme/buildTableCssVars.d.ts +25 -0
  87. package/dist/theme/buildVegaThemeOverride.d.ts +16 -0
  88. package/dist/theme/defaults.d.ts +7 -0
  89. package/dist/theme/index.d.ts +8 -0
  90. package/dist/theme/keys.d.ts +20 -0
  91. package/dist/theme/readChartAnnotations.d.ts +23 -0
  92. package/dist/theme/resolveTheme.d.ts +22 -0
  93. package/dist/theme/types.d.ts +70 -0
  94. package/dist/utils/dataAppEmbed.d.ts +44 -0
  95. package/dist/utils/formatting.d.ts +1 -1
  96. package/dist/utils/malloyString.d.ts +7 -0
  97. package/dist/utils/parsing.d.ts +2 -2
  98. package/dist/utils/queryClient.d.ts +5 -0
  99. package/package.json +19 -8
  100. package/src/client-entry.ts +3 -0
  101. package/src/components/AnalyzePackageButton.tsx +9 -3
  102. package/src/components/ApiErrorDisplay.tsx +3 -0
  103. package/src/components/Connections/AddConnectionDialog.tsx +30 -2
  104. package/src/components/Connections/DeleteConnectionDialog.tsx +14 -3
  105. package/src/components/Connections/EditConnectionDialog.tsx +33 -4
  106. package/src/components/Connections/common.ts +64 -1
  107. package/src/components/DOMElement/DOMElement.tsx +3 -0
  108. package/src/components/DOMElement/index.ts +3 -0
  109. package/src/components/Dashboard/Dashboard.tsx +398 -0
  110. package/src/components/Dashboard/DashboardTile.tsx +153 -0
  111. package/src/components/Dashboard/index.ts +5 -0
  112. package/src/components/DataAppViewer/DataAppViewer.tsx +214 -0
  113. package/src/components/DataAppViewer/index.ts +4 -0
  114. package/src/components/{Project → Environment}/About.tsx +11 -4
  115. package/src/components/Environment/AddPackageDialog.tsx +202 -0
  116. package/src/components/{Project → Environment}/ConnectionExplorer.tsx +17 -14
  117. package/src/components/Environment/Connections.tsx +391 -0
  118. package/src/components/{Project → Environment}/DeletePackageDialog.tsx +8 -4
  119. package/src/components/{Project → Environment}/EditPackageDialog.tsx +21 -13
  120. package/src/components/Environment/Environment.tsx +89 -0
  121. package/src/components/Environment/Packages.tsx +206 -0
  122. package/src/components/Environment/index.ts +5 -0
  123. package/src/components/Home/{AddProjectDialog.tsx → AddEnvironmentDialog.tsx} +25 -19
  124. package/src/components/Home/{DeleteProjectDialog.tsx → DeleteEnvironmentDialog.tsx} +20 -15
  125. package/src/components/Home/{EditProjectDialog.tsx → EditEnvironmentDialog.tsx} +35 -28
  126. package/src/components/Home/Home.tsx +386 -408
  127. package/src/components/Home/index.ts +3 -0
  128. package/src/components/Loading.tsx +3 -0
  129. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +179 -0
  130. package/src/components/Materializations/CreateMaterializationDialog.tsx +112 -0
  131. package/src/components/Materializations/DeleteMaterializationDialog.tsx +109 -0
  132. package/src/components/Materializations/EnvironmentMaterializations.tsx +267 -0
  133. package/src/components/Materializations/ManifestView.tsx +87 -0
  134. package/src/components/Materializations/MaterializationDetailDialog.tsx +259 -0
  135. package/src/components/Materializations/MaterializationRunsList.tsx +256 -0
  136. package/src/components/Materializations/Materializations.tsx +355 -0
  137. package/src/components/Materializations/ScheduleCard.tsx +231 -0
  138. package/src/components/Materializations/SectionLabel.tsx +30 -0
  139. package/src/components/Materializations/SetScheduleDialog.tsx +162 -0
  140. package/src/components/Materializations/TriggerChip.tsx +44 -0
  141. package/src/components/Materializations/cron.ts +124 -0
  142. package/src/components/Materializations/index.ts +5 -0
  143. package/src/components/Materializations/utils.ts +145 -0
  144. package/src/components/Model/Model.tsx +44 -2
  145. package/src/components/Model/ModelCell.tsx +14 -5
  146. package/src/components/Model/ModelExplorer.tsx +3 -0
  147. package/src/components/Model/ModelExplorerDialog.tsx +4 -1
  148. package/src/components/Model/SourcesExplorer.tsx +9 -6
  149. package/src/components/Model/index.ts +3 -0
  150. package/src/components/Model/useModelData.ts +6 -3
  151. package/src/components/Notebook/Notebook.tsx +475 -339
  152. package/src/components/Notebook/NotebookCell.tsx +264 -25
  153. package/src/components/Notebook/index.ts +3 -0
  154. package/src/components/Notebook/runPlan.spec.ts +155 -0
  155. package/src/components/Notebook/runPlan.ts +67 -0
  156. package/src/components/Notebook/types.ts +14 -0
  157. package/src/components/Package/ContentTypeIcon.spec.ts +91 -0
  158. package/src/components/Package/ContentTypeIcon.tsx +177 -0
  159. package/src/components/Package/FileTreeView.tsx +3 -0
  160. package/src/components/Package/Models.tsx +7 -4
  161. package/src/components/Package/Package.tsx +666 -59
  162. package/src/components/Package/index.ts +3 -0
  163. package/src/components/QueryResult/QueryResult.tsx +17 -8
  164. package/src/components/QueryResult/index.ts +3 -0
  165. package/src/components/RenderedResult/RenderedResult.tsx +685 -67
  166. package/src/components/RenderedResult/ResultContainer.tsx +71 -2
  167. package/src/components/RenderedResult/index.ts +3 -0
  168. package/src/components/RenderedResult/renderLogs.spec.ts +58 -0
  169. package/src/components/RenderedResult/renderLogs.ts +43 -0
  170. package/src/components/ResultsDialog.tsx +13 -1
  171. package/src/components/ServerProvider.tsx +175 -51
  172. package/src/components/Workbook/BrowserWorkbookStorage.ts +3 -0
  173. package/src/components/Workbook/EditableMalloyCell.tsx +3 -0
  174. package/src/components/Workbook/ModelPicker.tsx +7 -4
  175. package/src/components/Workbook/MutableCell.tsx +10 -5
  176. package/src/components/Workbook/Workbook.tsx +8 -5
  177. package/src/components/Workbook/WorkbookList.tsx +3 -0
  178. package/src/components/Workbook/WorkbookManager.ts +3 -0
  179. package/src/components/Workbook/WorkbookStorage.ts +3 -0
  180. package/src/components/Workbook/WorkbookStorageProvider.tsx +3 -0
  181. package/src/components/Workbook/index.ts +3 -0
  182. package/src/components/click_helper.ts +17 -1
  183. package/src/components/drill/index.ts +28 -0
  184. package/src/components/drill/markDrillableCells.dom.spec.ts +313 -0
  185. package/src/components/drill/markDrillableCells.spec.ts +109 -0
  186. package/src/components/drill/markDrillableCells.ts +314 -0
  187. package/src/components/drill/resolveDrill.spec.ts +449 -0
  188. package/src/components/drill/resolveDrill.ts +375 -0
  189. package/src/components/drill/useDrill.tsx +203 -0
  190. package/src/components/filter/DimensionFilter.tsx +3 -0
  191. package/src/components/filter/index.ts +3 -0
  192. package/src/components/filter/utils.ts +16 -5
  193. package/src/components/given/GivenInput.spec.tsx +689 -0
  194. package/src/components/given/GivenInput.tsx +801 -0
  195. package/src/components/given/GivensPanel.spec.tsx +175 -0
  196. package/src/components/given/GivensPanel.tsx +195 -0
  197. package/src/components/given/filterValue.spec.ts +364 -0
  198. package/src/components/given/filterValue.ts +207 -0
  199. package/src/components/given/index.ts +9 -0
  200. package/src/components/given/paramCodec.spec.ts +857 -0
  201. package/src/components/given/paramCodec.ts +483 -0
  202. package/src/components/given/utils.spec.ts +60 -0
  203. package/src/components/given/utils.ts +79 -0
  204. package/src/components/highlighter.ts +22 -5
  205. package/src/components/index.ts +10 -2
  206. package/src/components/styles.ts +82 -33
  207. package/src/constants/docLinks.spec.ts +54 -0
  208. package/src/constants/docLinks.ts +46 -0
  209. package/src/hooks/givenValue.ts +13 -0
  210. package/src/hooks/index.ts +13 -0
  211. package/src/hooks/useDimensionFilters.ts +4 -7
  212. package/src/hooks/useDimensionFiltersFromSpec.ts +8 -5
  213. package/src/hooks/useDimensionFiltersQuery.ts +10 -13
  214. package/src/hooks/useDimensionalFilterRangeData.ts +11 -14
  215. package/src/hooks/useGivensState.spec.ts +449 -0
  216. package/src/hooks/useGivensState.ts +340 -0
  217. package/src/hooks/useModelGivens.ts +29 -0
  218. package/src/hooks/useQueryWithApiError.ts +3 -0
  219. package/src/hooks/useRawQueryData.ts +6 -3
  220. package/src/hooks/useSuggestOptions.spec.ts +112 -0
  221. package/src/hooks/useSuggestOptions.ts +263 -0
  222. package/src/index.ts +10 -1
  223. package/src/react-app-env.d.ts +3 -0
  224. package/src/theme/ThemeContext.tsx +86 -0
  225. package/src/theme/buildMalloyExplicitTheme.ts +61 -0
  226. package/src/theme/buildTableCssVars.spec.ts +67 -0
  227. package/src/theme/buildTableCssVars.ts +67 -0
  228. package/src/theme/buildVegaThemeOverride.spec.ts +56 -0
  229. package/src/theme/buildVegaThemeOverride.ts +47 -0
  230. package/src/theme/defaults.ts +78 -0
  231. package/src/theme/index.ts +11 -0
  232. package/src/theme/keys.ts +32 -0
  233. package/src/theme/readChartAnnotations.spec.ts +58 -0
  234. package/src/theme/readChartAnnotations.ts +69 -0
  235. package/src/theme/resolveTheme.spec.ts +160 -0
  236. package/src/theme/resolveTheme.ts +121 -0
  237. package/src/theme/types.ts +79 -0
  238. package/src/utils/dataAppEmbed.spec.ts +63 -0
  239. package/src/utils/dataAppEmbed.ts +84 -0
  240. package/src/utils/formatting.spec.ts +25 -21
  241. package/src/utils/formatting.ts +11 -7
  242. package/src/utils/malloyString.spec.ts +24 -0
  243. package/src/utils/malloyString.ts +12 -0
  244. package/src/utils/parsing.spec.ts +26 -19
  245. package/src/utils/parsing.ts +11 -6
  246. package/src/utils/queryClient.ts +17 -0
  247. package/test/README.md +141 -0
  248. package/test/setup.ts +29 -0
  249. package/tsconfig.json +12 -1
  250. package/tsconfig.spec.json +22 -0
  251. package/vite.config.ts +3 -0
  252. package/dist/ServerProvider-lOQXDlqB.cjs.js +0 -1
  253. package/dist/ServerProvider-on-8FH5Z.es.js +0 -3060
  254. package/dist/components/Home/AddProjectDialog.d.ts +0 -1
  255. package/dist/components/Home/DeleteProjectDialog.d.ts +0 -5
  256. package/dist/components/Home/EditProjectDialog.d.ts +0 -7
  257. package/dist/components/Package/Config.d.ts +0 -5
  258. package/dist/components/Package/Databases.d.ts +0 -5
  259. package/dist/components/Package/Notebooks.d.ts +0 -6
  260. package/dist/components/Project/Project.d.ts +0 -6
  261. package/dist/components/Project/index.d.ts +0 -2
  262. package/dist/index-BOLBP6_i.cjs.js +0 -233
  263. package/src/components/Package/Config.tsx +0 -97
  264. package/src/components/Package/Connections.tsx +0 -373
  265. package/src/components/Package/Databases.tsx +0 -228
  266. package/src/components/Package/Notebooks.tsx +0 -77
  267. package/src/components/Project/AddPackageDialog.tsx +0 -159
  268. package/src/components/Project/Packages.tsx +0 -191
  269. package/src/components/Project/Project.tsx +0 -52
  270. package/src/components/Project/index.ts +0 -2
  271. /package/dist/components/{Project → Environment}/About.d.ts +0 -0
  272. /package/dist/components/{Project → Environment}/AddPackageDialog.d.ts +0 -0
  273. /package/dist/components/{Project → Environment}/ConnectionExplorer.d.ts +0 -0
  274. /package/dist/components/{Package → Environment}/Connections.d.ts +0 -0
  275. /package/dist/components/{Project → Environment}/DeletePackageDialog.d.ts +0 -0
  276. /package/dist/components/{Project → Environment}/EditPackageDialog.d.ts +0 -0
  277. /package/dist/components/{Project → Environment}/Packages.d.ts +0 -0
@@ -1,77 +0,0 @@
1
- import { Box, Typography } from "@mui/material";
2
- import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
3
- import { ApiErrorDisplay } from "../ApiErrorDisplay";
4
- import { Loading } from "../Loading";
5
- import {
6
- PackageCard,
7
- PackageCardContent,
8
- PackageSectionTitle,
9
- } from "../styles";
10
- import { FileTreeView } from "./FileTreeView";
11
- import { parseResourceUri } from "../../utils/formatting";
12
- import { useServer } from "../ServerProvider";
13
-
14
- const DEFAULT_EXPANDED_FOLDERS = ["notebooks/"];
15
-
16
- interface NotebooksProps {
17
- onClickNotebookFile: (to: string, event?: React.MouseEvent) => void;
18
- resourceUri: string;
19
- }
20
-
21
- export default function Notebooks({
22
- onClickNotebookFile,
23
- resourceUri,
24
- }: NotebooksProps) {
25
- const { apiClients } = useServer();
26
- const {
27
- projectName: projectName,
28
- packageName: packageName,
29
- versionId: versionId,
30
- } = parseResourceUri(resourceUri);
31
-
32
- const { data, isError, error, isSuccess } = useQueryWithApiError({
33
- queryKey: ["notebooks", projectName, packageName, versionId],
34
- queryFn: () =>
35
- apiClients.notebooks.listNotebooks(
36
- projectName,
37
- packageName,
38
- versionId,
39
- ),
40
- });
41
-
42
- return (
43
- <PackageCard>
44
- <PackageCardContent>
45
- <PackageSectionTitle>Notebooks</PackageSectionTitle>
46
- <Box
47
- sx={{
48
- maxHeight: "200px",
49
- overflowY: "auto",
50
- }}
51
- >
52
- {!isSuccess && !isError && (
53
- <Loading text="Fetching Notebooks..." />
54
- )}
55
- {isError && (
56
- <ApiErrorDisplay
57
- error={error}
58
- context={`${projectName} > ${packageName} > Notebooks`}
59
- />
60
- )}
61
- {isSuccess && data.data.length > 0 && (
62
- <FileTreeView
63
- items={data.data.sort((a, b) => {
64
- return a.path.localeCompare(b.path);
65
- })}
66
- defaultExpandedItems={DEFAULT_EXPANDED_FOLDERS}
67
- onClickTreeNode={onClickNotebookFile}
68
- />
69
- )}
70
- {isSuccess && data.data.length === 0 && (
71
- <Typography variant="body2">No notebooks found</Typography>
72
- )}
73
- </Box>
74
- </PackageCardContent>
75
- </PackageCard>
76
- );
77
- }
@@ -1,159 +0,0 @@
1
- import React from "react";
2
- import Button from "@mui/material/Button";
3
- import TextField from "@mui/material/TextField";
4
- import Dialog from "@mui/material/Dialog";
5
- import DialogActions from "@mui/material/DialogActions";
6
- import DialogContent from "@mui/material/DialogContent";
7
- import DialogContentText from "@mui/material/DialogContentText";
8
- import DialogTitle from "@mui/material/DialogTitle";
9
- import { useState } from "react";
10
- import { Add } from "@mui/icons-material";
11
- import { Snackbar } from "@mui/material";
12
- import { Package } from "../../client";
13
- import { useQueryClient } from "@tanstack/react-query";
14
- import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
15
- import { useServer } from "../ServerProvider";
16
- import { parseResourceUri } from "../../utils/formatting";
17
-
18
- interface AddPackageDialogProps {
19
- resourceUri: string;
20
- }
21
-
22
- export default function AddPackageDialog({
23
- resourceUri,
24
- }: AddPackageDialogProps) {
25
- const [open, setOpen] = useState(false);
26
- const { apiClients } = useServer();
27
- const queryClient = useQueryClient();
28
- const [notificationMessage, setNotificationMessage] = useState("");
29
-
30
- const handleClickOpen = () => {
31
- setOpen(true);
32
- };
33
-
34
- const handleClose = () => {
35
- setOpen(false);
36
- };
37
-
38
- const { projectName } = parseResourceUri(resourceUri);
39
- const addPackage = useMutationWithApiError({
40
- async mutationFn(variables: Package) {
41
- return apiClients.packages.createPackage(projectName, {
42
- name: variables.name,
43
- description: variables.description,
44
- location: variables.location,
45
- });
46
- },
47
- onSuccess() {
48
- handleClose();
49
- setNotificationMessage("Package created successfully");
50
- queryClient.invalidateQueries({ queryKey: ["packages", projectName] });
51
- },
52
- onError(error) {
53
- setNotificationMessage(
54
- error instanceof Error
55
- ? error.message
56
- : "An unknown error occurred",
57
- );
58
- },
59
- });
60
-
61
- const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
62
- event.preventDefault();
63
- const formData = new FormData(event.currentTarget);
64
- const name = formData.get("name")?.toString();
65
- const description = formData.get("description")?.toString();
66
- const location = formData.get("location")?.toString();
67
- addPackage.mutate({ name, description, location });
68
- };
69
-
70
- return (
71
- <React.Fragment>
72
- <Button
73
- onClick={handleClickOpen}
74
- variant="contained"
75
- color="primary"
76
- startIcon={<Add />}
77
- sx={{
78
- color: "white",
79
- }}
80
- >
81
- Add Package
82
- </Button>
83
-
84
- <Dialog open={open} onClose={handleClose}>
85
- <DialogTitle>Create New Package</DialogTitle>
86
- <DialogContent>
87
- <DialogContentText>
88
- Create a new malloy package to start exploring your data.
89
- <br />
90
- <br />
91
- The location can be a GitHub/S3/GCP URL containing a package
92
- (Zipped or unzipped), or an absolute path to a directory that
93
- the publisher server has access to.
94
- <br />
95
- <br />
96
- Make sure to conform the{" "}
97
- <a
98
- href="https://github.com/malloydata/publisher/blob/main/README.md#architecture-overview"
99
- target="_blank"
100
- rel="noopener noreferrer"
101
- >
102
- Malloy Package Format
103
- </a>
104
- .
105
- </DialogContentText>
106
- <form onSubmit={handleSubmit} id="package-form">
107
- <TextField
108
- autoFocus
109
- required
110
- margin="dense"
111
- id="name"
112
- name="name"
113
- label="Package Name"
114
- type="text"
115
- fullWidth
116
- variant="standard"
117
- />
118
- <TextField
119
- id="description"
120
- name="description"
121
- label="Description"
122
- multiline
123
- fullWidth
124
- rows={4}
125
- variant="standard"
126
- />
127
- <TextField
128
- id="location"
129
- name="location"
130
- label="Location"
131
- type="text"
132
- placeholder="E.g. s3://my-bucket/my-package.zip"
133
- fullWidth
134
- variant="standard"
135
- />
136
- </form>
137
- </DialogContent>
138
- <DialogActions>
139
- <Button disabled={addPackage.isPending} onClick={handleClose}>
140
- Cancel
141
- </Button>
142
- <Button
143
- type="submit"
144
- form="package-form"
145
- loading={addPackage.isPending}
146
- >
147
- Save Changes
148
- </Button>
149
- </DialogActions>
150
- </Dialog>
151
- <Snackbar
152
- open={notificationMessage !== ""}
153
- autoHideDuration={6000}
154
- onClose={() => setNotificationMessage("")}
155
- message={notificationMessage}
156
- />
157
- </React.Fragment>
158
- );
159
- }
@@ -1,191 +0,0 @@
1
- import { MoreVert } from "@mui/icons-material";
2
- import {
3
- Box,
4
- Divider,
5
- Grid,
6
- IconButton,
7
- Menu,
8
- Typography,
9
- } from "@mui/material";
10
- import { useState } from "react";
11
- import { Package } from "../../client";
12
- import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
13
- import { encodeResourceUri, parseResourceUri } from "../../utils/formatting";
14
- import { ApiErrorDisplay } from "../ApiErrorDisplay";
15
- import { Loading } from "../Loading";
16
- import { useServer } from "../ServerProvider";
17
- import { PackageCard, PackageCardContent } from "../styles";
18
- import DeletePackageDialog from "./DeletePackageDialog";
19
- import EditPackageDialog from "./EditPackageDialog";
20
-
21
- interface PackagesProps {
22
- onSelectPackage: (to: string, event?: React.MouseEvent) => void;
23
- resourceUri: string;
24
- }
25
-
26
- const PackageMenu = ({
27
- package: p,
28
- resourceUri: packageResourceUri,
29
- }: {
30
- package: Package;
31
- resourceUri: string;
32
- }) => {
33
- const { mutable } = useServer();
34
- const [menuAnchorEl, setMenuAnchorEl] = useState<null | HTMLElement>(null);
35
- const isMenuOpen = Boolean(menuAnchorEl);
36
- const openMenu = (event: React.MouseEvent<HTMLElement>) => {
37
- setMenuAnchorEl(event.currentTarget);
38
- };
39
- const closeMenu = () => {
40
- setMenuAnchorEl(null);
41
- };
42
-
43
- return (
44
- <>
45
- {mutable && (
46
- <>
47
- <IconButton
48
- onClick={(event) => {
49
- event.stopPropagation();
50
- openMenu(event);
51
- }}
52
- aria-controls={isMenuOpen ? "package-menu" : undefined}
53
- aria-haspopup="true"
54
- aria-expanded={isMenuOpen ? "true" : undefined}
55
- >
56
- <MoreVert fontSize="small" />
57
- </IconButton>
58
- <Menu
59
- id="package-menu"
60
- aria-haspopup="true"
61
- aria-expanded={isMenuOpen ? "true" : undefined}
62
- open={isMenuOpen}
63
- anchorEl={menuAnchorEl}
64
- onClose={closeMenu}
65
- disableRestoreFocus
66
- anchorOrigin={{
67
- vertical: "top",
68
- horizontal: "left",
69
- }}
70
- transformOrigin={{
71
- vertical: "top",
72
- horizontal: "right",
73
- }}
74
- onClick={(event) => {
75
- event.stopPropagation();
76
- }}
77
- >
78
- <EditPackageDialog
79
- package={p}
80
- resourceUri={packageResourceUri}
81
- onCloseDialog={closeMenu}
82
- />
83
- <DeletePackageDialog
84
- resourceUri={packageResourceUri}
85
- onCloseDialog={closeMenu}
86
- />
87
- </Menu>
88
- </>
89
- )}
90
- </>
91
- );
92
- };
93
-
94
- export default function Packages({
95
- onSelectPackage,
96
- resourceUri,
97
- }: PackagesProps) {
98
- const { apiClients } = useServer();
99
- const { projectName: projectName } = parseResourceUri(resourceUri);
100
- const { data, isSuccess, isError, error } = useQueryWithApiError({
101
- queryKey: ["packages", projectName],
102
- queryFn: () => apiClients.packages.listPackages(projectName),
103
- });
104
-
105
- return (
106
- <>
107
- {!isSuccess && !isError && <Loading text="Fetching Packages..." />}
108
- {isSuccess && (
109
- <Grid container spacing={3} columns={12}>
110
- {data.data
111
- .sort((a, b) => {
112
- return a.name.localeCompare(b.name);
113
- })
114
- .map((p) => {
115
- const packageResourceUri = encodeResourceUri({
116
- projectName,
117
- packageName: p.name,
118
- });
119
- return (
120
- <Grid
121
- size={{ xs: 12, sm: 12, md: 12, lg: 4 }}
122
- key={p.name}
123
- >
124
- <PackageCard
125
- sx={{
126
- cursor: "pointer",
127
- transition: "all 0.2s ease-in-out",
128
- paddingTop: "8px",
129
- "&:hover": {
130
- boxShadow: "0 2px 6px rgba(0, 0, 0, 0.08)",
131
- transform: "translateY(-1px)",
132
- },
133
- }}
134
- onClick={(event) => {
135
- onSelectPackage(p.name, event);
136
- }}
137
- >
138
- <PackageCardContent>
139
- <Box
140
- display="flex"
141
- alignItems="center"
142
- justifyContent="space-between"
143
- sx={{
144
- marginBottom: "8px",
145
- }}
146
- >
147
- <Typography
148
- variant="overline"
149
- sx={{
150
- fontSize: "12px",
151
- fontWeight: "600",
152
- color: "primary.main",
153
- textTransform: "uppercase",
154
- letterSpacing: "0.5px",
155
- }}
156
- >
157
- {p.name}
158
- </Typography>
159
- <PackageMenu
160
- package={p}
161
- resourceUri={packageResourceUri}
162
- />
163
- </Box>
164
- <Divider sx={{ mb: 2 }} />
165
- <Box
166
- sx={{
167
- maxHeight: "120px",
168
- overflowY: "auto",
169
- mt: 2,
170
- }}
171
- >
172
- <Typography variant="body2">
173
- {p.description}
174
- </Typography>
175
- </Box>
176
- </PackageCardContent>
177
- </PackageCard>
178
- </Grid>
179
- );
180
- })}
181
- </Grid>
182
- )}
183
- {isError && (
184
- <ApiErrorDisplay
185
- error={error}
186
- context={`${projectName} > Packages`}
187
- />
188
- )}
189
- </>
190
- );
191
- }
@@ -1,52 +0,0 @@
1
- import { Box, Grid, Typography } from "@mui/material";
2
- import { parseResourceUri } from "../../utils/formatting";
3
- import { useServer } from "../ServerProvider";
4
- import { PackageContainer } from "../styles";
5
- import About from "./About";
6
- import AddPackageDialog from "./AddPackageDialog";
7
- import Packages from "./Packages";
8
- import { useEffect } from "react";
9
-
10
- interface ProjectProps {
11
- onSelectPackage: (to: string, event?: React.MouseEvent) => void;
12
- resourceUri: string;
13
- }
14
-
15
- export default function Project({
16
- onSelectPackage,
17
- resourceUri,
18
- }: ProjectProps) {
19
- const { mutable } = useServer();
20
- const { projectName } = parseResourceUri(resourceUri);
21
-
22
- useEffect(() => {
23
- window.scrollTo({ top: 0, behavior: "auto" });
24
- }, []);
25
-
26
- return (
27
- <>
28
- <PackageContainer>
29
- <Box
30
- display="flex"
31
- justifyContent="space-between"
32
- alignItems="center"
33
- mb={2}
34
- >
35
- <Typography variant="h6">{projectName} packages</Typography>
36
- {mutable && <AddPackageDialog resourceUri={resourceUri} />}
37
- </Box>
38
- <Grid container spacing={3} columns={12}>
39
- <Grid size={{ xs: 12, md: 12 }}>
40
- <Packages
41
- onSelectPackage={onSelectPackage}
42
- resourceUri={resourceUri}
43
- />
44
- </Grid>
45
- <Grid size={{ xs: 12, md: 12 }}>
46
- <About resourceUri={resourceUri} />
47
- </Grid>
48
- </Grid>
49
- </PackageContainer>
50
- </>
51
- );
52
- }
@@ -1,2 +0,0 @@
1
- export { default as Project } from "./Project";
2
- export { default as Packages } from "./Packages";