Files
Yaelle Chaudy c00f488f89 Azure Monitor : Add support for the resource picker to be configurable to only select some entry types (#46735)
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>
2022-03-25 12:22:28 +01:00

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;