mirror of
https://github.com/grafana/grafana.git
synced 2025-09-24 20:23:49 +08:00

Co-authored-by: Kevin Yu <kevinwcyu@users.noreply.github.com> Co-authored-by: Andres Martinez Gotor <andres.mgotor@gmail.com> Co-authored-by: Isabella Siu <isabella.siu@grafana.com> Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import React from 'react';
|
|
import { cx } from '@emotion/css';
|
|
|
|
import { useStyles2 } from '@grafana/ui';
|
|
|
|
import NestedRows from './NestedRows';
|
|
import getStyles from './styles';
|
|
import { ResourceRow, ResourceRowGroup, ResourceRowType } from './types';
|
|
|
|
interface NestedResourceTableProps {
|
|
rows: ResourceRowGroup;
|
|
selectedRows: ResourceRowGroup;
|
|
noHeader?: boolean;
|
|
requestNestedRows: (row: ResourceRow) => Promise<void>;
|
|
onRowSelectedChange: (row: ResourceRow, selected: boolean) => void;
|
|
selectableEntryTypes: ResourceRowType[];
|
|
}
|
|
|
|
const NestedResourceTable: React.FC<NestedResourceTableProps> = ({
|
|
rows,
|
|
selectedRows,
|
|
noHeader,
|
|
requestNestedRows,
|
|
onRowSelectedChange,
|
|
selectableEntryTypes,
|
|
}) => {
|
|
const styles = useStyles2(getStyles);
|
|
|
|
return (
|
|
<>
|
|
<table className={styles.table}>
|
|
{!noHeader && (
|
|
<thead>
|
|
<tr className={cx(styles.row, styles.header)}>
|
|
<td className={styles.cell}>Scope</td>
|
|
<td className={styles.cell}>Type</td>
|
|
<td className={styles.cell}>Location</td>
|
|
</tr>
|
|
</thead>
|
|
)}
|
|
</table>
|
|
|
|
<div className={styles.tableScroller}>
|
|
<table className={styles.table}>
|
|
<tbody>
|
|
<NestedRows
|
|
rows={rows}
|
|
selectedRows={selectedRows}
|
|
level={0}
|
|
requestNestedRows={requestNestedRows}
|
|
onRowSelectedChange={onRowSelectedChange}
|
|
selectableEntryTypes={selectableEntryTypes}
|
|
/>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default NestedResourceTable;
|