@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
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import { AddCircleRounded } from "@mui/icons-material";
|
|
5
4
|
import Button from "@mui/material/Button";
|
|
6
|
-
import Dialog from "@mui/material/Dialog";
|
|
7
|
-
import DialogActions from "@mui/material/DialogActions";
|
|
8
|
-
import DialogContent from "@mui/material/DialogContent";
|
|
9
|
-
import DialogContentText from "@mui/material/DialogContentText";
|
|
10
|
-
import DialogTitle from "@mui/material/DialogTitle";
|
|
11
|
-
import Snackbar from "@mui/material/Snackbar";
|
|
12
5
|
import TextField from "@mui/material/TextField";
|
|
13
|
-
import { useQueryClient } from "@tanstack/react-query";
|
|
14
6
|
import React, { useState } from "react";
|
|
15
|
-
import {
|
|
7
|
+
import { useCrudMutation } from "../../hooks/useCrudMutation";
|
|
16
8
|
import { generateEnvironmentReadme } from "../../utils/parsing";
|
|
17
9
|
import { useServer } from "../ServerProvider";
|
|
10
|
+
import { AddButton } from "../buttons";
|
|
11
|
+
import Stack from "@mui/material/Stack";
|
|
12
|
+
import { AppDialog } from "../AppDialog";
|
|
18
13
|
|
|
19
14
|
export default function AddEnvironmentDialog() {
|
|
20
15
|
const [open, setOpen] = useState(false);
|
|
21
16
|
const { apiClients } = useServer();
|
|
22
|
-
const [notificationMessage, setNotificationMessage] = useState("");
|
|
23
17
|
const handleClickOpen = () => {
|
|
24
18
|
setOpen(true);
|
|
25
19
|
};
|
|
@@ -27,9 +21,8 @@ export default function AddEnvironmentDialog() {
|
|
|
27
21
|
const handleClose = () => {
|
|
28
22
|
setOpen(false);
|
|
29
23
|
};
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
async mutationFn(variables: { name: string; description: string }) {
|
|
24
|
+
const addEnvironment = useCrudMutation({
|
|
25
|
+
mutationFn(variables: { name: string; description: string }) {
|
|
33
26
|
return apiClients.environments.createEnvironment({
|
|
34
27
|
name: variables.name,
|
|
35
28
|
readme: generateEnvironmentReadme(
|
|
@@ -41,18 +34,11 @@ export default function AddEnvironmentDialog() {
|
|
|
41
34
|
),
|
|
42
35
|
});
|
|
43
36
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
onError(error) {
|
|
50
|
-
setNotificationMessage(
|
|
51
|
-
error instanceof Error
|
|
52
|
-
? error.message
|
|
53
|
-
: "An unknown error occurred",
|
|
54
|
-
);
|
|
55
|
-
},
|
|
37
|
+
success: "Environment created",
|
|
38
|
+
invalidates: [["environments"]],
|
|
39
|
+
closeDialog: handleClose,
|
|
40
|
+
resource: "environment",
|
|
41
|
+
action: "create",
|
|
56
42
|
});
|
|
57
43
|
|
|
58
44
|
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
|
|
@@ -69,67 +55,58 @@ export default function AddEnvironmentDialog() {
|
|
|
69
55
|
|
|
70
56
|
return (
|
|
71
57
|
<React.Fragment>
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
58
|
+
<AddButton label="Environment" onClick={handleClickOpen} />
|
|
59
|
+
<AppDialog
|
|
60
|
+
open={open}
|
|
61
|
+
onClose={handleClose}
|
|
62
|
+
title="New environment"
|
|
63
|
+
description="An environment holds packages and the connections they query through."
|
|
64
|
+
actions={
|
|
65
|
+
<>
|
|
66
|
+
<Button
|
|
67
|
+
disabled={addEnvironment.isPending}
|
|
68
|
+
onClick={handleClose}
|
|
69
|
+
>
|
|
70
|
+
Cancel
|
|
71
|
+
</Button>
|
|
72
|
+
<Button
|
|
73
|
+
type="submit"
|
|
74
|
+
form="environment-form"
|
|
75
|
+
variant="contained"
|
|
76
|
+
loading={addEnvironment.isPending}
|
|
77
|
+
>
|
|
78
|
+
Create environment
|
|
79
|
+
</Button>
|
|
80
|
+
</>
|
|
81
|
+
}
|
|
77
82
|
>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<Dialog open={open} onClose={handleClose}>
|
|
81
|
-
<DialogTitle>Create New Environment</DialogTitle>
|
|
82
|
-
<DialogContent>
|
|
83
|
-
<DialogContentText>
|
|
84
|
-
Add a new environment to start exploring semantic models and
|
|
85
|
-
analyzing data.
|
|
86
|
-
</DialogContentText>
|
|
87
|
-
<form onSubmit={handleSubmit} id="environment-form">
|
|
83
|
+
<form onSubmit={handleSubmit} id="environment-form">
|
|
84
|
+
<Stack sx={{ gap: 2 }}>
|
|
88
85
|
<TextField
|
|
89
86
|
autoFocus
|
|
90
87
|
required
|
|
91
|
-
margin="dense"
|
|
92
88
|
id="name"
|
|
93
89
|
name="name"
|
|
94
|
-
label="
|
|
90
|
+
label="Name"
|
|
95
91
|
type="text"
|
|
96
92
|
fullWidth
|
|
97
|
-
|
|
93
|
+
size="small"
|
|
94
|
+
InputLabelProps={{ shrink: true }}
|
|
98
95
|
/>
|
|
99
96
|
<TextField
|
|
100
|
-
margin="dense"
|
|
101
97
|
id="description"
|
|
102
98
|
name="description"
|
|
103
|
-
label="
|
|
99
|
+
label="Description"
|
|
104
100
|
placeholder="Explore semantic models, run queries, and build dashboards"
|
|
105
101
|
type="text"
|
|
106
102
|
fullWidth
|
|
107
|
-
|
|
103
|
+
size="small"
|
|
104
|
+
InputLabelProps={{ shrink: true }}
|
|
108
105
|
/>
|
|
109
|
-
</
|
|
110
|
-
</
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
disabled={addEnvironment.isPending}
|
|
114
|
-
onClick={handleClose}
|
|
115
|
-
>
|
|
116
|
-
Cancel
|
|
117
|
-
</Button>
|
|
118
|
-
<Button
|
|
119
|
-
type="submit"
|
|
120
|
-
form="environment-form"
|
|
121
|
-
loading={addEnvironment.isPending}
|
|
122
|
-
>
|
|
123
|
-
Create Environment
|
|
124
|
-
</Button>
|
|
125
|
-
</DialogActions>
|
|
126
|
-
</Dialog>
|
|
127
|
-
<Snackbar
|
|
128
|
-
open={notificationMessage !== ""}
|
|
129
|
-
autoHideDuration={6000}
|
|
130
|
-
onClose={() => setNotificationMessage("")}
|
|
131
|
-
message={notificationMessage}
|
|
132
|
-
/>
|
|
106
|
+
</Stack>
|
|
107
|
+
</form>
|
|
108
|
+
</AppDialog>
|
|
109
|
+
{addEnvironment.notice}
|
|
133
110
|
</React.Fragment>
|
|
134
111
|
);
|
|
135
112
|
}
|
|
@@ -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
9
|
import { Environment } from "../../client";
|
|
16
|
-
import {
|
|
10
|
+
import { useCrudMutation } from "../../hooks/useCrudMutation";
|
|
17
11
|
import { useServer } from "../ServerProvider";
|
|
18
|
-
import {
|
|
19
|
-
import { MALLOY_BRAND } from "../styles";
|
|
12
|
+
import { AppDialog } from "../AppDialog";
|
|
20
13
|
|
|
21
14
|
export default function DeleteEnvironmentDialog({
|
|
22
15
|
environment,
|
|
@@ -27,8 +20,6 @@ export default function DeleteEnvironmentDialog({
|
|
|
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
|
};
|
|
@@ -37,21 +28,14 @@ export default function DeleteEnvironmentDialog({
|
|
|
37
28
|
onCloseDialog();
|
|
38
29
|
};
|
|
39
30
|
|
|
40
|
-
const deleteEnvironment =
|
|
31
|
+
const deleteEnvironment = useCrudMutation({
|
|
41
32
|
mutationFn: () =>
|
|
42
33
|
apiClients.environments.deleteEnvironment(environment.name),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
onError(error) {
|
|
49
|
-
setNotificationMessage(
|
|
50
|
-
error instanceof Error
|
|
51
|
-
? error.message
|
|
52
|
-
: "An unknown error occurred",
|
|
53
|
-
);
|
|
54
|
-
},
|
|
34
|
+
success: "Environment deleted",
|
|
35
|
+
invalidates: [["environments"]],
|
|
36
|
+
closeDialog: handleClose,
|
|
37
|
+
resource: "environment",
|
|
38
|
+
action: "delete",
|
|
55
39
|
});
|
|
56
40
|
|
|
57
41
|
return (
|
|
@@ -62,60 +46,31 @@ export default function DeleteEnvironmentDialog({
|
|
|
62
46
|
</ListItemIcon>
|
|
63
47
|
<ListItemText>Delete</ListItemText>
|
|
64
48
|
</MenuItem>
|
|
65
|
-
<
|
|
66
|
-
onClose={handleClose}
|
|
67
|
-
aria-labelledby="customized-dialog-title"
|
|
49
|
+
<AppDialog
|
|
68
50
|
open={open}
|
|
51
|
+
onClose={handleClose}
|
|
52
|
+
title="Delete environment"
|
|
53
|
+
actions={
|
|
54
|
+
<>
|
|
55
|
+
<Button onClick={handleClose}>Cancel</Button>
|
|
56
|
+
<Button
|
|
57
|
+
variant="contained"
|
|
58
|
+
color="error"
|
|
59
|
+
autoFocus
|
|
60
|
+
onClick={() => deleteEnvironment.mutate()}
|
|
61
|
+
loading={deleteEnvironment.isPending}
|
|
62
|
+
>
|
|
63
|
+
Delete environment
|
|
64
|
+
</Button>
|
|
65
|
+
</>
|
|
66
|
+
}
|
|
69
67
|
>
|
|
70
|
-
<
|
|
71
|
-
Delete
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
sx={(theme) => ({
|
|
77
|
-
position: "absolute",
|
|
78
|
-
right: 8,
|
|
79
|
-
top: 8,
|
|
80
|
-
color: theme.palette.grey[500],
|
|
81
|
-
})}
|
|
82
|
-
>
|
|
83
|
-
<CloseIcon />
|
|
84
|
-
</IconButton>
|
|
85
|
-
<DialogContent dividers>
|
|
86
|
-
<Typography gutterBottom>
|
|
87
|
-
Are you sure you want to delete "{environment.name}
|
|
88
|
-
"? This action cannot be undone.
|
|
89
|
-
</Typography>
|
|
90
|
-
</DialogContent>
|
|
91
|
-
<DialogActions>
|
|
92
|
-
<Button
|
|
93
|
-
variant="outlined"
|
|
94
|
-
onClick={handleClose}
|
|
95
|
-
style={{
|
|
96
|
-
borderColor: MALLOY_BRAND.teal,
|
|
97
|
-
color: MALLOY_BRAND.teal,
|
|
98
|
-
}}
|
|
99
|
-
>
|
|
100
|
-
Cancel
|
|
101
|
-
</Button>
|
|
102
|
-
<Button
|
|
103
|
-
loading={deleteEnvironment.isPending}
|
|
104
|
-
variant="contained"
|
|
105
|
-
autoFocus
|
|
106
|
-
onClick={() => deleteEnvironment.mutate()}
|
|
107
|
-
color="error"
|
|
108
|
-
>
|
|
109
|
-
Delete
|
|
110
|
-
</Button>
|
|
111
|
-
</DialogActions>
|
|
112
|
-
<Snackbar
|
|
113
|
-
open={notificationMessage !== ""}
|
|
114
|
-
autoHideDuration={6000}
|
|
115
|
-
onClose={() => setNotificationMessage("")}
|
|
116
|
-
message={notificationMessage}
|
|
117
|
-
/>
|
|
118
|
-
</Dialog>
|
|
68
|
+
<Typography variant="body2">
|
|
69
|
+
Delete <strong>{environment.name}</strong>? Its packages stop
|
|
70
|
+
being served and this cannot be undone.
|
|
71
|
+
</Typography>
|
|
72
|
+
</AppDialog>
|
|
73
|
+
{deleteEnvironment.notice}
|
|
119
74
|
</React.Fragment>
|
|
120
75
|
);
|
|
121
76
|
}
|
|
@@ -4,22 +4,18 @@
|
|
|
4
4
|
import React from "react";
|
|
5
5
|
import Button from "@mui/material/Button";
|
|
6
6
|
import TextField from "@mui/material/TextField";
|
|
7
|
-
import Dialog from "@mui/material/Dialog";
|
|
8
|
-
import DialogActions from "@mui/material/DialogActions";
|
|
9
|
-
import DialogContent from "@mui/material/DialogContent";
|
|
10
|
-
import DialogContentText from "@mui/material/DialogContentText";
|
|
11
|
-
import DialogTitle from "@mui/material/DialogTitle";
|
|
12
7
|
import { useState } from "react";
|
|
13
8
|
import { Edit } from "@mui/icons-material";
|
|
14
|
-
import { MenuItem, ListItemIcon, ListItemText
|
|
9
|
+
import { MenuItem, ListItemIcon, ListItemText } from "@mui/material";
|
|
15
10
|
import { Environment } from "../../client";
|
|
16
11
|
import {
|
|
17
12
|
generateEnvironmentReadme,
|
|
18
13
|
getEnvironmentDescription,
|
|
19
14
|
} from "../../utils/parsing";
|
|
20
|
-
import {
|
|
21
|
-
import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
|
|
15
|
+
import { useCrudMutation } from "../../hooks/useCrudMutation";
|
|
22
16
|
import { useServer } from "../ServerProvider";
|
|
17
|
+
import Stack from "@mui/material/Stack";
|
|
18
|
+
import { AppDialog } from "../AppDialog";
|
|
23
19
|
|
|
24
20
|
interface EditEnvironmentModalProps {
|
|
25
21
|
environment: Environment;
|
|
@@ -32,8 +28,6 @@ export default function EditEnvironmentDialog({
|
|
|
32
28
|
}: EditEnvironmentModalProps) {
|
|
33
29
|
const [open, setOpen] = useState(false);
|
|
34
30
|
const { apiClients } = useServer();
|
|
35
|
-
const queryClient = useQueryClient();
|
|
36
|
-
const [notificationMessage, setNotificationMessage] = useState("");
|
|
37
31
|
|
|
38
32
|
const handleClickOpen = () => {
|
|
39
33
|
setOpen(true);
|
|
@@ -44,8 +38,8 @@ export default function EditEnvironmentDialog({
|
|
|
44
38
|
onCloseDialog();
|
|
45
39
|
};
|
|
46
40
|
|
|
47
|
-
const editEnvironment =
|
|
48
|
-
|
|
41
|
+
const editEnvironment = useCrudMutation({
|
|
42
|
+
mutationFn(variables: { description: string }) {
|
|
49
43
|
return apiClients.environments.updateEnvironment(environment.name, {
|
|
50
44
|
name: environment.name,
|
|
51
45
|
readme: generateEnvironmentReadme(
|
|
@@ -57,18 +51,11 @@ export default function EditEnvironmentDialog({
|
|
|
57
51
|
),
|
|
58
52
|
});
|
|
59
53
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
onError(error) {
|
|
66
|
-
setNotificationMessage(
|
|
67
|
-
error instanceof Error
|
|
68
|
-
? error.message
|
|
69
|
-
: "An unknown error occurred",
|
|
70
|
-
);
|
|
71
|
-
},
|
|
54
|
+
success: "Environment updated",
|
|
55
|
+
invalidates: [["environments"]],
|
|
56
|
+
closeDialog: handleClose,
|
|
57
|
+
resource: "environment",
|
|
58
|
+
action: "update",
|
|
72
59
|
});
|
|
73
60
|
|
|
74
61
|
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
|
|
@@ -87,62 +74,61 @@ export default function EditEnvironmentDialog({
|
|
|
87
74
|
<ListItemText>Edit</ListItemText>
|
|
88
75
|
</MenuItem>
|
|
89
76
|
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
77
|
+
<AppDialog
|
|
78
|
+
open={open}
|
|
79
|
+
onClose={handleClose}
|
|
80
|
+
title="Edit environment"
|
|
81
|
+
description="What this environment is, for the people who open it."
|
|
82
|
+
actions={
|
|
83
|
+
<>
|
|
84
|
+
<Button
|
|
85
|
+
disabled={editEnvironment.isPending}
|
|
86
|
+
onClick={handleClose}
|
|
87
|
+
>
|
|
88
|
+
Cancel
|
|
89
|
+
</Button>
|
|
90
|
+
<Button
|
|
91
|
+
type="submit"
|
|
92
|
+
form="environment-form"
|
|
93
|
+
variant="contained"
|
|
94
|
+
loading={editEnvironment.isPending}
|
|
95
|
+
>
|
|
96
|
+
Save changes
|
|
97
|
+
</Button>
|
|
98
|
+
</>
|
|
99
|
+
}
|
|
100
|
+
>
|
|
101
|
+
<form onSubmit={handleSubmit} id="environment-form">
|
|
102
|
+
<Stack sx={{ gap: 2 }}>
|
|
97
103
|
<TextField
|
|
98
104
|
autoFocus
|
|
99
105
|
required
|
|
100
|
-
margin="dense"
|
|
101
106
|
id="name"
|
|
102
107
|
name="name"
|
|
103
|
-
label="
|
|
108
|
+
label="Name"
|
|
104
109
|
disabled
|
|
105
110
|
type="text"
|
|
106
111
|
fullWidth
|
|
107
|
-
|
|
112
|
+
size="small"
|
|
108
113
|
defaultValue={environment.name}
|
|
114
|
+
InputLabelProps={{ shrink: true }}
|
|
109
115
|
/>
|
|
110
116
|
<TextField
|
|
111
|
-
margin="dense"
|
|
112
117
|
id="description"
|
|
113
118
|
name="description"
|
|
114
|
-
label="
|
|
119
|
+
label="Description"
|
|
115
120
|
type="text"
|
|
116
121
|
fullWidth
|
|
117
|
-
|
|
122
|
+
size="small"
|
|
118
123
|
defaultValue={getEnvironmentDescription(
|
|
119
124
|
environment.readme,
|
|
120
125
|
)}
|
|
126
|
+
InputLabelProps={{ shrink: true }}
|
|
121
127
|
/>
|
|
122
|
-
</
|
|
123
|
-
</
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
disabled={editEnvironment.isPending}
|
|
127
|
-
onClick={handleClose}
|
|
128
|
-
>
|
|
129
|
-
Cancel
|
|
130
|
-
</Button>
|
|
131
|
-
<Button
|
|
132
|
-
type="submit"
|
|
133
|
-
form="environment-form"
|
|
134
|
-
loading={editEnvironment.isPending}
|
|
135
|
-
>
|
|
136
|
-
Save Changes
|
|
137
|
-
</Button>
|
|
138
|
-
</DialogActions>
|
|
139
|
-
</Dialog>
|
|
140
|
-
<Snackbar
|
|
141
|
-
open={notificationMessage !== ""}
|
|
142
|
-
autoHideDuration={6000}
|
|
143
|
-
onClose={() => setNotificationMessage("")}
|
|
144
|
-
message={notificationMessage}
|
|
145
|
-
/>
|
|
128
|
+
</Stack>
|
|
129
|
+
</form>
|
|
130
|
+
</AppDialog>
|
|
131
|
+
{editEnvironment.notice}
|
|
146
132
|
</React.Fragment>
|
|
147
133
|
);
|
|
148
134
|
}
|