import { css } from '@emotion/css'; import React, { useState } from 'react'; import Skeleton from 'react-loading-skeleton'; import { GrafanaTheme2 } from '@grafana/data'; import { Button, ConfirmModal, useStyles2 } from '@grafana/ui'; import { SkeletonComponent, attachSkeleton } from '@grafana/ui/src/unstable'; import { contextSrv } from 'app/core/core'; import { AccessControlAction, Organization } from 'app/types'; interface Props { orgs: Organization[]; onDelete: (orgId: number) => void; } const getTableHeader = () => ( ID Name ); function AdminOrgsTableComponent({ orgs, onDelete }: Props) { const canDeleteOrgs = contextSrv.hasPermission(AccessControlAction.OrgsDelete); const [deleteOrg, setDeleteOrg] = useState(); return ( {getTableHeader()} {orgs.map((org) => ( ))} {deleteOrg && ( Are you sure you want to delete '{deleteOrg.name}'?
All dashboards for this organization will be removed! } confirmText="Delete" onDismiss={() => setDeleteOrg(undefined)} onConfirm={() => { onDelete(deleteOrg.id); setDeleteOrg(undefined); }} /> )}
{org.id} {org.name}
); } const AdminOrgsTableSkeleton: SkeletonComponent = ({ rootProps }) => { const styles = useStyles2(getSkeletonStyles); return ( {getTableHeader()} {new Array(3).fill(null).map((_, index) => ( ))}
); }; export const AdminOrgsTable = attachSkeleton(AdminOrgsTableComponent, AdminOrgsTableSkeleton); const getSkeletonStyles = (theme: GrafanaTheme2) => ({ deleteButton: css({ alignItems: 'center', display: 'flex', height: 30, lineHeight: 1, }), });