-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathIndex.tsx
More file actions
54 lines (44 loc) · 1.52 KB
/
Index.tsx
File metadata and controls
54 lines (44 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React, { useContext } from "react";
import { EuiPageTemplate, EuiLoadingSpinner } from "@elastic/eui";
import { DatasetIcon } from "../../graphics/DatasetIcon";
import useLoadRegistry from "../../queries/useLoadRegistry";
import { useDocumentTitle } from "../../hooks/useDocumentTitle";
import RegistryPathContext from "../../contexts/RegistryPathContext";
import DatasetsListingTable from "./DatasetsListingTable";
import DatasetsIndexEmptyState from "./DatasetsIndexEmptyState";
const useLoadSavedDataSets = () => {
const registryUrl = useContext(RegistryPathContext);
const registryQuery = useLoadRegistry(registryUrl);
const data =
registryQuery.data === undefined
? undefined
: registryQuery.data.objects.savedDatasets;
return {
...registryQuery,
data,
};
};
const Index = () => {
const { isLoading, isSuccess, isError, data } = useLoadSavedDataSets();
useDocumentTitle(`Saved Datasets | Feast`);
return (
<EuiPageTemplate panelled>
<EuiPageTemplate.Header
restrictWidth
iconType={DatasetIcon}
pageTitle="Datasets"
/>
<EuiPageTemplate.Section>
{isLoading && (
<p>
<EuiLoadingSpinner size="m" /> Loading
</p>
)}
{isError && <p>We encountered an error while loading.</p>}
{isSuccess && data && <DatasetsListingTable datasets={data} />}
{isSuccess && !data && <DatasetsIndexEmptyState />}
</EuiPageTemplate.Section>
</EuiPageTemplate>
);
};
export default Index;