Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 | import { FormControl, FormControlLabel, Radio, RadioGroup, Typography, } from "@mui/material"; import Button from "components/Button"; import { useTranslation } from "i18n"; import { AUTH, GLOBAL } from "i18n/namespaces"; import { ActivenessProbeResponse } from "proto/jail_pb"; import React, { useState } from "react"; import { service } from "service"; import { theme } from "theme"; interface ActivenessProbeSectionProps { updateJailed: () => void; className?: string; } export default function ActivenessProbeSection({ updateJailed, className, }: ActivenessProbeSectionProps) { const { t } = useTranslation([AUTH, GLOBAL]); const [isSelected, setIsSelected] = useState<boolean | undefined>(undefined); const [isLoading, setIsLoading] = useState(false); const handleSave = async () => { setIsLoading(true); const info = await service.jail.respondToActivenessProbe( isSelected ? ActivenessProbeResponse.ACTIVENESS_PROBE_RESPONSE_STILL_ACTIVE : ActivenessProbeResponse.ACTIVENESS_PROBE_RESPONSE_NO_LONGER_ACTIVE, ); Iif (!info.isJailed) { updateJailed(); } setIsLoading(false); }; return ( <div className={className}> <Typography variant="h2" id="still-hosting"> {t("auth:jail.activeness_probe.title")} </Typography> <Typography variant="body1"> {t("auth:jail.activeness_probe.description")} </Typography> <FormControl variant="standard" component="fieldset"> <RadioGroup value={isSelected} onChange={(e, val) => setIsSelected(val === "true")} > <FormControlLabel value={true} control={<Radio />} label={t("auth:jail.activeness_probe.still_hosting")} /> <FormControlLabel value={false} control={<Radio />} label={t("auth:jail.activeness_probe.not_hosting")} /> </RadioGroup> </FormControl> <Typography variant="body2" gutterBottom sx={{ marginTop: theme.spacing(2) }} > {t("auth:jail.activeness_probe.note")} </Typography> <Button loading={isLoading} onClick={handleSave} disabled={isSelected === undefined} sx={{ marginTop: theme.spacing(2) }} > {t("global:save")} </Button> </div> ); } |