{isPremiumTier ? renderPermissions() : renderGlobalRoleForm()}
{isPremiumTier && (
diff --git a/frontend/pages/hosts/details/cards/Labels/_styles.scss b/frontend/pages/hosts/details/cards/Labels/_styles.scss
index d9fc4969ac..2848d18409 100644
--- a/frontend/pages/hosts/details/cards/Labels/_styles.scss
+++ b/frontend/pages/hosts/details/cards/Labels/_styles.scss
@@ -13,6 +13,8 @@
&__list-item {
margin-bottom: 0;
+ max-width: 100%;
+ min-width: 0;
}
.button,
@@ -22,4 +24,8 @@
font-weight: $regular;
}
}
+
+ .button.host-labels-card__list-button {
+ max-width: 300px;
+ }
}
diff --git a/frontend/pages/labels/NewLabelPage/NewLabelPage.tsx b/frontend/pages/labels/NewLabelPage/NewLabelPage.tsx
index 2c146ddcdb..9ac7ae3b2c 100644
--- a/frontend/pages/labels/NewLabelPage/NewLabelPage.tsx
+++ b/frontend/pages/labels/NewLabelPage/NewLabelPage.tsx
@@ -14,7 +14,10 @@ import customHostVitalsAPI, {
IListCustomHostVitalsApiParams,
} from "services/entities/custom_host_vitals";
-import { DEFAULT_USE_QUERY_OPTIONS } from "utilities/constants";
+import {
+ DEFAULT_USE_QUERY_OPTIONS,
+ MAX_ENTITY_CHAR_LENGTH,
+} from "utilities/constants";
// TODO - move this table config near here once expanded this logic to encompass editing and
// therefore not longer needed anywhere else
import { generateTableHeaders } from "pages/labels/components/ManualLabelForm/LabelHostTargetTableConfig";
@@ -299,7 +302,6 @@ const NewLabelPage = ({
// start from previous errors
if (prev.name) next.name = prev.name;
- if (prev.description) next.description = prev.description;
if (prev.labelQuery) next.labelQuery = prev.labelQuery;
if (prev.criteria) next.criteria = prev.criteria;
@@ -308,22 +310,13 @@ const NewLabelPage = ({
if (prev.name && fullValidation.name?.isValid) {
next.name = undefined;
}
- } else if (fieldName === "description") {
- if (prev.description && fullValidation.description?.isValid) {
- next.description = undefined;
- }
} else if (fieldName === "vitalValue") {
if (prev.criteria && fullValidation.criteria?.isValid) {
next.criteria = undefined;
}
}
- const fields = [
- next.name,
- next.description,
- next.labelQuery,
- next.criteria,
- ];
+ const fields = [next.name, next.labelQuery, next.criteria];
next.isValid = fields.every((f) => !f || f.isValid);
return next;
@@ -351,7 +344,6 @@ const NewLabelPage = ({
const next: INewLabelFormValidation = { ...prev, isValid: true };
if (prev.name) next.name = prev.name;
- if (prev.description) next.description = prev.description;
if (prev.labelQuery) next.labelQuery = prev.labelQuery;
if (prev.criteria && fullValidation.criteria?.isValid) {
next.criteria = undefined;
@@ -359,12 +351,7 @@ const NewLabelPage = ({
next.criteria = prev.criteria;
}
- const fields = [
- next.name,
- next.description,
- next.labelQuery,
- next.criteria,
- ];
+ const fields = [next.name, next.labelQuery, next.criteria];
next.isValid = fields.every((f) => !f || f.isValid);
return next;
@@ -395,19 +382,12 @@ const NewLabelPage = ({
const next: INewLabelFormValidation = { ...prev, isValid: true };
if (prev.name) next.name = fullValidation.name ?? prev.name;
- if (prev.description)
- next.description = fullValidation.description ?? prev.description;
if (prev.labelQuery)
next.labelQuery = fullValidation.labelQuery ?? prev.labelQuery;
if (prev.criteria)
next.criteria = fullValidation.criteria ?? prev.criteria;
- const fields = [
- next.name,
- next.description,
- next.labelQuery,
- next.criteria,
- ];
+ const fields = [next.name, next.labelQuery, next.criteria];
next.isValid = fields.every((f) => !f || f.isValid);
return next;
@@ -464,7 +444,6 @@ const NewLabelPage = ({
const next: INewLabelFormValidation = { ...prev, isValid: true };
if (prev.name) next.name = prev.name;
- if (prev.description) next.description = prev.description;
if (prev.labelQuery) next.labelQuery = prev.labelQuery;
if (prev.criteria) next.criteria = prev.criteria;
@@ -472,12 +451,7 @@ const NewLabelPage = ({
next.labelQuery = undefined;
}
- const fields = [
- next.name,
- next.description,
- next.labelQuery,
- next.criteria,
- ];
+ const fields = [next.name, next.labelQuery, next.criteria];
next.isValid = fields.every((f) => !f || f.isValid);
return next;
@@ -646,9 +620,9 @@ const NewLabelPage = ({
label="Name"
placeholder="Label name"
parseTarget
+ inputOptions={{ maxLength: MAX_ENTITY_CHAR_LENGTH }}
/>
Type
diff --git a/frontend/pages/labels/NewLabelPage/helpers.ts b/frontend/pages/labels/NewLabelPage/helpers.ts
index 29e2ef7147..38cf6fb773 100644
--- a/frontend/pages/labels/NewLabelPage/helpers.ts
+++ b/frontend/pages/labels/NewLabelPage/helpers.ts
@@ -49,20 +49,15 @@ export const getCriterionHelpText = (vital: LabelHostVitalsCriterion) => {
export interface INewLabelFormValidation {
isValid: boolean;
name?: { isValid: boolean; message?: string };
- description?: { isValid: boolean; message?: string };
labelQuery?: { isValid: boolean; message?: string };
criteria?: { isValid: boolean; message?: string };
}
-// Matches DB
-const MAX_LABEL_NAME_LENGTH = 255;
-const MAX_DESCRIPTION_LENGTH = 255;
-
type IMessageFunc = (formData: INewLabelFormData) => string;
type IValidationMessage = string | IMessageFunc;
type IFormValidationKey = keyof Pick<
INewLabelFormData,
- "name" | "description" | "labelQuery" | "vitalValue"
+ "name" | "labelQuery" | "vitalValue"
>;
interface IValidation {
@@ -87,22 +82,6 @@ const FORM_VALIDATIONS: IFormValidations = {
isValid: (formData) => formData.name.trim().length > 0,
message: "Label name must be present",
},
- {
- name: "notTooLong",
- isValid: (formData) => formData.name.length <= MAX_LABEL_NAME_LENGTH,
- message: `Name may not exceed ${MAX_LABEL_NAME_LENGTH} characters`,
- },
- ],
- },
- description: {
- validations: [
- {
- name: "notTooLong",
- isValid: (formData) =>
- !formData.description ||
- formData.description.length <= MAX_DESCRIPTION_LENGTH,
- message: `Description may not exceed ${MAX_DESCRIPTION_LENGTH} characters`,
- },
],
},
labelQuery: {
@@ -174,9 +153,6 @@ export const validateNewLabelFormData = (
case "name":
formValidation.name = { isValid: true };
break;
- case "description":
- formValidation.description = { isValid: true };
- break;
case "labelQuery":
formValidation.labelQuery = { isValid: true };
break;
@@ -194,9 +170,6 @@ export const validateNewLabelFormData = (
case "name":
formValidation.name = { isValid: false, message };
break;
- case "description":
- formValidation.description = { isValid: false, message };
- break;
case "labelQuery":
formValidation.labelQuery = { isValid: false, message };
break;
diff --git a/frontend/pages/labels/components/LabelForm/LabelForm.tsx b/frontend/pages/labels/components/LabelForm/LabelForm.tsx
index 241133d08f..0ca3d6a0c5 100644
--- a/frontend/pages/labels/components/LabelForm/LabelForm.tsx
+++ b/frontend/pages/labels/components/LabelForm/LabelForm.tsx
@@ -1,5 +1,7 @@
import React, { ReactNode, useState } from "react";
+import { MAX_ENTITY_CHAR_LENGTH } from "utilities/constants";
+
import InputField from "components/forms/fields/InputField";
import Button from "components/buttons/Button";
import GitOpsModeTooltipWrapper from "components/GitOpsModeTooltipWrapper";
@@ -88,7 +90,6 @@ const LabelForm = ({
// start from previous errors
if (prev.name) next.name = prev.name;
- if (prev.description) next.description = prev.description;
// ONLY CLEAR existing error on this field if it is now valid.
// Do NOT set a new error if there wasn't one before.
@@ -96,15 +97,10 @@ const LabelForm = ({
if (prev.name && fullValidation.name?.isValid) {
next.name = undefined; // clear existing name error
}
- } else if (fieldName === "description") {
- if (prev.description && fullValidation.description?.isValid) {
- next.description = undefined; // clear existing description error
- }
}
// recompute isValid from remaining errors
- const fields = [next.name, next.description];
- next.isValid = fields.every((f) => !f || f.isValid);
+ next.isValid = !next.name || next.name.isValid;
return next;
});
@@ -150,9 +146,9 @@ const LabelForm = ({
inputClassName={`${baseClass}__label-title`}
label="Name"
placeholder="Label name"
+ inputOptions={{ maxLength: MAX_ENTITY_CHAR_LENGTH }}
/>
{immutableFields.length > 0 ? (
diff --git a/frontend/pages/labels/components/LabelForm/helpers.ts b/frontend/pages/labels/components/LabelForm/helpers.ts
index 93d9f7d31f..9e4770b686 100644
--- a/frontend/pages/labels/components/LabelForm/helpers.ts
+++ b/frontend/pages/labels/components/LabelForm/helpers.ts
@@ -3,16 +3,11 @@ import { ILabelFormData } from "./LabelForm";
export interface ILabelFormValidation {
isValid: boolean;
name?: { isValid: boolean; message?: string };
- description?: { isValid: boolean; message?: string };
}
-// Matches length in DB
-const MAX_LABEL_NAME_LENGTH = 255;
-const MAX_LABEL_DESCRIPTION_LENGTH = 255;
-
type IMessageFunc = (formData: ILabelFormData) => string;
type IValidationMessage = string | IMessageFunc;
-type IFormValidationKey = keyof ILabelFormData;
+type IFormValidationKey = "name";
interface IValidation {
name: string;
@@ -36,22 +31,6 @@ const FORM_VALIDATIONS: IFormValidations = {
isValid: (formData) => formData.name.trim().length > 0,
message: "Label name must be present",
},
- {
- name: "notTooLong",
- isValid: (formData) => formData.name.length <= MAX_LABEL_NAME_LENGTH,
- message: `Name may not exceed ${MAX_LABEL_NAME_LENGTH} characters`,
- },
- ],
- },
- description: {
- validations: [
- {
- name: "notTooLong",
- isValid: (formData) =>
- !formData.description ||
- formData.description.length <= MAX_LABEL_DESCRIPTION_LENGTH,
- message: `Description may not exceed ${MAX_LABEL_DESCRIPTION_LENGTH} characters`,
- },
],
},
};
@@ -81,9 +60,6 @@ export const validateLabelFormData = (
case "name":
formValidation.name = { isValid: true };
break;
- case "description":
- formValidation.description = { isValid: true };
- break;
default: {
const _exhaustiveCheck: never = objKey;
break;
@@ -96,9 +72,6 @@ export const validateLabelFormData = (
case "name":
formValidation.name = { isValid: false, message };
break;
- case "description":
- formValidation.description = { isValid: false, message };
- break;
default: {
const _exhaustiveCheck: never = objKey;
break;
diff --git a/frontend/pages/policies/edit/components/PolicyForm/PolicyForm.tsx b/frontend/pages/policies/edit/components/PolicyForm/PolicyForm.tsx
index 07fd52d86a..1438b681b0 100644
--- a/frontend/pages/policies/edit/components/PolicyForm/PolicyForm.tsx
+++ b/frontend/pages/policies/edit/components/PolicyForm/PolicyForm.tsx
@@ -29,7 +29,10 @@ import {
POLICY_TARGET_EMPTY_STATE_DESCRIPTION,
} from "pages/policies/constants";
-import { LEARN_MORE_ABOUT_BASE_LINK } from "utilities/constants";
+import {
+ LEARN_MORE_ABOUT_BASE_LINK,
+ MAX_ENTITY_CHAR_LENGTH,
+} from "utilities/constants";
import SQLEditor from "components/SQLEditor";
import {
@@ -64,8 +67,6 @@ import SaveNewPolicyModal from "../SaveNewPolicyModal";
const baseClass = "policy-form";
-const NAME_MAX_LENGTH = 255;
-
interface IPolicyFormProps {
router: InjectedRouter;
teamIdForApi?: number;
@@ -520,7 +521,7 @@ const PolicyForm = ({
error={errors && errors.name}
onChange={(value: string) => setLastEditedQueryName(value)}
disabled={gitOpsModeEnabled}
- inputOptions={{ maxLength: NAME_MAX_LENGTH }}
+ inputOptions={{ maxLength: MAX_ENTITY_CHAR_LENGTH }}
/>
);
}
diff --git a/frontend/pages/policies/edit/components/SaveNewPolicyModal/SaveNewPolicyModal.tsx b/frontend/pages/policies/edit/components/SaveNewPolicyModal/SaveNewPolicyModal.tsx
index e3744f25d9..fd8148f3f5 100644
--- a/frontend/pages/policies/edit/components/SaveNewPolicyModal/SaveNewPolicyModal.tsx
+++ b/frontend/pages/policies/edit/components/SaveNewPolicyModal/SaveNewPolicyModal.tsx
@@ -20,6 +20,7 @@ import { IPolicy, IPolicyFormData } from "interfaces/policy";
import { CommaSeparatedPlatformString } from "interfaces/platform";
import { ITeamConfig } from "interfaces/team";
import useDeepEffect from "hooks/useDeepEffect";
+import { MAX_ENTITY_CHAR_LENGTH } from "utilities/constants";
import configAPI from "services/entities/config";
import teamPoliciesAPI from "services/entities/team_policies";
@@ -39,8 +40,6 @@ import PolicyAutomationsFields, {
import { usePolicyLabelTargets } from "pages/policies/hooks";
import { POLICY_TARGET_EMPTY_STATE_DESCRIPTION } from "pages/policies/constants";
-const NAME_MAX_LENGTH = 255;
-
export interface ISaveNewPolicyModalProps {
baseClass: string;
queryValue: string;
@@ -344,7 +343,7 @@ const SaveNewPolicyModal = ({
label="Name"
autofocus
disabled={disableForm}
- inputOptions={{ maxLength: NAME_MAX_LENGTH }}
+ inputOptions={{ maxLength: MAX_ENTITY_CHAR_LENGTH }}
/>
);
}
diff --git a/frontend/pages/queries/edit/components/SaveNewQueryModal/SaveNewQueryModal.tsx b/frontend/pages/queries/edit/components/SaveNewQueryModal/SaveNewQueryModal.tsx
index 692e163974..290180a5e9 100644
--- a/frontend/pages/queries/edit/components/SaveNewQueryModal/SaveNewQueryModal.tsx
+++ b/frontend/pages/queries/edit/components/SaveNewQueryModal/SaveNewQueryModal.tsx
@@ -18,6 +18,7 @@ import {
LOGGING_TYPE_OPTIONS,
MIN_OSQUERY_VERSION_OPTIONS,
DEFAULT_USE_QUERY_OPTIONS,
+ MAX_ENTITY_CHAR_LENGTH,
} from "utilities/constants";
import { CommaSeparatedPlatformString } from "interfaces/platform";
@@ -48,8 +49,6 @@ import DiscardDataOption from "../DiscardDataOption";
const baseClass = "save-query-modal";
-const NAME_MAX_LENGTH = 255;
-
export interface ISaveNewQueryModalProps {
queryValue: string;
apiTeamIdForQuery?: number; // query will be global if omitted
@@ -241,7 +240,7 @@ const SaveNewQueryModal = ({
inputClassName={`${baseClass}__name`}
label="Name"
autofocus
- inputOptions={{ maxLength: NAME_MAX_LENGTH }}
+ inputOptions={{ maxLength: MAX_ENTITY_CHAR_LENGTH }}
/>