mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 01:18:42 +00:00
Fleet UI: Label errors (#7406)
This commit is contained in:
parent
87e42d4dd8
commit
aa3c70be92
3 changed files with 36 additions and 0 deletions
1
changes/issue-7196-label-name-description-char-limit
Normal file
1
changes/issue-7196-label-name-description-char-limit
Normal file
|
|
@ -0,0 +1 @@
|
|||
* Fleet UI: Show user errors for creating/editing a label with a label name or label description that is too long
|
||||
|
|
@ -984,6 +984,22 @@ const ManageHostsPage = ({
|
|||
setLabelValidator({
|
||||
name: "A label with this name already exists",
|
||||
});
|
||||
} else if (
|
||||
updateError.data.errors[0].reason.includes(
|
||||
"Data too long for column 'name'"
|
||||
)
|
||||
) {
|
||||
setLabelValidator({
|
||||
name: "Label name is too long",
|
||||
});
|
||||
} else if (
|
||||
updateError.data.errors[0].reason.includes(
|
||||
"Data too long for column 'description'"
|
||||
)
|
||||
) {
|
||||
setLabelValidator({
|
||||
description: "Label description is too long",
|
||||
});
|
||||
} else {
|
||||
renderFlash("error", "Could not create label. Please try again.");
|
||||
}
|
||||
|
|
@ -1011,6 +1027,22 @@ const ManageHostsPage = ({
|
|||
setLabelValidator({
|
||||
name: "A label with this name already exists",
|
||||
});
|
||||
} else if (
|
||||
updateError.data.errors[0].reason.includes(
|
||||
"Data too long for column 'name'"
|
||||
)
|
||||
) {
|
||||
setLabelValidator({
|
||||
name: "Label name is too long",
|
||||
});
|
||||
} else if (
|
||||
updateError.data.errors[0].reason.includes(
|
||||
"Data too long for column 'description'"
|
||||
)
|
||||
) {
|
||||
setLabelValidator({
|
||||
description: "Label description is too long",
|
||||
});
|
||||
} else {
|
||||
renderFlash("error", "Could not create label. Please try again.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ const LabelForm = ({
|
|||
const [description, setDescription] = useState<string>(
|
||||
selectedLabel?.description || ""
|
||||
);
|
||||
const [descriptionError, setDescriptionError] = useState<string>("");
|
||||
const [query, setQuery] = useState<string>(selectedLabel?.query || "");
|
||||
const [queryError, setQueryError] = useState<string>("");
|
||||
const [platform, setPlatform] = useState<string>(
|
||||
|
|
@ -88,6 +89,7 @@ const LabelForm = ({
|
|||
|
||||
useEffect(() => {
|
||||
setNameError(backendValidators.name);
|
||||
setDescriptionError(backendValidators.description);
|
||||
}, [backendValidators]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -206,6 +208,7 @@ const LabelForm = ({
|
|||
placeholder="Label name"
|
||||
/>
|
||||
<InputField
|
||||
error={descriptionError}
|
||||
name="description"
|
||||
onChange={onDescriptionChange}
|
||||
value={description}
|
||||
|
|
|
|||
Loading…
Reference in a new issue