@malloy-publisher/sdk 0.0.34 → 0.0.36
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/README.md +21 -0
- package/dist/{RenderedResult-CKEsEevp.js → RenderedResult-BlNz8j4d.js} +2 -2
- package/dist/{RenderedResult-9A74lwfO.cjs → RenderedResult-DphykkT6.cjs} +1 -1
- package/dist/client/api.d.ts +18 -0
- package/dist/components/ApiErrorDisplay.d.ts +13 -0
- package/dist/components/Model/ModelCell.d.ts +1 -6
- package/dist/components/Package/Config.d.ts +1 -9
- package/dist/components/Package/Connections.d.ts +1 -8
- package/dist/components/Package/Databases.d.ts +1 -9
- package/dist/components/Package/Models.d.ts +1 -6
- package/dist/components/Package/Notebooks.d.ts +2 -7
- package/dist/components/Package/Package.d.ts +1 -6
- package/dist/components/Package/PackageProvider.d.ts +14 -0
- package/dist/components/Package/Schedules.d.ts +1 -9
- package/dist/components/Package/index.d.ts +2 -1
- package/dist/components/Project/About.d.ts +1 -7
- package/dist/components/Project/ConnectionExplorer.d.ts +1 -4
- package/dist/components/Project/Packages.d.ts +2 -5
- package/dist/components/Project/Project.d.ts +11 -3
- package/dist/components/Project/index.d.ts +1 -1
- package/dist/components/QueryResult/QueryResult.d.ts +1 -6
- package/dist/{index-DahUc0AC.js → index-DvGSfdDD.js} +29197 -29339
- package/dist/{index-TNDWxBXR.cjs → index-nKbldp0y.cjs} +598 -598
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +17 -13
- package/dist/{vendor-DfRellEl.js → vendor-C8UD-eyK.js} +5 -5
- package/package.json +1 -1
- package/src/components/ApiErrorDisplay.tsx +40 -0
- package/src/components/Home/Home.tsx +8 -1
- package/src/components/Model/Model.tsx +59 -28
- package/src/components/Model/ModelCell.tsx +26 -63
- package/src/components/Model/NamedQueries.tsx +2 -2
- package/src/components/Model/SourcesExplorer.tsx +14 -15
- package/src/components/MutableNotebook/ModelPicker.tsx +13 -3
- package/src/components/MutableNotebook/MutableCell.tsx +5 -14
- package/src/components/MutableNotebook/MutableNotebook.tsx +2 -2
- package/src/components/Notebook/Notebook.tsx +48 -24
- package/src/components/Package/Config.tsx +10 -18
- package/src/components/Package/Connections.tsx +10 -12
- package/src/components/Package/Databases.tsx +93 -198
- package/src/components/Package/FileTreeView.tsx +21 -4
- package/src/components/Package/Models.tsx +21 -31
- package/src/components/Package/Notebooks.tsx +22 -32
- package/src/components/Package/Package.tsx +31 -89
- package/src/components/Package/PackageProvider.tsx +46 -0
- package/src/components/Package/Schedules.tsx +10 -19
- package/src/components/Package/index.ts +6 -1
- package/src/components/Project/About.tsx +7 -15
- package/src/components/Project/ConnectionExplorer.tsx +131 -52
- package/src/components/Project/Packages.tsx +12 -13
- package/src/components/Project/Project.tsx +35 -16
- package/src/components/Project/index.ts +1 -1
- package/src/components/QueryResult/QueryResult.tsx +12 -15
- package/src/components/RenderedResult/ResultContainer.tsx +0 -1
- package/dist/components/Package/PublisherPackageProvider.d.ts +0 -14
- package/dist/components/Project/TablesInSchema.d.ts +0 -10
- package/src/components/Package/PublisherPackageProvider.tsx +0 -48
- package/src/components/Project/TablesInSchema.tsx +0 -84
|
@@ -22,7 +22,7 @@ import Collapse from "@mui/material/Collapse";
|
|
|
22
22
|
import DnsIcon from "@mui/icons-material/DnsOutlined";
|
|
23
23
|
import DataArrayIcon from "@mui/icons-material/DataArrayOutlined";
|
|
24
24
|
import { Database, Model } from "../../client";
|
|
25
|
-
import { Typography } from "@mui/material";
|
|
25
|
+
import { Typography, Tooltip } from "@mui/material";
|
|
26
26
|
|
|
27
27
|
interface FiieTreeViewProps {
|
|
28
28
|
items: Model[] | Database[];
|
|
@@ -65,6 +65,7 @@ type ExtendedTreeItemProps = {
|
|
|
65
65
|
fileType: FileType;
|
|
66
66
|
selectable: boolean;
|
|
67
67
|
link: ((event?: React.MouseEvent) => void) | undefined;
|
|
68
|
+
error?: string;
|
|
68
69
|
};
|
|
69
70
|
|
|
70
71
|
interface CustomLabelProps {
|
|
@@ -72,13 +73,13 @@ interface CustomLabelProps {
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
function CustomTreeItem2Label({ item, ...other }: CustomLabelProps) {
|
|
75
|
-
|
|
76
|
+
const label = (
|
|
76
77
|
<TreeItem2Label
|
|
77
78
|
{...other}
|
|
78
79
|
sx={{
|
|
79
80
|
display: "flex",
|
|
80
81
|
alignItems: "center",
|
|
81
|
-
color: "grey.600",
|
|
82
|
+
color: item.error ? "error.main" : "grey.600",
|
|
82
83
|
}}
|
|
83
84
|
>
|
|
84
85
|
{(item.fileType === "directory" && <FolderIcon />) ||
|
|
@@ -88,12 +89,26 @@ function CustomTreeItem2Label({ item, ...other }: CustomLabelProps) {
|
|
|
88
89
|
<Typography
|
|
89
90
|
variant="body2"
|
|
90
91
|
sx={{ marginLeft: "5px" }}
|
|
91
|
-
color={
|
|
92
|
+
color={
|
|
93
|
+
item.error
|
|
94
|
+
? "error.main"
|
|
95
|
+
: item.link
|
|
96
|
+
? "primary.main"
|
|
97
|
+
: "grey.600"
|
|
98
|
+
}
|
|
92
99
|
>
|
|
93
100
|
{item.label}
|
|
94
101
|
</Typography>
|
|
95
102
|
</TreeItem2Label>
|
|
96
103
|
);
|
|
104
|
+
|
|
105
|
+
return item.error ? (
|
|
106
|
+
<Tooltip title={item.error} placement="right">
|
|
107
|
+
{label}
|
|
108
|
+
</Tooltip>
|
|
109
|
+
) : (
|
|
110
|
+
label
|
|
111
|
+
);
|
|
97
112
|
}
|
|
98
113
|
|
|
99
114
|
interface CustomTreeItemProps
|
|
@@ -193,6 +208,7 @@ function getTreeViewRecursive(
|
|
|
193
208
|
"unknown";
|
|
194
209
|
if (fileType !== "unknown") {
|
|
195
210
|
// This is a model or database.
|
|
211
|
+
const entry = value as Model | Database;
|
|
196
212
|
treeViewItems.push({
|
|
197
213
|
id: path + key,
|
|
198
214
|
label: key,
|
|
@@ -202,6 +218,7 @@ function getTreeViewRecursive(
|
|
|
202
218
|
? (event) => navigate(path + key, event)
|
|
203
219
|
: undefined,
|
|
204
220
|
selectable: fileType === "model" || fileType === "notebook",
|
|
221
|
+
error: "error" in entry ? entry.error : undefined,
|
|
205
222
|
});
|
|
206
223
|
} else {
|
|
207
224
|
// This is a directory.
|
|
@@ -4,6 +4,8 @@ import axios from "axios";
|
|
|
4
4
|
import { Configuration, ModelsApi } from "../../client";
|
|
5
5
|
import { StyledCard, StyledCardContent } from "../styles";
|
|
6
6
|
import { FileTreeView } from "./FileTreeView";
|
|
7
|
+
import { usePackage } from "./PackageProvider";
|
|
8
|
+
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
7
9
|
|
|
8
10
|
axios.defaults.baseURL = "http://localhost:4000";
|
|
9
11
|
const modelsApi = new ModelsApi(new Configuration());
|
|
@@ -12,22 +14,13 @@ const queryClient = new QueryClient();
|
|
|
12
14
|
const DEFAULT_EXPANDED_FOLDERS = ["notebooks/", "models/"];
|
|
13
15
|
|
|
14
16
|
interface ModelsProps {
|
|
15
|
-
server?: string;
|
|
16
|
-
projectName: string;
|
|
17
|
-
packageName: string;
|
|
18
|
-
versionId?: string;
|
|
19
17
|
navigate: (to: string, event?: React.MouseEvent) => void;
|
|
20
|
-
accessToken?: string;
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
export default function Models({
|
|
24
|
-
server,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
versionId,
|
|
28
|
-
navigate,
|
|
29
|
-
accessToken,
|
|
30
|
-
}: ModelsProps) {
|
|
20
|
+
export default function Models({ navigate }: ModelsProps) {
|
|
21
|
+
const { server, projectName, packageName, versionId, accessToken } =
|
|
22
|
+
usePackage();
|
|
23
|
+
|
|
31
24
|
const { data, isError, error, isLoading, isSuccess } = useQuery(
|
|
32
25
|
{
|
|
33
26
|
queryKey: ["models", server, projectName, packageName, versionId],
|
|
@@ -39,6 +32,7 @@ export default function Models({
|
|
|
39
32
|
Authorization: accessToken && `Bearer ${accessToken}`,
|
|
40
33
|
},
|
|
41
34
|
}),
|
|
35
|
+
throwOnError: false,
|
|
42
36
|
retry: false,
|
|
43
37
|
},
|
|
44
38
|
queryClient,
|
|
@@ -58,29 +52,25 @@ export default function Models({
|
|
|
58
52
|
overflowY: "auto",
|
|
59
53
|
}}
|
|
60
54
|
>
|
|
61
|
-
{
|
|
55
|
+
{!isSuccess && !isError && (
|
|
62
56
|
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
63
57
|
Fetching Models...
|
|
64
58
|
</Typography>
|
|
65
59
|
)}
|
|
66
|
-
{isSuccess &&
|
|
67
|
-
(data.data.length > 0 ? (
|
|
68
|
-
<FileTreeView
|
|
69
|
-
items={data.data.sort((a, b) => {
|
|
70
|
-
return a.path.localeCompare(b.path);
|
|
71
|
-
})}
|
|
72
|
-
defaultExpandedItems={DEFAULT_EXPANDED_FOLDERS}
|
|
73
|
-
navigate={navigate}
|
|
74
|
-
/>
|
|
75
|
-
) : (
|
|
76
|
-
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
77
|
-
No models found
|
|
78
|
-
</Typography>
|
|
79
|
-
))}
|
|
80
60
|
{isError && (
|
|
81
|
-
<
|
|
82
|
-
{
|
|
83
|
-
|
|
61
|
+
<ApiErrorDisplay
|
|
62
|
+
error={error}
|
|
63
|
+
context={`${projectName} > ${packageName} > Models`}
|
|
64
|
+
/>
|
|
65
|
+
)}
|
|
66
|
+
{isSuccess && (
|
|
67
|
+
<FileTreeView
|
|
68
|
+
items={data.data.sort((a, b) => {
|
|
69
|
+
return a.path.localeCompare(b.path);
|
|
70
|
+
})}
|
|
71
|
+
navigate={navigate}
|
|
72
|
+
defaultExpandedItems={DEFAULT_EXPANDED_FOLDERS}
|
|
73
|
+
/>
|
|
84
74
|
)}
|
|
85
75
|
</Box>
|
|
86
76
|
</StyledCardContent>
|
|
@@ -3,29 +3,22 @@ import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
|
3
3
|
import { Configuration, NotebooksApi } from "../../client";
|
|
4
4
|
import { StyledCard, StyledCardContent } from "../styles";
|
|
5
5
|
import { FileTreeView } from "./FileTreeView";
|
|
6
|
+
import { usePackage } from "./PackageProvider";
|
|
7
|
+
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
6
8
|
|
|
7
9
|
const notebooksApi = new NotebooksApi(new Configuration());
|
|
8
10
|
const queryClient = new QueryClient();
|
|
9
11
|
|
|
10
12
|
const DEFAULT_EXPANDED_FOLDERS = ["notebooks/"];
|
|
11
13
|
|
|
12
|
-
interface
|
|
13
|
-
server?: string;
|
|
14
|
-
projectName: string;
|
|
15
|
-
packageName: string;
|
|
16
|
-
versionId?: string;
|
|
14
|
+
interface NotebooksProps {
|
|
17
15
|
navigate: (to: string, event?: React.MouseEvent) => void;
|
|
18
|
-
accessToken?: string;
|
|
19
16
|
}
|
|
20
17
|
|
|
21
|
-
export default function Notebooks({
|
|
22
|
-
server,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
versionId,
|
|
26
|
-
navigate,
|
|
27
|
-
accessToken,
|
|
28
|
-
}: ModelsProps) {
|
|
18
|
+
export default function Notebooks({ navigate }: NotebooksProps) {
|
|
19
|
+
const { server, projectName, packageName, versionId, accessToken } =
|
|
20
|
+
usePackage();
|
|
21
|
+
|
|
29
22
|
const { data, isLoading, isError, error, isSuccess } = useQuery(
|
|
30
23
|
{
|
|
31
24
|
queryKey: ["notebooks", server, projectName, packageName, versionId],
|
|
@@ -37,6 +30,7 @@ export default function Notebooks({
|
|
|
37
30
|
Authorization: accessToken && `Bearer ${accessToken}`,
|
|
38
31
|
},
|
|
39
32
|
}),
|
|
33
|
+
throwOnError: false,
|
|
40
34
|
retry: false,
|
|
41
35
|
},
|
|
42
36
|
queryClient,
|
|
@@ -56,29 +50,25 @@ export default function Notebooks({
|
|
|
56
50
|
overflowY: "auto",
|
|
57
51
|
}}
|
|
58
52
|
>
|
|
59
|
-
{
|
|
53
|
+
{!isSuccess && !isError && (
|
|
60
54
|
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
61
55
|
Fetching Notebooks...
|
|
62
56
|
</Typography>
|
|
63
57
|
)}
|
|
64
|
-
{isSuccess &&
|
|
65
|
-
(data.data.length > 0 ? (
|
|
66
|
-
<FileTreeView
|
|
67
|
-
items={data.data.sort((a, b) => {
|
|
68
|
-
return a.path.localeCompare(b.path);
|
|
69
|
-
})}
|
|
70
|
-
defaultExpandedItems={DEFAULT_EXPANDED_FOLDERS}
|
|
71
|
-
navigate={navigate}
|
|
72
|
-
/>
|
|
73
|
-
) : (
|
|
74
|
-
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
75
|
-
No notebooks found
|
|
76
|
-
</Typography>
|
|
77
|
-
))}
|
|
78
58
|
{isError && (
|
|
79
|
-
<
|
|
80
|
-
{
|
|
81
|
-
|
|
59
|
+
<ApiErrorDisplay
|
|
60
|
+
error={error}
|
|
61
|
+
context={`${projectName} > ${packageName} > Notebooks`}
|
|
62
|
+
/>
|
|
63
|
+
)}
|
|
64
|
+
{isSuccess && (
|
|
65
|
+
<FileTreeView
|
|
66
|
+
items={data.data.sort((a, b) => {
|
|
67
|
+
return a.path.localeCompare(b.path);
|
|
68
|
+
})}
|
|
69
|
+
defaultExpandedItems={DEFAULT_EXPANDED_FOLDERS}
|
|
70
|
+
navigate={navigate}
|
|
71
|
+
/>
|
|
82
72
|
)}
|
|
83
73
|
</Box>
|
|
84
74
|
</StyledCardContent>
|
|
@@ -5,28 +5,15 @@ import Connections from "./Connections";
|
|
|
5
5
|
import Databases from "./Databases";
|
|
6
6
|
import Models from "./Models";
|
|
7
7
|
import Notebooks from "./Notebooks";
|
|
8
|
-
import { PublisherPackageProvider } from "./PublisherPackageProvider";
|
|
9
8
|
import Schedules from "./Schedules";
|
|
10
9
|
|
|
11
10
|
const README_NOTEBOOK = "README.malloynb";
|
|
12
11
|
|
|
13
12
|
interface PackageProps {
|
|
14
|
-
server?: string;
|
|
15
|
-
projectName: string;
|
|
16
|
-
packageName: string;
|
|
17
|
-
versionId?: string;
|
|
18
13
|
navigate?: (to: string, event?: React.MouseEvent) => void;
|
|
19
|
-
accessToken?: string;
|
|
20
14
|
}
|
|
21
15
|
|
|
22
|
-
export default function Package({
|
|
23
|
-
server,
|
|
24
|
-
projectName,
|
|
25
|
-
packageName,
|
|
26
|
-
versionId,
|
|
27
|
-
navigate,
|
|
28
|
-
accessToken,
|
|
29
|
-
}: PackageProps) {
|
|
16
|
+
export default function Package({ navigate }: PackageProps) {
|
|
30
17
|
if (!navigate) {
|
|
31
18
|
navigate = (to: string) => {
|
|
32
19
|
window.location.href = to;
|
|
@@ -34,82 +21,37 @@ export default function Package({
|
|
|
34
21
|
}
|
|
35
22
|
|
|
36
23
|
return (
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
versionId={versionId}
|
|
24
|
+
<Grid
|
|
25
|
+
container
|
|
26
|
+
spacing={2}
|
|
27
|
+
columns={12}
|
|
28
|
+
sx={{ mb: (theme) => theme.spacing(2) }}
|
|
43
29
|
>
|
|
44
|
-
<Grid
|
|
45
|
-
|
|
46
|
-
spacing={2}
|
|
47
|
-
columns={12}
|
|
48
|
-
sx={{ mb: (theme) => theme.spacing(2) }}
|
|
49
|
-
>
|
|
50
|
-
<Grid size={{ xs: 12, md: 4 }}>
|
|
51
|
-
<Config
|
|
52
|
-
server={server}
|
|
53
|
-
projectName={projectName}
|
|
54
|
-
packageName={packageName}
|
|
55
|
-
versionId={versionId}
|
|
56
|
-
accessToken={accessToken}
|
|
57
|
-
/>
|
|
58
|
-
</Grid>
|
|
59
|
-
<Grid size={{ xs: 12, md: 4 }}>
|
|
60
|
-
<Notebooks
|
|
61
|
-
server={server}
|
|
62
|
-
projectName={projectName}
|
|
63
|
-
packageName={packageName}
|
|
64
|
-
versionId={versionId}
|
|
65
|
-
navigate={navigate}
|
|
66
|
-
accessToken={accessToken}
|
|
67
|
-
/>
|
|
68
|
-
</Grid>
|
|
69
|
-
<Grid size={{ xs: 12, md: 4 }}>
|
|
70
|
-
<Models
|
|
71
|
-
server={server}
|
|
72
|
-
projectName={projectName}
|
|
73
|
-
packageName={packageName}
|
|
74
|
-
versionId={versionId}
|
|
75
|
-
navigate={navigate}
|
|
76
|
-
accessToken={accessToken}
|
|
77
|
-
/>
|
|
78
|
-
</Grid>
|
|
79
|
-
<Grid size={{ xs: 12, md: 6 }}>
|
|
80
|
-
<Databases
|
|
81
|
-
server={server}
|
|
82
|
-
projectName={projectName}
|
|
83
|
-
packageName={packageName}
|
|
84
|
-
versionId={versionId}
|
|
85
|
-
accessToken={accessToken}
|
|
86
|
-
/>
|
|
87
|
-
</Grid>
|
|
88
|
-
<Grid size={{ xs: 12, md: 6 }}>
|
|
89
|
-
<Connections
|
|
90
|
-
navigate={navigate}
|
|
91
|
-
server={server}
|
|
92
|
-
projectName={projectName}
|
|
93
|
-
accessToken={accessToken}
|
|
94
|
-
/>
|
|
95
|
-
</Grid>
|
|
96
|
-
<Grid size={{ xs: 12, md: 12 }}>
|
|
97
|
-
<Schedules
|
|
98
|
-
server={server}
|
|
99
|
-
projectName={projectName}
|
|
100
|
-
packageName={packageName}
|
|
101
|
-
versionId={versionId}
|
|
102
|
-
accessToken={accessToken}
|
|
103
|
-
/>
|
|
104
|
-
</Grid>
|
|
105
|
-
<Grid size={{ xs: 12, md: 12 }}>
|
|
106
|
-
<Notebook
|
|
107
|
-
notebookPath={README_NOTEBOOK}
|
|
108
|
-
expandCodeCells={false}
|
|
109
|
-
hideEmbeddingIcons={true}
|
|
110
|
-
/>
|
|
111
|
-
</Grid>
|
|
30
|
+
<Grid size={{ xs: 12, md: 4 }}>
|
|
31
|
+
<Config />
|
|
112
32
|
</Grid>
|
|
113
|
-
|
|
33
|
+
<Grid size={{ xs: 12, md: 4 }}>
|
|
34
|
+
<Notebooks navigate={navigate} />
|
|
35
|
+
</Grid>
|
|
36
|
+
<Grid size={{ xs: 12, md: 4 }}>
|
|
37
|
+
<Models navigate={navigate} />
|
|
38
|
+
</Grid>
|
|
39
|
+
<Grid size={{ xs: 12, md: 6 }}>
|
|
40
|
+
<Databases />
|
|
41
|
+
</Grid>
|
|
42
|
+
<Grid size={{ xs: 12, md: 6 }}>
|
|
43
|
+
<Connections navigate={navigate} />
|
|
44
|
+
</Grid>
|
|
45
|
+
<Grid size={{ xs: 12, md: 12 }}>
|
|
46
|
+
<Schedules />
|
|
47
|
+
</Grid>
|
|
48
|
+
<Grid size={{ xs: 12, md: 12 }}>
|
|
49
|
+
<Notebook
|
|
50
|
+
notebookPath={README_NOTEBOOK}
|
|
51
|
+
expandCodeCells={false}
|
|
52
|
+
hideEmbeddingIcons={true}
|
|
53
|
+
/>
|
|
54
|
+
</Grid>
|
|
55
|
+
</Grid>
|
|
114
56
|
);
|
|
115
57
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { createContext, useContext, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export interface PackageContextProps {
|
|
4
|
+
server?: string;
|
|
5
|
+
projectName: string;
|
|
6
|
+
packageName: string;
|
|
7
|
+
versionId?: string;
|
|
8
|
+
accessToken?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const PackageContext = createContext<PackageContextProps | undefined>(
|
|
12
|
+
undefined,
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
interface PackageProviderProps extends PackageContextProps {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Provider for the Package context.
|
|
20
|
+
// This context is used to pass the package information to the components
|
|
21
|
+
// that need it.
|
|
22
|
+
// The package information is passed to the components via the usePackage hook.
|
|
23
|
+
export const PackageProvider = ({
|
|
24
|
+
server,
|
|
25
|
+
projectName,
|
|
26
|
+
packageName,
|
|
27
|
+
versionId,
|
|
28
|
+
accessToken,
|
|
29
|
+
children,
|
|
30
|
+
}: PackageProviderProps) => {
|
|
31
|
+
return (
|
|
32
|
+
<PackageContext.Provider
|
|
33
|
+
value={{ server, projectName, packageName, versionId, accessToken }}
|
|
34
|
+
>
|
|
35
|
+
{children}
|
|
36
|
+
</PackageContext.Provider>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export function usePackage() {
|
|
41
|
+
const context = useContext(PackageContext);
|
|
42
|
+
if (!context) {
|
|
43
|
+
throw new Error("usePackage must be used within a PackageProvider");
|
|
44
|
+
}
|
|
45
|
+
return context;
|
|
46
|
+
}
|
|
@@ -11,29 +11,18 @@ import {
|
|
|
11
11
|
Typography,
|
|
12
12
|
} from "@mui/material";
|
|
13
13
|
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
14
|
-
import axios from "axios";
|
|
15
14
|
import { Configuration, SchedulesApi } from "../../client";
|
|
16
15
|
import { StyledCard, StyledCardContent } from "../styles";
|
|
16
|
+
import { usePackage } from "./PackageProvider";
|
|
17
|
+
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
17
18
|
|
|
18
|
-
axios.defaults.baseURL = "http://localhost:4000";
|
|
19
19
|
const schedulesApi = new SchedulesApi(new Configuration());
|
|
20
20
|
const queryClient = new QueryClient();
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
server
|
|
24
|
-
|
|
25
|
-
packageName: string;
|
|
26
|
-
versionId?: string;
|
|
27
|
-
accessToken: string;
|
|
28
|
-
}
|
|
22
|
+
export default function Schedules() {
|
|
23
|
+
const { server, projectName, packageName, versionId, accessToken } =
|
|
24
|
+
usePackage();
|
|
29
25
|
|
|
30
|
-
export default function Package({
|
|
31
|
-
server,
|
|
32
|
-
projectName,
|
|
33
|
-
packageName,
|
|
34
|
-
versionId,
|
|
35
|
-
accessToken,
|
|
36
|
-
}: PackageProps) {
|
|
37
26
|
const { data, isError, isLoading, error } = useQuery(
|
|
38
27
|
{
|
|
39
28
|
queryKey: ["schedules", server, projectName, packageName, versionId],
|
|
@@ -46,6 +35,7 @@ export default function Package({
|
|
|
46
35
|
},
|
|
47
36
|
}),
|
|
48
37
|
retry: false,
|
|
38
|
+
throwOnError: false,
|
|
49
39
|
},
|
|
50
40
|
queryClient,
|
|
51
41
|
);
|
|
@@ -60,9 +50,10 @@ export default function Package({
|
|
|
60
50
|
|
|
61
51
|
if (isError) {
|
|
62
52
|
return (
|
|
63
|
-
<
|
|
64
|
-
{
|
|
65
|
-
|
|
53
|
+
<ApiErrorDisplay
|
|
54
|
+
error={error}
|
|
55
|
+
context={`${projectName} > ${packageName} > Schedules`}
|
|
56
|
+
/>
|
|
66
57
|
);
|
|
67
58
|
}
|
|
68
59
|
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
export { default as Package } from "./Package";
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./PackageProvider";
|
|
3
|
+
// Backward compatibility
|
|
4
|
+
export {
|
|
5
|
+
PackageProvider as PublisherPackageProvider,
|
|
6
|
+
usePackage as usePublisherPackage,
|
|
7
|
+
} from "./PackageProvider";
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
import { Divider, Typography } from "@mui/material";
|
|
2
2
|
import { Configuration, ProjectsApi } from "../../client";
|
|
3
|
-
import axios from "axios";
|
|
4
3
|
import Markdown from "markdown-to-jsx";
|
|
5
4
|
import { StyledCard, StyledCardContent, StyledCardMedia } from "../styles";
|
|
6
5
|
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
6
|
+
import { useProject } from "./Project";
|
|
7
|
+
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
7
8
|
|
|
8
|
-
axios.defaults.baseURL = "http://localhost:4000";
|
|
9
9
|
const projectsApi = new ProjectsApi(new Configuration());
|
|
10
10
|
const queryClient = new QueryClient();
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
server
|
|
14
|
-
projectName: string;
|
|
15
|
-
accessToken?: string;
|
|
16
|
-
}
|
|
12
|
+
export default function About() {
|
|
13
|
+
const { server, projectName, accessToken } = useProject();
|
|
17
14
|
|
|
18
|
-
export default function About({
|
|
19
|
-
server,
|
|
20
|
-
projectName,
|
|
21
|
-
accessToken,
|
|
22
|
-
}: AboutProps) {
|
|
23
15
|
const { data, isSuccess, isError, error } = useQuery(
|
|
24
16
|
{
|
|
25
17
|
queryKey: ["about", server, projectName],
|
|
@@ -31,6 +23,8 @@ export default function About({
|
|
|
31
23
|
Authorization: accessToken && `Bearer ${accessToken}`,
|
|
32
24
|
},
|
|
33
25
|
}),
|
|
26
|
+
retry: false,
|
|
27
|
+
throwOnError: false,
|
|
34
28
|
},
|
|
35
29
|
queryClient,
|
|
36
30
|
);
|
|
@@ -56,9 +50,7 @@ export default function About({
|
|
|
56
50
|
</StyledCard>
|
|
57
51
|
)}
|
|
58
52
|
{isError && (
|
|
59
|
-
<
|
|
60
|
-
{error.message}
|
|
61
|
-
</Typography>
|
|
53
|
+
<ApiErrorDisplay error={error} context={`${projectName} > About`} />
|
|
62
54
|
)}
|
|
63
55
|
</>
|
|
64
56
|
);
|