-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathNoProjectGuard.tsx
More file actions
72 lines (64 loc) · 1.9 KB
/
NoProjectGuard.tsx
File metadata and controls
72 lines (64 loc) · 1.9 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { EuiEmptyPrompt, EuiSkeletonText } from "@elastic/eui";
import React, { useContext } from "react";
import { Outlet, useParams } from "react-router-dom";
import {
ProjectListContext,
useLoadProjectsList,
} from "../contexts/ProjectListContext";
import ProjectSelector from "./ProjectSelector";
const NoProjectGuard = () => {
const { projectName } = useParams();
const { isLoading, isError, data } = useLoadProjectsList();
const projectListContext = useContext(ProjectListContext);
if (isLoading && !data) {
return <EuiSkeletonText lines={3} />;
}
if (isError) {
return (
<EuiEmptyPrompt
iconType="alert"
color="danger"
title={<h2>Error Loading Project List</h2>}
body={
projectListContext?.isCustom ? (
<p>
Unable to fetch project list. Check the promise provided to Feast
UI in <code>projectListPromise</code>.
</p>
) : (
<p>
Unable to find
<code>projects-list.json</code>. Check that you have a project
list file defined.
</p>
)
}
/>
);
}
const currentProject = data?.projects.find((project) => {
return project.id === projectName;
});
if (currentProject === undefined) {
return (
<EuiEmptyPrompt
iconType="alert"
color="danger"
title={<h2>Error Loading Project</h2>}
body={
<React.Fragment>
<p>
There is no project with id <strong>{projectName}</strong> in{" "}
<code>projects-list.json</code>. Check that you have the correct
project id.
</p>
<p>You can also select one of the project in the following list:</p>
<ProjectSelector />
</React.Fragment>
}
/>
);
}
return <Outlet />;
};
export default NoProjectGuard;