@malloy-publisher/sdk 0.0.30 → 0.0.32
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/RenderedResult-B9Gth8IY.cjs +1 -0
- package/dist/RenderedResult-Drg_uJPZ.js +30 -0
- package/dist/client/api.d.ts +6 -0
- package/dist/components/Home/Home.d.ts +1 -1
- package/dist/components/Model/NamedQueries.d.ts +7 -0
- package/dist/components/Package/Connections.d.ts +1 -1
- package/dist/components/Package/FileTreeView.d.ts +2 -1
- package/dist/components/Package/Models.d.ts +1 -1
- package/dist/components/Package/Notebooks.d.ts +1 -1
- package/dist/components/Package/Package.d.ts +1 -1
- package/dist/components/Project/Packages.d.ts +1 -1
- package/dist/components/Project/Project.d.ts +1 -1
- package/dist/components/RenderedResult/RenderedResult.d.ts +2 -1
- package/dist/components/RenderedResult/ResultContainer.d.ts +7 -0
- package/dist/components/click_helper.d.ts +8 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/styles.d.ts +2 -2
- package/dist/index.cjs.js +463 -463
- package/dist/index.es.js +12221 -12111
- package/dist/vendor-BH1c2Hhy.cjs +443 -0
- package/dist/{vendor-C36FjD0v.js → vendor-DfRellEl.js} +27439 -24442
- package/package.json +8 -8
- package/src/components/Home/Home.tsx +4 -2
- package/src/components/Model/Model.tsx +35 -30
- package/src/components/Model/NamedQueries.tsx +156 -0
- package/src/components/Model/SourcesExplorer.tsx +14 -14
- package/src/components/MutableNotebook/MutableCell.tsx +3 -1
- package/src/components/MutableNotebook/MutableNotebook.tsx +5 -5
- package/src/components/Notebook/Notebook.tsx +24 -20
- package/src/components/Notebook/NotebookCell.tsx +33 -41
- package/src/components/Package/Connections.tsx +1 -1
- package/src/components/Package/FileTreeView.tsx +6 -6
- package/src/components/Package/Models.tsx +1 -1
- package/src/components/Package/Notebooks.tsx +1 -1
- package/src/components/Package/Package.tsx +2 -1
- package/src/components/Project/Packages.tsx +4 -8
- package/src/components/Project/Project.tsx +1 -1
- package/src/components/RenderedResult/RenderedResult.tsx +42 -2
- package/src/components/RenderedResult/ResultContainer.tsx +161 -0
- package/src/components/click_helper.ts +37 -0
- package/src/components/index.ts +1 -0
- package/src/components/styles.ts +2 -2
- package/vite.config.ts +0 -1
- package/dist/RenderedResult-C1_N6KvU.js +0 -12
- package/dist/RenderedResult-Df-v_vru.cjs +0 -1
- package/dist/vendor-DSpmIox9.cjs +0 -360
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.0.
|
|
4
|
+
"version": "0.0.32",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
7
7
|
"module": "dist/index.es.js",
|
|
@@ -28,25 +28,25 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": "^19.1.0",
|
|
31
|
-
"react-dom": "^19.1.0"
|
|
31
|
+
"react-dom": "^19.1.0",
|
|
32
|
+
"react-router-dom": "^7.6.2"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@emotion/react": "^11.14.0",
|
|
35
36
|
"@emotion/styled": "^11.14.0",
|
|
36
37
|
"@malloydata/malloy-explorer": "^0.0.285-dev250530165648",
|
|
37
|
-
"@malloydata/malloy-query-builder": "^0.0.285",
|
|
38
38
|
"@malloydata/malloy-interfaces": "^0.0.285",
|
|
39
|
+
"@malloydata/malloy-query-builder": "^0.0.285",
|
|
39
40
|
"@malloydata/render": "^0.0.285",
|
|
40
|
-
"@mui/icons-material": "^7.
|
|
41
|
-
"@mui/material": "^7.
|
|
42
|
-
"@mui/system": "^7.
|
|
41
|
+
"@mui/icons-material": "^7.1.1",
|
|
42
|
+
"@mui/material": "^7.1.1",
|
|
43
|
+
"@mui/system": "^7.1.1",
|
|
43
44
|
"@mui/x-tree-view": "^7.16.0",
|
|
44
45
|
"@react-spring/web": "^10.0.1",
|
|
45
46
|
"@tanstack/react-query": "^5.59.16",
|
|
46
47
|
"@uiw/react-md-editor": "^4.0.6",
|
|
47
48
|
"axios": "^1.7.7",
|
|
48
|
-
"markdown-to-jsx": "^7.
|
|
49
|
-
"react-router-dom": "^6.26.1"
|
|
49
|
+
"markdown-to-jsx": "^7.7.6"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@openapitools/openapi-generator-cli": "^2.13.5",
|
|
@@ -9,7 +9,7 @@ const queryClient = new QueryClient();
|
|
|
9
9
|
|
|
10
10
|
interface HomeProps {
|
|
11
11
|
server?: string;
|
|
12
|
-
navigate?: (to: string) => void;
|
|
12
|
+
navigate?: (to: string, event?: React.MouseEvent) => void;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export default function Home({ server, navigate }: HomeProps) {
|
|
@@ -44,7 +44,9 @@ export default function Home({ server, navigate }: HomeProps) {
|
|
|
44
44
|
<Grid key={project.name}>
|
|
45
45
|
<Typography
|
|
46
46
|
variant="h1"
|
|
47
|
-
onClick={() =>
|
|
47
|
+
onClick={(event) =>
|
|
48
|
+
navigate(`/${project.name}/`, event)
|
|
49
|
+
}
|
|
48
50
|
>
|
|
49
51
|
{project.name}
|
|
50
52
|
</Typography>
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
|
|
2
|
+
import LinkOutlinedIcon from "@mui/icons-material/LinkOutlined";
|
|
2
3
|
import {
|
|
3
4
|
Box,
|
|
4
|
-
Typography,
|
|
5
|
-
Stack,
|
|
6
5
|
CardActions,
|
|
7
|
-
Tooltip,
|
|
8
|
-
IconButton,
|
|
9
6
|
Collapse,
|
|
10
7
|
Divider,
|
|
11
|
-
|
|
8
|
+
IconButton,
|
|
9
|
+
Stack,
|
|
12
10
|
Tab,
|
|
11
|
+
Tabs,
|
|
12
|
+
Tooltip,
|
|
13
|
+
Typography,
|
|
13
14
|
} from "@mui/material";
|
|
14
15
|
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
15
|
-
import
|
|
16
|
-
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
|
|
16
|
+
import React, { useEffect } from "react";
|
|
17
17
|
import { Configuration, ModelsApi } from "../../client";
|
|
18
|
-
import { ModelCell } from "./ModelCell";
|
|
19
|
-
import { StyledCard, StyledCardContent, StyledCardMedia } from "../styles";
|
|
20
18
|
import { highlight } from "../highlighter";
|
|
19
|
+
import { StyledCard, StyledCardContent, StyledCardMedia } from "../styles";
|
|
20
|
+
import { ModelCell } from "./ModelCell";
|
|
21
21
|
|
|
22
22
|
import "@malloydata/malloy-explorer/styles.css";
|
|
23
23
|
import { usePublisherPackage } from "../Package/PublisherPackageProvider";
|
|
24
24
|
import { SourceExplorerComponent } from "./SourcesExplorer";
|
|
25
|
+
import NamedQueries from "./NamedQueries";
|
|
25
26
|
const modelsApi = new ModelsApi(new Configuration());
|
|
26
27
|
|
|
27
28
|
const queryClient = new QueryClient();
|
|
@@ -136,28 +137,32 @@ export default function Model({
|
|
|
136
137
|
})}
|
|
137
138
|
</Tabs>
|
|
138
139
|
)}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
<Tooltip
|
|
147
|
-
title={
|
|
148
|
-
embeddingExpanded ? "Hide Embedding" : "View Embedding"
|
|
149
|
-
}
|
|
140
|
+
{!hideEmbeddingIcons && (
|
|
141
|
+
<CardActions
|
|
142
|
+
sx={{
|
|
143
|
+
padding: "0px 10px 0px 10px",
|
|
144
|
+
mb: "auto",
|
|
145
|
+
mt: "auto",
|
|
146
|
+
}}
|
|
150
147
|
>
|
|
151
|
-
<
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
148
|
+
<Tooltip
|
|
149
|
+
title={
|
|
150
|
+
embeddingExpanded
|
|
151
|
+
? "Hide Embedding"
|
|
152
|
+
: "View Embedding"
|
|
153
|
+
}
|
|
156
154
|
>
|
|
157
|
-
<
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
155
|
+
<IconButton
|
|
156
|
+
size="small"
|
|
157
|
+
onClick={() => {
|
|
158
|
+
setEmbeddingExpanded(!embeddingExpanded);
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
<LinkOutlinedIcon />
|
|
162
|
+
</IconButton>
|
|
163
|
+
</Tooltip>
|
|
164
|
+
</CardActions>
|
|
165
|
+
)}
|
|
161
166
|
</Stack>
|
|
162
167
|
<Collapse in={embeddingExpanded} timeout="auto" unmountOnExit>
|
|
163
168
|
<Divider />
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Typography,
|
|
3
|
+
Accordion,
|
|
4
|
+
AccordionSummary,
|
|
5
|
+
AccordionDetails,
|
|
6
|
+
} from "@mui/material";
|
|
7
|
+
import { Box } from "@mui/system";
|
|
8
|
+
import { Query, QueryresultsApi } from "../../client/api";
|
|
9
|
+
import { StyledCard, StyledCardContent } from "../styles";
|
|
10
|
+
|
|
11
|
+
import { QueryClient, useMutation } from "@tanstack/react-query";
|
|
12
|
+
import { Configuration } from "../../client";
|
|
13
|
+
import { usePublisherPackage } from "../Package";
|
|
14
|
+
import React from "react";
|
|
15
|
+
import ResultContainer from "../RenderedResult/ResultContainer";
|
|
16
|
+
|
|
17
|
+
const queryResultsApi = new QueryresultsApi(new Configuration());
|
|
18
|
+
const queryClient = new QueryClient();
|
|
19
|
+
|
|
20
|
+
interface NamedQueryProps {
|
|
21
|
+
modelPath: string;
|
|
22
|
+
namedQueries: Array<Query>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default function NamedQueries({
|
|
26
|
+
namedQueries,
|
|
27
|
+
modelPath,
|
|
28
|
+
}: NamedQueryProps) {
|
|
29
|
+
const { server, projectName, packageName, versionId, accessToken } =
|
|
30
|
+
usePublisherPackage();
|
|
31
|
+
const [namedQueryResults, setNamedQueryResults] = React.useState<
|
|
32
|
+
Record<string, string>
|
|
33
|
+
>({});
|
|
34
|
+
const [expandedAccordions, setExpandedAccordions] = React.useState<
|
|
35
|
+
Record<string, boolean>
|
|
36
|
+
>({});
|
|
37
|
+
|
|
38
|
+
const mutation = useMutation(
|
|
39
|
+
{
|
|
40
|
+
mutationFn: ({ query }: { query: Query }) => {
|
|
41
|
+
const val = queryResultsApi.executeQuery(
|
|
42
|
+
projectName,
|
|
43
|
+
packageName,
|
|
44
|
+
modelPath,
|
|
45
|
+
undefined,
|
|
46
|
+
undefined,
|
|
47
|
+
query.name,
|
|
48
|
+
versionId,
|
|
49
|
+
{
|
|
50
|
+
baseURL: server,
|
|
51
|
+
withCredentials: !accessToken,
|
|
52
|
+
headers: {
|
|
53
|
+
Authorization: accessToken && `Bearer ${accessToken}`,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
return val;
|
|
58
|
+
},
|
|
59
|
+
onSuccess: (data, { query }: { query: Query }) => {
|
|
60
|
+
if (data) {
|
|
61
|
+
setNamedQueryResults((prev) => ({
|
|
62
|
+
...prev,
|
|
63
|
+
[query.name]: data.data.result,
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
queryClient,
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const handleAccordionChange =
|
|
72
|
+
(query: Query, queryKey: string) =>
|
|
73
|
+
(event: React.SyntheticEvent, isExpanded: boolean) => {
|
|
74
|
+
setExpandedAccordions((prev) => ({
|
|
75
|
+
...prev,
|
|
76
|
+
[queryKey]: isExpanded,
|
|
77
|
+
}));
|
|
78
|
+
|
|
79
|
+
// Trigger mutation only if expanding and we haven't executed this query before
|
|
80
|
+
if (isExpanded && !namedQueryResults[query.name]) {
|
|
81
|
+
mutation.mutate({ query });
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
if (!namedQueries) {
|
|
86
|
+
return <div> Loading Named Queries</div>;
|
|
87
|
+
}
|
|
88
|
+
if (namedQueries.length == 0) {
|
|
89
|
+
return <div> No Named Queries</div>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<StyledCard variant="outlined">
|
|
94
|
+
<StyledCardContent>
|
|
95
|
+
<Typography variant="subtitle1">Named Queries</Typography>
|
|
96
|
+
</StyledCardContent>
|
|
97
|
+
<Box>
|
|
98
|
+
{namedQueries.map((query: any, idx: number) => {
|
|
99
|
+
const queryKey = query.name || `query-${idx}`;
|
|
100
|
+
return (
|
|
101
|
+
<Accordion
|
|
102
|
+
key={queryKey}
|
|
103
|
+
expanded={expandedAccordions[queryKey] || false}
|
|
104
|
+
onChange={handleAccordionChange(query, queryKey)}
|
|
105
|
+
>
|
|
106
|
+
<AccordionSummary>
|
|
107
|
+
<Typography variant="body1">
|
|
108
|
+
{query.name || `Query ${idx + 1}`}
|
|
109
|
+
</Typography>
|
|
110
|
+
</AccordionSummary>
|
|
111
|
+
<AccordionDetails>
|
|
112
|
+
{mutation.isPending && expandedAccordions[queryKey] && (
|
|
113
|
+
<div
|
|
114
|
+
style={{
|
|
115
|
+
marginTop: "10px",
|
|
116
|
+
fontStyle: "italic",
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
Executing query...
|
|
120
|
+
</div>
|
|
121
|
+
)}
|
|
122
|
+
<ResultContainer
|
|
123
|
+
result={namedQueryResults[query.name]}
|
|
124
|
+
minHeight={300}
|
|
125
|
+
maxHeight={900}
|
|
126
|
+
/>
|
|
127
|
+
{Array.isArray(query.annotations) &&
|
|
128
|
+
query.annotations.length > 0 && (
|
|
129
|
+
<Box sx={{ mt: 1 }}>
|
|
130
|
+
<Typography
|
|
131
|
+
variant="caption"
|
|
132
|
+
color="text.secondary"
|
|
133
|
+
>
|
|
134
|
+
Annotations:
|
|
135
|
+
</Typography>
|
|
136
|
+
<ul style={{ margin: 0, paddingLeft: 16 }}>
|
|
137
|
+
{query.annotations.map(
|
|
138
|
+
(annotation: string, aidx: number) => (
|
|
139
|
+
<li key={aidx}>
|
|
140
|
+
<Typography variant="caption">
|
|
141
|
+
{annotation}
|
|
142
|
+
</Typography>
|
|
143
|
+
</li>
|
|
144
|
+
),
|
|
145
|
+
)}
|
|
146
|
+
</ul>
|
|
147
|
+
</Box>
|
|
148
|
+
)}
|
|
149
|
+
</AccordionDetails>
|
|
150
|
+
</Accordion>
|
|
151
|
+
);
|
|
152
|
+
})}
|
|
153
|
+
</Box>
|
|
154
|
+
</StyledCard>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
@@ -87,8 +87,8 @@ export function SourcesExplorer({
|
|
|
87
87
|
const [selectedTab, setSelectedTab] = React.useState(
|
|
88
88
|
existingSourceName
|
|
89
89
|
? sourceAndPaths.findIndex(
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
(entry) => entry.sourceInfo.name === existingSourceName,
|
|
91
|
+
)
|
|
92
92
|
: 0,
|
|
93
93
|
);
|
|
94
94
|
|
|
@@ -291,7 +291,7 @@ export function SourceExplorerComponent({
|
|
|
291
291
|
>
|
|
292
292
|
<ResizableCollapsiblePanel
|
|
293
293
|
isInitiallyExpanded={true}
|
|
294
|
-
initialWidth={
|
|
294
|
+
initialWidth={180}
|
|
295
295
|
minWidth={180}
|
|
296
296
|
icon="database"
|
|
297
297
|
title={sourceAndPath.sourceInfo.name}
|
|
@@ -304,7 +304,7 @@ export function SourceExplorerComponent({
|
|
|
304
304
|
</ResizableCollapsiblePanel>
|
|
305
305
|
<ResizableCollapsiblePanel
|
|
306
306
|
isInitiallyExpanded={true}
|
|
307
|
-
initialWidth={
|
|
307
|
+
initialWidth={280}
|
|
308
308
|
minWidth={280}
|
|
309
309
|
icon="filterSliders"
|
|
310
310
|
title="Query"
|
|
@@ -324,16 +324,16 @@ export function SourceExplorerComponent({
|
|
|
324
324
|
submittedQuery={
|
|
325
325
|
query?.malloyQuery
|
|
326
326
|
? {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
327
|
+
executionState: mutation.isPending
|
|
328
|
+
? "running"
|
|
329
|
+
: "finished",
|
|
330
|
+
response: {
|
|
331
|
+
result: query.malloyResult,
|
|
332
|
+
},
|
|
333
|
+
query: query.malloyQuery,
|
|
334
|
+
queryResolutionStartMillis: Date.now(),
|
|
335
|
+
onCancel: mutation.reset,
|
|
336
|
+
}
|
|
337
337
|
: undefined
|
|
338
338
|
}
|
|
339
339
|
options={{ showRawQuery: true }}
|
|
@@ -311,7 +311,9 @@ export function MutableCell({
|
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
function useDebounce<T>(callback: (value: T) => void, delay: number = 2000) {
|
|
314
|
-
const timeoutRef = React.useRef<
|
|
314
|
+
const timeoutRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(
|
|
315
|
+
undefined,
|
|
316
|
+
);
|
|
315
317
|
|
|
316
318
|
return React.useCallback(
|
|
317
319
|
(value: T) => {
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "@mui/material";
|
|
17
17
|
import Stack from "@mui/material/Stack";
|
|
18
18
|
import React from "react";
|
|
19
|
-
import {
|
|
19
|
+
import { useRouterClickHandler } from "../click_helper";
|
|
20
20
|
import { Configuration, ModelsApi } from "../../client";
|
|
21
21
|
import { SourceAndPath } from "../Model/SourcesExplorer";
|
|
22
22
|
import { NotebookManager } from "../NotebookManager";
|
|
@@ -46,7 +46,7 @@ export default function MutableNotebook({
|
|
|
46
46
|
expandCodeCells,
|
|
47
47
|
expandEmbeddings,
|
|
48
48
|
}: MutableNotebookProps) {
|
|
49
|
-
const navigate =
|
|
49
|
+
const navigate = useRouterClickHandler();
|
|
50
50
|
const { server, projectName, packageName, versionId, accessToken } =
|
|
51
51
|
usePublisherPackage();
|
|
52
52
|
if (!projectName || !packageName) {
|
|
@@ -107,12 +107,12 @@ export default function MutableNotebook({
|
|
|
107
107
|
setDeleteDialogOpen(true);
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
const handleDeleteConfirm = () => {
|
|
110
|
+
const handleDeleteConfirm = (event?: React.MouseEvent) => {
|
|
111
111
|
if (notebookPath && notebookStorage && userContext) {
|
|
112
112
|
notebookStorage.deleteNotebook(userContext, notebookPath);
|
|
113
113
|
}
|
|
114
114
|
setDeleteDialogOpen(false);
|
|
115
|
-
navigate(`/${projectName}/${packageName}
|
|
115
|
+
navigate(`/${projectName}/${packageName}`, event);
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
const handleDeleteCancel = () => {
|
|
@@ -286,7 +286,7 @@ export default function MutableNotebook({
|
|
|
286
286
|
Cancel
|
|
287
287
|
</Button>
|
|
288
288
|
<Button
|
|
289
|
-
onClick={handleDeleteConfirm}
|
|
289
|
+
onClick={(event) => handleDeleteConfirm(event)}
|
|
290
290
|
color="error"
|
|
291
291
|
autoFocus
|
|
292
292
|
>
|
|
@@ -100,28 +100,32 @@ export default function Notebook({
|
|
|
100
100
|
<Typography variant="overline" fontWeight="bold">
|
|
101
101
|
Notebook
|
|
102
102
|
</Typography>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
<Tooltip
|
|
111
|
-
title={
|
|
112
|
-
embeddingExpanded ? "Hide Embedding" : "View Embedding"
|
|
113
|
-
}
|
|
103
|
+
{!hideEmbeddingIcons && (
|
|
104
|
+
<CardActions
|
|
105
|
+
sx={{
|
|
106
|
+
padding: "0px 10px 0px 10px",
|
|
107
|
+
mb: "auto",
|
|
108
|
+
mt: "auto",
|
|
109
|
+
}}
|
|
114
110
|
>
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
<Tooltip
|
|
112
|
+
title={
|
|
113
|
+
embeddingExpanded
|
|
114
|
+
? "Hide Embedding"
|
|
115
|
+
: "View Embedding"
|
|
116
|
+
}
|
|
120
117
|
>
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
118
|
+
<IconButton
|
|
119
|
+
size="small"
|
|
120
|
+
onClick={() => {
|
|
121
|
+
setEmbeddingExpanded(!embeddingExpanded);
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
<LinkOutlinedIcon />
|
|
125
|
+
</IconButton>
|
|
126
|
+
</Tooltip>
|
|
127
|
+
</CardActions>
|
|
128
|
+
)}
|
|
125
129
|
</Stack>
|
|
126
130
|
<Collapse in={embeddingExpanded} timeout="auto" unmountOnExit>
|
|
127
131
|
<Divider />
|
|
@@ -4,13 +4,13 @@ import ContentCopyIcon from "@mui/icons-material/ContentCopy";
|
|
|
4
4
|
import LinkOutlinedIcon from "@mui/icons-material/LinkOutlined";
|
|
5
5
|
import {
|
|
6
6
|
CardActions,
|
|
7
|
-
CardContent,
|
|
8
7
|
Collapse,
|
|
9
8
|
Divider,
|
|
10
9
|
IconButton,
|
|
11
10
|
Stack,
|
|
12
11
|
Tooltip,
|
|
13
12
|
Typography,
|
|
13
|
+
Box,
|
|
14
14
|
} from "@mui/material";
|
|
15
15
|
import Markdown from "markdown-to-jsx";
|
|
16
16
|
import React, { Suspense, lazy, useEffect } from "react";
|
|
@@ -18,8 +18,7 @@ import { NotebookCell as ClientNotebookCell } from "../../client";
|
|
|
18
18
|
import { highlight } from "../highlighter";
|
|
19
19
|
import { SourcesExplorer } from "../Model";
|
|
20
20
|
import { StyledCard, StyledCardContent } from "../styles";
|
|
21
|
-
|
|
22
|
-
const RenderedResult = lazy(() => import("../RenderedResult/RenderedResult"));
|
|
21
|
+
import ResultContainer from "../RenderedResult/ResultContainer";
|
|
23
22
|
|
|
24
23
|
interface NotebookCellProps {
|
|
25
24
|
cell: ClientNotebookCell;
|
|
@@ -72,7 +71,7 @@ export function NotebookCell({
|
|
|
72
71
|
</StyledCard>
|
|
73
72
|
)) ||
|
|
74
73
|
(cell.type === "code" && (
|
|
75
|
-
<StyledCard variant="outlined">
|
|
74
|
+
<StyledCard variant="outlined" sx={{ height: "auto" }}>
|
|
76
75
|
{(!hideCodeCellIcon || (!hideEmbeddingIcon && cell.result)) && (
|
|
77
76
|
<Stack sx={{ flexDirection: "row", justifyContent: "right" }}>
|
|
78
77
|
<CardActions
|
|
@@ -82,6 +81,31 @@ export function NotebookCell({
|
|
|
82
81
|
mt: "auto",
|
|
83
82
|
}}
|
|
84
83
|
>
|
|
84
|
+
{cell.newSources && cell.newSources.length > 0 && (
|
|
85
|
+
<Tooltip title="Explore Data Sources">
|
|
86
|
+
<IconButton
|
|
87
|
+
size="small"
|
|
88
|
+
onClick={() => {
|
|
89
|
+
setSourcesExpanded(!sourcesExpanded);
|
|
90
|
+
setEmbeddingExpanded(false);
|
|
91
|
+
setCodeExpanded(false);
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
<svg
|
|
95
|
+
width="24"
|
|
96
|
+
height="24"
|
|
97
|
+
viewBox="0 0 24 24"
|
|
98
|
+
fill="none"
|
|
99
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
100
|
+
>
|
|
101
|
+
<path
|
|
102
|
+
d="M3 3h18v18H3V3zm2 2v14h14V5H5zm2 2h10v2H7V7zm0 4h10v2H7v-2zm0 4h10v2H7v-2z"
|
|
103
|
+
fill="currentColor"
|
|
104
|
+
/>
|
|
105
|
+
</svg>
|
|
106
|
+
</IconButton>
|
|
107
|
+
</Tooltip>
|
|
108
|
+
)}
|
|
85
109
|
{!hideCodeCellIcon && (
|
|
86
110
|
<Tooltip
|
|
87
111
|
title={codeExpanded ? "Hide Code" : "View Code"}
|
|
@@ -114,31 +138,6 @@ export function NotebookCell({
|
|
|
114
138
|
</IconButton>
|
|
115
139
|
</Tooltip>
|
|
116
140
|
)}
|
|
117
|
-
{cell.newSources && cell.newSources.length > 0 && (
|
|
118
|
-
<Tooltip title="Explore Data Sources">
|
|
119
|
-
<IconButton
|
|
120
|
-
size="small"
|
|
121
|
-
onClick={() => {
|
|
122
|
-
setSourcesExpanded(!sourcesExpanded);
|
|
123
|
-
setEmbeddingExpanded(false);
|
|
124
|
-
setCodeExpanded(false);
|
|
125
|
-
}}
|
|
126
|
-
>
|
|
127
|
-
<svg
|
|
128
|
-
width="24"
|
|
129
|
-
height="24"
|
|
130
|
-
viewBox="0 0 24 24"
|
|
131
|
-
fill="none"
|
|
132
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
133
|
-
>
|
|
134
|
-
<path
|
|
135
|
-
d="M3 3h18v18H3V3zm2 2v14h14V5H5zm2 2h10v2H7V7zm0 4h10v2H7v-2zm0 4h10v2H7v-2z"
|
|
136
|
-
fill="currentColor"
|
|
137
|
-
/>
|
|
138
|
-
</svg>
|
|
139
|
-
</IconButton>
|
|
140
|
-
</Tooltip>
|
|
141
|
-
)}
|
|
142
141
|
</CardActions>
|
|
143
142
|
</Stack>
|
|
144
143
|
)}
|
|
@@ -212,18 +211,11 @@ export function NotebookCell({
|
|
|
212
211
|
</Collapse>
|
|
213
212
|
{cell.result && !sourcesExpanded && (
|
|
214
213
|
<>
|
|
215
|
-
<
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
overflow: "auto",
|
|
221
|
-
}}
|
|
222
|
-
>
|
|
223
|
-
<Suspense fallback="Loading malloy...">
|
|
224
|
-
<RenderedResult result={cell.result} />
|
|
225
|
-
</Suspense>
|
|
226
|
-
</CardContent>
|
|
214
|
+
<ResultContainer
|
|
215
|
+
result={cell.result}
|
|
216
|
+
minHeight={200}
|
|
217
|
+
maxHeight={800}
|
|
218
|
+
/>
|
|
227
219
|
</>
|
|
228
220
|
)}
|
|
229
221
|
</StyledCard>
|
|
@@ -19,7 +19,7 @@ interface ConnectionsProps {
|
|
|
19
19
|
server?: string;
|
|
20
20
|
projectName: string;
|
|
21
21
|
accessToken: string;
|
|
22
|
-
navigate: (to: string) => void;
|
|
22
|
+
navigate: (to: string, event?: React.MouseEvent) => void;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// TODO(jjs) - Move this UI to the ConnectionExplorer component
|
|
@@ -27,7 +27,7 @@ import { Typography } from "@mui/material";
|
|
|
27
27
|
interface FiieTreeViewProps {
|
|
28
28
|
items: Model[] | Database[];
|
|
29
29
|
defaultExpandedItems: string[];
|
|
30
|
-
navigate?: (to: string) => void;
|
|
30
|
+
navigate?: (to: string, event?: React.MouseEvent) => void;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export function FileTreeView({
|
|
@@ -64,7 +64,7 @@ type ExtendedTreeItemProps = {
|
|
|
64
64
|
label: string;
|
|
65
65
|
fileType: FileType;
|
|
66
66
|
selectable: boolean;
|
|
67
|
-
link: () => void | undefined;
|
|
67
|
+
link: ((event?: React.MouseEvent) => void) | undefined;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
interface CustomLabelProps {
|
|
@@ -135,7 +135,7 @@ const CustomTreeItem = React.forwardRef(function CustomTreeItem(
|
|
|
135
135
|
<TreeItem2Content
|
|
136
136
|
{...getContentProps()}
|
|
137
137
|
{...(item.link && {
|
|
138
|
-
onClick: () => item.link(),
|
|
138
|
+
onClick: (event) => item.link(event),
|
|
139
139
|
})}
|
|
140
140
|
sx={{
|
|
141
141
|
// If the item is not selectable, disable pointer events.
|
|
@@ -159,7 +159,7 @@ const CustomTreeItem = React.forwardRef(function CustomTreeItem(
|
|
|
159
159
|
|
|
160
160
|
function getTreeView(
|
|
161
161
|
metadataEntries: Model[] | Database[],
|
|
162
|
-
navigate: (to: string) => void,
|
|
162
|
+
navigate: (to: string, event?: React.MouseEvent) => void,
|
|
163
163
|
): TreeViewBaseItem<ExtendedTreeItemProps>[] {
|
|
164
164
|
const tree = new Map<string, unknown>();
|
|
165
165
|
metadataEntries.map((entry: Model | Database) => {
|
|
@@ -182,7 +182,7 @@ function getTreeView(
|
|
|
182
182
|
function getTreeViewRecursive(
|
|
183
183
|
node: Map<string, unknown>,
|
|
184
184
|
path: string,
|
|
185
|
-
navigate: (to: string) => void,
|
|
185
|
+
navigate: (to: string, event?: React.MouseEvent) => void,
|
|
186
186
|
): TreeViewBaseItem<ExtendedTreeItemProps>[] {
|
|
187
187
|
const treeViewItems: TreeViewBaseItem<ExtendedTreeItemProps>[] = [];
|
|
188
188
|
node.forEach((value, key) => {
|
|
@@ -199,7 +199,7 @@ function getTreeViewRecursive(
|
|
|
199
199
|
fileType: fileType,
|
|
200
200
|
link:
|
|
201
201
|
fileType === "model" || fileType === "notebook"
|
|
202
|
-
? navigate
|
|
202
|
+
? (event) => navigate(path + key, event)
|
|
203
203
|
: undefined,
|
|
204
204
|
selectable: fileType === "model" || fileType === "notebook",
|
|
205
205
|
});
|