Add NDES error message (#28960)

For #28948 adds LearnMoreLink for NDES error messages as well. Also
refactored the code that creates the errors slightly to genericize in
case we need to add more links in the future

- [x] A detailed QA plan exists on the associated ticket (if it isn't
there, work with the product group's QA engineer to add it)
- [ ] Manual QA for all new/changed functionality
- [x] For unreleased bug fixes in a release candidate, confirmed that
the fix is not expected to adversely impact load test results or alerted
the release DRI if additional load testing is needed.
This commit is contained in:
Jordan Montgomery 2025-05-08 12:19:08 -04:00 committed by GitHub
parent 7a66e37ec4
commit 844723bfbc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,12 +37,12 @@ const generateUnsupportedVariableErrMsg = (errMsg: string) => {
: DEFAULT_ERROR_MESSAGE;
};
const generateCAVarsErrMsg = (errMsg: string) => {
const generateLearnMoreErrMsg = (errMsg: string, learnMoreUrl: string) => {
return (
<>
Couldn&apos;t add. {errMsg}{" "}
<CustomLink
url="https://fleetdm.com/learn-more-about/certificate-authorities"
url={learnMoreUrl}
text="Learn more"
variant="flash-message-link"
newTab
@ -51,20 +51,6 @@ const generateCAVarsErrMsg = (errMsg: string) => {
);
};
const generateCustomSCEPProfileErrMsg = (errMsg: string) => {
return (
<span>
Couldn&apos;t add. {errMsg}{" "}
<CustomLink
url="https://fleetdm.com/learn-more-about/custom-scep-configuration-profile"
text="Learn more"
variant="flash-message-link"
newTab
/>
</span>
);
};
/** We want to add some additional messageing to some of the error messages so
* we add them in this function. Otherwise, we'll just return the error message from the
* API.
@ -129,7 +115,10 @@ export const getErrorMessage = (err: AxiosResponse<IApiError>) => {
"can't be used if variables for SCEP URL and Challenge are not specified"
)
) {
return generateCAVarsErrMsg(apiReason);
return generateLearnMoreErrMsg(
apiReason,
"https://fleetdm.com/learn-more-about/certificate-authorities"
);
}
if (
@ -137,7 +126,21 @@ export const getErrorMessage = (err: AxiosResponse<IApiError>) => {
"SCEP profile for custom SCEP certificate authority requires"
)
) {
return generateCustomSCEPProfileErrMsg(apiReason);
return generateLearnMoreErrMsg(
apiReason,
"https://fleetdm.com/learn-more-about/custom-scep-configuration-profile"
);
}
if (
apiReason.includes(
"SCEP profile for NDES certificate authority requires: $FLEET_VAR_NDES_SCEP_CHALLENGE"
)
) {
return generateLearnMoreErrMsg(
apiReason,
"https://fleetdm.com/learn-more-about/ndes-scep-configuration-profile"
);
}
return `Couldn't add. ${apiReason}` || DEFAULT_ERROR_MESSAGE;