Merge pull request #3088 from bluewave-labs/fix-traslator-error
fix translator error and add format
This commit is contained in:
7 files changed
+168
-143
No files matched your search
@@ -7,81 +7,84 @@ import { useTranslation } from "react-i18next";
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
const DiskSelection = ({ availableDisks, selectedDisks, onChange }) => {
|
const DiskSelection = ({ availableDisks, selectedDisks, onChange }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const handleDiskChange = (event, mountpoint) => {
|
const handleDiskChange = (event, mountpoint) => {
|
||||||
const isChecked = event.target.checked;
|
const isChecked = event.target.checked;
|
||||||
let newSelectedDisks = [];
|
let newSelectedDisks = [];
|
||||||
|
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
newSelectedDisks = [...selectedDisks, mountpoint];
|
newSelectedDisks = [...selectedDisks, mountpoint];
|
||||||
} else {
|
} else {
|
||||||
newSelectedDisks = selectedDisks.filter((disk) => disk !== mountpoint);
|
newSelectedDisks = selectedDisks.filter((disk) => disk !== mountpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(newSelectedDisks);
|
onChange(newSelectedDisks);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConfigBox>
|
<ConfigBox>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h2" variant="h2">
|
<Typography
|
||||||
{t("v1.infrastructure.disk_selection_title")}
|
component="h2"
|
||||||
</Typography>
|
variant="h2"
|
||||||
<Typography component="p">
|
>
|
||||||
{t("v1.infrastructure.disk_selection_description")}
|
{t("v1.infrastructure.disk_selection_title")}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
<Typography component="p">
|
||||||
|
{t("v1.infrastructure.disk_selection_description")}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
|
||||||
<Stack gap={theme.spacing(6)}>
|
<Stack gap={theme.spacing(6)}>
|
||||||
{(!availableDisks || availableDisks.length === 0) ? (
|
{!availableDisks || availableDisks.length === 0 ? (
|
||||||
<Typography
|
<Typography
|
||||||
variant="body2"
|
variant="body2"
|
||||||
sx={{ fontStyle: 'italic', opacity: 0.8 }}
|
sx={{ fontStyle: "italic", opacity: 0.8 }}
|
||||||
>
|
>
|
||||||
{t("v1.infrastructure.disk_selection_info")}
|
{t("v1.infrastructure.disk_selection_info")}
|
||||||
</Typography>
|
</Typography>
|
||||||
) : (
|
) : (
|
||||||
availableDisks.map((disk) => {
|
availableDisks.map((disk) => {
|
||||||
const identifier = disk.mountpoint || disk.device;
|
const identifier = disk.mountpoint || disk.device;
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
key={identifier}
|
key={identifier}
|
||||||
direction={{ sm: "column", md: "row" }}
|
direction={{ sm: "column", md: "row" }}
|
||||||
spacing={theme.spacing(2)}
|
spacing={theme.spacing(2)}
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
}}
|
}}
|
||||||
justifyContent="flex-start"
|
justifyContent="flex-start"
|
||||||
>
|
>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id={`disk-${identifier}`}
|
id={`disk-${identifier}`}
|
||||||
name={identifier}
|
name={identifier}
|
||||||
label={identifier}
|
label={identifier}
|
||||||
isChecked={selectedDisks.includes(identifier)}
|
isChecked={selectedDisks.includes(identifier)}
|
||||||
onChange={(e) => handleDiskChange(e, identifier)}
|
onChange={(e) => handleDiskChange(e, identifier)}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
)
|
);
|
||||||
})
|
})
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
DiskSelection.propTypes = {
|
DiskSelection.propTypes = {
|
||||||
availableDisks: PropTypes.arrayOf(
|
availableDisks: PropTypes.arrayOf(
|
||||||
PropTypes.shape({
|
PropTypes.shape({
|
||||||
mountpoint: PropTypes.string.isRequired,
|
mountpoint: PropTypes.string.isRequired,
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
selectedDisks: PropTypes.arrayOf(PropTypes.string).isRequired,
|
selectedDisks: PropTypes.arrayOf(PropTypes.string).isRequired,
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default DiskSelection;
|
export default DiskSelection;
|
||||||
@@ -75,9 +75,9 @@ const CreateInfrastructureMonitor = () => {
|
|||||||
...(isCreate
|
...(isCreate
|
||||||
? [{ name: "Create", path: "/infrastructure/create" }]
|
? [{ name: "Create", path: "/infrastructure/create" }]
|
||||||
: [
|
: [
|
||||||
{ name: "Details", path: `/infrastructure/${monitorId}` },
|
{ name: "Details", path: `/infrastructure/${monitorId}` },
|
||||||
{ name: "Configure", path: `/infrastructure/configure/${monitorId}` },
|
{ name: "Configure", path: `/infrastructure/configure/${monitorId}` },
|
||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
// Populate form fields if editing
|
// Populate form fields if editing
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -161,8 +161,6 @@ const CreateInfrastructureMonitor = () => {
|
|||||||
isPausing ||
|
isPausing ||
|
||||||
notificationsAreLoading;
|
notificationsAreLoading;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className="create-infrastructure-monitor">
|
<Box className="create-infrastructure-monitor">
|
||||||
<Breadcrumbs list={CRUMBS} />
|
<Breadcrumbs list={CRUMBS} />
|
||||||
|
|||||||
@@ -6,8 +6,18 @@ import { Stack, Typography, Box } from "@mui/material";
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
const Gauge = ({ value, heading, metricOne, valueOne, metricTwo, valueTwo,
|
const Gauge = ({
|
||||||
metricThree, valueThree, metricFour, valueFour }) => {
|
value,
|
||||||
|
heading,
|
||||||
|
metricOne,
|
||||||
|
valueOne,
|
||||||
|
metricTwo,
|
||||||
|
valueTwo,
|
||||||
|
metricThree,
|
||||||
|
valueThree,
|
||||||
|
metricFour,
|
||||||
|
valueFour,
|
||||||
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
const valueStyle = {
|
const valueStyle = {
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import { useTheme } from "@emotion/react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const Gauges = ({ isLoading = false, monitor }) => {
|
const Gauges = ({ isLoading = false, monitor }) => {
|
||||||
const { decimalToPercentage, formatBytes, formatDeviceName, formatMountpoint } = useHardwareUtils();
|
const { decimalToPercentage, formatBytes, formatDeviceName, formatMountpoint } =
|
||||||
|
useHardwareUtils();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
|||||||
@@ -121,10 +121,10 @@ const useHardwareUtils = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const formatDeviceName = (device) => {
|
const formatDeviceName = (device) => {
|
||||||
const deviceStr = String(device || '');
|
const deviceStr = String(device || "");
|
||||||
|
|
||||||
// Extract the last part of the path (after last '/')
|
// Extract the last part of the path (after last '/')
|
||||||
const parts = deviceStr.split('/');
|
const parts = deviceStr.split("/");
|
||||||
const lastPart = parts[parts.length - 1];
|
const lastPart = parts[parts.length - 1];
|
||||||
|
|
||||||
// If there's more than one part, show with "..." prefix
|
// If there's more than one part, show with "..." prefix
|
||||||
@@ -132,17 +132,21 @@ const useHardwareUtils = () => {
|
|||||||
|
|
||||||
// Always show tooltip with full device path
|
// Always show tooltip with full device path
|
||||||
return (
|
return (
|
||||||
<Tooltip title={deviceStr} arrow placement="top">
|
<Tooltip
|
||||||
|
title={deviceStr}
|
||||||
|
arrow
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
sx={{
|
sx={{
|
||||||
cursor: 'default',
|
cursor: "default",
|
||||||
display: 'inline-block',
|
display: "inline-block",
|
||||||
userSelect: 'none',
|
userSelect: "none",
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: "nowrap",
|
||||||
overflow: 'hidden',
|
overflow: "hidden",
|
||||||
textOverflow: 'ellipsis',
|
textOverflow: "ellipsis",
|
||||||
maxWidth: '100%'
|
maxWidth: "100%",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{displayText}
|
{displayText}
|
||||||
@@ -152,19 +156,23 @@ const useHardwareUtils = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const formatMountpoint = (mountpoint) => {
|
const formatMountpoint = (mountpoint) => {
|
||||||
const mountpointStr = String(mountpoint || '');
|
const mountpointStr = String(mountpoint || "");
|
||||||
|
|
||||||
if (!mountpointStr) {
|
if (!mountpointStr) {
|
||||||
return (
|
return (
|
||||||
<Tooltip title="No mountpoint available" arrow placement="top">
|
<Tooltip
|
||||||
|
title="No mountpoint available"
|
||||||
|
arrow
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
sx={{
|
sx={{
|
||||||
cursor: 'default',
|
cursor: "default",
|
||||||
display: 'inline-block',
|
display: "inline-block",
|
||||||
userSelect: 'none',
|
userSelect: "none",
|
||||||
color: 'text.secondary',
|
color: "text.secondary",
|
||||||
fontStyle: 'italic'
|
fontStyle: "italic",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
N/A
|
N/A
|
||||||
@@ -174,7 +182,7 @@ const useHardwareUtils = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract the last part of the path (after last '/')
|
// Extract the last part of the path (after last '/')
|
||||||
const parts = mountpointStr.split('/');
|
const parts = mountpointStr.split("/");
|
||||||
const lastPart = parts[parts.length - 1];
|
const lastPart = parts[parts.length - 1];
|
||||||
|
|
||||||
// If there's more than one part, show with "..." prefix
|
// If there's more than one part, show with "..." prefix
|
||||||
@@ -182,24 +190,28 @@ const useHardwareUtils = () => {
|
|||||||
|
|
||||||
// Always show tooltip with full mountpoint path
|
// Always show tooltip with full mountpoint path
|
||||||
return (
|
return (
|
||||||
<Tooltip title={mountpointStr} arrow placement="top">
|
<Tooltip
|
||||||
|
title={mountpointStr}
|
||||||
|
arrow
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
sx={{
|
sx={{
|
||||||
cursor: 'default',
|
cursor: "default",
|
||||||
display: 'inline-block',
|
display: "inline-block",
|
||||||
userSelect: 'none',
|
userSelect: "none",
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: "nowrap",
|
||||||
overflow: 'hidden',
|
overflow: "hidden",
|
||||||
textOverflow: 'ellipsis',
|
textOverflow: "ellipsis",
|
||||||
maxWidth: '100%'
|
maxWidth: "100%",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{displayText}
|
{displayText}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a decimal value to a percentage
|
* Converts a decimal value to a percentage
|
||||||
|
|||||||
@@ -144,44 +144,44 @@ const monitorValidation = joi.object({
|
|||||||
// Regex from https://gist.github.com/dperini/729294
|
// Regex from https://gist.github.com/dperini/729294
|
||||||
var urlRegex = new RegExp(
|
var urlRegex = new RegExp(
|
||||||
"^" +
|
"^" +
|
||||||
// protocol identifier (optional)
|
// protocol identifier (optional)
|
||||||
// short syntax // still required
|
// short syntax // still required
|
||||||
"(?:(?:https?|ftp):\\/\\/)?" +
|
"(?:(?:https?|ftp):\\/\\/)?" +
|
||||||
// user:pass BasicAuth (optional)
|
// user:pass BasicAuth (optional)
|
||||||
"(?:" +
|
"(?:" +
|
||||||
// IP address dotted notation octets
|
// IP address dotted notation octets
|
||||||
// excludes loopback network 0.0.0.0
|
// excludes loopback network 0.0.0.0
|
||||||
// excludes reserved space >= 224.0.0.0
|
// excludes reserved space >= 224.0.0.0
|
||||||
// excludes network & broadcast addresses
|
// excludes network & broadcast addresses
|
||||||
// (first & last IP address of each class)
|
// (first & last IP address of each class)
|
||||||
"(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
|
"(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
|
||||||
"(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
|
"(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
|
||||||
"(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
|
"(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
|
||||||
"|" +
|
"|" +
|
||||||
// host & domain names, may end with dot
|
// host & domain names, may end with dot
|
||||||
// can be replaced by a shortest alternative
|
// can be replaced by a shortest alternative
|
||||||
// (?![-_])(?:[-\\w\\u00a1-\\uffff]{0,63}[^-_]\\.)+
|
// (?![-_])(?:[-\\w\\u00a1-\\uffff]{0,63}[^-_]\\.)+
|
||||||
"(?:" +
|
"(?:" +
|
||||||
// Single hostname without dots (like localhost)
|
// Single hostname without dots (like localhost)
|
||||||
"[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62}" +
|
"[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62}" +
|
||||||
"|" +
|
"|" +
|
||||||
// Domain with dots
|
// Domain with dots
|
||||||
"(?:" +
|
"(?:" +
|
||||||
"(?:" +
|
"(?:" +
|
||||||
"[a-z0-9\\u00a1-\\uffff]" +
|
"[a-z0-9\\u00a1-\\uffff]" +
|
||||||
"[a-z0-9\\u00a1-\\uffff_-]{0,62}" +
|
"[a-z0-9\\u00a1-\\uffff_-]{0,62}" +
|
||||||
")?" +
|
")?" +
|
||||||
"[a-z0-9\\u00a1-\\uffff]\\." +
|
"[a-z0-9\\u00a1-\\uffff]\\." +
|
||||||
")+" +
|
")+" +
|
||||||
// TLD identifier name, may end with dot
|
// TLD identifier name, may end with dot
|
||||||
"(?:[a-z\\u00a1-\\uffff]{2,}\\.?)" +
|
"(?:[a-z\\u00a1-\\uffff]{2,}\\.?)" +
|
||||||
")" +
|
")" +
|
||||||
")" +
|
")" +
|
||||||
// port number (optional)
|
// port number (optional)
|
||||||
"(?::\\d{2,5})?" +
|
"(?::\\d{2,5})?" +
|
||||||
// resource path (optional)
|
// resource path (optional)
|
||||||
"(?:[/?#]\\S*)?" +
|
"(?:[/?#]\\S*)?" +
|
||||||
"$",
|
"$",
|
||||||
"i"
|
"i"
|
||||||
);
|
);
|
||||||
if (!urlRegex.test(value)) {
|
if (!urlRegex.test(value)) {
|
||||||
|
|||||||
@@ -1144,10 +1144,11 @@
|
|||||||
"selectInterface": "Select Interface",
|
"selectInterface": "Select Interface",
|
||||||
"v1": {
|
"v1": {
|
||||||
"infrastructure": {
|
"infrastructure": {
|
||||||
"disk_selection_title": "Disk Selection",
|
"disk_selection_title": "Disk Selection",
|
||||||
"disk_selection_info": "No disk detected for the moment.",
|
"disk_selection_info": "No disk detected for the moment.",
|
||||||
"disk_selection_description": "Select the specific disks you want to monitor."
|
"disk_selection_description": "Select the specific disks you want to monitor."
|
||||||
}
|
}
|
||||||
|
},
|
||||||
"incidentsPage": {
|
"incidentsPage": {
|
||||||
"title": "Incidents",
|
"title": "Incidents",
|
||||||
"description": "Manage incidents for your monitors. You can resolve incidents here.",
|
"description": "Manage incidents for your monitors. You can resolve incidents here.",
|
||||||
|
|||||||
Reference in new issue
Block a user