aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/users/components
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/users/components')
-rw-r--r--server/sonar-web/src/main/js/apps/users/components/UserListItem.tsx107
-rw-r--r--server/sonar-web/src/main/js/apps/users/components/UserListItemIdentity.tsx9
-rw-r--r--server/sonar-web/src/main/js/apps/users/components/__tests__/UserActions-test.tsx1
-rw-r--r--server/sonar-web/src/main/js/apps/users/components/__tests__/UserGroups-test.tsx1
-rw-r--r--server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItem-test.tsx6
-rw-r--r--server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItemIdentity-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/users/components/__tests__/__snapshots__/UserListItem-test.tsx.snap6
-rw-r--r--server/sonar-web/src/main/js/apps/users/components/__tests__/__snapshots__/UserListItemIdentity-test.tsx.snap1
8 files changed, 75 insertions, 58 deletions
diff --git a/server/sonar-web/src/main/js/apps/users/components/UserListItem.tsx b/server/sonar-web/src/main/js/apps/users/components/UserListItem.tsx
index 04a03dee287..4ec202012c5 100644
--- a/server/sonar-web/src/main/js/apps/users/components/UserListItem.tsx
+++ b/server/sonar-web/src/main/js/apps/users/components/UserListItem.tsx
@@ -31,67 +31,66 @@ import UserGroups from './UserGroups';
import UserListItemIdentity from './UserListItemIdentity';
import UserScmAccounts from './UserScmAccounts';
-interface Props {
+export interface UserListItemProps {
identityProvider?: IdentityProvider;
isCurrentUser: boolean;
onUpdateUsers: () => void;
updateTokensCount: (login: string, tokensCount: number) => void;
user: User;
+ manageProvider: string | undefined;
}
-interface State {
- openTokenForm: boolean;
-}
-
-export default class UserListItem extends React.PureComponent<Props, State> {
- state: State = { openTokenForm: false };
-
- handleOpenTokensForm = () => this.setState({ openTokenForm: true });
- handleCloseTokensForm = () => this.setState({ openTokenForm: false });
+export default function UserListItem(props: UserListItemProps) {
+ const [openTokenForm, setOpenTokenForm] = React.useState(false);
- render() {
- const { identityProvider, onUpdateUsers, user } = this.props;
+ const {
+ identityProvider,
+ onUpdateUsers,
+ user,
+ manageProvider,
+ isCurrentUser,
+ updateTokensCount,
+ } = props;
- return (
- <tr>
- <td className="thin nowrap text-middle">
- <Avatar hash={user.avatar} name={user.name} size={36} />
- </td>
- <UserListItemIdentity identityProvider={identityProvider} user={user} />
- <td className="thin nowrap text-middle">
- <UserScmAccounts scmAccounts={user.scmAccounts || []} />
- </td>
- <td className="thin nowrap text-middle">
- <DateFromNow date={user.lastConnectionDate} hourPrecision={true} />
- </td>
- <td className="thin nowrap text-middle">
- <UserGroups groups={user.groups || []} onUpdateUsers={onUpdateUsers} user={user} />
- </td>
- <td className="thin nowrap text-middle">
- {user.tokensCount}
- <ButtonIcon
- className="js-user-tokens spacer-left button-small"
- onClick={this.handleOpenTokensForm}
- tooltip={translate('users.update_tokens')}
- >
- <BulletListIcon />
- </ButtonIcon>
- </td>
- <td className="thin nowrap text-right text-middle">
- <UserActions
- isCurrentUser={this.props.isCurrentUser}
- onUpdateUsers={onUpdateUsers}
- user={user}
- />
- </td>
- {this.state.openTokenForm && (
- <TokensFormModal
- onClose={this.handleCloseTokensForm}
- updateTokensCount={this.props.updateTokensCount}
- user={user}
- />
- )}
- </tr>
- );
- }
+ return (
+ <tr>
+ <td className="thin nowrap text-middle">
+ <Avatar hash={user.avatar} name={user.name} size={36} />
+ </td>
+ <UserListItemIdentity
+ identityProvider={identityProvider}
+ user={user}
+ manageProvider={manageProvider}
+ />
+ <td className="thin nowrap text-middle">
+ <UserScmAccounts scmAccounts={user.scmAccounts || []} />
+ </td>
+ <td className="thin nowrap text-middle">
+ <DateFromNow date={user.lastConnectionDate} hourPrecision={true} />
+ </td>
+ <td className="thin nowrap text-middle">
+ <UserGroups groups={user.groups || []} onUpdateUsers={onUpdateUsers} user={user} />
+ </td>
+ <td className="thin nowrap text-middle">
+ {user.tokensCount}
+ <ButtonIcon
+ className="js-user-tokens spacer-left button-small"
+ onClick={() => setOpenTokenForm(true)}
+ tooltip={translate('users.update_tokens')}
+ >
+ <BulletListIcon />
+ </ButtonIcon>
+ </td>
+ <td className="thin nowrap text-right text-middle">
+ <UserActions isCurrentUser={isCurrentUser} onUpdateUsers={onUpdateUsers} user={user} />
+ </td>
+ {openTokenForm && (
+ <TokensFormModal
+ onClose={() => setOpenTokenForm(false)}
+ updateTokensCount={updateTokensCount}
+ user={user}
+ />
+ )}
+ </tr>
+ );
}
diff --git a/server/sonar-web/src/main/js/apps/users/components/UserListItemIdentity.tsx b/server/sonar-web/src/main/js/apps/users/components/UserListItemIdentity.tsx
index 6d4d6872ce8..f73eb688689 100644
--- a/server/sonar-web/src/main/js/apps/users/components/UserListItemIdentity.tsx
+++ b/server/sonar-web/src/main/js/apps/users/components/UserListItemIdentity.tsx
@@ -21,6 +21,7 @@
import { getTextColor } from 'design-system';
import * as React from 'react';
import { colors } from '../../../app/theme';
+import { translate } from '../../../helpers/l10n';
import { getBaseUrl } from '../../../helpers/system';
import { IdentityProvider } from '../../../types/types';
import { User } from '../../../types/users';
@@ -28,9 +29,10 @@ import { User } from '../../../types/users';
export interface Props {
identityProvider?: IdentityProvider;
user: User;
+ manageProvider?: string;
}
-export default function UserListItemIdentity({ identityProvider, user }: Props) {
+export default function UserListItemIdentity({ identityProvider, user, manageProvider }: Props) {
return (
<td className="text-middle">
<div>
@@ -41,11 +43,14 @@ export default function UserListItemIdentity({ identityProvider, user }: Props)
{!user.local && user.externalProvider !== 'sonarqube' && (
<ExternalProvider identityProvider={identityProvider} user={user} />
)}
+ {user.managed === false && manageProvider !== undefined && (
+ <span className="badge">{translate('users.local')}</span>
+ )}
</td>
);
}
-export function ExternalProvider({ identityProvider, user }: Props) {
+export function ExternalProvider({ identityProvider, user }: Omit<Props, 'manageProvider'>) {
if (!identityProvider) {
return (
<div className="js-user-identity-provider little-spacer-top">
diff --git a/server/sonar-web/src/main/js/apps/users/components/__tests__/UserActions-test.tsx b/server/sonar-web/src/main/js/apps/users/components/__tests__/UserActions-test.tsx
index ab9a64daa91..e4925c08c9a 100644
--- a/server/sonar-web/src/main/js/apps/users/components/__tests__/UserActions-test.tsx
+++ b/server/sonar-web/src/main/js/apps/users/components/__tests__/UserActions-test.tsx
@@ -28,6 +28,7 @@ const user = {
active: true,
scmAccounts: [],
local: false,
+ managed: false,
};
it('should render correctly', () => {
diff --git a/server/sonar-web/src/main/js/apps/users/components/__tests__/UserGroups-test.tsx b/server/sonar-web/src/main/js/apps/users/components/__tests__/UserGroups-test.tsx
index 5683e8ef5c2..47ea651dbe4 100644
--- a/server/sonar-web/src/main/js/apps/users/components/__tests__/UserGroups-test.tsx
+++ b/server/sonar-web/src/main/js/apps/users/components/__tests__/UserGroups-test.tsx
@@ -28,6 +28,7 @@ const user = {
active: true,
scmAccounts: [],
local: false,
+ managed: false,
};
const groups = ['foo', 'bar', 'baz', 'plop'];
diff --git a/server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItem-test.tsx b/server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItem-test.tsx
index a3c0c1eb34d..cfd69e9e579 100644
--- a/server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItem-test.tsx
+++ b/server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItem-test.tsx
@@ -21,7 +21,7 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import { click } from '../../../../helpers/testUtils';
import { User } from '../../../../types/users';
-import UserListItem from '../UserListItem';
+import UserListItem, { UserListItemProps } from '../UserListItem';
jest.mock('../../../../components/intl/DateFromNow');
jest.mock('../../../../components/intl/DateTimeFormatter');
@@ -33,6 +33,7 @@ const user: User = {
login: 'obi',
name: 'One',
scmAccounts: [],
+ managed: false,
};
it('should render correctly', () => {
@@ -49,13 +50,14 @@ it('should open the correct forms', () => {
expect(wrapper.find('TokensFormModal').exists()).toBe(true);
});
-function shallowRender(props: Partial<UserListItem['props']> = {}) {
+function shallowRender(props: Partial<UserListItemProps> = {}) {
return shallow(
<UserListItem
isCurrentUser={false}
onUpdateUsers={jest.fn()}
updateTokensCount={jest.fn()}
user={user}
+ manageProvider={undefined}
{...props}
/>
);
diff --git a/server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItemIdentity-test.tsx b/server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItemIdentity-test.tsx
index 661feb1fc1e..a362fd780d4 100644
--- a/server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItemIdentity-test.tsx
+++ b/server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItemIdentity-test.tsx
@@ -44,6 +44,7 @@ describe('#UserListItemIdentity', () => {
login: 'obi',
name: 'One',
scmAccounts: [],
+ managed: false,
}}
{...props}
/>
@@ -78,6 +79,7 @@ describe('#ExternalProvider', () => {
login: 'obi',
name: 'One',
scmAccounts: [],
+ managed: false,
}}
{...props}
/>
diff --git a/server/sonar-web/src/main/js/apps/users/components/__tests__/__snapshots__/UserListItem-test.tsx.snap b/server/sonar-web/src/main/js/apps/users/components/__tests__/__snapshots__/UserListItem-test.tsx.snap
index a4e8b65bfc3..5970d8c3871 100644
--- a/server/sonar-web/src/main/js/apps/users/components/__tests__/__snapshots__/UserListItem-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/users/components/__tests__/__snapshots__/UserListItem-test.tsx.snap
@@ -17,6 +17,7 @@ exports[`should render correctly 1`] = `
"lastConnectionDate": "2019-01-18T15:06:33+0100",
"local": false,
"login": "obi",
+ "managed": false,
"name": "One",
"scmAccounts": [],
}
@@ -49,6 +50,7 @@ exports[`should render correctly 1`] = `
"lastConnectionDate": "2019-01-18T15:06:33+0100",
"local": false,
"login": "obi",
+ "managed": false,
"name": "One",
"scmAccounts": [],
}
@@ -78,6 +80,7 @@ exports[`should render correctly 1`] = `
"lastConnectionDate": "2019-01-18T15:06:33+0100",
"local": false,
"login": "obi",
+ "managed": false,
"name": "One",
"scmAccounts": [],
}
@@ -104,6 +107,7 @@ exports[`should render correctly without last connection date 1`] = `
"lastConnectionDate": "2019-01-18T15:06:33+0100",
"local": false,
"login": "obi",
+ "managed": false,
"name": "One",
"scmAccounts": [],
}
@@ -136,6 +140,7 @@ exports[`should render correctly without last connection date 1`] = `
"lastConnectionDate": "2019-01-18T15:06:33+0100",
"local": false,
"login": "obi",
+ "managed": false,
"name": "One",
"scmAccounts": [],
}
@@ -165,6 +170,7 @@ exports[`should render correctly without last connection date 1`] = `
"lastConnectionDate": "2019-01-18T15:06:33+0100",
"local": false,
"login": "obi",
+ "managed": false,
"name": "One",
"scmAccounts": [],
}
diff --git a/server/sonar-web/src/main/js/apps/users/components/__tests__/__snapshots__/UserListItemIdentity-test.tsx.snap b/server/sonar-web/src/main/js/apps/users/components/__tests__/__snapshots__/UserListItemIdentity-test.tsx.snap
index eccdb8b8147..9fd139b23b9 100644
--- a/server/sonar-web/src/main/js/apps/users/components/__tests__/__snapshots__/UserListItemIdentity-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/users/components/__tests__/__snapshots__/UserListItemIdentity-test.tsx.snap
@@ -73,6 +73,7 @@ exports[`#UserListItemIdentity should render correctly 1`] = `
"lastConnectionDate": "2019-01-18T15:06:33+0100",
"local": false,
"login": "obi",
+ "managed": false,
"name": "One",
"scmAccounts": [],
}