mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
#20385 See notes on that issue for API limitations (which is why Windows and macOS are the only platforms listed). Will move out of draft after adding the changes file and tests. # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Added/updated tests - [x] Manual QA for all new/changed functionality
98 lines
2 KiB
TypeScript
98 lines
2 KiB
TypeScript
/** software/os OS tab */
|
|
|
|
import React from "react";
|
|
import { useQuery } from "react-query";
|
|
import { InjectedRouter } from "react-router";
|
|
import {
|
|
IGetOSVersionsQueryKey,
|
|
IOSVersionsResponse,
|
|
getOSVersions,
|
|
} from "services/entities/operating_systems";
|
|
|
|
import TableDataError from "components/DataError";
|
|
import Spinner from "components/Spinner";
|
|
import { SelectedPlatform } from "interfaces/platform";
|
|
|
|
import SoftwareOSTable from "./SoftwareOSTable";
|
|
|
|
const baseClass = "software-os";
|
|
|
|
interface ISoftwareOSProps {
|
|
router: InjectedRouter;
|
|
isSoftwareEnabled: boolean;
|
|
perPage: number;
|
|
orderDirection: "asc" | "desc";
|
|
orderKey: string;
|
|
currentPage: number;
|
|
teamId?: number;
|
|
resetPageIndex: boolean;
|
|
platform: SelectedPlatform;
|
|
}
|
|
|
|
const SoftwareOS = ({
|
|
router,
|
|
isSoftwareEnabled,
|
|
perPage,
|
|
orderDirection,
|
|
orderKey,
|
|
currentPage,
|
|
teamId,
|
|
resetPageIndex,
|
|
platform,
|
|
}: ISoftwareOSProps) => {
|
|
const queryParams = {
|
|
page: currentPage,
|
|
per_page: perPage,
|
|
order_direction: orderDirection,
|
|
order_key: orderKey,
|
|
platform: platform === "all" ? undefined : platform,
|
|
teamId,
|
|
};
|
|
|
|
const { data, isFetching, isLoading, isError } = useQuery<
|
|
IOSVersionsResponse,
|
|
Error,
|
|
IOSVersionsResponse,
|
|
IGetOSVersionsQueryKey[]
|
|
>(
|
|
[
|
|
{
|
|
scope: "software-os",
|
|
...queryParams,
|
|
},
|
|
],
|
|
() => getOSVersions(queryParams),
|
|
{
|
|
keepPreviousData: true,
|
|
staleTime: 30000,
|
|
}
|
|
);
|
|
|
|
if (isLoading) {
|
|
return <Spinner />;
|
|
}
|
|
|
|
if (isError) {
|
|
return <TableDataError className={`${baseClass}__table-error`} />;
|
|
}
|
|
|
|
return (
|
|
<div className={baseClass}>
|
|
<SoftwareOSTable
|
|
router={router}
|
|
data={data}
|
|
isSoftwareEnabled={isSoftwareEnabled}
|
|
perPage={perPage}
|
|
orderDirection={orderDirection}
|
|
orderKey={orderKey}
|
|
currentPage={currentPage}
|
|
teamId={teamId}
|
|
isLoading={isFetching}
|
|
resetPageIndex={resetPageIndex}
|
|
platform={platform}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default SoftwareOS;
|