aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/groups
diff options
context:
space:
mode:
authorPhilippe Perrin <philippe.perrin@sonarsource.com>2022-11-02 11:08:39 +0100
committersonartech <sonartech@sonarsource.com>2022-11-02 20:03:01 +0000
commit2ab6fc273ecbf405f7c126fab11ddc0b9bf516da (patch)
treea6e005b4f57fb488d3e551b7df52399e69b0674c /server/sonar-web/src/main/js/apps/groups
parent60e4b88e4567c1af3051b6cdc4c8858f8b0fca21 (diff)
downloadsonarqube-2ab6fc273ecbf405f7c126fab11ddc0b9bf516da.tar.gz
sonarqube-2ab6fc273ecbf405f7c126fab11ddc0b9bf516da.zip
SONAR-13368 Bump to prettier@2.7.1
Diffstat (limited to 'server/sonar-web/src/main/js/apps/groups')
-rw-r--r--server/sonar-web/src/main/js/apps/groups/components/App.tsx12
-rw-r--r--server/sonar-web/src/main/js/apps/groups/components/EditMembers.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx26
-rw-r--r--server/sonar-web/src/main/js/apps/groups/components/Form.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/groups/components/List.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/groups/components/ListItem.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/groups/components/__tests__/App-test.tsx16
-rw-r--r--server/sonar-web/src/main/js/apps/groups/components/__tests__/EditMembersModal-test.tsx29
-rw-r--r--server/sonar-web/src/main/js/apps/groups/components/__tests__/List-test.tsx8
9 files changed, 52 insertions, 54 deletions
diff --git a/server/sonar-web/src/main/js/apps/groups/components/App.tsx b/server/sonar-web/src/main/js/apps/groups/components/App.tsx
index ac751d235a8..af2478db6c2 100644
--- a/server/sonar-web/src/main/js/apps/groups/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/groups/components/App.tsx
@@ -57,7 +57,7 @@ export default class App extends React.PureComponent<{}, State> {
this.setState({ loading: true });
return searchUsersGroups({
q: this.state.query,
- ...data
+ ...data,
});
};
@@ -83,13 +83,13 @@ export default class App extends React.PureComponent<{}, State> {
if (currentPaging && currentPaging.total > currentPaging.pageIndex * currentPaging.pageSize) {
try {
const { groups, paging } = await this.makeFetchGroupsRequest({
- p: currentPaging.pageIndex + 1
+ p: currentPaging.pageIndex + 1,
});
if (this.mounted) {
this.setState(({ groups: existingGroups = [] }) => ({
groups: [...existingGroups, ...groups],
loading: false,
- paging
+ paging,
}));
}
} catch {
@@ -166,7 +166,7 @@ export default class App extends React.PureComponent<{}, State> {
description,
id: editedGroup.id,
// pass `name` only if it has changed, otherwise the WS fails
- ...omitNil({ name: name !== editedGroup.name ? name : undefined })
+ ...omitNil({ name: name !== editedGroup.name ? name : undefined }),
};
await updateGroup(data);
@@ -174,9 +174,9 @@ export default class App extends React.PureComponent<{}, State> {
if (this.mounted) {
this.setState(({ groups = [] }: State) => ({
editedGroup: undefined,
- groups: groups.map(group =>
+ groups: groups.map((group) =>
group.name === editedGroup.name ? { ...group, ...data } : group
- )
+ ),
}));
}
};
diff --git a/server/sonar-web/src/main/js/apps/groups/components/EditMembers.tsx b/server/sonar-web/src/main/js/apps/groups/components/EditMembers.tsx
index f67bbe2feb5..124af00a589 100644
--- a/server/sonar-web/src/main/js/apps/groups/components/EditMembers.tsx
+++ b/server/sonar-web/src/main/js/apps/groups/components/EditMembers.tsx
@@ -64,7 +64,8 @@ export default class EditMembers extends React.PureComponent<Props, State> {
aria-label={translate('groups.users.edit')}
className="button-small"
onClick={this.handleMembersClick}
- title={translate('groups.users.edit')}>
+ title={translate('groups.users.edit')}
+ >
<BulletListIcon />
</ButtonIcon>
{this.state.modal && (
diff --git a/server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx b/server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx
index b947ad325df..1cdbe4b051d 100644
--- a/server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx
+++ b/server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx
@@ -24,7 +24,7 @@ import { ResetButtonLink } from '../../../components/controls/buttons';
import Modal from '../../../components/controls/Modal';
import SelectList, {
SelectListFilter,
- SelectListSearchParams
+ SelectListSearchParams,
} from '../../../components/controls/SelectList';
import { translate } from '../../../helpers/l10n';
import { Group, UserSelected } from '../../../types/types';
@@ -51,7 +51,7 @@ export default class EditMembersModal extends React.PureComponent<Props, State>
this.state = {
needToReload: false,
users: [],
- selectedUsers: []
+ selectedUsers: [],
};
}
@@ -69,14 +69,16 @@ export default class EditMembersModal extends React.PureComponent<Props, State>
p: searchParams.page,
ps: searchParams.pageSize,
q: searchParams.query !== '' ? searchParams.query : undefined,
- selected: searchParams.filter
- }).then(data => {
+ selected: searchParams.filter,
+ }).then((data) => {
if (this.mounted) {
- this.setState(prevState => {
+ this.setState((prevState) => {
const more = searchParams.page != null && searchParams.page > 1;
const users = more ? [...prevState.users, ...data.users] : data.users;
- const newSelectedUsers = data.users.filter(user => user.selected).map(user => user.login);
+ const newSelectedUsers = data.users
+ .filter((user) => user.selected)
+ .map((user) => user.login);
const selectedUsers = more
? [...prevState.selectedUsers, ...newSelectedUsers]
: newSelectedUsers;
@@ -87,7 +89,7 @@ export default class EditMembersModal extends React.PureComponent<Props, State>
loading: false,
users,
usersTotalCount: data.total,
- selectedUsers
+ selectedUsers,
};
});
}
@@ -96,12 +98,12 @@ export default class EditMembersModal extends React.PureComponent<Props, State>
handleSelect = (login: string) =>
addUserToGroup({
name: this.props.group.name,
- login
+ login,
}).then(() => {
if (this.mounted) {
this.setState((state: State) => ({
needToReload: true,
- selectedUsers: [...state.selectedUsers, login]
+ selectedUsers: [...state.selectedUsers, login],
}));
}
});
@@ -109,12 +111,12 @@ export default class EditMembersModal extends React.PureComponent<Props, State>
handleUnselect = (login: string) =>
removeUserFromGroup({
name: this.props.group.name,
- login
+ login,
}).then(() => {
if (this.mounted) {
this.setState((state: State) => ({
needToReload: true,
- selectedUsers: without(state.selectedUsers, login)
+ selectedUsers: without(state.selectedUsers, login),
}));
}
});
@@ -146,7 +148,7 @@ export default class EditMembersModal extends React.PureComponent<Props, State>
<div className="modal-body modal-container">
<SelectList
- elements={this.state.users.map(user => user.login)}
+ elements={this.state.users.map((user) => user.login)}
elementsTotalCount={this.state.usersTotalCount}
needToReload={
this.state.needToReload &&
diff --git a/server/sonar-web/src/main/js/apps/groups/components/Form.tsx b/server/sonar-web/src/main/js/apps/groups/components/Form.tsx
index 4e35588f895..4f1fc0a539d 100644
--- a/server/sonar-web/src/main/js/apps/groups/components/Form.tsx
+++ b/server/sonar-web/src/main/js/apps/groups/components/Form.tsx
@@ -44,7 +44,7 @@ export default class Form extends React.PureComponent<Props, State> {
super(props);
this.state = {
description: (props.group && props.group.description) || '',
- name: (props.group && props.group.name) || ''
+ name: (props.group && props.group.name) || '',
};
}
@@ -68,7 +68,8 @@ export default class Form extends React.PureComponent<Props, State> {
header={this.props.header}
onClose={this.props.onClose}
onSubmit={this.handleSubmit}
- size="small">
+ size="small"
+ >
{({ onCloseClick, onFormSubmit, submitting }) => (
<form onSubmit={onFormSubmit}>
<header className="modal-head">
diff --git a/server/sonar-web/src/main/js/apps/groups/components/List.tsx b/server/sonar-web/src/main/js/apps/groups/components/List.tsx
index b985a18e98f..a07ca958903 100644
--- a/server/sonar-web/src/main/js/apps/groups/components/List.tsx
+++ b/server/sonar-web/src/main/js/apps/groups/components/List.tsx
@@ -60,7 +60,7 @@ export default function List(props: Props) {
</tr>
)}
- {sortBy(props.groups, group => group.name.toLowerCase()).map(group => (
+ {sortBy(props.groups, (group) => group.name.toLowerCase()).map((group) => (
<ListItem
group={group}
key={group.name}
diff --git a/server/sonar-web/src/main/js/apps/groups/components/ListItem.tsx b/server/sonar-web/src/main/js/apps/groups/components/ListItem.tsx
index 0b7309f4729..4c24f5dd8a0 100644
--- a/server/sonar-web/src/main/js/apps/groups/components/ListItem.tsx
+++ b/server/sonar-web/src/main/js/apps/groups/components/ListItem.tsx
@@ -20,7 +20,7 @@
import * as React from 'react';
import ActionsDropdown, {
ActionsDropdownDivider,
- ActionsDropdownItem
+ ActionsDropdownItem,
} from '../../../components/controls/ActionsDropdown';
import { translate } from '../../../helpers/l10n';
import { Group } from '../../../types/types';
@@ -62,7 +62,8 @@ export default function ListItem(props: ListItemProps) {
<ActionsDropdownItem
className="js-group-delete"
destructive={true}
- onClick={() => props.onDelete(group)}>
+ onClick={() => props.onDelete(group)}
+ >
{translate('delete')}
</ActionsDropdownItem>
</ActionsDropdown>
diff --git a/server/sonar-web/src/main/js/apps/groups/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/groups/components/__tests__/App-test.tsx
index 31fe6ef3cf1..7e5d25d83f5 100644
--- a/server/sonar-web/src/main/js/apps/groups/components/__tests__/App-test.tsx
+++ b/server/sonar-web/src/main/js/apps/groups/components/__tests__/App-test.tsx
@@ -23,7 +23,7 @@ import {
createGroup,
deleteGroup,
searchUsersGroups,
- updateGroup
+ updateGroup,
} from '../../../../api/user_groups';
import { mockGroup } from '../../../../helpers/testMocks';
import { waitAndUpdate } from '../../../../helpers/testUtils';
@@ -35,7 +35,7 @@ jest.mock('../../../../api/user_groups', () => ({
description: 'Desc foo',
id: 3,
membersCount: 0,
- name: 'Foo'
+ name: 'Foo',
}),
deleteGroup: jest.fn().mockResolvedValue({}),
searchUsersGroups: jest.fn().mockResolvedValue({
@@ -46,18 +46,18 @@ jest.mock('../../../../api/user_groups', () => ({
description: 'Owners of organization foo',
id: 1,
membersCount: 1,
- name: 'Owners'
+ name: 'Owners',
},
{
default: true,
description: 'Members of organization foo',
id: 2,
membersCount: 2,
- name: 'Members'
- }
- ]
+ name: 'Members',
+ },
+ ],
}),
- updateGroup: jest.fn().mockResolvedValue({})
+ updateGroup: jest.fn().mockResolvedValue({}),
}));
beforeEach(() => {
@@ -112,7 +112,7 @@ it('should correctly handle edition', async () => {
description: 'foo',
id: 1,
membersCount: 1,
- name: 'bar'
+ name: 'bar',
});
});
diff --git a/server/sonar-web/src/main/js/apps/groups/components/__tests__/EditMembersModal-test.tsx b/server/sonar-web/src/main/js/apps/groups/components/__tests__/EditMembersModal-test.tsx
index 0cd013f7572..5c60f04477c 100644
--- a/server/sonar-web/src/main/js/apps/groups/components/__tests__/EditMembersModal-test.tsx
+++ b/server/sonar-web/src/main/js/apps/groups/components/__tests__/EditMembersModal-test.tsx
@@ -33,12 +33,12 @@ jest.mock('../../../../api/user_groups', () => ({
{
login: 'foo',
name: 'bar',
- selected: true
- }
- ]
+ selected: true,
+ },
+ ],
}),
addUserToGroup: jest.fn().mockResolvedValue({}),
- removeUserFromGroup: jest.fn().mockResolvedValue({})
+ removeUserFromGroup: jest.fn().mockResolvedValue({}),
}));
beforeEach(() => {
@@ -47,15 +47,12 @@ beforeEach(() => {
it('should render modal properly', async () => {
const wrapper = shallowRender();
- wrapper
- .find(SelectList)
- .props()
- .onSearch({
- query: '',
- filter: SelectListFilter.Selected,
- page: 1,
- pageSize: 100
- });
+ wrapper.find(SelectList).props().onSearch({
+ query: '',
+ filter: SelectListFilter.Selected,
+ page: 1,
+ pageSize: 100,
+ });
await waitAndUpdate(wrapper);
expect(wrapper.state().needToReload).toBe(false);
@@ -70,7 +67,7 @@ it('should render modal properly', async () => {
p: 1,
ps: 100,
q: undefined,
- selected: SelectListFilter.Selected
+ selected: SelectListFilter.Selected,
})
);
@@ -86,7 +83,7 @@ it('should handle selection properly', async () => {
expect(addUserToGroup).toHaveBeenCalledWith(
expect.objectContaining({
name: group.name,
- login: 'toto'
+ login: 'toto',
})
);
expect(wrapper.state().needToReload).toBe(true);
@@ -100,7 +97,7 @@ it('should handle deselection properly', async () => {
expect(removeUserFromGroup).toHaveBeenCalledWith(
expect.objectContaining({
name: group.name,
- login: 'tata'
+ login: 'tata',
})
);
expect(wrapper.state().needToReload).toBe(true);
diff --git a/server/sonar-web/src/main/js/apps/groups/components/__tests__/List-test.tsx b/server/sonar-web/src/main/js/apps/groups/components/__tests__/List-test.tsx
index c5e8c25de54..50c9720a1c0 100644
--- a/server/sonar-web/src/main/js/apps/groups/components/__tests__/List-test.tsx
+++ b/server/sonar-web/src/main/js/apps/groups/components/__tests__/List-test.tsx
@@ -26,18 +26,14 @@ it('should render', () => {
});
it('should not render "Anyone"', () => {
- expect(
- shallowRender(false)
- .find('.js-anyone')
- .exists()
- ).toBe(false);
+ expect(shallowRender(false).find('.js-anyone').exists()).toBe(false);
});
function shallowRender(showAnyone = true) {
const groups = [
{ id: 1, name: 'sonar-users', description: '', membersCount: 55, default: true },
{ id: 2, name: 'foo', description: 'foobar', membersCount: 0, default: false },
- { id: 3, name: 'bar', description: 'barbar', membersCount: 1, default: false }
+ { id: 3, name: 'bar', description: 'barbar', membersCount: 1, default: false },
];
return shallow(
<List