fleet/frontend/pages/DashboardPage/components/MdmSolutionModal/MdmSolutionModalTableConfig.tsx
jacobshandling 0b45afcaa8
UI - update empty styles in 5 places (#20079)
## Addresses #19557 
<img width="143" alt="Screenshot 2024-06-27 at 1 44 12 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/e9ad83b2-dda4-4972-b8c2-412389e45823">
<img width="177" alt="Screenshot 2024-06-27 at 1 44 25 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/bb5f808e-0d5a-47cc-84ed-f55797caebfe">
<img width="210" alt="Screenshot 2024-06-27 at 1 49 47 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/2dff046b-6cfa-45fa-8a0c-93ab46e2c8a9">
<img width="194" alt="Screenshot 2024-06-27 at 1 56 56 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/fdaaeac8-e944-427b-917e-87b98ae763b9">
<img width="238" alt="Screenshot 2024-06-27 at 4 39 22 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/bb774af5-07c0-44b6-994f-dc787c5bf606">

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

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2024-07-03 09:40:03 -07:00

102 lines
2.6 KiB
TypeScript

import React from "react";
import { IMdmSolution } from "interfaces/mdm";
import TextCell from "components/TableContainer/DataTable/TextCell";
import ViewAllHostsLink from "components/ViewAllHostsLink";
import TooltipWrapper from "components/TooltipWrapper";
import HeaderCell from "components/TableContainer/DataTable/HeaderCell";
// NOTE: cellProps come from react-table
// more info here https://react-table.tanstack.com/docs/api/useTable#cell-properties
interface IMDMSolutionWithPlatformId extends IMdmSolution {
selectedPlatformLabelId?: number;
}
interface ICellProps {
cell: {
value: string;
};
row: {
original: IMDMSolutionWithPlatformId;
};
}
interface IHeaderProps {
column: {
title: string;
isSortedDesc: boolean;
};
}
interface IDataColumn {
title: string;
Header: ((props: IHeaderProps) => JSX.Element) | string;
accessor: string;
Cell: (props: ICellProps) => JSX.Element;
disableGlobalFilter?: boolean;
disableHidden?: boolean;
disableSortBy?: boolean;
}
export const generateSolutionsTableHeaders = (
teamId?: number
): IDataColumn[] => [
{
title: "Server URL",
Header: (): JSX.Element => {
const titleWithToolTip = (
<TooltipWrapper
tipContent={
<>
The MDM server URL is used to connect hosts with the MDM service.
For cross-platform MDM solutions, each operating system has a
different URL.
</>
}
className="server-url-header"
>
Server URL
</TooltipWrapper>
);
return <HeaderCell value={titleWithToolTip} disableSortBy />;
},
disableSortBy: true,
accessor: "server_url",
Cell: (cellProps: ICellProps) => <TextCell value={cellProps.cell.value} />,
},
{
title: "Hosts",
Header: "Hosts",
disableSortBy: true,
accessor: "hosts_count",
Cell: (cellProps: ICellProps) => (
<div className="host-count-cell">
<TextCell value={cellProps.cell.value} className="" />
<ViewAllHostsLink
queryParams={{ mdm_id: cellProps.row.original.id, team_id: teamId }}
className="view-mdm-solution-link"
platformLabelId={cellProps.row.original.selectedPlatformLabelId}
rowHover
/>
</div>
),
},
];
export const generateSolutionsDataSet = (
solutions: IMdmSolution[] | null,
selectedPlatformLabelId?: number
): IMdmSolution[] => {
if (!solutions) {
return [];
}
return solutions.map((solution) => {
return {
...solution,
selectedPlatformLabelId,
};
});
};