-
-
Notifications
You must be signed in to change notification settings - Fork 486
/
Copy pathPluginsContainer.jsx
163 lines (155 loc) · 4.11 KB
/
PluginsContainer.jsx
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import React, { Suspense } from "react";
import { AiOutlineApi } from "react-icons/ai";
import { TiFlowChildren, TiBook } from "react-icons/ti";
import { IoIosEye } from "react-icons/io";
import { MdInput } from "react-icons/md";
import { PiGraphFill } from "react-icons/pi";
import { BsFillPlusCircleFill } from "react-icons/bs";
import { useLocation } from "react-router-dom";
import { Button, Col } from "reactstrap";
import { RouterTabs, FallBackLoading } from "@certego/certego-ui";
import { useGuideContext } from "../../contexts/GuideContext";
import { PluginsTypes } from "../../constants/pluginConst";
import { PluginConfigModal } from "./PluginConfigModal";
const Analyzers = React.lazy(() => import("./tables/Analyzers"));
const Connectors = React.lazy(() => import("./tables/Connectors"));
const Pivots = React.lazy(() => import("./tables/Pivots"));
const Visualizers = React.lazy(() => import("./tables/Visualizers"));
const Ingestors = React.lazy(() => import("./tables/Ingestors"));
const Playbooks = React.lazy(() => import("./tables/Playbooks"));
const routes = [
{
key: "plugins-analyzers",
location: "analyzers",
Title: () => (
<span id="Analyzers">
<AiOutlineApi />
Analyzers
</span>
),
Component: () => (
<Suspense fallback={<FallBackLoading />}>
<Analyzers />
</Suspense>
),
},
{
key: "plugins-connectors",
location: "connectors",
Title: () => (
<span id="Connectors">
<TiFlowChildren />
Connectors
</span>
),
Component: () => (
<Suspense fallback={<FallBackLoading />}>
<Connectors />
</Suspense>
),
},
{
key: "plugins-pivots",
location: "pivots",
Title: () => (
<span id="Pivots">
<PiGraphFill />
Pivots
</span>
),
Component: () => (
<Suspense fallback={<FallBackLoading />}>
<Pivots />
</Suspense>
),
},
{
key: "plugins-visualizers",
location: "visualizers",
Title: () => (
<span>
<IoIosEye />
Visualizers
</span>
),
Component: () => (
<Suspense fallback={<FallBackLoading />}>
<Visualizers />
</Suspense>
),
},
{
key: "plugins-ingestors",
location: "ingestors",
Title: () => (
<span>
<MdInput />
Ingestors
</span>
),
Component: () => (
<Suspense fallback={<FallBackLoading />}>
<Ingestors />
</Suspense>
),
},
{
key: "plugins-playbooks",
location: "playbooks",
Title: () => (
<span>
<TiBook />
Playbooks
</span>
),
Component: () => (
<Suspense fallback={<FallBackLoading />}>
<Playbooks />
</Suspense>
),
},
];
export default function PluginsContainer() {
console.debug("PluginsContainer rendered!");
const location = useLocation();
const pluginsPage = location?.pathname?.split("/")[2]?.slice(0, -1);
const enableCreateButton = [
PluginsTypes.ANALYZER,
PluginsTypes.PIVOT,
PluginsTypes.PLAYBOOK,
].includes(pluginsPage);
const [showModalCreate, setShowModalCreate] = React.useState(false);
const { guideState, setGuideState } = useGuideContext();
React.useEffect(() => {
if (guideState.tourActive) {
setTimeout(() => {
setGuideState({ run: true, stepIndex: 1 });
}, 200);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const createButton = (
<Col className="d-flex justify-content-end">
{enableCreateButton && (
<Button
id="createbutton"
className="d-flex align-items-center"
size="sm"
color="darker"
onClick={() => setShowModalCreate(true)}
>
<BsFillPlusCircleFill />
Create {pluginsPage}
</Button>
)}
{showModalCreate && (
<PluginConfigModal
pluginType={pluginsPage}
toggle={setShowModalCreate}
isOpen={showModalCreate}
/>
)}
</Col>
);
return <RouterTabs routes={routes} extraNavComponent={createButton} />;
}