show correct install error messages for VPP software (#20732)

relates to #20710, #20709

a quick fix to show the correct install software error messages.
includes:

1. error message for no available VPP app licenses
2. Error when Vpp app is deleted and user tried to install
This commit is contained in:
Gabriel Hernandez
2024-07-26 15:42:45 +01:00
committed by GitHub
parent 07f6ed162c
commit 6abb854543
@@ -18,6 +18,15 @@ const createVPPTokenExpiredMessage = () => (
</>
);
// determines if we want to show the API message as is to the user.
const showAPIMessage = (message: string) => {
return (
message.includes("MDM is turned off") ||
message.includes("No available licenses") ||
message.includes("Software title is not available for install")
);
};
// eslint-disable-next-line import/prefer-default-export
export const getErrorMessage = (e: unknown) => {
const reason = upperFirst(trimEnd(getErrorReason(e), "."));
@@ -27,8 +36,8 @@ export const getErrorMessage = (e: unknown) => {
} else if (reason.includes("can be installed only on")) {
return createOnlyInstallableOnMacOSMessage(reason);
} else if (reason.includes("VPP token expired")) {
createVPPTokenExpiredMessage();
} else if (reason.includes("MDM is turned off")) {
return createVPPTokenExpiredMessage();
} else if (showAPIMessage(reason)) {
return reason;
}