mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
Team access changes for editors when editorsCanAdmin is enabled (#45405)
* filter teams for editors to only show the teams that they are members of * frontend changes to only allow clicking on teams that the user can edit * update frontend test snapshots * extend docs * reword * remove the comment for now * Update backend tests * reword the warning, and add it back in * docs feedback Co-authored-by: gamab <gabi.mabs@gmail.com>
This commit is contained in:
@@ -69,11 +69,9 @@ export class TeamList extends PureComponent<Props, State> {
|
||||
const { editorsCanAdmin, signedInUser } = this.props;
|
||||
const permission = team.permission;
|
||||
const teamUrl = `org/teams/edit/${team.id}`;
|
||||
const canDelete = contextSrv.hasAccessInMetadata(
|
||||
AccessControlAction.ActionTeamsDelete,
|
||||
team,
|
||||
isPermissionTeamAdmin({ permission, editorsCanAdmin, signedInUser })
|
||||
);
|
||||
const isTeamAdmin = isPermissionTeamAdmin({ permission, editorsCanAdmin, signedInUser });
|
||||
const canDelete = contextSrv.hasAccessInMetadata(AccessControlAction.ActionTeamsDelete, team, isTeamAdmin);
|
||||
const canReadTeam = contextSrv.hasAccessInMetadata(AccessControlAction.ActionTeamsRead, team, isTeamAdmin);
|
||||
const canSeeTeamRoles = contextSrv.hasAccessInMetadata(AccessControlAction.ActionTeamsRolesList, team, false);
|
||||
const canUpdateTeamRoles =
|
||||
contextSrv.hasAccess(AccessControlAction.ActionTeamsRolesAdd, false) ||
|
||||
@@ -86,20 +84,34 @@ export class TeamList extends PureComponent<Props, State> {
|
||||
return (
|
||||
<tr key={team.id}>
|
||||
<td className="width-4 text-center link-td">
|
||||
<a href={teamUrl}>
|
||||
{canReadTeam ? (
|
||||
<a href={teamUrl}>
|
||||
<img className="filter-table__avatar" src={team.avatarUrl} alt="Team avatar" />
|
||||
</a>
|
||||
) : (
|
||||
<img className="filter-table__avatar" src={team.avatarUrl} alt="Team avatar" />
|
||||
</a>
|
||||
)}
|
||||
</td>
|
||||
<td className="link-td">
|
||||
<a href={teamUrl}>{team.name}</a>
|
||||
{canReadTeam ? <a href={teamUrl}>{team.name}</a> : <div style={{ padding: '0px 8px' }}>{team.name}</div>}
|
||||
</td>
|
||||
<td className="link-td">
|
||||
<a href={teamUrl} aria-label={team.email?.length > 0 ? undefined : 'Empty email cell'}>
|
||||
{team.email}
|
||||
</a>
|
||||
{canReadTeam ? (
|
||||
<a href={teamUrl} aria-label={team.email?.length > 0 ? undefined : 'Empty email cell'}>
|
||||
{team.email}
|
||||
</a>
|
||||
) : (
|
||||
<div style={{ padding: '0px 8px' }} aria-label={team.email?.length > 0 ? undefined : 'Empty email cell'}>
|
||||
{team.email}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td className="link-td">
|
||||
<a href={teamUrl}>{team.memberCount}</a>
|
||||
{canReadTeam ? (
|
||||
<a href={teamUrl}>{team.memberCount}</a>
|
||||
) : (
|
||||
<div style={{ padding: '0px 8px' }}>{team.memberCount}</div>
|
||||
)}
|
||||
</td>
|
||||
{displayRolePicker && (
|
||||
<td>
|
||||
|
||||
@@ -445,42 +445,50 @@ exports[`Render when feature toggle editorsCanAdmin is turned on and signedin us
|
||||
<td
|
||||
className="width-4 text-center link-td"
|
||||
>
|
||||
<a
|
||||
href="org/teams/edit/1"
|
||||
>
|
||||
<img
|
||||
alt="Team avatar"
|
||||
className="filter-table__avatar"
|
||||
src="some/url/"
|
||||
/>
|
||||
</a>
|
||||
<img
|
||||
alt="Team avatar"
|
||||
className="filter-table__avatar"
|
||||
src="some/url/"
|
||||
/>
|
||||
</td>
|
||||
<td
|
||||
className="link-td"
|
||||
>
|
||||
<a
|
||||
href="org/teams/edit/1"
|
||||
<div
|
||||
style={
|
||||
Object {
|
||||
"padding": "0px 8px",
|
||||
}
|
||||
}
|
||||
>
|
||||
test-1
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
className="link-td"
|
||||
>
|
||||
<a
|
||||
href="org/teams/edit/1"
|
||||
<div
|
||||
style={
|
||||
Object {
|
||||
"padding": "0px 8px",
|
||||
}
|
||||
}
|
||||
>
|
||||
test-1@test.com
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
className="link-td"
|
||||
>
|
||||
<a
|
||||
href="org/teams/edit/1"
|
||||
<div
|
||||
style={
|
||||
Object {
|
||||
"padding": "0px 8px",
|
||||
}
|
||||
}
|
||||
>
|
||||
1
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
className="text-right"
|
||||
@@ -583,42 +591,50 @@ exports[`Render when feature toggle editorsCanAdmin is turned on and signedin us
|
||||
<td
|
||||
className="width-4 text-center link-td"
|
||||
>
|
||||
<a
|
||||
href="org/teams/edit/1"
|
||||
>
|
||||
<img
|
||||
alt="Team avatar"
|
||||
className="filter-table__avatar"
|
||||
src="some/url/"
|
||||
/>
|
||||
</a>
|
||||
<img
|
||||
alt="Team avatar"
|
||||
className="filter-table__avatar"
|
||||
src="some/url/"
|
||||
/>
|
||||
</td>
|
||||
<td
|
||||
className="link-td"
|
||||
>
|
||||
<a
|
||||
href="org/teams/edit/1"
|
||||
<div
|
||||
style={
|
||||
Object {
|
||||
"padding": "0px 8px",
|
||||
}
|
||||
}
|
||||
>
|
||||
test-1
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
className="link-td"
|
||||
>
|
||||
<a
|
||||
href="org/teams/edit/1"
|
||||
<div
|
||||
style={
|
||||
Object {
|
||||
"padding": "0px 8px",
|
||||
}
|
||||
}
|
||||
>
|
||||
test-1@test.com
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
className="link-td"
|
||||
>
|
||||
<a
|
||||
href="org/teams/edit/1"
|
||||
<div
|
||||
style={
|
||||
Object {
|
||||
"padding": "0px 8px",
|
||||
}
|
||||
}
|
||||
>
|
||||
1
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
className="text-right"
|
||||
|
||||
Reference in New Issue
Block a user