@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
|
@@ -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
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { IconButton, type IconButtonProps } from "@mui/material";
|
|
5
|
+
import { usePublisherTheme } from "../theme/ThemeContext";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A small round button that sits OVER content — a rendered result, an
|
|
9
|
+
* explorer, a chart — to open something about it: the code, the full result,
|
|
10
|
+
* a render warning.
|
|
11
|
+
*
|
|
12
|
+
* On the instance theme's tile colour, with its border, so it reads as a chip
|
|
13
|
+
* of the same card it floats on in both modes. Six of these were drawn by hand
|
|
14
|
+
* before, every one on a hardcoded white plate with a hardcoded dark icon,
|
|
15
|
+
* and the notebook's comment said why that was the only way: a white plate
|
|
16
|
+
* needs a dark icon whatever the mode. The plate follows the theme now, so
|
|
17
|
+
* the icon can too.
|
|
18
|
+
*
|
|
19
|
+
* Positioning is the caller's: it passes `sx` for where the button floats.
|
|
20
|
+
*/
|
|
21
|
+
export function FloatingIconButton({ sx, ...props }: IconButtonProps) {
|
|
22
|
+
const { theme } = usePublisherTheme();
|
|
23
|
+
return (
|
|
24
|
+
<IconButton
|
|
25
|
+
size="small"
|
|
26
|
+
{...props}
|
|
27
|
+
sx={[
|
|
28
|
+
{
|
|
29
|
+
width: 32,
|
|
30
|
+
height: 32,
|
|
31
|
+
bgcolor: theme.tile,
|
|
32
|
+
border: theme.border,
|
|
33
|
+
color: theme.tileTitle,
|
|
34
|
+
"&:hover": { bgcolor: theme.tile, color: theme.drillLink },
|
|
35
|
+
"& .MuiSvgIcon-root": { fontSize: 18 },
|
|
36
|
+
},
|
|
37
|
+
...(Array.isArray(sx) ? sx : [sx]),
|
|
38
|
+
]}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|