mirror of
https://github.com/Graylog2/graylog2-server.git
synced 2026-03-13 09:32:21 +08:00
Refactor user details and edit permissions (#23441)
This commit is contained in:
committed by
GitHub
parent
7e883e4b05
commit
c8e2ba35e0
@@ -126,7 +126,7 @@ describe('UserDetails', () => {
|
||||
it('should display info if license is not present', async () => {
|
||||
render(<UserDetails user={user} />);
|
||||
|
||||
await screen.findByText(/Enterprise Feature/);
|
||||
await screen.findAllByText(/Enterprise Feature/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -69,11 +69,9 @@ const UserDetails = ({ user }: Props) => {
|
||||
<TelemetrySettingsDetails />
|
||||
</IfPermitted>
|
||||
)}
|
||||
{(currentUser.id === user.id || isLocalAdmin) && (
|
||||
<IfPermitted permissions={`users:edit:${user.username}`}>
|
||||
<CollectionsSection user={user} />
|
||||
</IfPermitted>
|
||||
)}
|
||||
<IfPermitted permissions={`users:edit:${user.username}`}>
|
||||
<CollectionsSection user={user} />
|
||||
</IfPermitted>
|
||||
{currentUser.id === user.id && isLocalAdmin && (
|
||||
<IfPermitted permissions={`users:edit:${user.username}`}>
|
||||
<TelemetrySettingsConfig />
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
import * as React from 'react';
|
||||
|
||||
import { IfPermitted } from 'components/common';
|
||||
import { LinkContainer } from 'components/common/router';
|
||||
import type User from 'logic/users/User';
|
||||
import Routes from 'routing/Routes';
|
||||
@@ -24,21 +25,28 @@ import { ButtonToolbar, Button } from 'components/bootstrap';
|
||||
type Props = {
|
||||
userId: User['id'];
|
||||
userIsReadOnly: boolean;
|
||||
username: User['username'];
|
||||
};
|
||||
|
||||
const UserActionLinks = ({ userId, userIsReadOnly }: Props) => (
|
||||
const UserActionLinks = ({ userId, userIsReadOnly, username }: Props) => (
|
||||
<ButtonToolbar>
|
||||
<LinkContainer to={Routes.SYSTEM.USERS.show(userId)}>
|
||||
<Button bsStyle="success">View Details</Button>
|
||||
</LinkContainer>
|
||||
{!userIsReadOnly && (
|
||||
<LinkContainer to={Routes.SYSTEM.USERS.edit(userId)}>
|
||||
<Button bsStyle="success">Edit User</Button>
|
||||
<IfPermitted permissions={`users:edit:${username}`}>
|
||||
<LinkContainer to={Routes.SYSTEM.USERS.show(userId)}>
|
||||
<Button bsStyle="success">View Details</Button>
|
||||
</LinkContainer>
|
||||
</IfPermitted>
|
||||
{!userIsReadOnly && (
|
||||
<IfPermitted permissions={`users:edit:${username}`}>
|
||||
<LinkContainer to={Routes.SYSTEM.USERS.edit(userId)}>
|
||||
<Button bsStyle="success">Edit User</Button>
|
||||
</LinkContainer>
|
||||
</IfPermitted>
|
||||
)}
|
||||
<LinkContainer to={Routes.SYSTEM.USERS.TOKENS.edit(userId)}>
|
||||
<Button bsStyle="success">Edit Tokens</Button>
|
||||
</LinkContainer>
|
||||
<IfPermitted permissions={[`users:tokenlist:${username}`]}>
|
||||
<LinkContainer to={Routes.SYSTEM.USERS.TOKENS.edit(userId)}>
|
||||
<Button bsStyle="success">Edit Tokens</Button>
|
||||
</LinkContainer>
|
||||
</IfPermitted>
|
||||
</ButtonToolbar>
|
||||
);
|
||||
|
||||
|
||||
@@ -56,7 +56,13 @@ const UserDetailsPage = ({ params }: Props) => {
|
||||
<UsersPageNavigation />
|
||||
<PageHeader
|
||||
title={<PageTitle fullName={loadedUser?.fullName} />}
|
||||
actions={<UserActionLinks userId={userId} userIsReadOnly={loadedUser?.readOnly ?? false} />}
|
||||
actions={
|
||||
<UserActionLinks
|
||||
userId={userId}
|
||||
username={loadedUser?.username ?? ''}
|
||||
userIsReadOnly={loadedUser?.readOnly ?? false}
|
||||
/>
|
||||
}
|
||||
documentationLink={{
|
||||
title: 'Permissions documentation',
|
||||
path: DocsHelper.PAGES.USERS_ROLES,
|
||||
|
||||
@@ -67,7 +67,7 @@ const UserEditPage = ({ params }: Props) => {
|
||||
<UsersPageNavigation />
|
||||
<PageHeader
|
||||
title={<PageTitle fullName={fullName} />}
|
||||
actions={<UserActionLinks userId={userId} userIsReadOnly={readOnly} />}
|
||||
actions={<UserActionLinks userId={userId} username={loadedUser?.username ?? ''} userIsReadOnly={readOnly} />}
|
||||
documentationLink={{
|
||||
title: 'Permissions documentation',
|
||||
path: DocsHelper.PAGES.USERS_ROLES,
|
||||
|
||||
@@ -96,7 +96,13 @@ const UserEditPage = ({ params }: Props) => {
|
||||
<UsersPageNavigation />
|
||||
<PageHeader
|
||||
title={<PageTitle fullName={loadedUser?.fullName} />}
|
||||
actions={<UserActionLinks userId={userId} userIsReadOnly={loadedUser?.readOnly ?? false} />}
|
||||
actions={
|
||||
<UserActionLinks
|
||||
userId={userId}
|
||||
username={loadedUser?.username ?? ''}
|
||||
userIsReadOnly={loadedUser?.readOnly ?? false}
|
||||
/>
|
||||
}
|
||||
documentationLink={{
|
||||
title: 'Permissions documentation',
|
||||
path: DocsHelper.PAGES.USERS_ROLES,
|
||||
|
||||
Reference in New Issue
Block a user