@malloy-publisher/sdk 0.0.36 → 0.0.37

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.
@@ -1,32 +1,33 @@
1
1
  // TODO(jjs) - Export to .malloynb
2
2
  // TOOD(jjs) - Import via Publisher API that parses whole NB
3
3
 
4
+ import AddIcon from "@mui/icons-material/Add";
4
5
  import {
5
6
  Box,
6
7
  Button,
7
- CardActions,
8
8
  Dialog,
9
9
  DialogActions,
10
10
  DialogContent,
11
11
  DialogContentText,
12
12
  DialogTitle,
13
+ Divider,
13
14
  Menu,
14
15
  MenuItem,
15
16
  Typography,
16
17
  } from "@mui/material";
17
18
  import Stack from "@mui/material/Stack";
18
19
  import React from "react";
19
- import { useRouterClickHandler } from "../click_helper";
20
20
  import { Configuration, ModelsApi } from "../../client";
21
+ import { useRouterClickHandler } from "../click_helper";
21
22
  import { SourceAndPath } from "../Model/SourcesExplorer";
22
23
  import { NotebookManager } from "../NotebookManager";
23
24
  import { usePackage } from "../Package";
24
25
  import { StyledCard, StyledCardContent, StyledCardMedia } from "../styles";
25
- import { ModelPicker } from "./ModelPicker";
26
26
  import { MutableCell } from "./MutableCell";
27
27
  import { useNotebookStorage } from "./NotebookStorageProvider";
28
28
 
29
29
  import * as Malloy from "@malloydata/malloy-interfaces";
30
+ import { ModelPicker } from "./ModelPicker";
30
31
 
31
32
  const modelsApi = new ModelsApi(new Configuration());
32
33
 
@@ -34,6 +35,7 @@ interface MutableNotebookProps {
34
35
  notebookPath?: string;
35
36
  expandCodeCells?: boolean;
36
37
  expandEmbeddings?: boolean;
38
+ hideEmbeddingIcons?: boolean;
37
39
  }
38
40
 
39
41
  interface PathToSources {
@@ -45,6 +47,7 @@ export default function MutableNotebook({
45
47
  notebookPath,
46
48
  expandCodeCells,
47
49
  expandEmbeddings,
50
+ hideEmbeddingIcons,
48
51
  }: MutableNotebookProps) {
49
52
  const navigate = useRouterClickHandler();
50
53
  const { server, projectName, packageName, versionId, accessToken } =
@@ -201,27 +204,6 @@ export default function MutableNotebook({
201
204
  }
202
205
  return sourceAndPath;
203
206
  };
204
- const createButtons = (index: number) => {
205
- return (
206
- <CardActions
207
- sx={{
208
- padding: "0px 10px 0px 10px",
209
- mb: "auto",
210
- mt: "auto",
211
- justifyContent: "flex-end",
212
- }}
213
- >
214
- <Button
215
- variant="outlined"
216
- size="small"
217
- startIcon={<AddIcon />}
218
- onClick={(e) => handleMenuClick(e, index)}
219
- >
220
- New Cell
221
- </Button>
222
- </CardActions>
223
- );
224
- };
225
207
  return (
226
208
  <StyledCard variant="outlined">
227
209
  <StyledCardContent>
@@ -229,19 +211,32 @@ export default function MutableNotebook({
229
211
  sx={{
230
212
  flexDirection: "row",
231
213
  justifyContent: "space-between",
214
+ alignItems: "center",
232
215
  }}
233
216
  >
234
- <Box sx={{ display: "flex", alignItems: "top", gap: 1 }}>
217
+ <Stack direction="row" spacing={1} alignItems="center">
235
218
  <Typography
219
+ variant="overline"
236
220
  sx={{
237
- fontSize: "150%",
238
- minHeight: "56px",
221
+ fontSize: "13px",
239
222
  fontWeight: "bold",
223
+ verticalAlign: "middle",
240
224
  }}
241
225
  >
242
- Notebook - {notebookPath}
226
+ Workbook
243
227
  </Typography>
244
- </Box>
228
+ <Typography
229
+ variant="subtitle2"
230
+ sx={{
231
+ fontSize: "13px",
232
+ fontWeight: "normal",
233
+ verticalAlign: "middle",
234
+ ml: 1,
235
+ }}
236
+ >
237
+ {`${projectName} > ${packageName} > ${notebookPath}`}
238
+ </Typography>
239
+ </Stack>
245
240
  <Stack sx={{ display: "flex", flexDirection: "row", gap: 1 }}>
246
241
  <Box
247
242
  sx={{
@@ -262,11 +257,11 @@ export default function MutableNotebook({
262
257
  }}
263
258
  >
264
259
  <Button
265
- variant="outlined"
266
260
  color="error"
267
261
  onClick={handleDeleteClick}
262
+ size="small"
268
263
  >
269
- Delete Notebook
264
+ Delete
270
265
  </Button>
271
266
  <Dialog
272
267
  open={deleteDialogOpen}
@@ -282,13 +277,18 @@ export default function MutableNotebook({
282
277
  </DialogContentText>
283
278
  </DialogContent>
284
279
  <DialogActions>
285
- <Button onClick={handleDeleteCancel} color="primary">
280
+ <Button
281
+ onClick={handleDeleteCancel}
282
+ color="primary"
283
+ size="small"
284
+ >
286
285
  Cancel
287
286
  </Button>
288
287
  <Button
289
288
  onClick={(event) => handleDeleteConfirm(event)}
290
289
  color="error"
291
290
  autoFocus
291
+ size="small"
292
292
  >
293
293
  Delete
294
294
  </Button>
@@ -297,27 +297,86 @@ export default function MutableNotebook({
297
297
  </Box>
298
298
  </Stack>
299
299
  </Stack>
300
+ <Divider />
301
+ <Stack
302
+ sx={{
303
+ display: "flex",
304
+ flexDirection: "row",
305
+ width: "100%",
306
+ mt: 2,
307
+ }}
308
+ >
309
+ <Box sx={{ flex: 1 }}>
310
+ <ModelPicker
311
+ initialSelectedModels={notebookData.getModels()}
312
+ onModelChange={(models) => {
313
+ setNotebookData(notebookData.setModels(models));
314
+ saveNotebook();
315
+ }}
316
+ />
317
+ </Box>
318
+ <Box
319
+ sx={{
320
+ display: "flex",
321
+ gap: 1,
322
+ justifyContent: "center",
323
+ flex: 2,
324
+ }}
325
+ >
326
+ <Button
327
+ size="small"
328
+ startIcon={<AddIcon />}
329
+ onClick={() =>
330
+ handleAddCell(false, notebookData.getCells().length)
331
+ }
332
+ >
333
+ Explore
334
+ </Button>
335
+ <Button
336
+ size="small"
337
+ startIcon={<AddIcon />}
338
+ onClick={() =>
339
+ handleAddCell(true, notebookData.getCells().length)
340
+ }
341
+ >
342
+ Markdown
343
+ </Button>
344
+ </Box>
345
+ <Box sx={{ flex: 1 }} />
346
+ </Stack>
300
347
  </StyledCardContent>
301
- <ModelPicker
302
- initialSelectedModels={notebookData.getModels()}
303
- onModelChange={(models) => {
304
- setNotebookData(notebookData.setModels(models));
305
- saveNotebook();
306
- }}
307
- />
308
-
309
348
  <StyledCardMedia>
310
349
  <Stack>
350
+ {notebookData.getCells().length === 0 && (
351
+ <>
352
+ <Typography
353
+ sx={{
354
+ textAlign: "center",
355
+ p: 2,
356
+ variant: "subtitle2",
357
+ fontWeight: "medium",
358
+ }}
359
+ >
360
+ Workbook is empty
361
+ </Typography>
362
+ <Typography
363
+ variant="body2"
364
+ sx={{ textAlign: "center", mb: 2, variant: "body2" }}
365
+ >
366
+ Click the + buttons to add a markdown or code cell.
367
+ </Typography>
368
+ </>
369
+ )}
311
370
  {notebookData.getCells().map((cell, index) => (
312
371
  <React.Fragment
313
372
  key={`${index}-${notebookData.getCells().length}`}
314
373
  >
315
374
  <MutableCell
316
375
  cell={cell}
317
- newCell={createButtons(index)}
318
376
  sourceAndPaths={getSourceList(sourceAndPaths)}
319
377
  expandCodeCell={expandCodeCells}
320
378
  expandEmbedding={expandEmbeddings}
379
+ hideEmbeddingIcons={hideEmbeddingIcons}
321
380
  editingMarkdown={editingMarkdownIndex === index}
322
381
  editingMalloy={editingMalloyIndex === index}
323
382
  onDelete={() => {
@@ -345,9 +404,6 @@ export default function MutableNotebook({
345
404
  />
346
405
  </React.Fragment>
347
406
  ))}
348
- <Box style={{ paddingRight: "7px", paddingTop: "10px" }}>
349
- {createButtons(notebookData.getCells().length)}
350
- </Box>
351
407
  <Menu
352
408
  anchorEl={menuAnchorEl}
353
409
  open={menuOpen}
@@ -376,22 +432,6 @@ export default function MutableNotebook({
376
432
  </StyledCard>
377
433
  );
378
434
  }
379
- function AddIcon() {
380
- return (
381
- <svg
382
- width="24"
383
- height="24"
384
- viewBox="0 0 24 24"
385
- fill="none"
386
- xmlns="http://www.w3.org/2000/svg"
387
- >
388
- <path
389
- d="M19 13H13V19H11V13H5V11H11V5H13V11H19V13Z"
390
- fill="currentColor"
391
- />
392
- </svg>
393
- );
394
- }
395
435
 
396
436
  function ExportMalloyButton({
397
437
  notebookData,
@@ -412,8 +452,8 @@ function ExportMalloyButton({
412
452
  }
413
453
  };
414
454
  return (
415
- <Button variant="outlined" color="primary" onClick={handleExport}>
416
- {copied ? "Copied!" : "Export To Malloy"}
455
+ <Button color="primary" onClick={handleExport} size="small">
456
+ {copied ? "Copied!" : "Export"}
417
457
  </Button>
418
458
  );
419
459
  }
@@ -40,7 +40,7 @@ export default function Package({ navigate }: PackageProps) {
40
40
  <Databases />
41
41
  </Grid>
42
42
  <Grid size={{ xs: 12, md: 6 }}>
43
- <Connections navigate={navigate} />
43
+ <Connections />
44
44
  </Grid>
45
45
  <Grid size={{ xs: 12, md: 12 }}>
46
46
  <Schedules />