From 6abb854543fa9eda0a5a61caa42e7a991bde21f4 Mon Sep 17 00:00:00 2001 From: Gabriel Hernandez Date: Fri, 26 Jul 2024 15:42:45 +0100 Subject: [PATCH] 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 --- .../pages/hosts/details/cards/Software/helpers.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/pages/hosts/details/cards/Software/helpers.tsx b/frontend/pages/hosts/details/cards/Software/helpers.tsx index e251728bdf..2020a14870 100644 --- a/frontend/pages/hosts/details/cards/Software/helpers.tsx +++ b/frontend/pages/hosts/details/cards/Software/helpers.tsx @@ -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; }