From 03ddd18758e027e144701c0bea4db8dbac83d5db Mon Sep 17 00:00:00 2001 From: RachelElysia <71795832+RachelElysia@users.noreply.github.com> Date: Wed, 29 Oct 2025 16:04:44 -0400 Subject: [PATCH] Fleet UI: Hide install modals' details button if no details to display (#34954) --- .../SoftwareInstallDetailsModal.tests.tsx | 16 ++++------- .../SoftwareInstallDetailsModal.tsx | 27 +++++++++++-------- .../SoftwareIpaInstallDetailsModal.tsx | 5 ++++ .../SoftwareScriptDetailsModal.tsx | 26 ++++++++++-------- .../SoftwareUninstallDetailsModal.tsx | 7 ++++- .../VppInstallDetailsModal.tsx | 5 ++++ 6 files changed, 52 insertions(+), 34 deletions(-) diff --git a/frontend/components/ActivityDetails/InstallDetails/SoftwareInstallDetailsModal/SoftwareInstallDetailsModal.tests.tsx b/frontend/components/ActivityDetails/InstallDetails/SoftwareInstallDetailsModal/SoftwareInstallDetailsModal.tests.tsx index 889ec19ace..3daa56de3a 100644 --- a/frontend/components/ActivityDetails/InstallDetails/SoftwareInstallDetailsModal/SoftwareInstallDetailsModal.tests.tsx +++ b/frontend/components/ActivityDetails/InstallDetails/SoftwareInstallDetailsModal/SoftwareInstallDetailsModal.tests.tsx @@ -247,10 +247,10 @@ describe("SoftwareInstallDetailsModal", () => { expect(screen.getByText("Post-install success")).toBeInTheDocument(); }); - it("does not render output textareas if script outputs are empty", async () => { + it("does not render details button if details (script outputs) are empty", async () => { mockServer.use(getSoftwareInstallHandlerNoOutputs); const renderWithServer = createCustomRenderer({ withBackendMock: true }); - const { user } = renderWithServer( + renderWithServer( { /> ); - const detailsBtn = await screen.findByRole("button", { - name: /Details/i, - }); - await user.click(detailsBtn); - expect( - screen.queryByText(/Install script output:/i) - ).not.toBeInTheDocument(); - expect( - screen.queryByText(/Post-install script output:/i) + screen.queryByRole("button", { + name: /Details/i, + }) ).not.toBeInTheDocument(); }); diff --git a/frontend/components/ActivityDetails/InstallDetails/SoftwareInstallDetailsModal/SoftwareInstallDetailsModal.tsx b/frontend/components/ActivityDetails/InstallDetails/SoftwareInstallDetailsModal/SoftwareInstallDetailsModal.tsx index bf489c8edc..e0361f23f6 100644 --- a/frontend/components/ActivityDetails/InstallDetails/SoftwareInstallDetailsModal/SoftwareInstallDetailsModal.tsx +++ b/frontend/components/ActivityDetails/InstallDetails/SoftwareInstallDetailsModal/SoftwareInstallDetailsModal.tsx @@ -270,15 +270,23 @@ export const SoftwareInstallDetailsModal = ({ }, ]; + // Only show details button if there's details to display + const showDetailsButton = + (!!swInstallResult?.post_install_script_output || + !!swInstallResult?.output) && + swInstallResult?.status !== "pending_install"; + return ( <> - + {showDetailsButton && ( + + )} {showInstallDetails && outputs.map( ({ label, value }) => @@ -364,10 +372,7 @@ export const SoftwareInstallDetailsModal = ({ /> {hostSoftware && !excludeVersions && renderInventoryVersionsSection()} - - {swInstallResult?.status !== "pending_install" && - isInstalledByFleet && - renderInstallDetailsSection()} + {isInstalledByFleet && renderInstallDetailsSection()} ); }; diff --git a/frontend/components/ActivityDetails/InstallDetails/SoftwareIpaInstallDetailsModal/SoftwareIpaInstallDetailsModal.tsx b/frontend/components/ActivityDetails/InstallDetails/SoftwareIpaInstallDetailsModal/SoftwareIpaInstallDetailsModal.tsx index 47caab94ed..553792930f 100644 --- a/frontend/components/ActivityDetails/InstallDetails/SoftwareIpaInstallDetailsModal/SoftwareIpaInstallDetailsModal.tsx +++ b/frontend/components/ActivityDetails/InstallDetails/SoftwareIpaInstallDetailsModal/SoftwareIpaInstallDetailsModal.tsx @@ -317,6 +317,11 @@ export const SoftwareIpaInstallDetailsModal = ({ }; const renderInstallDetailsSection = () => { + // Hide section if there's no details to display + if (!swInstallResult?.result && !swInstallResult?.payload) { + return null; + } + return ( <> { - if (swInstallResult?.status !== "pending_install") { - return ( - <> + // Only show details button if there's details to display + const showDetailsButton = + swInstallResult?.status !== "pending_install" && swInstallResult?.output; + + return ( + <> + {showDetailsButton && ( - {showInstallDetails && swInstallResult?.output && ( - - )} - - ); - } + )} + {showInstallDetails && swInstallResult?.output && ( + + )} + + ); }; const hostDisplayname = diff --git a/frontend/components/ActivityDetails/InstallDetails/SoftwareUninstallDetailsModal/SoftwareUninstallDetailsModal.tsx b/frontend/components/ActivityDetails/InstallDetails/SoftwareUninstallDetailsModal/SoftwareUninstallDetailsModal.tsx index 52573dc33b..be2bc81a33 100644 --- a/frontend/components/ActivityDetails/InstallDetails/SoftwareUninstallDetailsModal/SoftwareUninstallDetailsModal.tsx +++ b/frontend/components/ActivityDetails/InstallDetails/SoftwareUninstallDetailsModal/SoftwareUninstallDetailsModal.tsx @@ -223,6 +223,11 @@ const SoftwareUninstallDetailsModal = ({ return ; } + // Only show details button if there's details to display + const showDetailsButton = + (!!uninstallResult?.script_contents || !!uninstallResult?.output) && + uninstallStatus !== "pending_uninstall"; + return (
- {uninstallStatus !== "pending_uninstall" && ( + {showDetailsButton && ( { + // Hide section if there's no details to display + if (!vppCommandResult?.result && !vppCommandResult?.payload) { + return null; + } + return ( <>