Merge pull request #3905 from eralpozcan/feat/maintenance-window-monitor-tags
feat(maintenance): show monitor tags in maintenance selector
This commit is contained in:
1 file changed
+24
-1
@@ -1,7 +1,8 @@
|
|||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
import { logger } from "@/Utils/logger";
|
import { logger } from "@/Utils/logger";
|
||||||
import { SPACING, LAYOUT } from "@/Utils/Theme/constants";
|
import { SPACING, LAYOUT } from "@/Utils/Theme/constants";
|
||||||
import { BasePage, ConfigBox } from "@/Components/design-elements";
|
import { BasePage, ColoredLabel, ConfigBox } from "@/Components/design-elements";
|
||||||
import { Button } from "@/Components/inputs";
|
import { Button } from "@/Components/inputs";
|
||||||
|
|
||||||
import { useTheme } from "@mui/material";
|
import { useTheme } from "@mui/material";
|
||||||
@@ -15,6 +16,7 @@ import { useGet, usePost, usePatch } from "@/Hooks/UseApi";
|
|||||||
import { mutate } from "swr";
|
import { mutate } from "swr";
|
||||||
import { useParams, useNavigate } from "react-router-dom";
|
import { useParams, useNavigate } from "react-router-dom";
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
import type { Monitor } from "@/Types/Monitor";
|
||||||
|
import type { Tag } from "@/Types/Tag";
|
||||||
import { useForm, FormProvider } from "react-hook-form";
|
import { useForm, FormProvider } from "react-hook-form";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod/dist/zod.js";
|
import { zodResolver } from "@hookform/resolvers/zod/dist/zod.js";
|
||||||
@@ -41,6 +43,7 @@ const CreateMaintenanceWindowPage = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const { data: monitors } = useGet<Monitor[]>("/monitors/team");
|
const { data: monitors } = useGet<Monitor[]>("/monitors/team");
|
||||||
|
const { data: tags } = useGet<Tag[]>("/tags/team");
|
||||||
|
|
||||||
const { post, loading: isPosting } = usePost();
|
const { post, loading: isPosting } = usePost();
|
||||||
const { patch, loading: isPatching } = usePatch();
|
const { patch, loading: isPatching } = usePatch();
|
||||||
@@ -203,6 +206,26 @@ const CreateMaintenanceWindowPage = () => {
|
|||||||
"pages.maintenanceWindow.form.startTime.monitors.option.addMonitors.label"
|
"pages.maintenanceWindow.form.startTime.monitors.option.addMonitors.label"
|
||||||
)}
|
)}
|
||||||
options={monitors ?? []}
|
options={monitors ?? []}
|
||||||
|
renderOptionContent={(monitor) => (
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
gap={theme.spacing(2)}
|
||||||
|
flexWrap="wrap"
|
||||||
|
>
|
||||||
|
<Typography>{monitor.name}</Typography>
|
||||||
|
{monitor.tags.map((tagId) => {
|
||||||
|
const tag = tags?.find(({ id }) => id === tagId);
|
||||||
|
return tag ? (
|
||||||
|
<ColoredLabel
|
||||||
|
key={tag.id}
|
||||||
|
text={tag.name}
|
||||||
|
color={tag.color}
|
||||||
|
/>
|
||||||
|
) : null;
|
||||||
|
})}
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in new issue
Block a user