@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
@@ -0,0 +1,391 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { MoreVert } from "@mui/icons-material";
5
+ import StorageOutlinedIcon from "@mui/icons-material/StorageOutlined";
6
+ import {
7
+ Box,
8
+ Card,
9
+ CardContent,
10
+ Dialog,
11
+ DialogContent,
12
+ DialogTitle,
13
+ Grid,
14
+ IconButton,
15
+ Menu,
16
+ Snackbar,
17
+ Typography,
18
+ } from "@mui/material";
19
+ import { useQueryClient } from "@tanstack/react-query";
20
+ import { useState } from "react";
21
+ import { Connection as ApiConnection } from "../../client/api";
22
+ import {
23
+ useMutationWithApiError,
24
+ useQueryWithApiError,
25
+ } from "../../hooks/useQueryWithApiError";
26
+ import { encodeResourceUri, parseResourceUri } from "../../utils/formatting";
27
+ import { ApiErrorDisplay } from "../ApiErrorDisplay";
28
+ import AddConnectionDialog from "../Connections/AddConnectionDialog";
29
+ import DeleteConnectionDialog from "../Connections/DeleteConnectionDialog";
30
+ import EditConnectionDialog from "../Connections/EditConnectionDialog";
31
+ import { useServer } from "../ServerProvider";
32
+ import ConnectionExplorer from "./ConnectionExplorer";
33
+
34
+ const CONNECTION_TYPE_LABELS: Record<string, string> = {
35
+ bigquery: "BigQuery",
36
+ snowflake: "Snowflake",
37
+ postgres: "PostgreSQL",
38
+ mysql: "MySQL",
39
+ trino: "Trino",
40
+ databricks: "Databricks",
41
+ duckdb: "DuckDB",
42
+ ducklake: "DuckLake",
43
+ s3: "S3",
44
+ gcs: "GCS",
45
+ azure: "Azure",
46
+ };
47
+
48
+ function typeLabel(type: string | undefined): string {
49
+ if (!type) return "";
50
+ return CONNECTION_TYPE_LABELS[type] ?? type;
51
+ }
52
+
53
+ type ConnectionsProps = {
54
+ resourceUri: string;
55
+ };
56
+
57
+ export default function Connections({ resourceUri }: ConnectionsProps) {
58
+ const { apiClients, mutable } = useServer();
59
+ const queryClient = useQueryClient();
60
+ const { environmentName } = parseResourceUri(resourceUri);
61
+ const [notificationMessage, setNotificationMessage] = useState("");
62
+ const [selectedConnection, setSelectedConnection] = useState<string | null>(
63
+ null,
64
+ );
65
+ const selectedConnectionResourceUri = encodeResourceUri({
66
+ environmentName,
67
+ connectionName: selectedConnection,
68
+ });
69
+
70
+ const { data, isSuccess, isError, error } = useQueryWithApiError({
71
+ queryKey: ["connections", environmentName],
72
+ queryFn: () => apiClients.connections.listConnections(environmentName),
73
+ });
74
+
75
+ const handleCloseDialog = () => {
76
+ setSelectedConnection(null);
77
+ };
78
+
79
+ const addConnection = useMutationWithApiError({
80
+ mutationFn: (payload: ApiConnection) => {
81
+ return apiClients.environments.updateEnvironment(environmentName, {
82
+ name: environmentName,
83
+ connections: [...data!.data, payload],
84
+ });
85
+ },
86
+ onSuccess() {
87
+ setNotificationMessage("Connection added successfully");
88
+ queryClient.invalidateQueries({
89
+ queryKey: ["connections", environmentName],
90
+ });
91
+ },
92
+ onError(error) {
93
+ setNotificationMessage(error.message);
94
+ },
95
+ });
96
+
97
+ const updateConnection = useMutationWithApiError({
98
+ mutationFn: (payload: ApiConnection) => {
99
+ return apiClients.environments.updateEnvironment(environmentName, {
100
+ name: environmentName,
101
+ connections: data!.data.map((conn) =>
102
+ conn.name === payload.name ? payload : conn,
103
+ ),
104
+ });
105
+ },
106
+ onSuccess(_data, variables) {
107
+ setNotificationMessage(
108
+ `Connection ${variables.name} updated successfully`,
109
+ );
110
+ queryClient.invalidateQueries({
111
+ queryKey: ["connections", environmentName],
112
+ });
113
+ },
114
+ onError(error) {
115
+ setNotificationMessage(error.message);
116
+ },
117
+ });
118
+
119
+ const deleteConnection = useMutationWithApiError({
120
+ mutationFn: (payload: ApiConnection) => {
121
+ return apiClients.environments.updateEnvironment(environmentName, {
122
+ name: environmentName,
123
+ connections: data!.data.filter(
124
+ (conn) => conn.name !== payload.name,
125
+ ),
126
+ });
127
+ },
128
+ onSuccess(_data, variables) {
129
+ setNotificationMessage(
130
+ `Connection ${variables.name} deleted successfully`,
131
+ );
132
+ queryClient.invalidateQueries({
133
+ queryKey: ["connections", environmentName],
134
+ });
135
+ },
136
+ onError(error) {
137
+ setNotificationMessage(error.message);
138
+ },
139
+ });
140
+
141
+ const connections = isSuccess
142
+ ? [...data.data].sort((a, b) =>
143
+ (a.name ?? "").localeCompare(b.name ?? ""),
144
+ )
145
+ : [];
146
+
147
+ const isMutating =
148
+ addConnection.isPending ||
149
+ updateConnection.isPending ||
150
+ deleteConnection.isPending;
151
+
152
+ return (
153
+ <Box>
154
+ <Box
155
+ sx={{
156
+ display: "flex",
157
+ alignItems: "flex-start",
158
+ justifyContent: "space-between",
159
+ mb: 3,
160
+ }}
161
+ >
162
+ <Box>
163
+ <Typography
164
+ variant="h6"
165
+ sx={{ fontWeight: 600, letterSpacing: "-0.025em" }}
166
+ >
167
+ Connections
168
+ </Typography>
169
+ <Typography variant="body2" color="text.secondary">
170
+ Database connections available to packages in this environment
171
+ </Typography>
172
+ </Box>
173
+ {mutable && isSuccess && (
174
+ <AddConnectionDialog
175
+ onSubmit={(payload) => addConnection.mutateAsync(payload)}
176
+ isSubmitting={addConnection.isPending}
177
+ />
178
+ )}
179
+ </Box>
180
+
181
+ {!isSuccess && !isError && (
182
+ <Typography variant="body2" color="text.secondary">
183
+ Fetching Connections...
184
+ </Typography>
185
+ )}
186
+ {isError && (
187
+ <ApiErrorDisplay
188
+ error={error}
189
+ context={`${environmentName} > Connections`}
190
+ />
191
+ )}
192
+ {isSuccess && connections.length === 0 && (
193
+ <Typography variant="body2" color="text.secondary">
194
+ No connections yet.
195
+ </Typography>
196
+ )}
197
+ {isSuccess && connections.length > 0 && (
198
+ <Grid container spacing={2}>
199
+ {connections.map((conn) => (
200
+ <Grid size={{ xs: 12, sm: 6, md: 4 }} key={conn.name}>
201
+ <ConnectionCard
202
+ connection={conn}
203
+ mutable={mutable}
204
+ isMutating={isMutating}
205
+ onOpenExplorer={() =>
206
+ setSelectedConnection(conn.name ?? null)
207
+ }
208
+ onEdit={(payload) =>
209
+ updateConnection.mutateAsync(payload)
210
+ }
211
+ onDelete={(payload) => {
212
+ if (!conn.resource) {
213
+ deleteConnection.mutateAsync(payload);
214
+ } else {
215
+ setNotificationMessage(
216
+ "Cannot delete this connection",
217
+ );
218
+ }
219
+ }}
220
+ />
221
+ </Grid>
222
+ ))}
223
+ </Grid>
224
+ )}
225
+
226
+ <Snackbar
227
+ open={notificationMessage !== ""}
228
+ autoHideDuration={6000}
229
+ onClose={() => setNotificationMessage("")}
230
+ message={notificationMessage}
231
+ />
232
+
233
+ <Dialog
234
+ open={selectedConnection !== null}
235
+ onClose={handleCloseDialog}
236
+ maxWidth="lg"
237
+ fullWidth
238
+ >
239
+ <DialogTitle>
240
+ Connection Explorer: {selectedConnection}
241
+ <IconButton
242
+ aria-label="close"
243
+ onClick={handleCloseDialog}
244
+ sx={{ position: "absolute", right: 8, top: 8 }}
245
+ >
246
+ <Box
247
+ sx={{
248
+ width: 24,
249
+ height: 24,
250
+ display: "flex",
251
+ alignItems: "center",
252
+ justifyContent: "center",
253
+ }}
254
+ >
255
+ X
256
+ </Box>
257
+ </IconButton>
258
+ </DialogTitle>
259
+ <DialogContent>
260
+ {selectedConnection && (
261
+ <ConnectionExplorer
262
+ resourceUri={selectedConnectionResourceUri}
263
+ connectionName={selectedConnection}
264
+ connection={data?.data?.find(
265
+ (c) => c.name === selectedConnection,
266
+ )}
267
+ />
268
+ )}
269
+ </DialogContent>
270
+ </Dialog>
271
+ </Box>
272
+ );
273
+ }
274
+
275
+ type ConnectionCardProps = {
276
+ connection: ApiConnection;
277
+ mutable: boolean;
278
+ isMutating: boolean;
279
+ onOpenExplorer: () => void;
280
+ onEdit: (connection: ApiConnection) => Promise<unknown>;
281
+ onDelete: (connection: ApiConnection) => Promise<unknown> | void;
282
+ };
283
+
284
+ function ConnectionCard({
285
+ connection,
286
+ mutable,
287
+ isMutating,
288
+ onOpenExplorer,
289
+ onEdit,
290
+ onDelete,
291
+ }: ConnectionCardProps) {
292
+ const [menuAnchorEl, setMenuAnchorEl] = useState<null | HTMLElement>(null);
293
+ const menuOpen = Boolean(menuAnchorEl);
294
+
295
+ const handleMenuClick = (event: React.MouseEvent<HTMLElement>) => {
296
+ event.stopPropagation();
297
+ setMenuAnchorEl(event.currentTarget);
298
+ };
299
+
300
+ const handleMenuClose = () => {
301
+ setMenuAnchorEl(null);
302
+ };
303
+
304
+ return (
305
+ <Card
306
+ variant="outlined"
307
+ onClick={onOpenExplorer}
308
+ sx={{
309
+ height: "100%",
310
+ cursor: "pointer",
311
+ borderRadius: 3,
312
+ borderColor: "divider",
313
+ boxShadow: "none",
314
+ transition: "all 0.2s ease-in-out",
315
+ "&:hover": { boxShadow: 2, borderColor: "primary.main" },
316
+ }}
317
+ >
318
+ <CardContent sx={{ p: 2.5, "&:last-child": { pb: 2.5 } }}>
319
+ <Box sx={{ display: "flex", alignItems: "flex-start", gap: 1.5 }}>
320
+ <Box
321
+ sx={{
322
+ width: 36,
323
+ height: 36,
324
+ borderRadius: 1.5,
325
+ bgcolor: "warning.light",
326
+ display: "flex",
327
+ alignItems: "center",
328
+ justifyContent: "center",
329
+ flexShrink: 0,
330
+ color: "warning.main",
331
+ }}
332
+ >
333
+ <StorageOutlinedIcon sx={{ fontSize: 20 }} />
334
+ </Box>
335
+ <Box sx={{ flex: 1, minWidth: 0 }}>
336
+ <Typography
337
+ variant="subtitle1"
338
+ component="h6"
339
+ noWrap
340
+ sx={{ fontWeight: 600, mb: 0.5 }}
341
+ >
342
+ {connection.name}
343
+ </Typography>
344
+ <Typography variant="body2" color="text.secondary" noWrap>
345
+ {typeLabel(connection.type)}
346
+ </Typography>
347
+ </Box>
348
+ {mutable && (
349
+ <>
350
+ <IconButton
351
+ size="small"
352
+ onClick={handleMenuClick}
353
+ aria-label={`Connection actions for ${connection.name ?? ""}`.trim()}
354
+ sx={{ flexShrink: 0, mt: -0.5, mr: -0.5 }}
355
+ >
356
+ <MoreVert fontSize="small" />
357
+ </IconButton>
358
+ <Menu
359
+ anchorEl={menuAnchorEl}
360
+ open={menuOpen}
361
+ onClose={handleMenuClose}
362
+ onClick={(e) => e.stopPropagation()}
363
+ anchorOrigin={{
364
+ vertical: "bottom",
365
+ horizontal: "right",
366
+ }}
367
+ transformOrigin={{
368
+ vertical: "top",
369
+ horizontal: "right",
370
+ }}
371
+ >
372
+ <EditConnectionDialog
373
+ connection={connection}
374
+ onSubmit={onEdit}
375
+ isSubmitting={isMutating}
376
+ onCloseDialog={handleMenuClose}
377
+ />
378
+ <DeleteConnectionDialog
379
+ connection={connection}
380
+ onCloseDialog={handleMenuClose}
381
+ isMutating={isMutating}
382
+ onDelete={() => onDelete(connection)}
383
+ />
384
+ </Menu>
385
+ </>
386
+ )}
387
+ </Box>
388
+ </CardContent>
389
+ </Card>
390
+ );
391
+ }
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import React, { useState } from "react";
2
5
  import Button from "@mui/material/Button";
3
6
  import Dialog from "@mui/material/Dialog";
@@ -13,6 +16,7 @@ import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
13
16
  import { useServer } from "../ServerProvider";
14
17
  import { useQueryClient } from "@tanstack/react-query";
15
18
  import { parseResourceUri } from "../../utils/formatting";
19
+ import { MALLOY_BRAND } from "../styles";
16
20
 
17
21
  export default function DeletePackageDialog({
18
22
  resourceUri,
@@ -32,11 +36,11 @@ export default function DeletePackageDialog({
32
36
  setOpen(false);
33
37
  onCloseDialog();
34
38
  };
35
- const { projectName, packageName } = parseResourceUri(resourceUri);
39
+ const { environmentName, packageName } = parseResourceUri(resourceUri);
36
40
 
37
41
  const deletePackage = useMutationWithApiError({
38
42
  mutationFn: () =>
39
- apiClients.packages.deletePackage(projectName, packageName),
43
+ apiClients.packages.deletePackage(environmentName, packageName),
40
44
  onSuccess() {
41
45
  handleClose();
42
46
  queryClient.invalidateQueries({ queryKey: ["packages"] });
@@ -90,8 +94,8 @@ export default function DeletePackageDialog({
90
94
  variant="outlined"
91
95
  onClick={handleClose}
92
96
  style={{
93
- borderColor: "#14b3cb",
94
- color: "#14b3cb",
97
+ borderColor: MALLOY_BRAND.teal,
98
+ color: MALLOY_BRAND.teal,
95
99
  }}
96
100
  >
97
101
  Cancel
@@ -1,19 +1,21 @@
1
- import React from "react";
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { Edit } from "@mui/icons-material";
5
+ import { ListItemIcon, ListItemText, MenuItem, Snackbar } from "@mui/material";
2
6
  import Button from "@mui/material/Button";
3
- import TextField from "@mui/material/TextField";
4
7
  import Dialog from "@mui/material/Dialog";
5
8
  import DialogActions from "@mui/material/DialogActions";
6
9
  import DialogContent from "@mui/material/DialogContent";
7
10
  import DialogContentText from "@mui/material/DialogContentText";
8
11
  import DialogTitle from "@mui/material/DialogTitle";
9
- import { useState } from "react";
10
- import { Edit } from "@mui/icons-material";
11
- import { MenuItem, ListItemIcon, ListItemText, Snackbar } from "@mui/material";
12
- import { Package } from "../../client";
12
+ import TextField from "@mui/material/TextField";
13
13
  import { useQueryClient } from "@tanstack/react-query";
14
+ import React, { useState } from "react";
15
+ import { Package } from "../../client";
14
16
  import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
15
- import { useServer } from "../ServerProvider";
16
17
  import { parseResourceUri } from "../../utils/formatting";
18
+ import { useServer } from "../ServerProvider";
17
19
 
18
20
  interface EditPackageDialogProps {
19
21
  package: Package;
@@ -40,18 +42,24 @@ export default function EditPackageDialog({
40
42
  onCloseDialog();
41
43
  };
42
44
 
43
- const { packageName, projectName } = parseResourceUri(resourceUri);
45
+ const { packageName, environmentName } = parseResourceUri(resourceUri);
44
46
  const editPackage = useMutationWithApiError({
45
47
  async mutationFn(variables: { description: string }) {
46
- return apiClients.packages.updatePackage(projectName, packageName, {
47
- name: packageName,
48
- description: variables.description,
49
- });
48
+ return apiClients.packages.updatePackage(
49
+ environmentName,
50
+ packageName,
51
+ {
52
+ name: packageName,
53
+ description: variables.description,
54
+ },
55
+ );
50
56
  },
51
57
  onSuccess() {
52
58
  handleClose();
53
59
  setNotificationMessage("Package updated successfully");
54
- queryClient.invalidateQueries({ queryKey: ["packages", projectName] });
60
+ queryClient.invalidateQueries({
61
+ queryKey: ["packages", environmentName],
62
+ });
55
63
  },
56
64
  onError(error) {
57
65
  setNotificationMessage(
@@ -0,0 +1,89 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { Box, Container, Stack, Typography } from "@mui/material";
5
+ import { useEffect } from "react";
6
+ import { parseResourceUri } from "../../utils/formatting";
7
+ import { EnvironmentMaterializations } from "../Materializations";
8
+ import { useServer } from "../ServerProvider";
9
+ import About from "./About";
10
+ import AddPackageDialog from "./AddPackageDialog";
11
+ import Connections from "./Connections";
12
+ import Packages from "./Packages";
13
+
14
+ interface EnvironmentProps {
15
+ onSelectPackage: (to: string, event?: React.MouseEvent) => void;
16
+ resourceUri: string;
17
+ }
18
+
19
+ export default function Environment({
20
+ onSelectPackage,
21
+ resourceUri,
22
+ }: EnvironmentProps) {
23
+ const { mutable } = useServer();
24
+ const { environmentName } = parseResourceUri(resourceUri);
25
+
26
+ useEffect(() => {
27
+ window.scrollTo({ top: 0, behavior: "auto" });
28
+ }, []);
29
+
30
+ return (
31
+ <Container
32
+ maxWidth={false}
33
+ sx={{ maxWidth: 1024, mx: "auto", px: 4, py: 3 }}
34
+ >
35
+ <Box sx={{ mb: 5 }}>
36
+ <Typography
37
+ variant="h4"
38
+ component="h1"
39
+ sx={{ fontWeight: 600, letterSpacing: "-0.025em", mb: 0.5 }}
40
+ >
41
+ {environmentName}
42
+ </Typography>
43
+ <Typography variant="body2" color="text.secondary">
44
+ Manage packages and database connections in this environment.
45
+ Open a package to explore its models and notebooks.
46
+ </Typography>
47
+ </Box>
48
+
49
+ <Box sx={{ mb: 5 }}>
50
+ <Stack
51
+ direction="row"
52
+ justifyContent="space-between"
53
+ alignItems="flex-start"
54
+ sx={{ mb: 3 }}
55
+ >
56
+ <Box>
57
+ <Typography
58
+ variant="h6"
59
+ sx={{ fontWeight: 600, letterSpacing: "-0.025em" }}
60
+ >
61
+ Packages
62
+ </Typography>
63
+ <Typography variant="body2" color="text.secondary">
64
+ Published packages available for use in this environment
65
+ </Typography>
66
+ </Box>
67
+ {mutable && <AddPackageDialog resourceUri={resourceUri} />}
68
+ </Stack>
69
+ <Packages
70
+ onSelectPackage={onSelectPackage}
71
+ resourceUri={resourceUri}
72
+ />
73
+ </Box>
74
+
75
+ <Box sx={{ mb: 5 }}>
76
+ <Connections resourceUri={resourceUri} />
77
+ </Box>
78
+
79
+ <Box sx={{ mb: 5 }}>
80
+ <EnvironmentMaterializations
81
+ resourceUri={resourceUri}
82
+ onClickPackageFile={onSelectPackage}
83
+ />
84
+ </Box>
85
+
86
+ <About resourceUri={resourceUri} />
87
+ </Container>
88
+ );
89
+ }