Skip to content

Commit

Permalink
UI - Support software status filter for 'No teams' on the hosts page (#…
Browse files Browse the repository at this point in the history
…22143)

## #22136 


![ezgif-4-00c412809f](https://github.com/user-attachments/assets/5c22cc43-8182-4769-b0b3-4d34fa427488)

- [x] Changes file added for user-visible changes in `changes/`
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Jacob Shandling <[email protected]>
  • Loading branch information
jacobshandling and Jacob Shandling authored Sep 17, 2024
1 parent 8575535 commit b93d262
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions changes/22136-software-status-no-teams-hosts-page
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Support the software status filter for 'No teams' on the hosts page
23 changes: 12 additions & 11 deletions frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import {
isValidSoftwareAggregateStatus,
SoftwareAggregateStatus,
} from "interfaces/software";
import { ITeam } from "interfaces/team";
import { API_ALL_TEAMS_ID, ITeam } from "interfaces/team";
import { IEmptyTableProps } from "interfaces/empty_table";
import {
DiskEncryptionStatus,
Expand Down Expand Up @@ -169,9 +169,9 @@ const ManageHostsPage = ({
includeAllTeams: true,
includeNoTeam: true,
overrideParamsOnTeamChange: {
// remove the software status filter when selecting all teams
// TODO - update if supporting 'No teams' for this filter
[HOSTS_QUERY_PARAMS.SOFTWARE_STATUS]: (newTeamId?: number) => !newTeamId,
// remove the software status filter when selecting All teams
[HOSTS_QUERY_PARAMS.SOFTWARE_STATUS]: (newTeamId?: number) =>
newTeamId === API_ALL_TEAMS_ID,
},
});

Expand Down Expand Up @@ -738,7 +738,7 @@ const ManageHostsPage = ({
);
};

const handleSoftwareInstallStatausChange = (
const handleSoftwareInstallStatusChange = (
newStatus: SoftwareAggregateStatus
) => {
handleResetPageIndex();
Expand Down Expand Up @@ -848,9 +848,8 @@ const ManageHostsPage = ({
newQueryParams.software_version_id = softwareVersionId;
} else if (softwareTitleId) {
newQueryParams.software_title_id = softwareTitleId;
if (softwareStatus && teamIdForApi && teamIdForApi > 0) {
// software_status is only valid when software_title_id is present and a team (other than
// 'No team') is selected
if (softwareStatus && teamIdForApi !== API_ALL_TEAMS_ID) {
// software_status is only valid when software_title_id is present and a subset of hosts ('No team' or a team) is selected
newQueryParams[HOSTS_QUERY_PARAMS.SOFTWARE_STATUS] = softwareStatus;
}
} else if (mdmId) {
Expand Down Expand Up @@ -1379,7 +1378,10 @@ const ManageHostsPage = ({
teamId: teamIdForApi,
};

if (queryParams.team_id) {
if (
queryParams.team_id !== API_ALL_TEAMS_ID &&
queryParams.team_id !== ""
) {
options.teamId = queryParams.team_id;
}

Expand Down Expand Up @@ -1554,7 +1556,6 @@ const ManageHostsPage = ({
softwareId ||
softwareTitleId ||
softwareVersionId ||
softwareStatus ||
osName ||
osVersionId ||
osVersion ||
Expand Down Expand Up @@ -1726,7 +1727,7 @@ const ManageHostsPage = ({
}
onChangeMacSettingsFilter={handleMacSettingsStatusDropdownChange}
onChangeSoftwareInstallStatusFilter={
handleSoftwareInstallStatausChange
handleSoftwareInstallStatusChange
}
onClickEditLabel={onEditLabelClick}
onClickDeleteLabel={toggleDeleteLabelModal}
Expand Down
5 changes: 2 additions & 3 deletions frontend/utilities/url/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
MacSettingsStatusQueryParam,
} from "services/entities/hosts";
import { isValidSoftwareAggregateStatus } from "interfaces/software";
import { API_ALL_TEAMS_ID } from "interfaces/team";

export type QueryValues = string | number | boolean | undefined | null;
export type QueryParams = Record<string, QueryValues>;
Expand Down Expand Up @@ -121,9 +122,7 @@ export const reconcileSoftwareParams = ({
if (
isValidSoftwareAggregateStatus(softwareStatus) &&
softwareTitleId &&
// TODO - update if supporting 'No team' for software status filter
teamId &&
teamId > 0
teamId !== API_ALL_TEAMS_ID
) {
return {
software_title_id: softwareTitleId,
Expand Down

0 comments on commit b93d262

Please sign in to comment.