@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.
Files changed (136) hide show
  1. package/README.md +33 -9
  2. package/dist/{DocumentStorageProvider-tGvodI8f.es.js → DocumentStorage-BiFqO15i.es.js} +7126 -6943
  3. package/dist/DocumentStorage-CMyLifsz.cjs.js +134 -0
  4. package/dist/RenderedResult-CZzE8wv-.cjs.js +115 -0
  5. package/dist/{RenderedResult-mDE-4u8S.es.js → RenderedResult-CvrmYyr5.es.js} +64 -57
  6. package/dist/{ServerProvider-X2Ma0HRs.es.js → ServerProvider-BWOEKg0O.es.js} +1217 -1244
  7. package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
  8. package/dist/builder/index.cjs.js +52 -52
  9. package/dist/builder/index.es.js +3961 -3960
  10. package/dist/client/api.d.ts +100 -42
  11. package/dist/client/index.cjs.js +1 -1
  12. package/dist/client/index.es.js +1 -1
  13. package/dist/components/AppDialog.d.ts +30 -0
  14. package/dist/components/BackLink.d.ts +32 -0
  15. package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
  16. package/dist/components/Dashboard/telemetry.d.ts +24 -7
  17. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +12 -10
  18. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +20 -2
  19. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +21 -11
  20. package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
  21. package/dist/components/DashboardBuilder/spliceDocument.d.ts +10 -1
  22. package/dist/components/DocumentStorage/DocumentStorage.d.ts +69 -5
  23. package/dist/components/DocumentStorage/index.d.ts +1 -0
  24. package/dist/components/ItemRow.d.ts +38 -0
  25. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
  26. package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
  27. package/dist/components/Materializations/Materializations.d.ts +7 -3
  28. package/dist/components/Materializations/ScopeButton.d.ts +18 -0
  29. package/dist/components/Materializations/SectionLabel.d.ts +7 -4
  30. package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
  31. package/dist/components/Materializations/index.d.ts +0 -1
  32. package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
  33. package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
  34. package/dist/components/Package/index.d.ts +0 -1
  35. package/dist/components/PackageSection.d.ts +23 -0
  36. package/dist/components/buttons.d.ts +53 -0
  37. package/dist/components/index.d.ts +5 -0
  38. package/dist/components/styles.d.ts +49 -40
  39. package/dist/hooks/useCrudMutation.d.ts +42 -0
  40. package/dist/index.cjs.js +22 -26
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.es.js +17431 -20676
  43. package/dist/telemetry/consoleEvents.d.ts +60 -0
  44. package/dist/utils/sha256.d.ts +2 -0
  45. package/package.json +1 -1
  46. package/src/components/AppDialog.tsx +115 -0
  47. package/src/components/BackLink.tsx +83 -0
  48. package/src/components/Connections/AddConnectionDialog.tsx +50 -70
  49. package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
  50. package/src/components/Connections/EditConnectionDialog.tsx +54 -73
  51. package/src/components/Dashboard/DashboardBar.tsx +88 -0
  52. package/src/components/Dashboard/telemetry.ts +24 -5
  53. package/src/components/DashboardBuilder/AddTileDialog.tsx +141 -143
  54. package/src/components/DashboardBuilder/BuilderToolbar.tsx +110 -218
  55. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +5 -11
  56. package/src/components/DashboardBuilder/DashboardBuilder.tsx +202 -171
  57. package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +706 -0
  58. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
  59. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +2 -25
  60. package/src/components/DashboardBuilder/DashboardEditor.tsx +442 -94
  61. package/src/components/DashboardBuilder/DiffDialog.tsx +75 -82
  62. package/src/components/DashboardBuilder/DrillDialog.tsx +144 -156
  63. package/src/components/DashboardBuilder/FilterDialog.tsx +276 -295
  64. package/src/components/DashboardBuilder/FilterStrip.tsx +11 -10
  65. package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
  66. package/src/components/DashboardBuilder/newDashboard.ts +48 -0
  67. package/src/components/DashboardBuilder/spliceDocument.spec.ts +53 -0
  68. package/src/components/DashboardBuilder/spliceDocument.ts +45 -8
  69. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +56 -0
  70. package/src/components/DashboardBuilder/useDashboardEditor.ts +12 -4
  71. package/src/components/DocumentStorage/BrowserDocumentStorage.ts +7 -6
  72. package/src/components/DocumentStorage/DocumentStorage.ts +78 -5
  73. package/src/components/DocumentStorage/index.ts +1 -0
  74. package/src/components/Environment/About.tsx +14 -28
  75. package/src/components/Environment/AddPackageDialog.tsx +85 -154
  76. package/src/components/Environment/Connections.tsx +125 -205
  77. package/src/components/Environment/DeletePackageDialog.tsx +32 -77
  78. package/src/components/Environment/EditPackageDialog.tsx +46 -58
  79. package/src/components/Environment/Environment.tsx +34 -36
  80. package/src/components/Environment/Packages.tsx +63 -128
  81. package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
  82. package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
  83. package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
  84. package/src/components/Home/Home.tsx +101 -214
  85. package/src/components/ItemRow.tsx +165 -0
  86. package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
  87. package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
  88. package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
  89. package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
  90. package/src/components/Materializations/Materializations.tsx +137 -140
  91. package/src/components/Materializations/ScopeButton.tsx +85 -0
  92. package/src/components/Materializations/SectionLabel.tsx +7 -4
  93. package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
  94. package/src/components/Materializations/TriggerLabel.tsx +36 -0
  95. package/src/components/Materializations/cron.spec.ts +113 -0
  96. package/src/components/Materializations/index.ts +0 -1
  97. package/src/components/Materializations/utils.spec.ts +182 -0
  98. package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
  99. package/src/components/Package/ContentTypeIcon.tsx +10 -12
  100. package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
  101. package/src/components/Package/NewDashboardDialog.tsx +265 -0
  102. package/src/components/Package/Package.tsx +184 -238
  103. package/src/components/Package/index.ts +0 -1
  104. package/src/components/PackageSection.tsx +85 -0
  105. package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
  106. package/src/components/RenderedResult/RenderedResult.tsx +22 -8
  107. package/src/components/ResultsDialog.tsx +8 -32
  108. package/src/components/buttons.tsx +114 -0
  109. package/src/components/designSystem.spec.tsx +316 -0
  110. package/src/components/given/paramCodec.spec.ts +1 -1
  111. package/src/components/index.ts +10 -0
  112. package/src/components/styles.ts +49 -85
  113. package/src/hooks/useCrudMutation.spec.tsx +119 -0
  114. package/src/hooks/useCrudMutation.tsx +85 -0
  115. package/src/index.ts +9 -0
  116. package/src/telemetry/consoleEvents.spec.ts +130 -0
  117. package/src/telemetry/consoleEvents.ts +124 -0
  118. package/src/theme/defaults.ts +34 -23
  119. package/src/theme/resolveTheme.spec.ts +9 -4
  120. package/src/theme/resolveTheme.ts +12 -8
  121. package/src/utils/sha256.ts +13 -0
  122. package/test/README.md +1 -1
  123. package/test/serverProvider.tsx +5 -2
  124. package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +0 -134
  125. package/dist/RenderedResult-CPi6uQWq.cjs.js +0 -115
  126. package/dist/ServerProvider-CH71GsoL.cjs.js +0 -1
  127. package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
  128. package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
  129. package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
  130. package/dist/components/Materializations/TriggerChip.d.ts +0 -10
  131. package/dist/components/Package/Models.d.ts +0 -6
  132. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
  133. package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
  134. package/src/components/Materializations/ScheduleCard.tsx +0 -231
  135. package/src/components/Materializations/TriggerChip.tsx +0 -44
  136. package/src/components/Package/Models.tsx +0 -71
@@ -0,0 +1,60 @@
1
+ /**
2
+ * What the Console reports about the things it CHANGES.
3
+ *
4
+ * The dashboard surfaces already report themselves through `DashboardEvent`,
5
+ * which the host wires per surface because each one is mounted with a
6
+ * dashboard's name. The Console's writes are not like that: create, edit and
7
+ * delete for environments, packages, connections and materializations happen
8
+ * inside dialogs the host never mounts directly, and there is no seam to pass
9
+ * a handler down through. So the sink is set once, by the host, at boot.
10
+ *
11
+ * Until now those writes reported to a six-second snackbar and nothing else.
12
+ * There was no record that a package had been deleted, or that a delete had
13
+ * failed — the operations whose outcome someone is most likely to be asked
14
+ * about afterwards.
15
+ */
16
+ /** The thing being written. */
17
+ export type ConsoleResource = "environment" | "package" | "connection" | "materialization" | "schedule" | "scope";
18
+ export type ConsoleEvent = {
19
+ type: "console.mutation";
20
+ resource: ConsoleResource;
21
+ /** What was done to it. */
22
+ action: "create" | "update" | "delete";
23
+ ok: boolean;
24
+ durationMs: number;
25
+ /** Present when `ok` is false: the message the operator was shown. */
26
+ reason?: string;
27
+ };
28
+ export type ConsoleEventHandler = (event: ConsoleEvent) => void;
29
+ /**
30
+ * Install the host's sink. Called once at boot; called again, it replaces.
31
+ * Passing `undefined` removes it, which is what a test wants between cases.
32
+ */
33
+ export declare function setConsoleEventHandler(next: ConsoleEventHandler | undefined): void;
34
+ /**
35
+ * Report one event, if anyone is listening.
36
+ *
37
+ * Never throws, and never lets a sink's own failure reach the caller: this is
38
+ * called from the success and error paths of a write, and a telemetry bug that
39
+ * turned a successful delete into a visible error would be worse than the
40
+ * missing line it is reporting.
41
+ */
42
+ export declare function reportConsoleEvent(event: ConsoleEvent): void;
43
+ /**
44
+ * Wrap a mutation's function so it reports itself.
45
+ *
46
+ * The write that reports is the `mutationFn`, not the hook around it, because
47
+ * the Console has two shapes of write and only one of them fits a shared hook.
48
+ * The CRUD dialogs each own a mutation, a snackbar and a dialog to close, and
49
+ * {@link useCrudMutation} holds all three. Connections and Materializations do
50
+ * not: they `mutateAsync` from a caller that awaits the promise, and share one
51
+ * snackbar across several mutations at the component level. Forcing those onto
52
+ * the dialog hook would mean giving them a snackbar each and a dialog to close
53
+ * that they do not have.
54
+ *
55
+ * Wrapping the function instead fits both, and reports the same event either
56
+ * way: it times what the caller actually waits on, it sees the rejection
57
+ * before any handler has turned it into a message, and it re-throws unchanged
58
+ * so nothing downstream can tell it is there.
59
+ */
60
+ export declare function reporting<F extends (variables: never) => Promise<unknown>>(resource: ConsoleResource, action: ConsoleEvent["action"], mutationFn: F): F;
@@ -0,0 +1,2 @@
1
+ /** SHA-256 of a string, hex — the `expectedHash` a dashboard write carries. */
2
+ export declare function sha256Hex(text: string): Promise<string>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@malloy-publisher/sdk",
3
3
  "description": "Malloy Publisher SDK",
4
- "version": "0.3.1",
4
+ "version": "0.4.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.es.js",
@@ -0,0 +1,115 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import CloseIcon from "@mui/icons-material/Close";
5
+ import {
6
+ Dialog,
7
+ DialogActions,
8
+ DialogContent,
9
+ DialogTitle,
10
+ IconButton,
11
+ Stack,
12
+ Typography,
13
+ } from "@mui/material";
14
+ import * as React from "react";
15
+ import { useId } from "react";
16
+
17
+ /**
18
+ * Every dialog in the Console, in one shape.
19
+ *
20
+ * A dialog is a page that arrived in a box: it should be set like one. The
21
+ * title is the page's heading at the same size, weight and tracking; a line
22
+ * under it says what the dialog is for, where a page's description would be;
23
+ * the body is one column with one gap; and the actions sit at the bottom right
24
+ * with the same padding every time — a text Cancel and a filled confirm, the
25
+ * two roles `buttons.tsx` names.
26
+ *
27
+ * Three dialogs stay off it deliberately, and each needs something this does
28
+ * not have: `ModelExplorerDialog` is `fullScreen`, and `RowsDialog` and
29
+ * `MaterializationDetailDialog` title themselves with a node rather than a
30
+ * string. Widening this for three callers would cost more than it saves —
31
+ * but a fourth exception is a reason to widen it, not to hand-roll a fourth.
32
+ */
33
+ export function AppDialog({
34
+ open,
35
+ onClose,
36
+ title,
37
+ description,
38
+ maxWidth = "sm",
39
+ showClose = false,
40
+ actions,
41
+ children,
42
+ }: {
43
+ open: boolean;
44
+ onClose: () => void;
45
+ title: string;
46
+ /** What the dialog is for, in a line. The page's description, in a box. */
47
+ description?: React.ReactNode;
48
+ maxWidth?: "xs" | "sm" | "md" | "lg" | false;
49
+ /** An X in the title, for a dialog whose actions do not include a way out. */
50
+ showClose?: boolean;
51
+ /** The buttons, in order. Cancel first, the thing it does last. */
52
+ actions?: React.ReactNode;
53
+ children: React.ReactNode;
54
+ }) {
55
+ const titleId = useId();
56
+ return (
57
+ <Dialog
58
+ open={open}
59
+ onClose={onClose}
60
+ maxWidth={maxWidth}
61
+ fullWidth
62
+ aria-labelledby={titleId}
63
+ >
64
+ <DialogTitle
65
+ id={titleId}
66
+ sx={{
67
+ px: 3,
68
+ pt: 3,
69
+ pb: description ? 0.5 : 1,
70
+ display: "flex",
71
+ alignItems: "center",
72
+ justifyContent: "space-between",
73
+ gap: 1,
74
+ // The page heading's type, so a dialog reads as part of the same
75
+ // application rather than as a system alert.
76
+ fontSize: "1.25rem",
77
+ fontWeight: 600,
78
+ letterSpacing: "-0.025em",
79
+ lineHeight: 1.2,
80
+ }}
81
+ >
82
+ {title}
83
+ {showClose && (
84
+ <IconButton
85
+ aria-label="Close"
86
+ onClick={onClose}
87
+ size="small"
88
+ sx={{ color: "text.secondary", mr: -1 }}
89
+ >
90
+ <CloseIcon fontSize="small" />
91
+ </IconButton>
92
+ )}
93
+ </DialogTitle>
94
+ <DialogContent sx={{ px: 3, pb: 1, pt: 1 }}>
95
+ {description && (
96
+ <Typography
97
+ variant="body2"
98
+ color="text.secondary"
99
+ sx={{ mb: 2 }}
100
+ >
101
+ {description}
102
+ </Typography>
103
+ )}
104
+ {/* One column, one gap: a dialog's fields are a list, and the list
105
+ should not be spaced by whatever margin each field brought. */}
106
+ <Stack sx={{ gap: 2, pt: description ? 0 : 1 }}>{children}</Stack>
107
+ </DialogContent>
108
+ {actions && (
109
+ <DialogActions sx={{ px: 3, pb: 3, pt: 2, gap: 1 }}>
110
+ {actions}
111
+ </DialogActions>
112
+ )}
113
+ </Dialog>
114
+ );
115
+ }
@@ -0,0 +1,83 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import ArrowBackIcon from "@mui/icons-material/ArrowBack";
5
+ import { Link } from "@mui/material";
6
+ import * as React from "react";
7
+
8
+ /**
9
+ * The way up, at the top of a page: an arrow and the name of the thing you came
10
+ * from.
11
+ *
12
+ * Every page that has a parent shows one, in this one shape. The breadcrumb in
13
+ * the app's header bar is a different affordance and does not replace it: it is
14
+ * chrome the eye skips, it cannot say what the parent IS (it renders a model
15
+ * path as one opaque chip), and it is absent on the pages the app shell does
16
+ * not parameterise.
17
+ *
18
+ * The click is the host's, so a Console navigates its router and an embedder
19
+ * does whatever it does. Give it an `href` as well wherever the parent has a
20
+ * URL: that is what makes it a link rather than a widget that looks like one —
21
+ * focusable from the keyboard, announced as a link, and shown in the status bar
22
+ * on hover. Without an `href` it still has to be reachable, so it renders as a
23
+ * button rather than as an anchor with nothing to point at, which is focusable
24
+ * by neither keyboard nor assistive technology.
25
+ *
26
+ * A PLAIN left click is the host's and the default is suppressed, or the page
27
+ * would navigate twice — once through the host's router and once as a document
28
+ * load, which is the slower of the two and undoes the first. A middle-click or
29
+ * a modified click is deliberately left to the browser: that is what opens the
30
+ * parent in a new tab, and it is the reason for the `href` in the first place.
31
+ */
32
+ export function BackLink({
33
+ label,
34
+ href,
35
+ onClick,
36
+ }: {
37
+ /** The parent, named: "Back to {label}". */
38
+ label: string;
39
+ /** The parent's URL, when it has one. */
40
+ href?: string;
41
+ onClick: (event: React.MouseEvent) => void;
42
+ }) {
43
+ const handleClick = (event: React.MouseEvent) => {
44
+ const modified =
45
+ event.metaKey ||
46
+ event.ctrlKey ||
47
+ event.shiftKey ||
48
+ event.altKey ||
49
+ event.button !== 0;
50
+ if (href !== undefined && modified) return;
51
+ event.preventDefault();
52
+ onClick(event);
53
+ };
54
+ return (
55
+ <Link
56
+ {...(href === undefined
57
+ ? { component: "button" as const, type: "button" as const }
58
+ : { href })}
59
+ onClick={handleClick}
60
+ underline="none"
61
+ aria-label={`Back to ${label}`}
62
+ sx={{
63
+ display: "inline-flex",
64
+ alignItems: "center",
65
+ gap: 0.5,
66
+ cursor: "pointer",
67
+ color: "text.secondary",
68
+ fontSize: "0.875rem",
69
+ mb: 2,
70
+ // A `component="button"` link brings the platform's button chrome
71
+ // with it; this is a link either way.
72
+ border: 0,
73
+ p: 0,
74
+ background: "none",
75
+ font: "inherit",
76
+ "&:hover": { color: "primary.main" },
77
+ }}
78
+ >
79
+ <ArrowBackIcon sx={{ fontSize: 18 }} />
80
+ Back to {label}
81
+ </Link>
82
+ );
83
+ }
@@ -5,12 +5,8 @@ import AddIcon from "@mui/icons-material/Add";
5
5
  import DeleteIcon from "@mui/icons-material/Delete";
6
6
  import Box from "@mui/material/Box";
7
7
  import Button from "@mui/material/Button";
8
- import Dialog from "@mui/material/Dialog";
9
- import DialogActions from "@mui/material/DialogActions";
10
- import DialogContent from "@mui/material/DialogContent";
11
- import DialogContentText from "@mui/material/DialogContentText";
12
- import DialogTitle from "@mui/material/DialogTitle";
13
8
  import IconButton from "@mui/material/IconButton";
9
+ import Stack from "@mui/material/Stack";
14
10
  import TextField from "@mui/material/TextField";
15
11
  import Typography from "@mui/material/Typography";
16
12
  import React, { useState } from "react";
@@ -23,6 +19,8 @@ import {
23
19
  ConnectionTypeEnum,
24
20
  DucklakeConnection,
25
21
  } from "../../client/api";
22
+ import { AppDialog } from "../AppDialog";
23
+ import { AddButton, SecondaryButton } from "../buttons";
26
24
  import {
27
25
  attachedDatabaseConnectionFieldName,
28
26
  attributesFieldName,
@@ -401,43 +399,49 @@ export default function AddConnectionDialog({
401
399
 
402
400
  return (
403
401
  <React.Fragment>
404
- {/* Contained with a start icon, matching AddEnvironmentDialog and
405
- AddPackageDialog. This was the only add-trigger of the three still
406
- outlined and icon-less, which read as the secondary action on a
407
- screen where it is the primary one. */}
408
- <Button
409
- variant="contained"
410
- color="primary"
411
- startIcon={<AddIcon />}
412
- onClick={handleClickOpen}
402
+ <AddButton label="Connection" onClick={handleClickOpen} />
403
+ <AppDialog
404
+ open={open}
405
+ onClose={handleClose}
406
+ title="New connection"
407
+ description="Add a connection so packages in this environment can query your database with Malloy."
408
+ actions={
409
+ <>
410
+ <Button disabled={isSubmitting} onClick={handleClose}>
411
+ Cancel
412
+ </Button>
413
+ <Button
414
+ type="submit"
415
+ form="connection-form"
416
+ variant="contained"
417
+ loading={isSubmitting}
418
+ >
419
+ Create connection
420
+ </Button>
421
+ </>
422
+ }
413
423
  >
414
- Add Connection
415
- </Button>
416
- <Dialog open={open} onClose={handleClose}>
417
- <DialogTitle>Create New Connection</DialogTitle>
418
- <DialogContent>
419
- <DialogContentText>
420
- Add a new connection to query your data database using Malloy.
421
- </DialogContentText>
422
- <form onSubmit={handleSubmit} id="connection-form">
424
+ <form onSubmit={handleSubmit} id="connection-form">
425
+ {/* One column, one gap. The fields carry no margin of
426
+ their own, so without this they sit flush and their
427
+ borders overlap. */}
428
+ <Stack sx={{ gap: 2 }}>
423
429
  <TextField
424
430
  autoFocus
425
431
  required
426
- margin="dense"
427
432
  id="name"
428
433
  name="name"
429
- label="Connection Name"
434
+ label="Name"
430
435
  type="text"
431
436
  fullWidth
432
- variant="standard"
437
+ size="small"
433
438
  />
434
439
  <TextField
435
- margin="dense"
436
440
  id="type"
437
441
  name="type"
438
442
  label="Connection Type"
439
443
  fullWidth
440
- variant="standard"
444
+ size="small"
441
445
  value={type}
442
446
  select
443
447
  onChange={(event) =>
@@ -469,11 +473,10 @@ export default function AddConnectionDialog({
469
473
  Catalog
470
474
  </Typography>
471
475
  <TextField
472
- margin="dense"
473
476
  id="ducklake_catalogType"
474
477
  label="Catalog Type"
475
478
  fullWidth
476
- variant="standard"
479
+ size="small"
477
480
  value={ducklakeCatalogType}
478
481
  select
479
482
  onChange={(event) =>
@@ -488,13 +491,12 @@ export default function AddConnectionDialog({
488
491
  (field) => (
489
492
  <TextField
490
493
  key={`pg_${field.name}`}
491
- margin="dense"
492
494
  id={`ducklake_pg_${field.name}`}
493
495
  name={`ducklake_pg_${field.name}`}
494
496
  label={field.label}
495
497
  type={field.type}
496
498
  fullWidth
497
- variant="standard"
499
+ size="small"
498
500
  />
499
501
  ),
500
502
  )}
@@ -518,11 +520,10 @@ export default function AddConnectionDialog({
518
520
  Storage
519
521
  </Typography>
520
522
  <TextField
521
- margin="dense"
522
523
  id="ducklake_storageType"
523
524
  label="Storage Type"
524
525
  fullWidth
525
- variant="standard"
526
+ size="small"
526
527
  value={ducklakeStorageType}
527
528
  select
528
529
  onChange={(event) =>
@@ -533,7 +534,6 @@ export default function AddConnectionDialog({
533
534
  <MenuItem value="gcs">GCS</MenuItem>
534
535
  </TextField>
535
536
  <TextField
536
- margin="dense"
537
537
  required
538
538
  id="ducklake_bucketUrl"
539
539
  name="ducklake_bucketUrl"
@@ -544,7 +544,7 @@ export default function AddConnectionDialog({
544
544
  }
545
545
  type="text"
546
546
  fullWidth
547
- variant="standard"
547
+ size="small"
548
548
  />
549
549
  {ducklakeStorageType === "s3" && (
550
550
  <>
@@ -565,7 +565,6 @@ export default function AddConnectionDialog({
565
565
  .map((field) => (
566
566
  <TextField
567
567
  key={`s3_${field.name}`}
568
- margin="dense"
569
568
  id={`ducklake_s3_${field.name}`}
570
569
  name={`ducklake_s3_${field.name}`}
571
570
  label={field.label}
@@ -575,7 +574,7 @@ export default function AddConnectionDialog({
575
574
  : field.type
576
575
  }
577
576
  fullWidth
578
- variant="standard"
577
+ size="small"
579
578
  required={field.required}
580
579
  select={!!field.selectOptions}
581
580
  defaultValue={
@@ -623,13 +622,12 @@ export default function AddConnectionDialog({
623
622
  {gcsAttachedDatabaseFields.map((field) => (
624
623
  <TextField
625
624
  key={`gcs_${field.name}`}
626
- margin="dense"
627
625
  id={`ducklake_gcs_${field.name}`}
628
626
  name={`ducklake_gcs_${field.name}`}
629
627
  label={field.label}
630
628
  type={field.type}
631
629
  fullWidth
632
- variant="standard"
630
+ size="small"
633
631
  required={field.required}
634
632
  />
635
633
  ))}
@@ -650,14 +648,12 @@ export default function AddConnectionDialog({
650
648
  <Typography variant="subtitle1" fontWeight={500}>
651
649
  Attached Databases
652
650
  </Typography>
653
- <Button
654
- startIcon={<AddIcon />}
651
+ <SecondaryButton
652
+ label="Database"
653
+ icon={<AddIcon />}
655
654
  onClick={addAttachedDatabase}
656
- size="small"
657
- variant="outlined"
658
- >
659
- Add Database
660
- </Button>
655
+ ariaLabel="Add database"
656
+ />
661
657
  </Box>
662
658
  {attachedDatabases.length === 0 && (
663
659
  <Typography
@@ -707,23 +703,21 @@ export default function AddConnectionDialog({
707
703
  </IconButton>
708
704
  </Box>
709
705
  <TextField
710
- margin="dense"
711
706
  required
712
707
  id={`attachedDb_${index}_name`}
713
708
  name={`attachedDb_${index}_name`}
714
709
  label="Database Name"
715
710
  type="text"
716
711
  fullWidth
717
- variant="standard"
712
+ size="small"
718
713
  defaultValue={db.name}
719
714
  />
720
715
  <TextField
721
- margin="dense"
722
716
  id={`attachedDb_${index}_type`}
723
717
  name={`attachedDb_${index}_type`}
724
718
  label="Database Type"
725
719
  fullWidth
726
- variant="standard"
720
+ size="small"
727
721
  value={db.dbType}
728
722
  select
729
723
  onChange={(event) =>
@@ -760,7 +754,6 @@ export default function AddConnectionDialog({
760
754
  .map((field) => (
761
755
  <TextField
762
756
  key={field.name}
763
- margin="dense"
764
757
  id={`attachedDb_${index}_${field.name}`}
765
758
  name={`attachedDb_${index}_${field.name}`}
766
759
  label={field.label}
@@ -770,7 +763,7 @@ export default function AddConnectionDialog({
770
763
  : field.type
771
764
  }
772
765
  fullWidth
773
- variant="standard"
766
+ size="small"
774
767
  required={field.required}
775
768
  select={!!field.selectOptions}
776
769
  defaultValue={
@@ -814,32 +807,19 @@ export default function AddConnectionDialog({
814
807
  connectionFieldsByType[type].map((field) => (
815
808
  <TextField
816
809
  key={field.name}
817
- margin="dense"
818
810
  id={field.name}
819
811
  name={field.name}
820
812
  label={field.label}
821
813
  type={field.type}
822
814
  fullWidth
823
- variant="standard"
815
+ size="small"
824
816
  required={field.required}
825
817
  />
826
818
  ))
827
819
  )}
828
- </form>
829
- </DialogContent>
830
- <DialogActions>
831
- <Button disabled={isSubmitting} onClick={handleClose}>
832
- Cancel
833
- </Button>
834
- <Button
835
- type="submit"
836
- form="connection-form"
837
- loading={isSubmitting}
838
- >
839
- Create Connection
840
- </Button>
841
- </DialogActions>
842
- </Dialog>
820
+ </Stack>
821
+ </form>
822
+ </AppDialog>
843
823
  </React.Fragment>
844
824
  );
845
825
  }
@@ -2,20 +2,14 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
4
  import { Delete } from "@mui/icons-material";
5
- import CloseIcon from "@mui/icons-material/Close";
6
- import { Snackbar } from "@mui/material";
7
5
  import Button from "@mui/material/Button";
8
- import Dialog from "@mui/material/Dialog";
9
- import DialogActions from "@mui/material/DialogActions";
10
- import DialogContent from "@mui/material/DialogContent";
11
- import DialogTitle from "@mui/material/DialogTitle";
12
- import IconButton from "@mui/material/IconButton";
13
6
  import ListItemIcon from "@mui/material/ListItemIcon";
14
7
  import ListItemText from "@mui/material/ListItemText";
15
8
  import MenuItem from "@mui/material/MenuItem";
16
9
  import Typography from "@mui/material/Typography";
17
10
  import React, { useState } from "react";
18
11
  import { Connection } from "../../client";
12
+ import { AppDialog } from "../AppDialog";
19
13
 
20
14
  export default function DeleteConnectionDialog({
21
15
  connection,
@@ -29,7 +23,6 @@ export default function DeleteConnectionDialog({
29
23
  onDelete: () => void;
30
24
  }) {
31
25
  const [open, setOpen] = useState(false);
32
- const [notificationMessage, setNotificationMessage] = useState("");
33
26
  const handleClickOpen = () => {
34
27
  setOpen(true);
35
28
  };
@@ -54,50 +47,30 @@ export default function DeleteConnectionDialog({
54
47
  <ListItemText>Delete</ListItemText>
55
48
  </MenuItem>
56
49
 
57
- <Dialog
58
- onClose={handleClose}
59
- aria-labelledby="customized-dialog-title"
50
+ <AppDialog
60
51
  open={open}
52
+ onClose={handleClose}
53
+ title="Delete connection"
54
+ actions={
55
+ <>
56
+ <Button onClick={handleClose}>Cancel</Button>
57
+ <Button
58
+ variant="contained"
59
+ color="error"
60
+ autoFocus
61
+ onClick={() => onDelete()}
62
+ loading={isMutating}
63
+ >
64
+ Delete connection
65
+ </Button>
66
+ </>
67
+ }
61
68
  >
62
- <DialogTitle sx={{ m: 0, p: 2 }} id="customized-dialog-title">
63
- Delete Connection
64
- </DialogTitle>
65
- <IconButton
66
- aria-label="close"
67
- onClick={handleClose}
68
- sx={(theme) => ({
69
- position: "absolute",
70
- right: 8,
71
- top: 8,
72
- color: theme.palette.grey[500],
73
- })}
74
- >
75
- <CloseIcon />
76
- </IconButton>
77
- <DialogContent dividers>
78
- <Typography gutterBottom>
79
- Are you sure you want to delete &quot;{connection.name}&quot;?
80
- This action cannot be undone.
81
- </Typography>
82
- </DialogContent>
83
- <DialogActions>
84
- <Button
85
- loading={isMutating}
86
- variant="contained"
87
- autoFocus
88
- onClick={() => onDelete()}
89
- color="error"
90
- >
91
- Delete
92
- </Button>
93
- </DialogActions>
94
- <Snackbar
95
- open={notificationMessage !== ""}
96
- autoHideDuration={6000}
97
- onClose={() => setNotificationMessage("")}
98
- message={notificationMessage}
99
- />
100
- </Dialog>
69
+ <Typography variant="body2">
70
+ Delete <strong>{connection.name}</strong>? Packages that query
71
+ through it stop working, and this cannot be undone.
72
+ </Typography>
73
+ </AppDialog>
101
74
  </React.Fragment>
102
75
  );
103
76
  }