Fix teams duplication and user list permission control (#1591)
# What this PR does ## Which issue(s) this PR fixes ## Checklist - [ ] Tests updated - [ ] Documentation added - [ ] `CHANGELOG.md` updated
This commit is contained in:
parent
58dbcd9439
commit
748e8462a4
2 changed files with 17 additions and 17 deletions
|
|
@ -188,7 +188,7 @@ class User(models.Model):
|
|||
def available_teams(self):
|
||||
if self.role == LegacyAccessControlRole.ADMIN:
|
||||
return self.organization.teams.all()
|
||||
return self.organization.teams.filter(Q(is_sharing_resources_to_all=True) | Q(users=self))
|
||||
return self.organization.teams.filter(Q(is_sharing_resources_to_all=True) | Q(users=self)).distinct()
|
||||
|
||||
@property
|
||||
def is_authenticated(self):
|
||||
|
|
|
|||
|
|
@ -52,20 +52,20 @@ const TeamsList = observer(() => {
|
|||
|
||||
const renderActionButtons = (record: GrafanaTeam) => {
|
||||
const editButton = (
|
||||
<WithPermissionControlTooltip userAction={UserActions.APIKeysWrite}>
|
||||
<HorizontalGroup justify="flex-end">
|
||||
<Tooltip content="Default team will be selected when creating new resources">
|
||||
<Button
|
||||
onClick={async () => {
|
||||
await userStore.updateCurrentUser({ current_team: record.id });
|
||||
store.grafanaTeamStore.updateItems();
|
||||
}}
|
||||
disabled={isTeamDefault(record)}
|
||||
fill="text"
|
||||
>
|
||||
Make default
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<HorizontalGroup justify="flex-end">
|
||||
<Tooltip content="Default team will be selected when creating new resources">
|
||||
<Button
|
||||
onClick={async () => {
|
||||
await userStore.updateCurrentUser({ current_team: record.id });
|
||||
store.grafanaTeamStore.updateItems();
|
||||
}}
|
||||
disabled={isTeamDefault(record)}
|
||||
fill="text"
|
||||
>
|
||||
Make default
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<WithPermissionControlTooltip userAction={UserActions.TeamsWrite}>
|
||||
<Button
|
||||
fill="text"
|
||||
disabled={record.id === 'null'}
|
||||
|
|
@ -76,8 +76,8 @@ const TeamsList = observer(() => {
|
|||
>
|
||||
Edit
|
||||
</Button>
|
||||
</HorizontalGroup>
|
||||
</WithPermissionControlTooltip>
|
||||
</WithPermissionControlTooltip>
|
||||
</HorizontalGroup>
|
||||
);
|
||||
return editButton;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue