@malloy-publisher/sdk 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -9
- package/dist/{DocumentStorageProvider-tGvodI8f.es.js → DocumentStorage-BiFqO15i.es.js} +7126 -6943
- package/dist/DocumentStorage-CMyLifsz.cjs.js +134 -0
- package/dist/RenderedResult-CZzE8wv-.cjs.js +115 -0
- package/dist/{RenderedResult-mDE-4u8S.es.js → RenderedResult-CvrmYyr5.es.js} +64 -57
- package/dist/{ServerProvider-X2Ma0HRs.es.js → ServerProvider-BWOEKg0O.es.js} +1217 -1244
- package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
- package/dist/builder/index.cjs.js +52 -52
- package/dist/builder/index.es.js +3961 -3960
- 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/DashboardBar.d.ts +21 -0
- package/dist/components/Dashboard/telemetry.d.ts +24 -7
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +12 -10
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +20 -2
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +21 -11
- package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +10 -1
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +69 -5
- package/dist/components/DocumentStorage/index.d.ts +1 -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/buttons.d.ts +53 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/styles.d.ts +49 -40
- package/dist/hooks/useCrudMutation.d.ts +42 -0
- package/dist/index.cjs.js +22 -26
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +17431 -20676
- package/dist/telemetry/consoleEvents.d.ts +60 -0
- package/dist/utils/sha256.d.ts +2 -0
- package/package.json +1 -1
- 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/DashboardBar.tsx +88 -0
- package/src/components/Dashboard/telemetry.ts +24 -5
- package/src/components/DashboardBuilder/AddTileDialog.tsx +141 -143
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +110 -218
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +5 -11
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +202 -171
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +706 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +2 -25
- package/src/components/DashboardBuilder/DashboardEditor.tsx +442 -94
- package/src/components/DashboardBuilder/DiffDialog.tsx +75 -82
- package/src/components/DashboardBuilder/DrillDialog.tsx +144 -156
- package/src/components/DashboardBuilder/FilterDialog.tsx +276 -295
- package/src/components/DashboardBuilder/FilterStrip.tsx +11 -10
- package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
- package/src/components/DashboardBuilder/newDashboard.ts +48 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +53 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +45 -8
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +56 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +12 -4
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +7 -6
- package/src/components/DocumentStorage/DocumentStorage.ts +78 -5
- package/src/components/DocumentStorage/index.ts +1 -0
- package/src/components/Environment/About.tsx +14 -28
- 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/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/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 +184 -238
- package/src/components/Package/index.ts +0 -1
- package/src/components/PackageSection.tsx +85 -0
- package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
- package/src/components/RenderedResult/RenderedResult.tsx +22 -8
- 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/given/paramCodec.spec.ts +1 -1
- package/src/components/index.ts +10 -0
- package/src/components/styles.ts +49 -85
- package/src/hooks/useCrudMutation.spec.tsx +119 -0
- package/src/hooks/useCrudMutation.tsx +85 -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/sha256.ts +13 -0
- package/test/README.md +1 -1
- package/test/serverProvider.tsx +5 -2
- package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +0 -134
- package/dist/RenderedResult-CPi6uQWq.cjs.js +0 -115
- package/dist/ServerProvider-CH71GsoL.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
|
@@ -2,20 +2,16 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import { Edit } from "@mui/icons-material";
|
|
5
|
-
import { ListItemIcon, ListItemText, MenuItem
|
|
5
|
+
import { ListItemIcon, ListItemText, MenuItem } from "@mui/material";
|
|
6
6
|
import Button from "@mui/material/Button";
|
|
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 TextField from "@mui/material/TextField";
|
|
13
|
-
import { useQueryClient } from "@tanstack/react-query";
|
|
14
8
|
import React, { useState } from "react";
|
|
15
9
|
import { Package } from "../../client";
|
|
16
|
-
import {
|
|
10
|
+
import { useCrudMutation } from "../../hooks/useCrudMutation";
|
|
17
11
|
import { parseResourceUri } from "../../utils/formatting";
|
|
18
12
|
import { useServer } from "../ServerProvider";
|
|
13
|
+
import { Stack } from "@mui/material";
|
|
14
|
+
import { AppDialog } from "../AppDialog";
|
|
19
15
|
|
|
20
16
|
interface EditPackageDialogProps {
|
|
21
17
|
package: Package;
|
|
@@ -30,8 +26,6 @@ export default function EditPackageDialog({
|
|
|
30
26
|
}: EditPackageDialogProps) {
|
|
31
27
|
const [open, setOpen] = useState(false);
|
|
32
28
|
const { apiClients } = useServer();
|
|
33
|
-
const queryClient = useQueryClient();
|
|
34
|
-
const [notificationMessage, setNotificationMessage] = useState("");
|
|
35
29
|
|
|
36
30
|
const handleClickOpen = () => {
|
|
37
31
|
setOpen(true);
|
|
@@ -43,8 +37,8 @@ export default function EditPackageDialog({
|
|
|
43
37
|
};
|
|
44
38
|
|
|
45
39
|
const { packageName, environmentName } = parseResourceUri(resourceUri);
|
|
46
|
-
const editPackage =
|
|
47
|
-
|
|
40
|
+
const editPackage = useCrudMutation({
|
|
41
|
+
mutationFn(variables: { description: string }) {
|
|
48
42
|
return apiClients.packages.updatePackage(
|
|
49
43
|
environmentName,
|
|
50
44
|
packageName,
|
|
@@ -54,20 +48,11 @@ export default function EditPackageDialog({
|
|
|
54
48
|
},
|
|
55
49
|
);
|
|
56
50
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
onError(error) {
|
|
65
|
-
setNotificationMessage(
|
|
66
|
-
error instanceof Error
|
|
67
|
-
? error.message
|
|
68
|
-
: "An unknown error occurred",
|
|
69
|
-
);
|
|
70
|
-
},
|
|
51
|
+
success: "Package updated",
|
|
52
|
+
invalidates: [["packages", environmentName]],
|
|
53
|
+
closeDialog: handleClose,
|
|
54
|
+
resource: "package",
|
|
55
|
+
action: "update",
|
|
71
56
|
});
|
|
72
57
|
|
|
73
58
|
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
|
|
@@ -86,25 +71,44 @@ export default function EditPackageDialog({
|
|
|
86
71
|
<ListItemText>Edit</ListItemText>
|
|
87
72
|
</MenuItem>
|
|
88
73
|
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
74
|
+
<AppDialog
|
|
75
|
+
open={open}
|
|
76
|
+
onClose={handleClose}
|
|
77
|
+
title="Edit package"
|
|
78
|
+
description={`What ${_package.name} is, for the people who open it.`}
|
|
79
|
+
actions={
|
|
80
|
+
<>
|
|
81
|
+
<Button
|
|
82
|
+
disabled={editPackage.isPending}
|
|
83
|
+
onClick={handleClose}
|
|
84
|
+
>
|
|
85
|
+
Cancel
|
|
86
|
+
</Button>
|
|
87
|
+
<Button
|
|
88
|
+
type="submit"
|
|
89
|
+
form="package-form"
|
|
90
|
+
variant="contained"
|
|
91
|
+
loading={editPackage.isPending}
|
|
92
|
+
>
|
|
93
|
+
Save changes
|
|
94
|
+
</Button>
|
|
95
|
+
</>
|
|
96
|
+
}
|
|
97
|
+
>
|
|
98
|
+
<form onSubmit={handleSubmit} id="package-form">
|
|
99
|
+
<Stack sx={{ gap: 2 }}>
|
|
96
100
|
<TextField
|
|
97
101
|
autoFocus
|
|
98
102
|
required
|
|
99
|
-
margin="dense"
|
|
100
103
|
id="name"
|
|
101
104
|
name="name"
|
|
102
|
-
label="
|
|
105
|
+
label="Name"
|
|
103
106
|
disabled
|
|
104
107
|
type="text"
|
|
105
108
|
fullWidth
|
|
106
|
-
|
|
109
|
+
size="small"
|
|
107
110
|
defaultValue={_package.name}
|
|
111
|
+
InputLabelProps={{ shrink: true }}
|
|
108
112
|
/>
|
|
109
113
|
<TextField
|
|
110
114
|
id="description"
|
|
@@ -113,30 +117,14 @@ export default function EditPackageDialog({
|
|
|
113
117
|
multiline
|
|
114
118
|
fullWidth
|
|
115
119
|
rows={4}
|
|
120
|
+
size="small"
|
|
116
121
|
defaultValue={_package.description}
|
|
117
|
-
|
|
122
|
+
InputLabelProps={{ shrink: true }}
|
|
118
123
|
/>
|
|
119
|
-
</
|
|
120
|
-
</
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
Cancel
|
|
124
|
-
</Button>
|
|
125
|
-
<Button
|
|
126
|
-
type="submit"
|
|
127
|
-
form="package-form"
|
|
128
|
-
loading={editPackage.isPending}
|
|
129
|
-
>
|
|
130
|
-
Save Changes
|
|
131
|
-
</Button>
|
|
132
|
-
</DialogActions>
|
|
133
|
-
</Dialog>
|
|
134
|
-
<Snackbar
|
|
135
|
-
open={notificationMessage !== ""}
|
|
136
|
-
autoHideDuration={6000}
|
|
137
|
-
onClose={() => setNotificationMessage("")}
|
|
138
|
-
message={notificationMessage}
|
|
139
|
-
/>
|
|
124
|
+
</Stack>
|
|
125
|
+
</form>
|
|
126
|
+
</AppDialog>
|
|
127
|
+
{editPackage.notice}
|
|
140
128
|
</React.Fragment>
|
|
141
129
|
);
|
|
142
130
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import { Box, Container,
|
|
4
|
+
import { Box, Container, Typography } from "@mui/material";
|
|
5
5
|
import { useEffect } from "react";
|
|
6
|
+
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
6
7
|
import { parseResourceUri } from "../../utils/formatting";
|
|
7
|
-
import {
|
|
8
|
+
import { BackLink } from "../BackLink";
|
|
9
|
+
import { PackageSection } from "../PackageSection";
|
|
8
10
|
import { useServer } from "../ServerProvider";
|
|
9
11
|
import About from "./About";
|
|
10
12
|
import AddPackageDialog from "./AddPackageDialog";
|
|
@@ -20,8 +22,14 @@ export default function Environment({
|
|
|
20
22
|
onSelectPackage,
|
|
21
23
|
resourceUri,
|
|
22
24
|
}: EnvironmentProps) {
|
|
23
|
-
const { mutable } = useServer();
|
|
25
|
+
const { apiClients, mutable } = useServer();
|
|
24
26
|
const { environmentName } = parseResourceUri(resourceUri);
|
|
27
|
+
// Only for the heading's count: the list below runs the same query under the
|
|
28
|
+
// same key, so this shares its cache rather than fetching twice.
|
|
29
|
+
const packages = useQueryWithApiError({
|
|
30
|
+
queryKey: ["packages", environmentName],
|
|
31
|
+
queryFn: () => apiClients.packages.listPackages(environmentName),
|
|
32
|
+
});
|
|
25
33
|
|
|
26
34
|
useEffect(() => {
|
|
27
35
|
window.scrollTo({ top: 0, behavior: "auto" });
|
|
@@ -30,9 +38,18 @@ export default function Environment({
|
|
|
30
38
|
return (
|
|
31
39
|
<Container
|
|
32
40
|
maxWidth={false}
|
|
33
|
-
sx={{ maxWidth: 1024, mx: "auto", px:
|
|
41
|
+
sx={{ maxWidth: 1024, mx: "auto", px: 3, py: 6 }}
|
|
34
42
|
>
|
|
35
|
-
<Box sx={{ mb:
|
|
43
|
+
<Box sx={{ mb: 4 }}>
|
|
44
|
+
{/* The environment's parent is the server itself, which is what
|
|
45
|
+
home lists. `onSelectPackage` is this component's one navigation
|
|
46
|
+
hook; the name is narrow but the job is not. */}
|
|
47
|
+
<Box>
|
|
48
|
+
<BackLink
|
|
49
|
+
label="Publisher"
|
|
50
|
+
onClick={(event) => onSelectPackage("/", event)}
|
|
51
|
+
/>
|
|
52
|
+
</Box>
|
|
36
53
|
<Typography
|
|
37
54
|
variant="h4"
|
|
38
55
|
component="h1"
|
|
@@ -46,42 +63,23 @@ export default function Environment({
|
|
|
46
63
|
</Typography>
|
|
47
64
|
</Box>
|
|
48
65
|
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
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>
|
|
66
|
+
<PackageSection
|
|
67
|
+
title="Packages"
|
|
68
|
+
{...(packages.isSuccess
|
|
69
|
+
? { count: packages.data.data.length }
|
|
70
|
+
: {})}
|
|
71
|
+
description="Published packages available for use in this environment"
|
|
72
|
+
{...(mutable
|
|
73
|
+
? { action: <AddPackageDialog resourceUri={resourceUri} /> }
|
|
74
|
+
: {})}
|
|
75
|
+
>
|
|
69
76
|
<Packages
|
|
70
77
|
onSelectPackage={onSelectPackage}
|
|
71
78
|
resourceUri={resourceUri}
|
|
72
79
|
/>
|
|
73
|
-
</
|
|
74
|
-
|
|
75
|
-
<Box sx={{ mb: 5 }}>
|
|
76
|
-
<Connections resourceUri={resourceUri} />
|
|
77
|
-
</Box>
|
|
80
|
+
</PackageSection>
|
|
78
81
|
|
|
79
|
-
<
|
|
80
|
-
<EnvironmentMaterializations
|
|
81
|
-
resourceUri={resourceUri}
|
|
82
|
-
onClickPackageFile={onSelectPackage}
|
|
83
|
-
/>
|
|
84
|
-
</Box>
|
|
82
|
+
<Connections resourceUri={resourceUri} />
|
|
85
83
|
|
|
86
84
|
<About resourceUri={resourceUri} />
|
|
87
85
|
</Container>
|
|
@@ -3,21 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
import { MoreVert } from "@mui/icons-material";
|
|
5
5
|
import Inventory2OutlinedIcon from "@mui/icons-material/Inventory2Outlined";
|
|
6
|
-
import {
|
|
7
|
-
Box,
|
|
8
|
-
Card,
|
|
9
|
-
CardContent,
|
|
10
|
-
Grid,
|
|
11
|
-
IconButton,
|
|
12
|
-
Menu,
|
|
13
|
-
Tooltip,
|
|
14
|
-
Typography,
|
|
15
|
-
} from "@mui/material";
|
|
6
|
+
import { IconButton, Menu, Stack } from "@mui/material";
|
|
16
7
|
import { useState } from "react";
|
|
17
8
|
import { Package } from "../../client";
|
|
18
9
|
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
19
10
|
import { encodeResourceUri, parseResourceUri } from "../../utils/formatting";
|
|
20
11
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
12
|
+
import { ItemRow } from "../ItemRow";
|
|
13
|
+
import { SURFACE_TINT } from "../styles";
|
|
21
14
|
import { Loading } from "../Loading";
|
|
22
15
|
import { useServer } from "../ServerProvider";
|
|
23
16
|
import DeletePackageDialog from "./DeletePackageDialog";
|
|
@@ -55,27 +48,29 @@ export default function Packages({
|
|
|
55
48
|
const packages = [...data.data].sort((a, b) => a.name.localeCompare(b.name));
|
|
56
49
|
|
|
57
50
|
return (
|
|
58
|
-
|
|
51
|
+
// The labelled region is the `PackageSection` above this: a reader can
|
|
52
|
+
// jump to the packages, and a test can name one without catching the
|
|
53
|
+
// same package's name in the materializations table below.
|
|
54
|
+
<Stack>
|
|
59
55
|
{packages.map((pkg) => {
|
|
60
56
|
const packageResourceUri = encodeResourceUri({
|
|
61
57
|
environmentName,
|
|
62
58
|
packageName: pkg.name,
|
|
63
59
|
});
|
|
64
60
|
return (
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
</Grid>
|
|
61
|
+
<PackageRow
|
|
62
|
+
key={pkg.name}
|
|
63
|
+
pkg={pkg}
|
|
64
|
+
packageResourceUri={packageResourceUri}
|
|
65
|
+
onSelectPackage={onSelectPackage}
|
|
66
|
+
/>
|
|
72
67
|
);
|
|
73
68
|
})}
|
|
74
|
-
</
|
|
69
|
+
</Stack>
|
|
75
70
|
);
|
|
76
71
|
}
|
|
77
72
|
|
|
78
|
-
function
|
|
73
|
+
function PackageRow({
|
|
79
74
|
pkg,
|
|
80
75
|
packageResourceUri,
|
|
81
76
|
onSelectPackage,
|
|
@@ -88,119 +83,59 @@ function PackageCard({
|
|
|
88
83
|
const [menuAnchorEl, setMenuAnchorEl] = useState<null | HTMLElement>(null);
|
|
89
84
|
const menuOpen = Boolean(menuAnchorEl);
|
|
90
85
|
|
|
91
|
-
const handleClick = (event: React.MouseEvent) => {
|
|
92
|
-
onSelectPackage(pkg.name, event);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
86
|
const handleMenuClick = (event: React.MouseEvent<HTMLElement>) => {
|
|
96
87
|
event.stopPropagation();
|
|
97
88
|
setMenuAnchorEl(event.currentTarget);
|
|
98
89
|
};
|
|
99
|
-
|
|
100
|
-
const handleMenuClose = () => {
|
|
101
|
-
setMenuAnchorEl(null);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const description = pkg.description ?? "";
|
|
90
|
+
const handleMenuClose = () => setMenuAnchorEl(null);
|
|
105
91
|
|
|
106
92
|
return (
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
overflow: "hidden",
|
|
155
|
-
textOverflow: "ellipsis",
|
|
156
|
-
display: "-webkit-box",
|
|
157
|
-
WebkitLineClamp: 2,
|
|
158
|
-
WebkitBoxOrient: "vertical",
|
|
159
|
-
lineHeight: 1.5,
|
|
160
|
-
}}
|
|
161
|
-
>
|
|
162
|
-
{description}
|
|
163
|
-
</Typography>
|
|
164
|
-
</Tooltip>
|
|
165
|
-
</Box>
|
|
166
|
-
{mutable && (
|
|
167
|
-
<>
|
|
168
|
-
<IconButton
|
|
169
|
-
size="small"
|
|
170
|
-
onClick={handleMenuClick}
|
|
171
|
-
aria-label={`Package actions for ${pkg.name}`}
|
|
172
|
-
sx={{ flexShrink: 0, mt: -0.5, mr: -0.5 }}
|
|
173
|
-
>
|
|
174
|
-
<MoreVert fontSize="small" />
|
|
175
|
-
</IconButton>
|
|
176
|
-
<Menu
|
|
177
|
-
anchorEl={menuAnchorEl}
|
|
178
|
-
open={menuOpen}
|
|
179
|
-
onClose={handleMenuClose}
|
|
180
|
-
onClick={(e) => e.stopPropagation()}
|
|
181
|
-
anchorOrigin={{
|
|
182
|
-
vertical: "bottom",
|
|
183
|
-
horizontal: "right",
|
|
184
|
-
}}
|
|
185
|
-
transformOrigin={{
|
|
186
|
-
vertical: "top",
|
|
187
|
-
horizontal: "right",
|
|
188
|
-
}}
|
|
189
|
-
>
|
|
190
|
-
<EditPackageDialog
|
|
191
|
-
package={pkg}
|
|
192
|
-
resourceUri={packageResourceUri}
|
|
193
|
-
onCloseDialog={handleMenuClose}
|
|
194
|
-
/>
|
|
195
|
-
<DeletePackageDialog
|
|
196
|
-
resourceUri={packageResourceUri}
|
|
197
|
-
onCloseDialog={handleMenuClose}
|
|
198
|
-
/>
|
|
199
|
-
</Menu>
|
|
200
|
-
</>
|
|
201
|
-
)}
|
|
202
|
-
</Box>
|
|
203
|
-
</CardContent>
|
|
204
|
-
</Card>
|
|
93
|
+
<ItemRow
|
|
94
|
+
icon={<Inventory2OutlinedIcon sx={{ fontSize: 18 }} />}
|
|
95
|
+
tint={SURFACE_TINT.package}
|
|
96
|
+
label={pkg.name}
|
|
97
|
+
ariaLabel={pkg.name}
|
|
98
|
+
{...(pkg.description ? { description: pkg.description } : {})}
|
|
99
|
+
onClick={(event) => onSelectPackage(pkg.name, event)}
|
|
100
|
+
{...(mutable
|
|
101
|
+
? {
|
|
102
|
+
trailingAction: (
|
|
103
|
+
<>
|
|
104
|
+
<IconButton
|
|
105
|
+
size="small"
|
|
106
|
+
onClick={handleMenuClick}
|
|
107
|
+
aria-label={`Package actions for ${pkg.name}`}
|
|
108
|
+
>
|
|
109
|
+
<MoreVert fontSize="small" />
|
|
110
|
+
</IconButton>
|
|
111
|
+
<Menu
|
|
112
|
+
anchorEl={menuAnchorEl}
|
|
113
|
+
open={menuOpen}
|
|
114
|
+
onClose={handleMenuClose}
|
|
115
|
+
onClick={(event) => event.stopPropagation()}
|
|
116
|
+
anchorOrigin={{
|
|
117
|
+
vertical: "bottom",
|
|
118
|
+
horizontal: "right",
|
|
119
|
+
}}
|
|
120
|
+
transformOrigin={{
|
|
121
|
+
vertical: "top",
|
|
122
|
+
horizontal: "right",
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
<EditPackageDialog
|
|
126
|
+
package={pkg}
|
|
127
|
+
resourceUri={packageResourceUri}
|
|
128
|
+
onCloseDialog={handleMenuClose}
|
|
129
|
+
/>
|
|
130
|
+
<DeletePackageDialog
|
|
131
|
+
resourceUri={packageResourceUri}
|
|
132
|
+
onCloseDialog={handleMenuClose}
|
|
133
|
+
/>
|
|
134
|
+
</Menu>
|
|
135
|
+
</>
|
|
136
|
+
),
|
|
137
|
+
}
|
|
138
|
+
: {})}
|
|
139
|
+
/>
|
|
205
140
|
);
|
|
206
141
|
}
|
|
@@ -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
|
}
|