Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ export const getConditionalSelectHeaderCheckboxProps = ({
checkIfRowIsSelectable,
}: GetConditionalSelectHeaderCheckboxProps) => {
// Define if the checkbox should show as checked or indeterminate
const checkIfAllSelectableRowsSelected = (rows: Row<any>[]) =>
rows.filter(checkIfRowIsSelectable).every((row) => row.isSelected);
const checkIfAllSelectableRowsSelected = (rows: Row<any>[]) => {
const selectableRows = rows.filter(checkIfRowIsSelectable);
return (
selectableRows.length > 0 && selectableRows.every((row) => row.isSelected)
);
Comment on lines +18 to +20
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably an existing bug; every returns true for empty arrays

};
const allSelectableRowsSelected = checkIfAllSelectableRowsSelected(
headerProps.rows
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,21 @@ const PoliciesTable = ({

const searchable = !(policiesList?.length === 0 && searchQuery === "");

const isPrimoMode = config?.partnerships?.enable_primo || false;
const viewingTeamPolicies =
currentTeam?.id !== undefined &&
currentTeam?.id !== null &&
currentTeam?.id !== APP_CONTEXT_ALL_TEAMS_ID;

// Hide the selection column if the current page has no selectable rows
// (e.g., all rows are inherited policies that can't be selected)
const pageHasSelectableRows =
!viewingTeamPolicies ||
isPrimoMode ||
policiesList.some((p) => p.team_id !== null);

const hasPermissionAndPoliciesToDelete =
canAddOrDeletePolicies && hasPoliciesToDelete;
canAddOrDeletePolicies && hasPoliciesToDelete && pageHasSelectableRows;
Comment on lines +98 to +106
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have this pattern in the Reports page so I decided to follow that.


return (
<div className={baseClass}>
Expand Down
18 changes: 15 additions & 3 deletions frontend/pages/queries/ManageQueriesPage/ManageQueriesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,21 @@ const ManageQueriesPage = ({
) : (
<TooltipWrapper
tipContent={
isAnyTeamSelected && (queriesResponse?.count ?? 0) > 0
? 'To manage automations add a report to this fleet. For inherited reports select "All fleets".'
: "To manage automations add a report."
<div
className={`${baseClass}__manage-automations-tooltip`}
>
{isAnyTeamSelected &&
(queriesResponse?.count ?? 0) > 0 ? (
<>
To manage automations add a report to this fleet.
<br />
For inherited reports select &ldquo;All
fleets&rdquo;.
</>
) : (
"To manage automations add a report."
)}
</div>
}
underline={false}
position="top"
Expand Down
4 changes: 4 additions & 0 deletions frontend/pages/queries/ManageQueriesPage/_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
}
}

&__manage-automations-tooltip {
text-align: center;
}

&__action-button-container {
display: flex;
gap: $pad-small;
Expand Down
Loading