mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* AccessControl: FGAC permissions for orgs endpoint on frontend Protect org update endpoints add or refactor missing right messages cover org page * removing scopes from orgs * Perform permission control with global org * Perform the error handling in case of 403 * Simplify frontend code by requiring read access for sure * Remove roles I added to decrease the number of changes * Remove the check for server admin to reduce the number of changes * change error message * Cleaning todos * Remove unecessary changes * Fix tests * Update test snapshot * Update pkg/api/roles.go Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com> * Update public/app/features/admin/AdminEditOrgPage.tsx Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com> * Format AdminEditOrgPage for linting * Update public/app/features/admin/AdminEditOrgPage.tsx Co-authored-by: Vardan Torosyan <vardants@gmail.com> * Update public/app/features/admin/AdminEditOrgPage.tsx Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com> * Update public/app/features/admin/AdminListOrgsPage.tsx Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com> * Commit suggestions * Commit suggestion canRead canWrite * fix typo Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com> Co-authored-by: Vardan Torosyan <vardants@gmail.com> Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
68 lines
2.0 KiB
TypeScript
68 lines
2.0 KiB
TypeScript
import React, { FC, useState } from 'react';
|
|
import { AccessControlAction, Organization } from 'app/types';
|
|
import { Button, ConfirmModal } from '@grafana/ui';
|
|
import { contextSrv } from 'app/core/core';
|
|
|
|
interface Props {
|
|
orgs: Organization[];
|
|
onDelete: (orgId: number) => void;
|
|
}
|
|
|
|
export const AdminOrgsTable: FC<Props> = ({ orgs, onDelete }) => {
|
|
const canDeleteOrgs = contextSrv.hasPermission(AccessControlAction.OrgsDelete);
|
|
|
|
const [deleteOrg, setDeleteOrg] = useState<Organization>();
|
|
return (
|
|
<table className="filter-table form-inline filter-table--hover">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Name</th>
|
|
<th style={{ width: '1%' }}></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{orgs.map((org) => (
|
|
<tr key={`${org.id}-${org.name}`}>
|
|
<td className="link-td">
|
|
<a href={`admin/orgs/edit/${org.id}`}>{org.id}</a>
|
|
</td>
|
|
<td className="link-td">
|
|
<a href={`admin/orgs/edit/${org.id}`}>{org.name}</a>
|
|
</td>
|
|
<td className="text-right">
|
|
<Button
|
|
variant="destructive"
|
|
size="sm"
|
|
icon="times"
|
|
onClick={() => setDeleteOrg(org)}
|
|
aria-label="Delete org"
|
|
disabled={!canDeleteOrgs}
|
|
/>
|
|
</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
{deleteOrg && (
|
|
<ConfirmModal
|
|
isOpen
|
|
icon="trash-alt"
|
|
title="Delete"
|
|
body={
|
|
<div>
|
|
Are you sure you want to delete '{deleteOrg.name}'?
|
|
<br /> <small>All dashboards for this organization will be removed!</small>
|
|
</div>
|
|
}
|
|
confirmText="Delete"
|
|
onDismiss={() => setDeleteOrg(undefined)}
|
|
onConfirm={() => {
|
|
onDelete(deleteOrg.id);
|
|
setDeleteOrg(undefined);
|
|
}}
|
|
/>
|
|
)}
|
|
</table>
|
|
);
|
|
};
|