Skip to content

Commit 341ba58

Browse files
Kautilya Tripathiyolossn
andcommitted
prometheus: Add InstallPrometheusBanner component
This adds a new component for metrics charts banner if prometheus is not installed. Co-authored-by: Santhosh Nagaraj <[email protected]> Signed-off-by: Kautilya Tripathi <[email protected]>
1 parent 9862973 commit 341ba58

File tree

1 file changed

+39
-60
lines changed

1 file changed

+39
-60
lines changed

prometheus/src/common.tsx

Lines changed: 39 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,43 @@ const useStyles = makeStyles(theme => ({
3030
},
3131
}));
3232

33+
function InstallPrometheusBanner() {
34+
const classes = useStyles();
35+
const pluginSettings = usePluginSettings();
36+
37+
return (
38+
<Grid
39+
container
40+
spacing={2}
41+
direction="column"
42+
justifyContent="center"
43+
alignItems="center"
44+
className={classes.skeletonBox}
45+
>
46+
<Grid item>
47+
<Typography variant="h5">Install Prometheus for accessing metrics charts</Typography>
48+
</Grid>
49+
<Grid item>
50+
<Typography>
51+
<Link href={learnMoreLink} target="_blank">
52+
Learn more about enabling advanced charts.
53+
</Link>
54+
</Typography>
55+
</Grid>
56+
<Grid item>
57+
<Button
58+
className={classes.dismissButton}
59+
size="small"
60+
variant="contained"
61+
onClick={() => pluginSettings.setIsVisible(false)}
62+
>
63+
Dismiss
64+
</Button>
65+
</Grid>
66+
</Grid>
67+
)
68+
}
69+
3370
export function GenericMetricsChart(props: {
3471
cpuQuery: string;
3572
memoryQuery: string;
@@ -45,7 +82,6 @@ export function GenericMetricsChart(props: {
4582
INSTALLED,
4683
}
4784

48-
const classes = useStyles();
4985
const pluginSettings = usePluginSettings();
5086
const [chartVariant, setChartVariant] = useState<string>('cpu');
5187
const [refresh, setRefresh] = useState<boolean>(true);
@@ -160,35 +196,7 @@ export function GenericMetricsChart(props: {
160196
<Alert severity="warning">Error fetching prometheus Info</Alert>
161197
</Box>
162198
) : (
163-
<Grid
164-
container
165-
spacing={2}
166-
direction="column"
167-
justifyContent="center"
168-
alignItems="center"
169-
className={classes.skeletonBox}
170-
>
171-
<Grid item>
172-
<Typography variant="h5">Install Prometheus for accessing metrics charts</Typography>
173-
</Grid>
174-
<Grid item>
175-
<Typography>
176-
<Link href={learnMoreLink} target="_blank">
177-
Learn more about enabling advanced charts.
178-
</Link>
179-
</Typography>
180-
</Grid>
181-
<Grid item>
182-
<Button
183-
className={classes.dismissButton}
184-
size="small"
185-
variant="contained"
186-
onClick={() => pluginSettings.setIsVisible(false)}
187-
>
188-
Dismiss
189-
</Button>
190-
</Grid>
191-
</Grid>
199+
<InstallPrometheusBanner />
192200
)}
193201
</SectionBox>
194202
);
@@ -205,7 +213,6 @@ export function DiskMetricsChart(props: {
205213
INSTALLED,
206214
}
207215

208-
const classes = useStyles();
209216
const pluginSettings = usePluginSettings();
210217
const [refresh, setRefresh] = useState<boolean>(true);
211218

@@ -281,35 +288,7 @@ export function DiskMetricsChart(props: {
281288
<Alert severity="warning">Error fetching prometheus Info</Alert>
282289
</Box>
283290
) : (
284-
<Grid
285-
container
286-
spacing={2}
287-
direction="column"
288-
justifyContent="center"
289-
alignItems="center"
290-
className={classes.skeletonBox}
291-
>
292-
<Grid item>
293-
<Typography variant="h5">Install Prometheus for accessing metrics charts</Typography>
294-
</Grid>
295-
<Grid item>
296-
<Typography>
297-
<Link href={learnMoreLink} target="_blank">
298-
Learn more about enabling advanced charts.
299-
</Link>
300-
</Typography>
301-
</Grid>
302-
<Grid item>
303-
<Button
304-
className={classes.dismissButton}
305-
size="small"
306-
variant="contained"
307-
onClick={() => pluginSettings.setIsVisible(false)}
308-
>
309-
Dismiss
310-
</Button>
311-
</Grid>
312-
</Grid>
291+
<InstallPrometheusBanner />
313292
)}
314293
</SectionBox>
315294
);

0 commit comments

Comments
 (0)