@malloy-publisher/sdk 0.3.0 → 0.4.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.
- package/README.md +22 -9
- package/dist/DocumentStorageProvider-CyOJ0hqf.es.js +24443 -0
- package/dist/DocumentStorageProvider-DGPQEd_l.cjs.js +134 -0
- package/dist/RenderedResult-BnPzJ9Jf.es.js +549 -0
- package/dist/RenderedResult-Dp22kZsQ.cjs.js +115 -0
- package/dist/{ServerProvider-DSK9rfSY.es.js → ServerProvider-BWOEKg0O.es.js} +1256 -1318
- package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
- package/dist/builder/index.cjs.js +105 -0
- package/dist/builder/index.d.ts +2 -0
- package/dist/builder/index.es.js +9482 -0
- package/dist/builder-entry.d.ts +8 -0
- package/dist/client/api.d.ts +100 -42
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +30 -0
- package/dist/components/BackLink.d.ts +32 -0
- package/dist/components/Dashboard/Dashboard.d.ts +19 -14
- package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
- package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
- package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
- package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
- package/dist/components/Dashboard/TileCard.d.ts +44 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +7 -3
- package/dist/components/Dashboard/telemetry.d.ts +48 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +31 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +118 -0
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +30 -0
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
- package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
- package/dist/components/DashboardBuilder/controls.d.ts +157 -0
- package/dist/components/DashboardBuilder/diff.d.ts +35 -0
- package/dist/components/DashboardBuilder/document.d.ts +218 -0
- package/dist/components/DashboardBuilder/layout.d.ts +71 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
- package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
- package/dist/components/DashboardBuilder/preview.d.ts +60 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +53 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
- package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
- package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +7 -0
- package/dist/components/DocumentStorage/index.d.ts +1 -1
- package/dist/components/FloatingIconButton.d.ts +16 -0
- package/dist/components/ItemRow.d.ts +38 -0
- package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
- package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
- package/dist/components/Materializations/Materializations.d.ts +7 -3
- package/dist/components/Materializations/ScopeButton.d.ts +18 -0
- package/dist/components/Materializations/SectionLabel.d.ts +7 -4
- package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
- package/dist/components/Materializations/index.d.ts +0 -1
- package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
- package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
- package/dist/components/Package/index.d.ts +0 -1
- package/dist/components/PackageSection.d.ts +23 -0
- package/dist/components/Prose.d.ts +46 -0
- package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
- package/dist/components/RenderedResult/index.d.ts +1 -0
- package/dist/components/buttons.d.ts +53 -0
- package/dist/components/drill/index.d.ts +1 -1
- package/dist/components/drill/resolveDrill.d.ts +22 -0
- package/dist/components/drill/useDrill.d.ts +11 -2
- package/dist/components/index.d.ts +6 -0
- package/dist/components/styles.d.ts +49 -44
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useCrudMutation.d.ts +42 -0
- package/dist/hooks/useDocumentControls.d.ts +70 -0
- package/dist/hooks/useQueryResult.d.ts +40 -0
- package/dist/index.cjs.js +22 -273
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +16888 -44451
- package/dist/telemetry/consoleEvents.d.ts +60 -0
- package/dist/utils/malloyLiteral.d.ts +11 -0
- package/dist/utils/sha256.d.ts +2 -0
- package/package.json +24 -9
- package/src/builder-entry.ts +55 -0
- package/src/components/AppDialog.tsx +115 -0
- package/src/components/BackLink.tsx +83 -0
- package/src/components/Connections/AddConnectionDialog.tsx +50 -70
- package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
- package/src/components/Connections/EditConnectionDialog.tsx +54 -73
- package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
- package/src/components/Dashboard/Dashboard.tsx +165 -175
- package/src/components/Dashboard/DashboardBar.tsx +88 -0
- package/src/components/Dashboard/DashboardGrid.tsx +124 -0
- package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
- package/src/components/Dashboard/DashboardTile.tsx +66 -123
- package/src/components/Dashboard/ExploreDialog.tsx +84 -0
- package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
- package/src/components/Dashboard/RowsDialog.tsx +234 -0
- package/src/components/Dashboard/TileCard.tsx +120 -0
- package/src/components/Dashboard/index.ts +2 -0
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +70 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +33 -2
- package/src/components/Dashboard/telemetry.ts +51 -0
- package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
- package/src/components/DashboardBuilder/AddTileDialog.tsx +247 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +852 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +666 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +188 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +567 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +122 -0
- package/src/components/DashboardBuilder/DrillDialog.tsx +269 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +562 -0
- package/src/components/DashboardBuilder/FilterStrip.tsx +126 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
- package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
- package/src/components/DashboardBuilder/catalog.ts +225 -0
- package/src/components/DashboardBuilder/controls.spec.ts +243 -0
- package/src/components/DashboardBuilder/controls.ts +398 -0
- package/src/components/DashboardBuilder/diff.spec.ts +44 -0
- package/src/components/DashboardBuilder/diff.ts +93 -0
- package/src/components/DashboardBuilder/document.ts +209 -0
- package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
- package/src/components/DashboardBuilder/layout.ts +143 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
- package/src/components/DashboardBuilder/malloyText.ts +151 -0
- package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
- package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
- package/src/components/DashboardBuilder/newDashboard.ts +48 -0
- package/src/components/DashboardBuilder/preview.spec.ts +149 -0
- package/src/components/DashboardBuilder/preview.ts +172 -0
- package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
- package/src/components/DashboardBuilder/readDocument.ts +467 -0
- package/src/components/DashboardBuilder/sortable.tsx +151 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +1161 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +1135 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +311 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +201 -0
- package/src/components/DashboardBuilder/useDraft.ts +43 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
- package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
- package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
- package/src/components/DashboardBuilder/useTileResize.ts +110 -0
- package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
- package/src/components/DocumentStorage/DocumentStorageProvider.tsx +12 -0
- package/src/components/DocumentStorage/index.ts +1 -0
- package/src/components/Environment/About.tsx +16 -62
- package/src/components/Environment/AddPackageDialog.tsx +85 -154
- package/src/components/Environment/Connections.tsx +125 -205
- package/src/components/Environment/DeletePackageDialog.tsx +32 -77
- package/src/components/Environment/EditPackageDialog.tsx +46 -58
- package/src/components/Environment/Environment.tsx +34 -36
- package/src/components/Environment/Packages.tsx +63 -128
- package/src/components/FloatingIconButton.tsx +41 -0
- package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
- package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
- package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
- package/src/components/Home/Home.tsx +101 -214
- package/src/components/ItemRow.tsx +165 -0
- package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
- package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
- package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
- package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
- package/src/components/Materializations/Materializations.tsx +137 -140
- package/src/components/Materializations/ScopeButton.tsx +85 -0
- package/src/components/Materializations/SectionLabel.tsx +7 -4
- package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
- package/src/components/Materializations/TriggerLabel.tsx +36 -0
- package/src/components/Materializations/cron.spec.ts +113 -0
- package/src/components/Materializations/index.ts +0 -1
- package/src/components/Materializations/utils.spec.ts +182 -0
- package/src/components/Model/Model.tsx +6 -23
- package/src/components/Model/ModelCell.tsx +33 -72
- package/src/components/Notebook/Notebook.tsx +25 -88
- package/src/components/Notebook/NotebookCell.tsx +35 -183
- package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
- package/src/components/Package/ContentTypeIcon.tsx +10 -12
- package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
- package/src/components/Package/NewDashboardDialog.tsx +265 -0
- package/src/components/Package/Package.tsx +179 -238
- package/src/components/Package/index.ts +0 -1
- package/src/components/PackageSection.tsx +85 -0
- package/src/components/Prose.spec.tsx +85 -0
- package/src/components/Prose.tsx +179 -0
- package/src/components/QueryResult/QueryResult.tsx +15 -43
- package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
- package/src/components/RenderedResult/RenderedResult.tsx +22 -8
- package/src/components/RenderedResult/ResultContainer.tsx +4 -12
- package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
- package/src/components/RenderedResult/ResultPanel.tsx +73 -0
- package/src/components/RenderedResult/index.ts +1 -0
- package/src/components/ResultsDialog.tsx +8 -32
- package/src/components/buttons.tsx +114 -0
- package/src/components/designSystem.spec.tsx +316 -0
- package/src/components/drill/index.ts +1 -0
- package/src/components/drill/resolveDrill.ts +22 -1
- package/src/components/drill/useDrill.spec.tsx +94 -0
- package/src/components/drill/useDrill.tsx +52 -12
- package/src/components/given/GivensPanel.tsx +1 -1
- package/src/components/given/paramCodec.spec.ts +1 -1
- package/src/components/index.ts +16 -0
- package/src/components/styles.ts +49 -122
- package/src/hooks/index.ts +13 -0
- package/src/hooks/useCrudMutation.spec.tsx +119 -0
- package/src/hooks/useCrudMutation.tsx +85 -0
- package/src/hooks/useDocumentControls.ts +170 -0
- package/src/hooks/useQueryResult.ts +82 -0
- package/src/index.ts +9 -0
- package/src/telemetry/consoleEvents.spec.ts +130 -0
- package/src/telemetry/consoleEvents.ts +124 -0
- package/src/theme/defaults.ts +34 -23
- package/src/theme/resolveTheme.spec.ts +9 -4
- package/src/theme/resolveTheme.ts +12 -8
- package/src/utils/malloyLiteral.spec.ts +43 -0
- package/src/utils/malloyLiteral.ts +76 -0
- package/src/utils/sha256.ts +13 -0
- package/test/README.md +1 -1
- package/test/serverProvider.tsx +5 -2
- package/vite.config.ts +5 -0
- package/dist/ServerProvider-CGnLjzag.cjs.js +0 -1
- package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
- package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
- package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
- package/dist/components/Materializations/TriggerChip.d.ts +0 -10
- package/dist/components/Package/Models.d.ts +0 -6
- package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
- package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
- package/src/components/Materializations/ScheduleCard.tsx +0 -231
- package/src/components/Materializations/TriggerChip.tsx +0 -44
- package/src/components/Package/Models.tsx +0 -71
|
@@ -3,19 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { MoreVert } from "@mui/icons-material";
|
|
5
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";
|
|
6
|
+
import { IconButton, Menu, Snackbar, Stack, Typography } from "@mui/material";
|
|
19
7
|
import { useQueryClient } from "@tanstack/react-query";
|
|
20
8
|
import { useState } from "react";
|
|
21
9
|
import { Connection as ApiConnection } from "../../client/api";
|
|
@@ -25,6 +13,11 @@ import {
|
|
|
25
13
|
} from "../../hooks/useQueryWithApiError";
|
|
26
14
|
import { encodeResourceUri, parseResourceUri } from "../../utils/formatting";
|
|
27
15
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
16
|
+
import { AppDialog } from "../AppDialog";
|
|
17
|
+
import { ItemRow } from "../ItemRow";
|
|
18
|
+
import { PackageSection } from "../PackageSection";
|
|
19
|
+
import { reporting } from "../../telemetry/consoleEvents";
|
|
20
|
+
import { SURFACE_TINT } from "../styles";
|
|
28
21
|
import AddConnectionDialog from "../Connections/AddConnectionDialog";
|
|
29
22
|
import DeleteConnectionDialog from "../Connections/DeleteConnectionDialog";
|
|
30
23
|
import EditConnectionDialog from "../Connections/EditConnectionDialog";
|
|
@@ -72,17 +65,13 @@ export default function Connections({ resourceUri }: ConnectionsProps) {
|
|
|
72
65
|
queryFn: () => apiClients.connections.listConnections(environmentName),
|
|
73
66
|
});
|
|
74
67
|
|
|
75
|
-
const handleCloseDialog = () => {
|
|
76
|
-
setSelectedConnection(null);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
68
|
const addConnection = useMutationWithApiError({
|
|
80
|
-
mutationFn: (payload: ApiConnection) =>
|
|
81
|
-
|
|
69
|
+
mutationFn: reporting("connection", "create", (payload: ApiConnection) =>
|
|
70
|
+
apiClients.environments.updateEnvironment(environmentName, {
|
|
82
71
|
name: environmentName,
|
|
83
72
|
connections: [...data!.data, payload],
|
|
84
|
-
})
|
|
85
|
-
|
|
73
|
+
}),
|
|
74
|
+
),
|
|
86
75
|
onSuccess() {
|
|
87
76
|
setNotificationMessage("Connection added successfully");
|
|
88
77
|
queryClient.invalidateQueries({
|
|
@@ -95,14 +84,14 @@ export default function Connections({ resourceUri }: ConnectionsProps) {
|
|
|
95
84
|
});
|
|
96
85
|
|
|
97
86
|
const updateConnection = useMutationWithApiError({
|
|
98
|
-
mutationFn: (payload: ApiConnection) =>
|
|
99
|
-
|
|
87
|
+
mutationFn: reporting("connection", "update", (payload: ApiConnection) =>
|
|
88
|
+
apiClients.environments.updateEnvironment(environmentName, {
|
|
100
89
|
name: environmentName,
|
|
101
90
|
connections: data!.data.map((conn) =>
|
|
102
91
|
conn.name === payload.name ? payload : conn,
|
|
103
92
|
),
|
|
104
|
-
})
|
|
105
|
-
|
|
93
|
+
}),
|
|
94
|
+
),
|
|
106
95
|
onSuccess(_data, variables) {
|
|
107
96
|
setNotificationMessage(
|
|
108
97
|
`Connection ${variables.name} updated successfully`,
|
|
@@ -122,15 +111,19 @@ export default function Connections({ resourceUri }: ConnectionsProps) {
|
|
|
122
111
|
// row for one that went away, so a deleted connection came back on the
|
|
123
112
|
// next boot. This path removes the row and cleans up a duckdb/ducklake
|
|
124
113
|
// connection's database file.
|
|
125
|
-
mutationFn: (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
114
|
+
mutationFn: reporting(
|
|
115
|
+
"connection",
|
|
116
|
+
"delete",
|
|
117
|
+
(payload: ApiConnection) => {
|
|
118
|
+
if (!payload.name) {
|
|
119
|
+
throw new Error("Cannot delete a connection with no name");
|
|
120
|
+
}
|
|
121
|
+
return apiClients.connections.deleteConnection(
|
|
122
|
+
environmentName,
|
|
123
|
+
payload.name,
|
|
124
|
+
);
|
|
125
|
+
},
|
|
126
|
+
),
|
|
134
127
|
onSuccess(_data, variables) {
|
|
135
128
|
setNotificationMessage(
|
|
136
129
|
`Connection ${variables.name} deleted successfully`,
|
|
@@ -156,34 +149,23 @@ export default function Connections({ resourceUri }: ConnectionsProps) {
|
|
|
156
149
|
deleteConnection.isPending;
|
|
157
150
|
|
|
158
151
|
return (
|
|
159
|
-
<
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
Database connections available to packages in this environment
|
|
177
|
-
</Typography>
|
|
178
|
-
</Box>
|
|
179
|
-
{mutable && isSuccess && (
|
|
180
|
-
<AddConnectionDialog
|
|
181
|
-
onSubmit={(payload) => addConnection.mutateAsync(payload)}
|
|
182
|
-
isSubmitting={addConnection.isPending}
|
|
183
|
-
/>
|
|
184
|
-
)}
|
|
185
|
-
</Box>
|
|
186
|
-
|
|
152
|
+
<PackageSection
|
|
153
|
+
title="Connections"
|
|
154
|
+
{...(isSuccess ? { count: connections.length } : {})}
|
|
155
|
+
description="Database connections available to packages in this environment"
|
|
156
|
+
{...(mutable && isSuccess
|
|
157
|
+
? {
|
|
158
|
+
action: (
|
|
159
|
+
<AddConnectionDialog
|
|
160
|
+
onSubmit={(payload) =>
|
|
161
|
+
addConnection.mutateAsync(payload)
|
|
162
|
+
}
|
|
163
|
+
isSubmitting={addConnection.isPending}
|
|
164
|
+
/>
|
|
165
|
+
),
|
|
166
|
+
}
|
|
167
|
+
: {})}
|
|
168
|
+
>
|
|
187
169
|
{!isSuccess && !isError && (
|
|
188
170
|
<Typography variant="body2" color="text.secondary">
|
|
189
171
|
Fetching Connections...
|
|
@@ -201,26 +183,23 @@ export default function Connections({ resourceUri }: ConnectionsProps) {
|
|
|
201
183
|
</Typography>
|
|
202
184
|
)}
|
|
203
185
|
{isSuccess && connections.length > 0 && (
|
|
204
|
-
<
|
|
186
|
+
<Stack>
|
|
205
187
|
{connections.map((conn) => (
|
|
206
|
-
<
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
/>
|
|
221
|
-
</Grid>
|
|
188
|
+
<ConnectionRow
|
|
189
|
+
key={conn.name}
|
|
190
|
+
connection={conn}
|
|
191
|
+
mutable={mutable}
|
|
192
|
+
isMutating={isMutating}
|
|
193
|
+
onOpenExplorer={() =>
|
|
194
|
+
setSelectedConnection(conn.name ?? null)
|
|
195
|
+
}
|
|
196
|
+
onEdit={(payload) => updateConnection.mutateAsync(payload)}
|
|
197
|
+
onDelete={(payload) =>
|
|
198
|
+
deleteConnection.mutateAsync(payload)
|
|
199
|
+
}
|
|
200
|
+
/>
|
|
222
201
|
))}
|
|
223
|
-
</
|
|
202
|
+
</Stack>
|
|
224
203
|
)}
|
|
225
204
|
|
|
226
205
|
<Snackbar
|
|
@@ -230,45 +209,24 @@ export default function Connections({ resourceUri }: ConnectionsProps) {
|
|
|
230
209
|
message={notificationMessage}
|
|
231
210
|
/>
|
|
232
211
|
|
|
233
|
-
<
|
|
212
|
+
<AppDialog
|
|
234
213
|
open={selectedConnection !== null}
|
|
235
|
-
onClose={
|
|
214
|
+
onClose={() => setSelectedConnection(null)}
|
|
236
215
|
maxWidth="lg"
|
|
237
|
-
|
|
216
|
+
title={`Connection explorer: ${selectedConnection ?? ""}`}
|
|
217
|
+
showClose
|
|
238
218
|
>
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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>
|
|
219
|
+
{selectedConnection && (
|
|
220
|
+
<ConnectionExplorer
|
|
221
|
+
resourceUri={selectedConnectionResourceUri}
|
|
222
|
+
connectionName={selectedConnection}
|
|
223
|
+
connection={data?.data?.find(
|
|
224
|
+
(c) => c.name === selectedConnection,
|
|
225
|
+
)}
|
|
226
|
+
/>
|
|
227
|
+
)}
|
|
228
|
+
</AppDialog>
|
|
229
|
+
</PackageSection>
|
|
272
230
|
);
|
|
273
231
|
}
|
|
274
232
|
|
|
@@ -281,7 +239,7 @@ type ConnectionCardProps = {
|
|
|
281
239
|
onDelete: (connection: ApiConnection) => Promise<unknown> | void;
|
|
282
240
|
};
|
|
283
241
|
|
|
284
|
-
function
|
|
242
|
+
function ConnectionRow({
|
|
285
243
|
connection,
|
|
286
244
|
mutable,
|
|
287
245
|
isMutating,
|
|
@@ -296,96 +254,58 @@ function ConnectionCard({
|
|
|
296
254
|
event.stopPropagation();
|
|
297
255
|
setMenuAnchorEl(event.currentTarget);
|
|
298
256
|
};
|
|
299
|
-
|
|
300
|
-
const handleMenuClose = () => {
|
|
301
|
-
setMenuAnchorEl(null);
|
|
302
|
-
};
|
|
257
|
+
const handleMenuClose = () => setMenuAnchorEl(null);
|
|
303
258
|
|
|
304
259
|
return (
|
|
305
|
-
<
|
|
306
|
-
|
|
260
|
+
<ItemRow
|
|
261
|
+
icon={<StorageOutlinedIcon sx={{ fontSize: 18 }} />}
|
|
262
|
+
tint={SURFACE_TINT.connection}
|
|
263
|
+
label={connection.name ?? ""}
|
|
264
|
+
ariaLabel={connection.name ?? ""}
|
|
265
|
+
description={typeLabel(connection.type)}
|
|
307
266
|
onClick={onOpenExplorer}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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>
|
|
267
|
+
{...(mutable
|
|
268
|
+
? {
|
|
269
|
+
trailingAction: (
|
|
270
|
+
<>
|
|
271
|
+
<IconButton
|
|
272
|
+
size="small"
|
|
273
|
+
onClick={handleMenuClick}
|
|
274
|
+
aria-label={`Connection actions for ${connection.name ?? ""}`.trim()}
|
|
275
|
+
>
|
|
276
|
+
<MoreVert fontSize="small" />
|
|
277
|
+
</IconButton>
|
|
278
|
+
<Menu
|
|
279
|
+
anchorEl={menuAnchorEl}
|
|
280
|
+
open={menuOpen}
|
|
281
|
+
onClose={handleMenuClose}
|
|
282
|
+
onClick={(event) => event.stopPropagation()}
|
|
283
|
+
anchorOrigin={{
|
|
284
|
+
vertical: "bottom",
|
|
285
|
+
horizontal: "right",
|
|
286
|
+
}}
|
|
287
|
+
transformOrigin={{
|
|
288
|
+
vertical: "top",
|
|
289
|
+
horizontal: "right",
|
|
290
|
+
}}
|
|
291
|
+
>
|
|
292
|
+
<EditConnectionDialog
|
|
293
|
+
connection={connection}
|
|
294
|
+
onSubmit={onEdit}
|
|
295
|
+
isSubmitting={isMutating}
|
|
296
|
+
onCloseDialog={handleMenuClose}
|
|
297
|
+
/>
|
|
298
|
+
<DeleteConnectionDialog
|
|
299
|
+
connection={connection}
|
|
300
|
+
onCloseDialog={handleMenuClose}
|
|
301
|
+
isMutating={isMutating}
|
|
302
|
+
onDelete={() => onDelete(connection)}
|
|
303
|
+
/>
|
|
304
|
+
</Menu>
|
|
305
|
+
</>
|
|
306
|
+
),
|
|
307
|
+
}
|
|
308
|
+
: {})}
|
|
309
|
+
/>
|
|
390
310
|
);
|
|
391
311
|
}
|
|
@@ -3,20 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
import React, { useState } from "react";
|
|
5
5
|
import Button from "@mui/material/Button";
|
|
6
|
-
import Dialog from "@mui/material/Dialog";
|
|
7
|
-
import DialogTitle from "@mui/material/DialogTitle";
|
|
8
|
-
import DialogContent from "@mui/material/DialogContent";
|
|
9
|
-
import DialogActions from "@mui/material/DialogActions";
|
|
10
|
-
import IconButton from "@mui/material/IconButton";
|
|
11
|
-
import CloseIcon from "@mui/icons-material/Close";
|
|
12
6
|
import Typography from "@mui/material/Typography";
|
|
13
|
-
import { ListItemIcon, ListItemText, MenuItem
|
|
7
|
+
import { ListItemIcon, ListItemText, MenuItem } from "@mui/material";
|
|
14
8
|
import { Delete } from "@mui/icons-material";
|
|
15
|
-
import {
|
|
9
|
+
import { useCrudMutation } from "../../hooks/useCrudMutation";
|
|
16
10
|
import { useServer } from "../ServerProvider";
|
|
17
|
-
import { useQueryClient } from "@tanstack/react-query";
|
|
18
11
|
import { parseResourceUri } from "../../utils/formatting";
|
|
19
|
-
import {
|
|
12
|
+
import { AppDialog } from "../AppDialog";
|
|
20
13
|
|
|
21
14
|
export default function DeletePackageDialog({
|
|
22
15
|
resourceUri,
|
|
@@ -27,8 +20,6 @@ export default function DeletePackageDialog({
|
|
|
27
20
|
}) {
|
|
28
21
|
const [open, setOpen] = useState(false);
|
|
29
22
|
const { apiClients } = useServer();
|
|
30
|
-
const queryClient = useQueryClient();
|
|
31
|
-
const [notificationMessage, setNotificationMessage] = useState("");
|
|
32
23
|
const handleClickOpen = () => {
|
|
33
24
|
setOpen(true);
|
|
34
25
|
};
|
|
@@ -38,21 +29,14 @@ export default function DeletePackageDialog({
|
|
|
38
29
|
};
|
|
39
30
|
const { environmentName, packageName } = parseResourceUri(resourceUri);
|
|
40
31
|
|
|
41
|
-
const deletePackage =
|
|
32
|
+
const deletePackage = useCrudMutation({
|
|
42
33
|
mutationFn: () =>
|
|
43
34
|
apiClients.packages.deletePackage(environmentName, packageName),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
onError(error) {
|
|
50
|
-
setNotificationMessage(
|
|
51
|
-
error instanceof Error
|
|
52
|
-
? error.message
|
|
53
|
-
: "An unknown error occurred",
|
|
54
|
-
);
|
|
55
|
-
},
|
|
35
|
+
success: "Package deleted",
|
|
36
|
+
invalidates: [["packages", environmentName]],
|
|
37
|
+
closeDialog: handleClose,
|
|
38
|
+
resource: "package",
|
|
39
|
+
action: "delete",
|
|
56
40
|
});
|
|
57
41
|
|
|
58
42
|
return (
|
|
@@ -63,60 +47,31 @@ export default function DeletePackageDialog({
|
|
|
63
47
|
</ListItemIcon>
|
|
64
48
|
<ListItemText>Delete</ListItemText>
|
|
65
49
|
</MenuItem>
|
|
66
|
-
<
|
|
67
|
-
onClose={handleClose}
|
|
68
|
-
aria-labelledby="customized-dialog-title"
|
|
50
|
+
<AppDialog
|
|
69
51
|
open={open}
|
|
52
|
+
onClose={handleClose}
|
|
53
|
+
title="Delete package"
|
|
54
|
+
actions={
|
|
55
|
+
<>
|
|
56
|
+
<Button onClick={handleClose}>Cancel</Button>
|
|
57
|
+
<Button
|
|
58
|
+
variant="contained"
|
|
59
|
+
color="error"
|
|
60
|
+
autoFocus
|
|
61
|
+
onClick={() => deletePackage.mutate()}
|
|
62
|
+
loading={deletePackage.isPending}
|
|
63
|
+
>
|
|
64
|
+
Delete package
|
|
65
|
+
</Button>
|
|
66
|
+
</>
|
|
67
|
+
}
|
|
70
68
|
>
|
|
71
|
-
<
|
|
72
|
-
Delete
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
sx={(theme) => ({
|
|
78
|
-
position: "absolute",
|
|
79
|
-
right: 8,
|
|
80
|
-
top: 8,
|
|
81
|
-
color: theme.palette.grey[500],
|
|
82
|
-
})}
|
|
83
|
-
>
|
|
84
|
-
<CloseIcon />
|
|
85
|
-
</IconButton>
|
|
86
|
-
<DialogContent dividers>
|
|
87
|
-
<Typography gutterBottom>
|
|
88
|
-
Are you sure you want to delete "{packageName}"?
|
|
89
|
-
This action cannot be undone.
|
|
90
|
-
</Typography>
|
|
91
|
-
</DialogContent>
|
|
92
|
-
<DialogActions>
|
|
93
|
-
<Button
|
|
94
|
-
variant="outlined"
|
|
95
|
-
onClick={handleClose}
|
|
96
|
-
style={{
|
|
97
|
-
borderColor: MALLOY_BRAND.teal,
|
|
98
|
-
color: MALLOY_BRAND.teal,
|
|
99
|
-
}}
|
|
100
|
-
>
|
|
101
|
-
Cancel
|
|
102
|
-
</Button>
|
|
103
|
-
<Button
|
|
104
|
-
variant="contained"
|
|
105
|
-
autoFocus
|
|
106
|
-
onClick={() => deletePackage.mutate()}
|
|
107
|
-
color="error"
|
|
108
|
-
loading={deletePackage.isPending}
|
|
109
|
-
>
|
|
110
|
-
Delete
|
|
111
|
-
</Button>
|
|
112
|
-
</DialogActions>
|
|
113
|
-
<Snackbar
|
|
114
|
-
open={notificationMessage !== ""}
|
|
115
|
-
autoHideDuration={6000}
|
|
116
|
-
onClose={() => setNotificationMessage("")}
|
|
117
|
-
message={notificationMessage}
|
|
118
|
-
/>
|
|
119
|
-
</Dialog>
|
|
69
|
+
<Typography variant="body2">
|
|
70
|
+
Delete <strong>{packageName}</strong>? The package stops being
|
|
71
|
+
served and this cannot be undone.
|
|
72
|
+
</Typography>
|
|
73
|
+
</AppDialog>
|
|
74
|
+
{deletePackage.notice}
|
|
120
75
|
</React.Fragment>
|
|
121
76
|
);
|
|
122
77
|
}
|