Skip to content

Commit

Permalink
add error message for host having mdm off to host details (#23080)
Browse files Browse the repository at this point in the history
relates to #22041

This adds an error message when refetching a host when mdm is not turned
on for it. This was accidentally added to the My Device page, so we are
moving it to the Host details page.
  • Loading branch information
ghernandez345 authored Oct 23, 2024
1 parent 010f80d commit c71237d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
12 changes: 1 addition & 11 deletions frontend/pages/hosts/details/DeviceUserPage/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import { getErrorReason } from "interfaces/errors";

const DEFAULT_ERROR_MESSAGE = "refetch error.";

// eslint-disable-next-line import/prefer-default-export
export const getErrorMessage = (e: unknown, hostName: string) => {
let errorMessage = getErrorReason(e, {
reasonIncludes: "Host does not have MDM turned on",
});

if (!errorMessage) {
errorMessage = DEFAULT_ERROR_MESSAGE;
}

return `Host "${hostName}" ${errorMessage}`;
return `Host "${hostName}" ${DEFAULT_ERROR_MESSAGE}`;
};
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ import {
import WipeModal from "./modals/WipeModal";
import SoftwareDetailsModal from "../cards/Software/SoftwareDetailsModal";
import { parseHostSoftwareQueryParams } from "../cards/Software/HostSoftware";
import { getErrorMessage } from "./helpers";

const baseClass = "host-details";

Expand Down Expand Up @@ -579,8 +580,7 @@ const HostDetailsPage = ({
}, 1000);
});
} catch (error) {
console.log(error);
renderFlash("error", `Host "${host.display_name}" refetch error`);
renderFlash("error", getErrorMessage(error, host.display_name));
setShowRefetchSpinner(false);
}
}
Expand Down
16 changes: 16 additions & 0 deletions frontend/pages/hosts/details/HostDetailsPage/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { getErrorReason } from "interfaces/errors";

const DEFAULT_ERROR_MESSAGE = "refetch error.";

// eslint-disable-next-line import/prefer-default-export
export const getErrorMessage = (e: unknown, hostName: string) => {
let errorMessage = getErrorReason(e, {
reasonIncludes: "Host does not have MDM turned on",
});

if (!errorMessage) {
errorMessage = DEFAULT_ERROR_MESSAGE;
}

return `Host "${hostName}" ${errorMessage}`;
};

0 comments on commit c71237d

Please sign in to comment.