diff --git a/public/app/features/serviceaccounts/ServiceAccountsListPage.tsx b/public/app/features/serviceaccounts/ServiceAccountsListPage.tsx index c689d3e9bd0..de7345125a3 100644 --- a/public/app/features/serviceaccounts/ServiceAccountsListPage.tsx +++ b/public/app/features/serviceaccounts/ServiceAccountsListPage.tsx @@ -45,7 +45,7 @@ export class ServiceAccountsListPage extends PureComponent { this.onRoleChange(role, serviceAccount)} - onRemoveServiceaccount={(serviceAccount) => this.props.removeServiceAccount(serviceAccount.serviceAccountId)} + onRemoveServiceAccount={(serviceAccount) => this.props.removeServiceAccount(serviceAccount.serviceAccountId)} /> void; - onRemoveServiceaccount: (serviceaccount: OrgServiceAccount) => void; + onRoleChange: (role: OrgRole, serviceAccount: OrgServiceAccount) => void; + onRemoveServiceAccount: (serviceAccount: OrgServiceAccount) => void; } -const ServiceaccountsTable: FC = (props) => { - const { serviceAccounts, orgId, onRoleChange, onRemoveServiceaccount: onRemoveserviceaccount } = props; +const ServiceAccountsTable: FC = (props) => { + const { serviceAccounts, orgId, onRoleChange, onRemoveServiceAccount } = props; const canUpdateRole = contextSrv.hasPermission(AccessControlAction.OrgUsersRoleUpdate); const canRemoveFromOrg = contextSrv.hasPermission(AccessControlAction.OrgUsersRemove); const rolePickerDisabled = !canUpdateRole; - const [showRemoveModal, setShowRemoveModal] = useState(false); const [roleOptions, setRoleOptions] = useState([]); + const [toRemove, setToRemove] = useState(null); const [builtinRoles, setBuiltinRoles] = useState>({}); + const [showRemoveModal, setShowRemoveModal] = useState(false); useEffect(() => { async function fetchOptions() { @@ -43,91 +44,92 @@ const ServiceaccountsTable: FC = (props) => { const getBuiltinRoles = async () => builtinRoles; return ( - - - - - - - - - - - - {serviceAccounts.map((serviceAccount, index) => { - return ( - - - - - - - - - - - {canRemoveFromOrg && ( - + + + + + + + {canRemoveFromOrg && ( + + )} + + ); + })} + +
- LoginEmailNameSeenRole -
- serviceaccount avatar - - - {serviceAccount.login} - - - - {serviceAccount.email} - - - - {serviceAccount.name} - - {serviceAccount.lastSeenAtAge} - {contextSrv.accessControlEnabled() ? ( - onRoleChange(newRole, serviceAccount)} - getRoleOptions={getRoleOptions} - getBuiltinRoles={getBuiltinRoles} - disabled={rolePickerDisabled} - /> - ) : ( - onRoleChange(newRole, serviceAccount)} - /> - )} - - + + {serviceAccount.login} + + + + {serviceAccount.email} + + + + {serviceAccount.name} + + {serviceAccount.lastSeenAtAge} + {contextSrv.accessControlEnabled() ? ( + onRoleChange(newRole, serviceAccount)} + getRoleOptions={getRoleOptions} + getBuiltinRoles={getBuiltinRoles} + disabled={rolePickerDisabled} + /> + ) : ( + onRoleChange(newRole, serviceAccount)} + /> + )} + +
+ {toRemove !== null && ( + setToRemove(null)} + isOpen={toRemove.login === showRemoveModal} + onConfirm={() => onRemoveServiceAccount(toRemove)} + /> + )} + ); }; -export default ServiceaccountsTable; +export default ServiceAccountsTable;