@malloy-publisher/sdk 0.0.52 → 0.0.54
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/dist/components/Model/SourcesExplorer.d.ts +3 -2
- package/dist/components/MutableNotebook/EditableMalloyCell.d.ts +3 -2
- package/dist/components/Project/Project.d.ts +4 -3
- package/dist/index.cjs.js +17 -17
- package/dist/index.es.js +1667 -1666
- package/package.json +1 -1
- package/src/components/AnalyzePackageButton.tsx +90 -56
- package/src/components/Model/ModelCell.tsx +12 -13
- package/src/components/Model/SourcesExplorer.tsx +26 -17
- package/src/components/MutableNotebook/EditableMalloyCell.tsx +8 -3
- package/src/components/MutableNotebook/MutableCell.tsx +19 -5
- package/src/components/MutableNotebook/MutableNotebook.tsx +43 -43
- package/src/components/Notebook/Notebook.tsx +7 -12
- package/src/components/Notebook/NotebookCell.tsx +4 -5
- package/src/components/Package/Config.tsx +24 -18
- package/src/components/Package/Connections.tsx +4 -5
- package/src/components/Package/Databases.tsx +6 -7
- package/src/components/Package/Models.tsx +2 -3
- package/src/components/Package/Notebooks.tsx +2 -3
- package/src/components/Package/Package.tsx +1 -6
- package/src/components/Project/About.tsx +11 -14
- package/src/components/Project/Packages.tsx +50 -57
- package/src/components/Project/Project.tsx +15 -19
- package/src/components/RenderedResult/ResultContainer.tsx +4 -4
- package/src/components/styles.ts +4 -7
package/package.json
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { Add, Launch } from "@mui/icons-material";
|
|
2
2
|
import {
|
|
3
3
|
Button,
|
|
4
|
-
Menu,
|
|
5
|
-
MenuItem,
|
|
6
|
-
ListItemIcon,
|
|
7
|
-
ListItemText,
|
|
8
|
-
Typography,
|
|
9
4
|
Dialog,
|
|
10
|
-
DialogTitle,
|
|
11
5
|
DialogContent,
|
|
6
|
+
DialogTitle,
|
|
12
7
|
FormControl,
|
|
8
|
+
ListItemIcon,
|
|
9
|
+
ListItemText,
|
|
10
|
+
Menu,
|
|
11
|
+
MenuItem,
|
|
12
|
+
Stack,
|
|
13
13
|
TextField,
|
|
14
|
+
Typography,
|
|
14
15
|
} from "@mui/material";
|
|
16
|
+
import React from "react";
|
|
17
|
+
import { useRouterClickHandler } from "./click_helper";
|
|
15
18
|
import {
|
|
16
|
-
NotebookStorageProvider,
|
|
17
19
|
BrowserNotebookStorage,
|
|
18
20
|
MutableNotebookList,
|
|
21
|
+
NotebookStorageProvider,
|
|
19
22
|
} from "./MutableNotebook";
|
|
20
|
-
import React from "react";
|
|
21
|
-
import { useRouterClickHandler } from "./click_helper";
|
|
22
23
|
|
|
23
24
|
export interface AnalyzePackageButtonProps {
|
|
24
25
|
projectName: string;
|
|
@@ -75,7 +76,15 @@ export function AnalyzePackageButton({
|
|
|
75
76
|
aria-haspopup="true"
|
|
76
77
|
aria-expanded={open ? "true" : undefined}
|
|
77
78
|
onClick={handleClick}
|
|
78
|
-
|
|
79
|
+
variant="contained"
|
|
80
|
+
sx={{
|
|
81
|
+
height: "40px",
|
|
82
|
+
px: 2,
|
|
83
|
+
backgroundColor: "#fbbb04",
|
|
84
|
+
"&:hover": {
|
|
85
|
+
backgroundColor: "#eab308",
|
|
86
|
+
},
|
|
87
|
+
}}
|
|
79
88
|
>
|
|
80
89
|
Analyze Package
|
|
81
90
|
</Button>
|
|
@@ -84,10 +93,9 @@ export function AnalyzePackageButton({
|
|
|
84
93
|
anchorEl={anchorEl}
|
|
85
94
|
open={open}
|
|
86
95
|
onClose={handleMenuClose}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
},
|
|
96
|
+
MenuListProps={{
|
|
97
|
+
"aria-labelledby": "basic-button",
|
|
98
|
+
sx: { py: 0.5 },
|
|
91
99
|
}}
|
|
92
100
|
>
|
|
93
101
|
<MenuItem
|
|
@@ -95,12 +103,18 @@ export function AnalyzePackageButton({
|
|
|
95
103
|
setNewDialogOpen(true);
|
|
96
104
|
handleMenuClose();
|
|
97
105
|
}}
|
|
106
|
+
sx={{ py: 1, px: 2 }}
|
|
98
107
|
>
|
|
99
108
|
<ListItemIcon>
|
|
100
109
|
<Add fontSize="small" />
|
|
101
110
|
</ListItemIcon>
|
|
102
111
|
<ListItemText>
|
|
103
|
-
<Typography variant="body2"
|
|
112
|
+
<Typography variant="body2" fontWeight={500}>
|
|
113
|
+
New Workbook
|
|
114
|
+
</Typography>
|
|
115
|
+
<Typography variant="caption" color="text.secondary">
|
|
116
|
+
Create a new analysis workbook
|
|
117
|
+
</Typography>
|
|
104
118
|
</ListItemText>
|
|
105
119
|
</MenuItem>
|
|
106
120
|
<MenuItem
|
|
@@ -108,67 +122,87 @@ export function AnalyzePackageButton({
|
|
|
108
122
|
setOpenDialogOpen(true);
|
|
109
123
|
handleMenuClose();
|
|
110
124
|
}}
|
|
125
|
+
sx={{ py: 1, px: 2 }}
|
|
111
126
|
>
|
|
112
127
|
<ListItemIcon>
|
|
113
128
|
<Launch fontSize="small" />
|
|
114
129
|
</ListItemIcon>
|
|
115
130
|
<ListItemText>
|
|
116
|
-
<Typography variant="body2"
|
|
131
|
+
<Typography variant="body2" fontWeight={500}>
|
|
132
|
+
Open Workbook
|
|
133
|
+
</Typography>
|
|
134
|
+
<Typography variant="caption" color="text.secondary">
|
|
135
|
+
Open an existing workbook
|
|
136
|
+
</Typography>
|
|
117
137
|
</ListItemText>
|
|
118
138
|
</MenuItem>
|
|
119
139
|
</Menu>
|
|
140
|
+
|
|
141
|
+
{/* Create New Workbook Dialog */}
|
|
120
142
|
<Dialog
|
|
121
143
|
open={newDialogOpen}
|
|
122
144
|
onClose={handleNewDialogClose}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
width: "100%",
|
|
126
|
-
maxWidth: "300px",
|
|
127
|
-
},
|
|
128
|
-
}}
|
|
145
|
+
maxWidth="sm"
|
|
146
|
+
fullWidth
|
|
129
147
|
>
|
|
130
|
-
<DialogTitle
|
|
131
|
-
|
|
148
|
+
<DialogTitle sx={{ pb: 1, pt: 2, px: 2 }}>
|
|
149
|
+
<Typography variant="h6" fontWeight={600} sx={{ mb: 0.5 }}>
|
|
150
|
+
Create New Workbook
|
|
151
|
+
</Typography>
|
|
152
|
+
<Typography variant="body2" color="text.secondary">
|
|
153
|
+
Start a new analysis workbook to explore your data
|
|
154
|
+
</Typography>
|
|
132
155
|
</DialogTitle>
|
|
133
|
-
<DialogContent>
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
<DialogContent sx={{ px: 2, pb: 2 }}>
|
|
157
|
+
<Stack spacing={2} sx={{ mt: 1 }}>
|
|
158
|
+
<FormControl fullWidth>
|
|
159
|
+
<TextField
|
|
160
|
+
label="Workbook Name"
|
|
161
|
+
value={workbookName}
|
|
162
|
+
onChange={(e) => setWorkbookName(e.target.value)}
|
|
163
|
+
placeholder="Enter workbook name..."
|
|
164
|
+
fullWidth
|
|
165
|
+
autoFocus
|
|
166
|
+
size="small"
|
|
167
|
+
/>
|
|
168
|
+
</FormControl>
|
|
169
|
+
<Stack direction="row" spacing={1} justifyContent="flex-end">
|
|
170
|
+
<Button
|
|
171
|
+
onClick={handleNewDialogClose}
|
|
172
|
+
variant="outlined"
|
|
173
|
+
size="small"
|
|
174
|
+
>
|
|
175
|
+
Cancel
|
|
176
|
+
</Button>
|
|
177
|
+
<Button
|
|
178
|
+
onClick={(event) => createNotebookClick(event)}
|
|
179
|
+
variant="contained"
|
|
180
|
+
disabled={!workbookName.trim()}
|
|
181
|
+
size="small"
|
|
182
|
+
>
|
|
183
|
+
Create Workbook
|
|
184
|
+
</Button>
|
|
185
|
+
</Stack>
|
|
186
|
+
</Stack>
|
|
156
187
|
</DialogContent>
|
|
157
188
|
</Dialog>
|
|
189
|
+
|
|
190
|
+
{/* Open Workbook Dialog */}
|
|
158
191
|
<Dialog
|
|
159
192
|
open={openDialogOpen}
|
|
160
193
|
onClose={handleOpenDialogClose}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
width: "100%",
|
|
164
|
-
maxWidth: "300px",
|
|
165
|
-
},
|
|
166
|
-
}}
|
|
194
|
+
maxWidth="md"
|
|
195
|
+
fullWidth
|
|
167
196
|
>
|
|
168
|
-
<DialogTitle
|
|
169
|
-
|
|
197
|
+
<DialogTitle sx={{ pb: 1, pt: 2, px: 2 }}>
|
|
198
|
+
<Typography variant="h6" fontWeight={600} sx={{ mb: 0.5 }}>
|
|
199
|
+
Open Workbook
|
|
200
|
+
</Typography>
|
|
201
|
+
<Typography variant="body2" color="text.secondary">
|
|
202
|
+
Select an existing workbook to continue your analysis
|
|
203
|
+
</Typography>
|
|
170
204
|
</DialogTitle>
|
|
171
|
-
<DialogContent>
|
|
205
|
+
<DialogContent sx={{ px: 2, pb: 2 }}>
|
|
172
206
|
<NotebookStorageProvider
|
|
173
207
|
notebookStorage={new BrowserNotebookStorage()}
|
|
174
208
|
userContext={{
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import AnalyticsOutlinedIcon from "@mui/icons-material/AnalyticsOutlined";
|
|
2
|
+
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
|
|
3
|
+
import LinkOutlinedIcon from "@mui/icons-material/LinkOutlined";
|
|
2
4
|
import {
|
|
3
|
-
styled,
|
|
4
|
-
Collapse,
|
|
5
|
-
CardActions,
|
|
6
5
|
Card,
|
|
6
|
+
CardActions,
|
|
7
7
|
CardContent,
|
|
8
|
+
Collapse,
|
|
8
9
|
Divider,
|
|
10
|
+
IconButton,
|
|
9
11
|
Stack,
|
|
10
|
-
|
|
12
|
+
styled,
|
|
11
13
|
Tooltip,
|
|
12
|
-
|
|
14
|
+
Typography,
|
|
13
15
|
} from "@mui/material";
|
|
14
|
-
import {
|
|
15
|
-
import AnalyticsOutlinedIcon from "@mui/icons-material/AnalyticsOutlined";
|
|
16
|
-
import LinkOutlinedIcon from "@mui/icons-material/LinkOutlined";
|
|
17
|
-
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
|
|
18
|
-
import { useEffect } from "react";
|
|
16
|
+
import React, { useEffect } from "react";
|
|
19
17
|
import { highlight } from "../highlighter";
|
|
18
|
+
import { QueryResult } from "../QueryResult";
|
|
20
19
|
|
|
21
20
|
const StyledCard = styled(Card)({
|
|
22
21
|
display: "flex",
|
|
@@ -170,7 +169,7 @@ export function ModelCell({
|
|
|
170
169
|
</Stack>
|
|
171
170
|
</Collapse>
|
|
172
171
|
<Collapse in={resultsExpanded} timeout="auto" unmountOnExit>
|
|
173
|
-
<Divider sx={{ mb: "
|
|
172
|
+
<Divider sx={{ mb: "4px" }} />
|
|
174
173
|
{highlightedAnnotations && (
|
|
175
174
|
<>
|
|
176
175
|
<Stack
|
|
@@ -195,7 +194,7 @@ export function ModelCell({
|
|
|
195
194
|
/>
|
|
196
195
|
</Typography>
|
|
197
196
|
</Stack>
|
|
198
|
-
<Divider sx={{ mb: "
|
|
197
|
+
<Divider sx={{ mb: "4px" }} />
|
|
199
198
|
</>
|
|
200
199
|
)}
|
|
201
200
|
<CardContent>
|
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
import { styled } from "@mui/material/styles";
|
|
21
21
|
import React from "react";
|
|
22
22
|
import { Configuration, QueryresultsApi } from "../../client";
|
|
23
|
-
import { usePackage } from "../Package/PackageProvider";
|
|
24
23
|
import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
|
|
24
|
+
import { usePackage } from "../Package/PackageProvider";
|
|
25
25
|
|
|
26
26
|
const queryResultsApi = new QueryresultsApi(new Configuration());
|
|
27
27
|
|
|
@@ -63,7 +63,8 @@ export interface SourceExplorerProps {
|
|
|
63
63
|
sourceAndPaths: SourceAndPath[];
|
|
64
64
|
existingQuery?: QueryExplorerResult;
|
|
65
65
|
existingSourceName?: string;
|
|
66
|
-
|
|
66
|
+
onQueryChange?: (query: QueryExplorerResult) => void;
|
|
67
|
+
onSourceChange?: (index: number) => void;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
/**
|
|
@@ -77,13 +78,14 @@ export function SourcesExplorer({
|
|
|
77
78
|
sourceAndPaths,
|
|
78
79
|
existingQuery,
|
|
79
80
|
existingSourceName,
|
|
80
|
-
|
|
81
|
+
onQueryChange,
|
|
82
|
+
onSourceChange,
|
|
81
83
|
}: SourceExplorerProps) {
|
|
82
84
|
const [selectedTab, setSelectedTab] = React.useState(
|
|
83
85
|
existingSourceName
|
|
84
86
|
? sourceAndPaths.findIndex(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
(entry) => entry.sourceInfo.name === existingSourceName,
|
|
88
|
+
)
|
|
87
89
|
: 0,
|
|
88
90
|
);
|
|
89
91
|
|
|
@@ -91,6 +93,13 @@ export function SourcesExplorer({
|
|
|
91
93
|
existingQuery || emptyQueryExplorerResult(),
|
|
92
94
|
);
|
|
93
95
|
|
|
96
|
+
// Notify parent component when selected source changes
|
|
97
|
+
React.useEffect(() => {
|
|
98
|
+
if (onSourceChange) {
|
|
99
|
+
onSourceChange(selectedTab);
|
|
100
|
+
}
|
|
101
|
+
}, [selectedTab, onSourceChange]);
|
|
102
|
+
|
|
94
103
|
return (
|
|
95
104
|
<StyledCard variant="outlined">
|
|
96
105
|
<StyledCardContent>
|
|
@@ -123,8 +132,8 @@ export function SourcesExplorer({
|
|
|
123
132
|
existingQuery={query}
|
|
124
133
|
onChange={(query) => {
|
|
125
134
|
setQuery(query);
|
|
126
|
-
if (
|
|
127
|
-
|
|
135
|
+
if (onQueryChange) {
|
|
136
|
+
onQueryChange(query);
|
|
128
137
|
}
|
|
129
138
|
}}
|
|
130
139
|
/>
|
|
@@ -292,16 +301,16 @@ export function SourceExplorerComponent({
|
|
|
292
301
|
submittedQuery={
|
|
293
302
|
query?.malloyQuery
|
|
294
303
|
? {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
304
|
+
executionState: mutation.isPending
|
|
305
|
+
? "running"
|
|
306
|
+
: "finished",
|
|
307
|
+
response: {
|
|
308
|
+
result: query.malloyResult,
|
|
309
|
+
},
|
|
310
|
+
query: query.malloyQuery,
|
|
311
|
+
queryResolutionStartMillis: Date.now(),
|
|
312
|
+
onCancel: mutation.reset,
|
|
313
|
+
}
|
|
305
314
|
: undefined
|
|
306
315
|
}
|
|
307
316
|
options={{ showRawQuery: true }}
|
|
@@ -5,25 +5,30 @@ import { NotebookCellValue } from "../NotebookManager";
|
|
|
5
5
|
interface EditableMalloyCellProps {
|
|
6
6
|
cell: NotebookCellValue;
|
|
7
7
|
sourceAndPaths: SourceAndPath[];
|
|
8
|
-
|
|
8
|
+
onQueryChange: (query: QueryExplorerResult) => void;
|
|
9
|
+
onSourceChange?: (index: number) => void;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export function EditableMalloyCell({
|
|
12
13
|
cell,
|
|
13
14
|
sourceAndPaths,
|
|
14
|
-
|
|
15
|
+
onQueryChange,
|
|
16
|
+
onSourceChange,
|
|
15
17
|
}: EditableMalloyCellProps) {
|
|
16
18
|
const query = {
|
|
17
19
|
query: cell.value,
|
|
18
20
|
malloyResult: cell.result ? JSON.parse(cell.result) : undefined,
|
|
19
21
|
malloyQuery: cell.queryInfo ? JSON.parse(cell.queryInfo) : undefined,
|
|
22
|
+
sourceName: cell.sourceName,
|
|
23
|
+
modelPath: cell.modelPath,
|
|
20
24
|
};
|
|
21
25
|
return (
|
|
22
26
|
<SourcesExplorer
|
|
23
27
|
sourceAndPaths={sourceAndPaths}
|
|
24
28
|
existingQuery={query}
|
|
25
29
|
existingSourceName={cell.sourceName}
|
|
26
|
-
|
|
30
|
+
onQueryChange={onQueryChange}
|
|
31
|
+
onSourceChange={onSourceChange}
|
|
27
32
|
/>
|
|
28
33
|
);
|
|
29
34
|
}
|
|
@@ -69,6 +69,13 @@ export function MutableCell({
|
|
|
69
69
|
emptyQueryExplorerResult(),
|
|
70
70
|
);
|
|
71
71
|
const [isHovered, setIsHovered] = React.useState<boolean>(false);
|
|
72
|
+
const [selectedSourceIndex, setSelectedSourceIndex] = React.useState<number>(
|
|
73
|
+
cell.sourceName
|
|
74
|
+
? sourceAndPaths.findIndex(
|
|
75
|
+
(entry) => entry.sourceInfo.name === cell.sourceName,
|
|
76
|
+
)
|
|
77
|
+
: 0,
|
|
78
|
+
);
|
|
72
79
|
|
|
73
80
|
useEffect(() => {
|
|
74
81
|
if (!cell.isMarkdown)
|
|
@@ -91,7 +98,13 @@ export function MutableCell({
|
|
|
91
98
|
};
|
|
92
99
|
const noSources = sourceAndPaths.length === 0;
|
|
93
100
|
|
|
94
|
-
const saveResult = (
|
|
101
|
+
const saveResult = () => {
|
|
102
|
+
// Get the current modelPath and sourceName from the selected source
|
|
103
|
+
const currentSource = sourceAndPaths[selectedSourceIndex];
|
|
104
|
+
const modelPath = currentSource?.modelPath || cell.modelPath || "";
|
|
105
|
+
const sourceName =
|
|
106
|
+
currentSource?.sourceInfo.name || cell.sourceName || "";
|
|
107
|
+
|
|
95
108
|
// Convert the results of the Query Explorer into
|
|
96
109
|
// the stringified JSON objects that are stored in the cell.
|
|
97
110
|
onCellChange({
|
|
@@ -197,7 +210,7 @@ export function MutableCell({
|
|
|
197
210
|
<IconButton
|
|
198
211
|
size="small"
|
|
199
212
|
onClick={() => {
|
|
200
|
-
saveResult(
|
|
213
|
+
saveResult();
|
|
201
214
|
onClose();
|
|
202
215
|
}}
|
|
203
216
|
>
|
|
@@ -229,7 +242,7 @@ export function MutableCell({
|
|
|
229
242
|
<IconButton
|
|
230
243
|
size="small"
|
|
231
244
|
onClick={() => {
|
|
232
|
-
saveResult(
|
|
245
|
+
saveResult();
|
|
233
246
|
onClose();
|
|
234
247
|
}}
|
|
235
248
|
>
|
|
@@ -295,7 +308,7 @@ export function MutableCell({
|
|
|
295
308
|
updateMarkdown(newValue);
|
|
296
309
|
}}
|
|
297
310
|
onBlur={() => {
|
|
298
|
-
saveResult(
|
|
311
|
+
saveResult();
|
|
299
312
|
if (!isHovered) {
|
|
300
313
|
onClose();
|
|
301
314
|
}
|
|
@@ -415,10 +428,11 @@ export function MutableCell({
|
|
|
415
428
|
) : (
|
|
416
429
|
<EditableMalloyCell
|
|
417
430
|
sourceAndPaths={sourceAndPaths}
|
|
418
|
-
|
|
431
|
+
onQueryChange={(query) => {
|
|
419
432
|
setQuery(query);
|
|
420
433
|
}}
|
|
421
434
|
cell={cell}
|
|
435
|
+
onSourceChange={setSelectedSourceIndex}
|
|
422
436
|
/>
|
|
423
437
|
))}
|
|
424
438
|
{!editingMalloy && cell.result && (
|
|
@@ -131,51 +131,51 @@ export default function MutableNotebook({
|
|
|
131
131
|
if (!notebookData) {
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
sourceInfos
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
134
|
+
|
|
135
|
+
const fetchModels = async () => {
|
|
136
|
+
const modelPathToSourceInfo = new Map(
|
|
137
|
+
sourceAndPaths.map(({ modelPath, sourceInfos }) => [
|
|
138
|
+
modelPath,
|
|
139
|
+
sourceInfos,
|
|
140
|
+
]),
|
|
141
|
+
);
|
|
142
|
+
const newSourceAndPaths = [];
|
|
143
|
+
const promises = [];
|
|
144
|
+
|
|
145
|
+
for (const model of notebookData.getModels()) {
|
|
146
|
+
if (!modelPathToSourceInfo.has(model)) {
|
|
147
|
+
console.log("Fetching model from Publisher", model);
|
|
148
|
+
promises.push(
|
|
149
|
+
modelsApi
|
|
150
|
+
.getModel(projectName, packageName, model, versionId, {
|
|
151
|
+
baseURL: server,
|
|
152
|
+
withCredentials: !accessToken,
|
|
153
|
+
})
|
|
154
|
+
.then((data) => ({
|
|
155
|
+
modelPath: model,
|
|
156
|
+
sourceInfos: data.data.sourceInfos.map((source) =>
|
|
157
|
+
JSON.parse(source),
|
|
158
|
+
),
|
|
159
|
+
})),
|
|
160
|
+
);
|
|
161
|
+
} else {
|
|
162
|
+
newSourceAndPaths.push({
|
|
163
|
+
modelPath: model,
|
|
164
|
+
sourceInfos: modelPathToSourceInfo.get(model),
|
|
165
|
+
});
|
|
166
|
+
}
|
|
163
167
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
168
|
+
|
|
169
|
+
if (promises.length > 0) {
|
|
170
|
+
const loadedSourceAndPaths = await Promise.all(promises);
|
|
167
171
|
setSourceAndPaths([...newSourceAndPaths, ...loadedSourceAndPaths]);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
server,
|
|
176
|
-
sourceAndPaths,
|
|
177
|
-
versionId,
|
|
178
|
-
]);
|
|
172
|
+
} else {
|
|
173
|
+
setSourceAndPaths(newSourceAndPaths);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
fetchModels();
|
|
178
|
+
}, [accessToken, notebookData, packageName, projectName, server, versionId]);
|
|
179
179
|
|
|
180
180
|
React.useEffect(() => {
|
|
181
181
|
if (!notebookPath) {
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
+
import "@malloydata/malloy-explorer/styles.css";
|
|
1
2
|
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
|
|
2
3
|
import LinkOutlinedIcon from "@mui/icons-material/LinkOutlined";
|
|
3
4
|
import {
|
|
4
|
-
Box,
|
|
5
5
|
CardActions,
|
|
6
6
|
Collapse,
|
|
7
|
-
Divider,
|
|
8
7
|
IconButton,
|
|
9
8
|
Stack,
|
|
10
9
|
Tooltip,
|
|
11
10
|
Typography,
|
|
12
11
|
} from "@mui/material";
|
|
13
12
|
import React, { useEffect } from "react";
|
|
14
|
-
import { Configuration, NotebooksApi
|
|
13
|
+
import { CompiledNotebook, Configuration, NotebooksApi } from "../../client";
|
|
14
|
+
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
15
|
+
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
15
16
|
import { highlight } from "../highlighter";
|
|
17
|
+
import { Loading } from "../Loading";
|
|
18
|
+
import { usePackage } from "../Package/PackageProvider";
|
|
16
19
|
import { StyledCard, StyledCardContent, StyledCardMedia } from "../styles";
|
|
17
20
|
import { NotebookCell } from "./NotebookCell";
|
|
18
|
-
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
19
|
-
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
20
|
-
import "@malloydata/malloy-explorer/styles.css";
|
|
21
|
-
import { usePackage } from "../Package/PackageProvider";
|
|
22
|
-
import { Loading } from "../Loading";
|
|
23
21
|
|
|
24
22
|
const notebooksApi = new NotebooksApi(new Configuration());
|
|
25
23
|
|
|
@@ -112,10 +110,8 @@ export default function Notebook({
|
|
|
112
110
|
)}
|
|
113
111
|
</Stack>
|
|
114
112
|
<Collapse in={embeddingExpanded} timeout="auto" unmountOnExit>
|
|
115
|
-
<Divider />
|
|
116
113
|
<Stack
|
|
117
114
|
sx={{
|
|
118
|
-
p: "10px",
|
|
119
115
|
borderRadius: 0,
|
|
120
116
|
flexDirection: "row",
|
|
121
117
|
justifyContent: "space-between",
|
|
@@ -145,10 +141,9 @@ export default function Notebook({
|
|
|
145
141
|
</Tooltip>
|
|
146
142
|
</Stack>
|
|
147
143
|
</Collapse>
|
|
148
|
-
<Divider />
|
|
149
144
|
</StyledCardContent>
|
|
150
145
|
<StyledCardMedia>
|
|
151
|
-
<Stack spacing={
|
|
146
|
+
<Stack spacing={2} component="section">
|
|
152
147
|
{!isSuccess && !isError && (
|
|
153
148
|
<Loading text="Fetching Notebook..." />
|
|
154
149
|
)}
|
|
@@ -69,7 +69,7 @@ export function NotebookCell({
|
|
|
69
69
|
|
|
70
70
|
return (
|
|
71
71
|
(cell.type === "markdown" && (
|
|
72
|
-
<StyledCard variant="outlined"
|
|
72
|
+
<StyledCard variant="outlined">
|
|
73
73
|
<StyledCardContent>
|
|
74
74
|
<Markdown>{cell.text}</Markdown>
|
|
75
75
|
</StyledCardContent>
|
|
@@ -86,7 +86,7 @@ export function NotebookCell({
|
|
|
86
86
|
>
|
|
87
87
|
<CardActions
|
|
88
88
|
sx={{
|
|
89
|
-
padding: "0px
|
|
89
|
+
padding: "0px 8px 0px 8px",
|
|
90
90
|
mb: "auto",
|
|
91
91
|
mt: "auto",
|
|
92
92
|
}}
|
|
@@ -154,7 +154,7 @@ export function NotebookCell({
|
|
|
154
154
|
<Collapse in={embeddingExpanded} timeout="auto" unmountOnExit>
|
|
155
155
|
<Stack
|
|
156
156
|
sx={{
|
|
157
|
-
p: "
|
|
157
|
+
p: "8px",
|
|
158
158
|
borderRadius: 0,
|
|
159
159
|
flexDirection: "row",
|
|
160
160
|
justifyContent: "space-between",
|
|
@@ -188,8 +188,7 @@ export function NotebookCell({
|
|
|
188
188
|
<style>{codeStyle}</style>
|
|
189
189
|
<Stack
|
|
190
190
|
sx={{
|
|
191
|
-
mx: "
|
|
192
|
-
mb: "10px",
|
|
191
|
+
mx: "8px",
|
|
193
192
|
borderRadius: 0,
|
|
194
193
|
flexDirection: "row",
|
|
195
194
|
justifyContent: "space-between",
|