@malloy-publisher/sdk 0.0.41 → 0.0.43
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-BX2zW03q.cjs → RenderedResult-qA34vdbd.cjs} +1 -1
- package/dist/{RenderedResult-gQPXZIVQ.js → RenderedResult-wM3HaFcq.js} +2 -2
- package/dist/components/MutableNotebook/MutableCell.d.ts +3 -1
- package/dist/components/Notebook/Notebook.d.ts +4 -3
- package/dist/hooks/useQueryWithApiError.d.ts +10 -0
- package/dist/{index-DCLrfHfE.js → index-ClVlSQMk.js} +27933 -27929
- package/dist/{index-xo1oaGoD.cjs → index-nsXS-gBw.cjs} +598 -598
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +16 -15
- package/dist/{vendor-BCM56_2K.js → vendor-BKsYdkmG.js} +5456 -5458
- package/dist/{vendor-Bg9-K32d.cjs → vendor-hHfbZ4ZT.cjs} +30 -30
- package/openapitools.json +1 -1
- package/package.json +2 -2
- package/src/components/ApiErrorDisplay.tsx +12 -12
- package/src/components/Home/Home.tsx +9 -14
- package/src/components/Model/Model.tsx +18 -45
- package/src/components/Model/NamedQueries.tsx +38 -42
- package/src/components/Model/SourcesExplorer.tsx +47 -51
- package/src/components/MutableNotebook/ModelPicker.tsx +12 -18
- package/src/components/MutableNotebook/MutableCell.tsx +120 -62
- package/src/components/MutableNotebook/MutableNotebook.tsx +45 -27
- package/src/components/Notebook/Notebook.tsx +37 -60
- package/src/components/Package/Config.tsx +28 -34
- package/src/components/Package/Connections.tsx +12 -18
- package/src/components/Package/Databases.tsx +12 -18
- package/src/components/Package/Models.tsx +12 -20
- package/src/components/Package/Notebooks.tsx +13 -12
- package/src/components/Package/Schedules.tsx +12 -18
- package/src/components/Project/About.tsx +12 -18
- package/src/components/Project/ConnectionExplorer.tsx +49 -65
- package/src/components/Project/Packages.tsx +12 -18
- package/src/components/QueryResult/QueryResult.tsx +24 -30
- package/src/hooks/useQueryWithApiError.ts +114 -0
- package/src/index.ts +5 -0
|
@@ -5,7 +5,6 @@ import LinkOutlinedIcon from "@mui/icons-material/LinkOutlined";
|
|
|
5
5
|
import {
|
|
6
6
|
Box,
|
|
7
7
|
Button,
|
|
8
|
-
CardActions,
|
|
9
8
|
Collapse,
|
|
10
9
|
Dialog,
|
|
11
10
|
DialogActions,
|
|
@@ -42,6 +41,7 @@ interface NotebookCellProps {
|
|
|
42
41
|
onClose: () => void;
|
|
43
42
|
onEdit: () => void;
|
|
44
43
|
onDelete: () => void;
|
|
44
|
+
addButtonCallback: (isMarkdown: boolean) => React.ReactNode;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export function MutableCell({
|
|
@@ -56,6 +56,7 @@ export function MutableCell({
|
|
|
56
56
|
onClose,
|
|
57
57
|
onEdit,
|
|
58
58
|
onDelete,
|
|
59
|
+
addButtonCallback,
|
|
59
60
|
}: NotebookCellProps) {
|
|
60
61
|
const [codeExpanded, setCodeExpanded] =
|
|
61
62
|
React.useState<boolean>(expandCodeCell);
|
|
@@ -63,11 +64,11 @@ export function MutableCell({
|
|
|
63
64
|
React.useState<boolean>(expandEmbedding);
|
|
64
65
|
const [highlightedMalloyCode, setHighlightedMalloyCode] =
|
|
65
66
|
React.useState<string>();
|
|
66
|
-
const [highlightedEmbedCode
|
|
67
|
-
React.useState<string>();
|
|
67
|
+
const [highlightedEmbedCode] = React.useState<string>();
|
|
68
68
|
const [query, setQuery] = React.useState<QueryExplorerResult>(
|
|
69
69
|
emptyQueryExplorerResult(),
|
|
70
70
|
);
|
|
71
|
+
const [isHovered, setIsHovered] = React.useState<boolean>(false);
|
|
71
72
|
|
|
72
73
|
useEffect(() => {
|
|
73
74
|
if (!cell.isMarkdown)
|
|
@@ -215,78 +216,136 @@ export function MutableCell({
|
|
|
215
216
|
</>
|
|
216
217
|
);
|
|
217
218
|
|
|
218
|
-
const
|
|
219
|
-
|
|
219
|
+
const isEditing = editingMalloy || editingMarkdown;
|
|
220
|
+
|
|
221
|
+
const editingButtons = editingMarkdown ? (
|
|
222
|
+
<Tooltip title="Save">
|
|
223
|
+
<IconButton size="small" onClick={onClose}>
|
|
224
|
+
<CheckIcon />
|
|
225
|
+
</IconButton>
|
|
226
|
+
</Tooltip>
|
|
227
|
+
) : editingMalloy ? (
|
|
228
|
+
<Tooltip title="Save">
|
|
229
|
+
<IconButton
|
|
230
|
+
size="small"
|
|
231
|
+
onClick={() => {
|
|
232
|
+
saveResult(cell.modelPath, cell.sourceName);
|
|
233
|
+
onClose();
|
|
234
|
+
}}
|
|
235
|
+
>
|
|
236
|
+
<CheckIcon />
|
|
237
|
+
</IconButton>
|
|
238
|
+
</Tooltip>
|
|
239
|
+
) : null;
|
|
240
|
+
|
|
241
|
+
const hoverButtonBox = isHovered && (
|
|
242
|
+
<Box
|
|
220
243
|
sx={{
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
244
|
+
position: "absolute",
|
|
245
|
+
top: "4px",
|
|
246
|
+
right: "4px",
|
|
247
|
+
// transform: "translateX(-50%)",
|
|
248
|
+
display: "flex",
|
|
249
|
+
gap: "8px",
|
|
250
|
+
backgroundColor: "background.paper",
|
|
251
|
+
border: "1px solid",
|
|
252
|
+
borderColor: "divider",
|
|
253
|
+
borderRadius: "8px",
|
|
254
|
+
padding: "2px 4px",
|
|
255
|
+
boxShadow: 1,
|
|
256
|
+
zIndex: 10,
|
|
226
257
|
}}
|
|
227
258
|
>
|
|
228
|
-
|
|
229
|
-
|
|
259
|
+
{(!isEditing && (
|
|
260
|
+
<>
|
|
261
|
+
{addButtonCallback(true)}
|
|
262
|
+
{addButtonCallback(false)}
|
|
263
|
+
{buttons}
|
|
264
|
+
</>
|
|
265
|
+
)) ||
|
|
266
|
+
editingButtons}
|
|
267
|
+
</Box>
|
|
230
268
|
);
|
|
269
|
+
|
|
231
270
|
return (
|
|
232
|
-
|
|
233
|
-
{
|
|
271
|
+
<StyledCard
|
|
272
|
+
sx={{
|
|
273
|
+
position: "relative",
|
|
274
|
+
marginTop: "5px",
|
|
275
|
+
marginBottom: "5px",
|
|
276
|
+
borderWidth: "1.5px",
|
|
277
|
+
backgroundColor: "#fff",
|
|
278
|
+
minHeight: "50px",
|
|
279
|
+
}}
|
|
280
|
+
onMouseEnter={() => setIsHovered(true)}
|
|
281
|
+
onMouseLeave={() => {
|
|
282
|
+
setIsHovered(false);
|
|
283
|
+
}}
|
|
284
|
+
>
|
|
285
|
+
{hoverButtonBox}
|
|
234
286
|
{cell.isMarkdown ? (
|
|
235
287
|
<>
|
|
236
288
|
{editingMarkdown ? (
|
|
237
289
|
<MDEditor
|
|
238
290
|
value={value}
|
|
239
291
|
preview="edit"
|
|
292
|
+
autoFocus
|
|
240
293
|
onChange={(newValue) => {
|
|
241
294
|
setValue(newValue);
|
|
242
295
|
updateMarkdown(newValue);
|
|
243
296
|
}}
|
|
297
|
+
onBlur={() => {
|
|
298
|
+
saveResult(cell.modelPath, cell.sourceName);
|
|
299
|
+
if (!isHovered) {
|
|
300
|
+
onClose();
|
|
301
|
+
}
|
|
302
|
+
}}
|
|
244
303
|
/>
|
|
245
304
|
) : (
|
|
246
|
-
<
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
{
|
|
305
|
+
<Box
|
|
306
|
+
sx={{
|
|
307
|
+
px: 0.5,
|
|
308
|
+
pt: 0,
|
|
309
|
+
mt: 0,
|
|
310
|
+
"& h1, & h2, & h3, & h4, & h5, & h6": {
|
|
311
|
+
mt: 0.5,
|
|
312
|
+
mb: 0.5,
|
|
313
|
+
},
|
|
314
|
+
"& p": { mt: 0.5, mb: 0.5 },
|
|
315
|
+
"& ul, & ol": { mt: 0.5, mb: 0.5 },
|
|
316
|
+
"& li": { mt: 0, mb: 0 },
|
|
317
|
+
"& pre, & code": { mt: 0.5, mb: 0.5 },
|
|
318
|
+
"& blockquote": { mt: 0.5, mb: 0.5 },
|
|
319
|
+
}}
|
|
320
|
+
>
|
|
321
|
+
{value ? (
|
|
322
|
+
<Box onClick={onEdit} sx={{ cursor: "pointer" }}>
|
|
264
323
|
<Markdown>{value}</Markdown>
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
</
|
|
324
|
+
</Box>
|
|
325
|
+
) : (
|
|
326
|
+
<Box onClick={onEdit} sx={{ cursor: "pointer" }}>
|
|
327
|
+
<Typography
|
|
328
|
+
sx={{
|
|
329
|
+
p: 2,
|
|
330
|
+
textAlign: "center",
|
|
331
|
+
variant: "subtitle2",
|
|
332
|
+
fontWeight: "medium",
|
|
333
|
+
}}
|
|
334
|
+
>
|
|
335
|
+
Markdown is empty
|
|
336
|
+
</Typography>
|
|
337
|
+
<Typography
|
|
338
|
+
sx={{
|
|
339
|
+
mb: 2,
|
|
340
|
+
textAlign: "center",
|
|
341
|
+
variant: "body2",
|
|
342
|
+
}}
|
|
343
|
+
>
|
|
344
|
+
Click to edit.
|
|
345
|
+
</Typography>
|
|
346
|
+
</Box>
|
|
347
|
+
)}
|
|
348
|
+
</Box>
|
|
290
349
|
)}
|
|
291
350
|
</>
|
|
292
351
|
) : (
|
|
@@ -372,7 +431,7 @@ export function MutableCell({
|
|
|
372
431
|
</StyledCard>
|
|
373
432
|
)}
|
|
374
433
|
{!editingMalloy && !cell.result && (
|
|
375
|
-
<
|
|
434
|
+
<Box onClick={onEdit} sx={{ cursor: "pointer" }}>
|
|
376
435
|
<Typography
|
|
377
436
|
sx={{
|
|
378
437
|
p: 2,
|
|
@@ -386,15 +445,14 @@ export function MutableCell({
|
|
|
386
445
|
<Typography
|
|
387
446
|
sx={{ mb: 2, textAlign: "center", variant: "body2" }}
|
|
388
447
|
>
|
|
389
|
-
Click
|
|
390
|
-
to see results.
|
|
448
|
+
Click to edit.
|
|
391
449
|
</Typography>
|
|
392
|
-
</
|
|
450
|
+
</Box>
|
|
393
451
|
)}
|
|
394
452
|
</>
|
|
395
453
|
)}
|
|
396
454
|
{deleteDialogOpen && deleteDialog}
|
|
397
|
-
|
|
455
|
+
</StyledCard>
|
|
398
456
|
);
|
|
399
457
|
}
|
|
400
458
|
|
|
@@ -204,6 +204,47 @@ export default function MutableNotebook({
|
|
|
204
204
|
}
|
|
205
205
|
return sourceAndPath;
|
|
206
206
|
};
|
|
207
|
+
const plusButton = (isMarkdown: boolean, index: number) => {
|
|
208
|
+
return (
|
|
209
|
+
<Button
|
|
210
|
+
size="small"
|
|
211
|
+
startIcon={<AddIcon />}
|
|
212
|
+
onClick={() => handleAddCell(isMarkdown, index)}
|
|
213
|
+
variant="contained"
|
|
214
|
+
sx={{
|
|
215
|
+
backgroundColor: "#fff",
|
|
216
|
+
color: (theme) =>
|
|
217
|
+
theme.palette.mode === "dark"
|
|
218
|
+
? theme.palette.grey[100]
|
|
219
|
+
: theme.palette.grey[700],
|
|
220
|
+
boxShadow: "none",
|
|
221
|
+
"&:hover": {
|
|
222
|
+
backgroundColor: (theme) =>
|
|
223
|
+
theme.palette.mode === "dark"
|
|
224
|
+
? theme.palette.grey[500]
|
|
225
|
+
: theme.palette.grey[300],
|
|
226
|
+
boxShadow: "none",
|
|
227
|
+
},
|
|
228
|
+
}}
|
|
229
|
+
>
|
|
230
|
+
{isMarkdown ? "Markdown" : "Explore"}
|
|
231
|
+
</Button>
|
|
232
|
+
);
|
|
233
|
+
};
|
|
234
|
+
const addButtonSet = (
|
|
235
|
+
<Box
|
|
236
|
+
sx={{
|
|
237
|
+
display: "flex",
|
|
238
|
+
gap: 1,
|
|
239
|
+
justifyContent: "center",
|
|
240
|
+
flex: 2,
|
|
241
|
+
}}
|
|
242
|
+
>
|
|
243
|
+
{plusButton(false, notebookData.getCells().length)}
|
|
244
|
+
{plusButton(true, notebookData.getCells().length)}
|
|
245
|
+
</Box>
|
|
246
|
+
);
|
|
247
|
+
|
|
207
248
|
return (
|
|
208
249
|
<StyledCard variant="outlined">
|
|
209
250
|
<StyledCardContent>
|
|
@@ -315,33 +356,6 @@ export default function MutableNotebook({
|
|
|
315
356
|
}}
|
|
316
357
|
/>
|
|
317
358
|
</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
359
|
<Box sx={{ flex: 1 }} />
|
|
346
360
|
</Stack>
|
|
347
361
|
</StyledCardContent>
|
|
@@ -373,6 +387,9 @@ export default function MutableNotebook({
|
|
|
373
387
|
>
|
|
374
388
|
<MutableCell
|
|
375
389
|
cell={cell}
|
|
390
|
+
addButtonCallback={(isMarkdown) =>
|
|
391
|
+
plusButton(isMarkdown, index)
|
|
392
|
+
}
|
|
376
393
|
sourceAndPaths={getSourceList(sourceAndPaths)}
|
|
377
394
|
expandCodeCell={expandCodeCells}
|
|
378
395
|
expandEmbedding={expandEmbeddings}
|
|
@@ -404,6 +421,7 @@ export default function MutableNotebook({
|
|
|
404
421
|
/>
|
|
405
422
|
</React.Fragment>
|
|
406
423
|
))}
|
|
424
|
+
{addButtonSet}
|
|
407
425
|
<Menu
|
|
408
426
|
anchorEl={menuAnchorEl}
|
|
409
427
|
open={menuOpen}
|
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
|
|
2
2
|
import LinkOutlinedIcon from "@mui/icons-material/LinkOutlined";
|
|
3
3
|
import {
|
|
4
|
+
Box,
|
|
4
5
|
CardActions,
|
|
5
6
|
Collapse,
|
|
6
7
|
Divider,
|
|
7
8
|
IconButton,
|
|
9
|
+
Stack,
|
|
8
10
|
Tooltip,
|
|
9
11
|
Typography,
|
|
10
12
|
} from "@mui/material";
|
|
11
|
-
import Stack from "@mui/material/Stack";
|
|
12
|
-
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
13
|
-
import { AxiosError } from "axios";
|
|
14
13
|
import React, { useEffect } from "react";
|
|
15
|
-
import {
|
|
16
|
-
import { ApiError, ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
14
|
+
import { Configuration, NotebooksApi, CompiledNotebook } from "../../client";
|
|
17
15
|
import { highlight } from "../highlighter";
|
|
18
|
-
import { Loading } from "../Loading";
|
|
19
|
-
import { usePackage } from "../Package";
|
|
20
16
|
import { StyledCard, StyledCardContent, StyledCardMedia } from "../styles";
|
|
21
17
|
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";
|
|
22
23
|
|
|
23
24
|
const notebooksApi = new NotebooksApi(new Configuration());
|
|
24
|
-
const queryClient = new QueryClient();
|
|
25
25
|
|
|
26
26
|
interface NotebookProps {
|
|
27
27
|
notebookPath: string;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
versionId?: string;
|
|
29
|
+
expandResults?: boolean;
|
|
30
|
+
hideResultIcons?: boolean;
|
|
30
31
|
expandEmbeddings?: boolean;
|
|
31
32
|
hideEmbeddingIcons?: boolean;
|
|
32
33
|
}
|
|
34
|
+
|
|
33
35
|
// Requires PackageProvider
|
|
34
36
|
export default function Notebook({
|
|
35
37
|
notebookPath,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
expandResults,
|
|
39
|
+
hideResultIcons,
|
|
38
40
|
expandEmbeddings,
|
|
39
41
|
hideEmbeddingIcons,
|
|
40
42
|
}: NotebookProps) {
|
|
@@ -62,57 +64,32 @@ export default function Notebook({
|
|
|
62
64
|
isSuccess,
|
|
63
65
|
isError,
|
|
64
66
|
error,
|
|
65
|
-
} =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
} = useQueryWithApiError<CompiledNotebook>({
|
|
68
|
+
queryKey: [
|
|
69
|
+
"notebook",
|
|
70
|
+
server,
|
|
71
|
+
projectName,
|
|
72
|
+
packageName,
|
|
73
|
+
notebookPath,
|
|
74
|
+
versionId,
|
|
75
|
+
],
|
|
76
|
+
queryFn: async () => {
|
|
77
|
+
const response = await notebooksApi.getNotebook(
|
|
70
78
|
projectName,
|
|
71
79
|
packageName,
|
|
72
80
|
notebookPath,
|
|
73
81
|
versionId,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
baseURL: server,
|
|
84
|
-
withCredentials: !accessToken,
|
|
85
|
-
headers: {
|
|
86
|
-
Authorization: accessToken && `Bearer ${accessToken}`,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
);
|
|
90
|
-
return response.data;
|
|
91
|
-
} catch (err) {
|
|
92
|
-
// If it's an Axios error, it will have response data
|
|
93
|
-
if (err && typeof err === "object" && "response" in err) {
|
|
94
|
-
const axiosError = err as AxiosError<{
|
|
95
|
-
code: string;
|
|
96
|
-
message: string;
|
|
97
|
-
}>;
|
|
98
|
-
if (axiosError.response?.data) {
|
|
99
|
-
const apiError: ApiError = new Error(
|
|
100
|
-
axiosError.response.data.message || axiosError.message,
|
|
101
|
-
);
|
|
102
|
-
apiError.status = axiosError.response.status;
|
|
103
|
-
apiError.data = axiosError.response.data;
|
|
104
|
-
throw apiError;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// For other errors, throw as is
|
|
108
|
-
throw err;
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
retry: false,
|
|
112
|
-
throwOnError: false,
|
|
82
|
+
{
|
|
83
|
+
baseURL: server,
|
|
84
|
+
withCredentials: !accessToken,
|
|
85
|
+
headers: {
|
|
86
|
+
Authorization: accessToken && `Bearer ${accessToken}`,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
return response.data;
|
|
113
91
|
},
|
|
114
|
-
|
|
115
|
-
);
|
|
92
|
+
});
|
|
116
93
|
|
|
117
94
|
return (
|
|
118
95
|
<StyledCard variant="outlined">
|
|
@@ -206,8 +183,8 @@ export default function Notebook({
|
|
|
206
183
|
notebookPath,
|
|
207
184
|
cell.text,
|
|
208
185
|
)}
|
|
209
|
-
expandCodeCell={
|
|
210
|
-
hideCodeCellIcon={
|
|
186
|
+
expandCodeCell={expandResults}
|
|
187
|
+
hideCodeCellIcon={hideResultIcons}
|
|
211
188
|
expandEmbedding={expandEmbeddings}
|
|
212
189
|
hideEmbeddingIcon={hideEmbeddingIcons}
|
|
213
190
|
key={index}
|
|
@@ -7,36 +7,30 @@ import {
|
|
|
7
7
|
ListItemText,
|
|
8
8
|
Typography,
|
|
9
9
|
} from "@mui/material";
|
|
10
|
-
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
11
10
|
import { Configuration, PackagesApi } from "../../client";
|
|
12
11
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
13
12
|
import { Loading } from "../Loading";
|
|
14
13
|
import { StyledCard, StyledCardContent } from "../styles";
|
|
15
14
|
import { usePackage } from "./PackageProvider";
|
|
15
|
+
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
16
16
|
|
|
17
17
|
const packagesApi = new PackagesApi(new Configuration());
|
|
18
|
-
const queryClient = new QueryClient();
|
|
19
18
|
|
|
20
19
|
export default function Config() {
|
|
21
20
|
const { server, projectName, packageName, versionId, accessToken } =
|
|
22
21
|
usePackage();
|
|
23
22
|
|
|
24
|
-
const { data, isSuccess, isError, error } =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
retry: false,
|
|
36
|
-
throwOnError: false,
|
|
37
|
-
},
|
|
38
|
-
queryClient,
|
|
39
|
-
);
|
|
23
|
+
const { data, isSuccess, isError, error } = useQueryWithApiError({
|
|
24
|
+
queryKey: ["package", server, projectName, packageName, versionId],
|
|
25
|
+
queryFn: () =>
|
|
26
|
+
packagesApi.getPackage(projectName, packageName, versionId, false, {
|
|
27
|
+
baseURL: server,
|
|
28
|
+
withCredentials: !accessToken,
|
|
29
|
+
headers: {
|
|
30
|
+
Authorization: accessToken && `Bearer ${accessToken}`,
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
40
34
|
|
|
41
35
|
return (
|
|
42
36
|
<StyledCard variant="outlined" sx={{ padding: "10px", width: "100%" }}>
|
|
@@ -57,9 +51,9 @@ export default function Config() {
|
|
|
57
51
|
<ListItemText primary="Name" secondary={packageName} />
|
|
58
52
|
</ListItem>
|
|
59
53
|
{!isSuccess && !isError && (
|
|
60
|
-
<
|
|
54
|
+
<ListItem>
|
|
61
55
|
<Loading text="Fetching Package Metadata..." />
|
|
62
|
-
</
|
|
56
|
+
</ListItem>
|
|
63
57
|
)}
|
|
64
58
|
{isSuccess &&
|
|
65
59
|
((data.data && (
|
|
@@ -70,20 +64,20 @@ export default function Config() {
|
|
|
70
64
|
/>
|
|
71
65
|
</ListItem>
|
|
72
66
|
)) || (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
67
|
+
<ListItem
|
|
68
|
+
disablePadding={true}
|
|
69
|
+
dense={true}
|
|
70
|
+
sx={{ mt: "20px" }}
|
|
71
|
+
>
|
|
72
|
+
<ErrorIcon
|
|
73
|
+
sx={{
|
|
74
|
+
color: "grey.600",
|
|
75
|
+
mr: "10px",
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
<ListItemText primary={"No package manifest"} />
|
|
79
|
+
</ListItem>
|
|
80
|
+
))}
|
|
87
81
|
{isError && (
|
|
88
82
|
<ApiErrorDisplay
|
|
89
83
|
error={error}
|
|
@@ -7,15 +7,14 @@ import {
|
|
|
7
7
|
TableRow,
|
|
8
8
|
Typography,
|
|
9
9
|
} from "@mui/material";
|
|
10
|
-
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
11
10
|
import { Configuration, ConnectionsApi } from "../../client";
|
|
12
11
|
import { Connection as ApiConnection } from "../../client/api";
|
|
13
12
|
import { StyledCard, StyledCardContent } from "../styles";
|
|
14
13
|
import { usePackage } from "./PackageProvider";
|
|
15
14
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
15
|
+
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
16
16
|
|
|
17
17
|
const connectionsApi = new ConnectionsApi(new Configuration());
|
|
18
|
-
const queryClient = new QueryClient();
|
|
19
18
|
|
|
20
19
|
// TODO(jjs) - Move this UI to the ConnectionExplorer component
|
|
21
20
|
function Connection({ connection }: { connection: ApiConnection }) {
|
|
@@ -34,22 +33,17 @@ function Connection({ connection }: { connection: ApiConnection }) {
|
|
|
34
33
|
export default function Connections() {
|
|
35
34
|
const { server, projectName, accessToken } = usePackage();
|
|
36
35
|
|
|
37
|
-
const { data, isSuccess, isError, error } =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
retry: false,
|
|
49
|
-
throwOnError: false,
|
|
50
|
-
},
|
|
51
|
-
queryClient,
|
|
52
|
-
);
|
|
36
|
+
const { data, isSuccess, isError, error } = useQueryWithApiError({
|
|
37
|
+
queryKey: ["connections", server, projectName],
|
|
38
|
+
queryFn: () =>
|
|
39
|
+
connectionsApi.listConnections(projectName, {
|
|
40
|
+
baseURL: server,
|
|
41
|
+
withCredentials: !accessToken,
|
|
42
|
+
headers: {
|
|
43
|
+
Authorization: accessToken && `Bearer ${accessToken}`,
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
53
47
|
|
|
54
48
|
return (
|
|
55
49
|
<StyledCard variant="outlined" sx={{ padding: "10px", width: "100%" }}>
|