@malloy-publisher/sdk 0.0.21 → 0.0.22

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/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.21",
4
+ "version": "0.0.22",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.es.js",
@@ -28,7 +28,7 @@ export default function Models({
28
28
  navigate,
29
29
  accessToken,
30
30
  }: ModelsProps) {
31
- const { data, isSuccess, isError, error } = useQuery(
31
+ const { data, isError, error, isLoading } = useQuery(
32
32
  {
33
33
  queryKey: ["models", server, projectName, packageName, versionId],
34
34
  queryFn: () =>
@@ -43,6 +43,20 @@ export default function Models({
43
43
  },
44
44
  queryClient,
45
45
  );
46
+ if (isError) {
47
+ return (
48
+ <Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
49
+ {`${projectName} > ${packageName} > ${versionId} - ${error.message}`}
50
+ </Typography>
51
+ );
52
+ }
53
+ if (isLoading) {
54
+ return (
55
+ <Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
56
+ Fetching Models...
57
+ </Typography>
58
+ );
59
+ }
46
60
 
47
61
  return (
48
62
  <StyledCard variant="outlined" sx={{ padding: "10px", width: "100%" }}>
@@ -58,12 +72,7 @@ export default function Models({
58
72
  overflowY: "auto",
59
73
  }}
60
74
  >
61
- {!isSuccess && !isError && (
62
- <Typography variant="body2" sx={{ p: "20px", m: "auto" }}>
63
- Fetching Models
64
- </Typography>
65
- )}
66
- {isSuccess && data.data.length > 0 && (
75
+ {data.data.length > 0 ? (
67
76
  <FileTreeView
68
77
  items={data.data.sort((a, b) => {
69
78
  return a.path.localeCompare(b.path);
@@ -71,10 +80,9 @@ export default function Models({
71
80
  defaultExpandedItems={DEFAULT_EXPANDED_FOLDERS}
72
81
  navigate={navigate}
73
82
  />
74
- )}
75
- {isError && (
83
+ ) : (
76
84
  <Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
77
- {`${projectName} > ${packageName} > ${versionId} - ${error.message}`}
85
+ No models found
78
86
  </Typography>
79
87
  )}
80
88
  </Box>
@@ -26,7 +26,7 @@ export default function Notebooks({
26
26
  navigate,
27
27
  accessToken,
28
28
  }: ModelsProps) {
29
- const { data, isSuccess, isError, error } = useQuery(
29
+ const { data, isLoading, isError, error } = useQuery(
30
30
  {
31
31
  queryKey: ["notebooks", server, projectName, packageName, versionId],
32
32
  queryFn: () =>
@@ -42,6 +42,22 @@ export default function Notebooks({
42
42
  queryClient,
43
43
  );
44
44
 
45
+ if (isError) {
46
+ return (
47
+ <Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
48
+ {`${projectName} > ${packageName} > ${versionId} - ${error.message}`}
49
+ </Typography>
50
+ );
51
+ }
52
+
53
+ if (isLoading) {
54
+ return (
55
+ <Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
56
+ Fetching Notebooks...
57
+ </Typography>
58
+ );
59
+ }
60
+
45
61
  return (
46
62
  <StyledCard variant="outlined" sx={{ padding: "10px", width: "100%" }}>
47
63
  <StyledCardContent>
@@ -56,12 +72,7 @@ export default function Notebooks({
56
72
  overflowY: "auto",
57
73
  }}
58
74
  >
59
- {!isSuccess && !isError && (
60
- <Typography variant="body2" sx={{ p: "20px", m: "auto" }}>
61
- Fetching Notebooks
62
- </Typography>
63
- )}
64
- {isSuccess && data.data.length > 0 && (
75
+ {data.data.length > 0 ? (
65
76
  <FileTreeView
66
77
  items={data.data.sort((a, b) => {
67
78
  return a.path.localeCompare(b.path);
@@ -69,10 +80,9 @@ export default function Notebooks({
69
80
  defaultExpandedItems={DEFAULT_EXPANDED_FOLDERS}
70
81
  navigate={navigate}
71
82
  />
72
- )}
73
- {isError && (
83
+ ) : (
74
84
  <Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
75
- {`${projectName} > ${packageName} > ${versionId} - ${error.message}`}
85
+ No notebooks found
76
86
  </Typography>
77
87
  )}
78
88
  </Box>