From 5893b8186be95ce4e06063cb7aabb0a6c6bb555a Mon Sep 17 00:00:00 2001 From: jacobshandling <61553566+jacobshandling@users.noreply.github.com> Date: Tue, 23 Sep 2025 09:55:18 -0700 Subject: [PATCH] UI: Maintain header titles, remove "select all," "clear selection" options and selected item count from Select software table (#33301) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## For #33277 Screenshot 2025-09-22 at 4 26 20 PM - [x] QA'd all new/changed functionality manually --------- Co-authored-by: Jacob Shandling --- .../TableContainer/DataTable/DataTable.tsx | 86 ++++++++++--------- .../TableContainer/TableContainer.tsx | 4 + .../SelectSoftwareModal.tsx | 8 -- .../SelectSoftwareTable.tsx | 12 +-- .../SelectSoftwareTableConfig.tsx | 29 +------ 5 files changed, 54 insertions(+), 85 deletions(-) diff --git a/frontend/components/TableContainer/DataTable/DataTable.tsx b/frontend/components/TableContainer/DataTable/DataTable.tsx index eff1574683..ab6cb98936 100644 --- a/frontend/components/TableContainer/DataTable/DataTable.tsx +++ b/frontend/components/TableContainer/DataTable/DataTable.tsx @@ -80,6 +80,7 @@ interface IDataTableProps { renderPagination?: () => JSX.Element | null; setExportRows?: (rows: Row[]) => void; onClearSelection?: () => void; + suppressHeaderActions?: boolean; } interface IHeaderGroup extends HeaderGroup { @@ -126,6 +127,7 @@ const DataTable = ({ renderPagination, setExportRows, onClearSelection = noop, + suppressHeaderActions, }: IDataTableProps): JSX.Element => { // used to track the initial mount of the component. const isInitialRender = useRef(true); @@ -515,6 +517,47 @@ const DataTable = ({ "is-observer": isOnlyObserver, }); + const renderHeaderWithActions = () => ( + + + + {headerGroups[0].headers[0].render("Header")} + + +
+ {renderSelectedCount()} +
+ {secondarySelectActions && renderSecondarySelectActions()} +
+
+ {primarySelectAction && renderPrimarySelectAction()} +
+ {toggleAllPagesSelected && renderAreAllSelected()} + {shouldRenderToggleAllPages && ( + + )} + +
+ + + + ); + return (
{isLoading && ( @@ -524,46 +567,9 @@ const DataTable = ({ )}
- {Object.keys(selectedRowIds).length !== 0 && ( - - - - - - - )} + {!suppressHeaderActions && + Object.keys(selectedRowIds).length !== 0 && + renderHeaderWithActions()} {headerGroups.map((headerGroup) => ( diff --git a/frontend/components/TableContainer/TableContainer.tsx b/frontend/components/TableContainer/TableContainer.tsx index 6299070d8f..95e775977a 100644 --- a/frontend/components/TableContainer/TableContainer.tsx +++ b/frontend/components/TableContainer/TableContainer.tsx @@ -123,6 +123,8 @@ interface ITableContainerProps { hideFooter?: boolean; /** handler called when the `clear selection` button is called */ onClearSelection?: () => void; + /** don't show the Clear selection button and selected item count when items are selected */ + suppressHeaderActions?: boolean; } const baseClass = "table-container"; @@ -184,6 +186,7 @@ const TableContainer = ({ disableTableHeader, persistSelectedRows, onClearSelection = noop, + suppressHeaderActions, }: ITableContainerProps) => { const isControlledSearchQuery = controlledSearchQuery !== undefined; const [searchQuery, setSearchQuery] = useState(defaultSearchQuery); @@ -574,6 +577,7 @@ const TableContainer = ({ } setExportRows={setExportRows} onClearSelection={onClearSelection} + suppressHeaderActions={suppressHeaderActions} persistSelectedRows={persistSelectedRows} hideFooter={hideFooter} /> diff --git a/frontend/pages/ManageControlsPage/SetupExperience/cards/InstallSoftware/components/SelectSoftwareModal/SelectSoftwareModal.tsx b/frontend/pages/ManageControlsPage/SetupExperience/cards/InstallSoftware/components/SelectSoftwareModal/SelectSoftwareModal.tsx index ff63063ecd..8764bad593 100644 --- a/frontend/pages/ManageControlsPage/SetupExperience/cards/InstallSoftware/components/SelectSoftwareModal/SelectSoftwareModal.tsx +++ b/frontend/pages/ManageControlsPage/SetupExperience/cards/InstallSoftware/components/SelectSoftwareModal/SelectSoftwareModal.tsx @@ -76,13 +76,6 @@ const SelectSoftwareModal = ({ }); }, []); - const onChangeSelectAll = useCallback( - (selectAll: boolean) => { - setSelectedSoftwareIds(selectAll ? softwareTitles.map((s) => s.id) : []); - }, - [softwareTitles] - ); - return (
diff --git a/frontend/pages/ManageControlsPage/SetupExperience/cards/InstallSoftware/components/SelectSoftwareTable/SelectSoftwareTable.tsx b/frontend/pages/ManageControlsPage/SetupExperience/cards/InstallSoftware/components/SelectSoftwareTable/SelectSoftwareTable.tsx index bbe31b19d0..d629bbac9b 100644 --- a/frontend/pages/ManageControlsPage/SetupExperience/cards/InstallSoftware/components/SelectSoftwareTable/SelectSoftwareTable.tsx +++ b/frontend/pages/ManageControlsPage/SetupExperience/cards/InstallSoftware/components/SelectSoftwareTable/SelectSoftwareTable.tsx @@ -26,23 +26,17 @@ const generateSelectedRows = (softwareTitles: ISoftwareTitle[]) => { interface ISelectSoftwareTableProps { softwareTitles: ISoftwareTitle[]; onChangeSoftwareSelect: (select: boolean, id: number) => void; - onChangeSelectAll: (selectAll: boolean) => void; platform: SetupExperiencePlatform; } const SelectSoftwareTable = ({ softwareTitles, onChangeSoftwareSelect, - onChangeSelectAll, platform, }: ISelectSoftwareTableProps) => { const tableConfig = useMemo(() => { - return generateTableConfig( - platform, - onChangeSelectAll, - onChangeSoftwareSelect - ); - }, [onChangeSelectAll, onChangeSoftwareSelect, platform]); + return generateTableConfig(platform, onChangeSoftwareSelect); + }, [onChangeSoftwareSelect, platform]); const initialSelectedSoftwareRows = useMemo(() => { return generateSelectedRows(softwareTitles); @@ -78,7 +72,6 @@ const SelectSoftwareTable = ({ searchable searchQueryColumn="name" isClientSideFilter - onClearSelection={() => onChangeSelectAll(false)} renderTableHelpText={() => (

Software will be installed on{" "} @@ -87,6 +80,7 @@ const SelectSoftwareTable = ({ experience.

)} + suppressHeaderActions /> ); }; diff --git a/frontend/pages/ManageControlsPage/SetupExperience/cards/InstallSoftware/components/SelectSoftwareTable/SelectSoftwareTableConfig.tsx b/frontend/pages/ManageControlsPage/SetupExperience/cards/InstallSoftware/components/SelectSoftwareTable/SelectSoftwareTableConfig.tsx index ddaab3fc3c..6f25ade804 100644 --- a/frontend/pages/ManageControlsPage/SetupExperience/cards/InstallSoftware/components/SelectSoftwareTable/SelectSoftwareTableConfig.tsx +++ b/frontend/pages/ManageControlsPage/SetupExperience/cards/InstallSoftware/components/SelectSoftwareTable/SelectSoftwareTableConfig.tsx @@ -1,7 +1,7 @@ import React from "react"; import { CellProps, Column } from "react-table"; -import { IHeaderProps, IStringCellProps } from "interfaces/datatable_config"; +import { IStringCellProps } from "interfaces/datatable_config"; import { ISoftwareTitle, SoftwareSource } from "interfaces/software"; import TextCell from "components/TableContainer/DataTable/TextCell"; @@ -13,7 +13,6 @@ import { SetupExperiencePlatform } from "interfaces/platform"; import { DEFAULT_EMPTY_CELL_VALUE } from "utilities/constants"; type ISelectSoftwareTableConfig = Column; -type ITableHeaderProps = IHeaderProps; type ITableStringCellProps = IStringCellProps; type ISelectionCellProps = CellProps; @@ -32,38 +31,12 @@ const getSetupExperienceLinuxPackageCopy = (source: SoftwareSource) => { const generateTableConfig = ( platform: SetupExperiencePlatform, - onSelectAll: (selectAll: boolean) => void, onSelectSoftware: (select: boolean, id: number) => void ): ISelectSoftwareTableConfig[] => { const headerConfigs: ISelectSoftwareTableConfig[] = [ { id: "selection", disableSortBy: true, - Header: (cellProps: ITableHeaderProps) => { - const { - checked, - indeterminate, - } = cellProps.getToggleAllRowsSelectedProps(); - - const checkboxProps = { - value: checked, - indeterminate, - onChange: () => { - onSelectAll(!checked); - cellProps.toggleAllRowsSelected(); - }, - }; - return ( - ( - - )} - /> - ); - }, Cell: (cellProps: ISelectionCellProps) => { const { checked } = cellProps.row.getToggleRowSelectedProps(); const checkboxProps = {
- {headerGroups[0].headers[0].render("Header")} - -
- {renderSelectedCount()} -
- {secondarySelectActions && renderSecondarySelectActions()} -
-
- {primarySelectAction && renderPrimarySelectAction()} -
- {toggleAllPagesSelected && renderAreAllSelected()} - {shouldRenderToggleAllPages && ( - - )} - -
-