From 9f174b7cdc945f93d7b9f1c53b82af549bc7e4ca Mon Sep 17 00:00:00 2001 From: RachelElysia <71795832+RachelElysia@users.noreply.github.com> Date: Fri, 31 Oct 2025 10:55:16 -0400 Subject: [PATCH] Fleet UI: Host details activity script package uses correct modal (#35050) --- .../SoftwareScriptDetailsModal.tsx | 4 +- .../HostDetailsPage/HostDetailsPage.tsx | 55 +++++++++++++------ .../InstallStatusCell.tests.tsx | 8 +-- .../InstallStatusCell/InstallStatusCell.tsx | 4 +- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/frontend/components/ActivityDetails/InstallDetails/SoftwareScriptDetailsModal/SoftwareScriptDetailsModal.tsx b/frontend/components/ActivityDetails/InstallDetails/SoftwareScriptDetailsModal/SoftwareScriptDetailsModal.tsx index daf91fb1ab..048ecac75c 100644 --- a/frontend/components/ActivityDetails/InstallDetails/SoftwareScriptDetailsModal/SoftwareScriptDetailsModal.tsx +++ b/frontend/components/ActivityDetails/InstallDetails/SoftwareScriptDetailsModal/SoftwareScriptDetailsModal.tsx @@ -193,7 +193,7 @@ interface ISoftwareInstallDetailsProps { contactUrl?: string; // My Device Page only } -export const SoftwareInstallDetailsModal = ({ +export const SoftwareScriptDetailsModal = ({ details: detailsFromProps, onCancel, hostSoftware, @@ -341,4 +341,4 @@ export const SoftwareInstallDetailsModal = ({ ); }; -export default SoftwareInstallDetailsModal; +export default SoftwareScriptDetailsModal; diff --git a/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx b/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx index 2af298b237..8e551748b7 100644 --- a/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx +++ b/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx @@ -34,6 +34,7 @@ import { IQueryStats } from "interfaces/query_stats"; import { IHostSoftware, resolveUninstallStatus, + SCRIPT_PACKAGE_SOURCES, SoftwareInstallUninstallStatus, } from "interfaces/software"; import { ITeam } from "interfaces/team"; @@ -78,6 +79,7 @@ import { SoftwareInstallDetailsModal, IPackageInstallDetails, } from "components/ActivityDetails/InstallDetails/SoftwareInstallDetailsModal/SoftwareInstallDetailsModal"; +import { SoftwareScriptDetailsModal } from "components/ActivityDetails/InstallDetails/SoftwareScriptDetailsModal/SoftwareScriptDetailsModal"; import { SoftwareIpaInstallDetailsModal, ISoftwareIpaInstallDetails, @@ -226,6 +228,10 @@ const HostDetailsPage = ({ packageInstallDetails, setPackageInstallDetails, ] = useState(null); + const [ + scriptPackageDetails, + setScriptPackageDetails, + ] = useState(null); const [ ipaPackageInstallDetails, setIpaPackageInstallDetails, @@ -689,22 +695,33 @@ const HostDetailsPage = ({ setScriptExecutiontId(details?.script_execution_id || ""); break; case "installed_software": - details?.command_uuid - ? setIpaPackageInstallDetails({ - fleetInstallStatus: details?.status as SoftwareInstallUninstallStatus, - hostDisplayName: - host?.display_name || details?.host_display_name || "", - appName: details?.name || "", - commandUuid: details?.command_uuid, - }) - : setPackageInstallDetails({ - ...details, - // FIXME: It seems like the backend is not using the correct display name when it returns - // upcoming install activities. As a workaround, we'll prefer the display name from - // the host object if it's available. - host_display_name: - host?.display_name || details?.host_display_name || "", - }); + if (details?.command_uuid) { + setIpaPackageInstallDetails({ + fleetInstallStatus: details?.status as SoftwareInstallUninstallStatus, + hostDisplayName: + host?.display_name || details?.host_display_name || "", + appName: details?.name || "", + commandUuid: details?.command_uuid, + }); + } else if (SCRIPT_PACKAGE_SOURCES.includes(details?.source || "")) { + setScriptPackageDetails({ + ...details, + // FIXME: It seems like the backend is not using the correct display name when it returns + // upcoming install activities. As a workaround, we'll prefer the display name from + // the host object if it's available. + host_display_name: + host?.display_name || details?.host_display_name || "", + }); + } else { + setPackageInstallDetails({ + ...details, + // FIXME: It seems like the backend is not using the correct display name when it returns + // upcoming install activities. As a workaround, we'll prefer the display name from + // the host object if it's available. + host_display_name: + host?.display_name || details?.host_display_name || "", + }); + } break; case "uninstalled_software": setPackageUninstallDetails({ @@ -1416,6 +1433,12 @@ const HostDetailsPage = ({ onCancel={onCancelSoftwareInstallDetailsModal} /> )} + {scriptPackageDetails && ( + setScriptPackageDetails(null)} + /> + )} {ipaPackageInstallDetails && ( { }); }); - it("renders 'Failed run' for a payload-free package that failed to run", async () => { + it("renders 'Failed' for a payload-free package that failed to run", async () => { const { user } = renderWithSetup( { /> ); - expect( - screen.getByRole("button", { name: /Failed run/i }) - ).toBeInTheDocument(); + expect(screen.getByRole("button", { name: /Failed/i })).toBeInTheDocument(); expect(screen.getByTestId("error-icon")).toBeInTheDocument(); - await user.hover(screen.getByText(/Failed run/)); + await user.hover(screen.getByText(/Failed/)); await waitFor(() => { expect(screen.getByText(/The script failed to run/i)).toBeInTheDocument(); }); diff --git a/frontend/pages/hosts/details/cards/Software/InstallStatusCell/InstallStatusCell.tsx b/frontend/pages/hosts/details/cards/Software/InstallStatusCell/InstallStatusCell.tsx index f2d8f61bd9..23fdb61fbe 100644 --- a/frontend/pages/hosts/details/cards/Software/InstallStatusCell/InstallStatusCell.tsx +++ b/frontend/pages/hosts/details/cards/Software/InstallStatusCell/InstallStatusCell.tsx @@ -294,7 +294,7 @@ export const INSTALL_STATUS_DISPLAY_OPTIONS: Record< }, failed_script: { iconName: "error", - displayText: "Failed run", + displayText: "Failed", tooltip: ({ lastInstalledAt, isSelfService }) => ( <> The script failed to run @@ -501,7 +501,7 @@ const InstallStatusCell = ({ const displayStatusConfig = [ { condition: true, // Allow click even if no last install to see details modal - statuses: ["Failed run", "Run (pending)", "Ran"], + statuses: ["Failed", "Run (pending)", "Ran"], onClick: onClickScriptStatus, }, {