loadHolders = () => {
this.setState({ loading: true });
- return this.loadUsersAndGroups().then(([usersResponse, groupsResponse]) => {
+
+ this.loadUsersAndGroups().then(([usersResponse, groupsResponse]) => {
if (this.mounted) {
this.setState({
groups: groupsResponse.groups,
handleLoadMore = () => {
const { usersPaging, groupsPaging } = this.state;
this.setState({ loading: true });
- return this.loadUsersAndGroups(
+
+ this.loadUsersAndGroups(
usersPaging ? usersPaging.pageIndex + 1 : 1,
groupsPaging ? groupsPaging.pageIndex + 1 : 1
).then(([usersResponse, groupsResponse]) => {
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { without } from 'lodash';
+import { noop, without } from 'lodash';
import * as React from 'react';
import { Helmet } from 'react-helmet-async';
import * as api from '../../../../api/permissions';
import { FilterOption } from '../../../../components/permissions/SearchForm';
import { translate } from '../../../../helpers/l10n';
import {
- convertToPermissionDefinitions,
PERMISSIONS_ORDER_BY_QUALIFIER,
+ convertToPermissionDefinitions,
} from '../../../../helpers/permissions';
import { ComponentContextShape, Visibility } from '../../../../types/component';
import { Permissions } from '../../../../types/permissions';
loadHolders = () => {
this.setState({ loading: true });
- return this.loadUsersAndGroups().then(([usersResponse, groupsResponse]) => {
+
+ this.loadUsersAndGroups().then(([usersResponse, groupsResponse]) => {
if (this.mounted) {
this.setState({
groups: groupsResponse.groups,
handleLoadMore = () => {
const { usersPaging, groupsPaging } = this.state;
this.setState({ loading: true });
- return this.loadUsersAndGroups(
+
+ this.loadUsersAndGroups(
usersPaging ? usersPaging.pageIndex + 1 : 1,
groupsPaging ? groupsPaging.pageIndex + 1 : 1
).then(([usersResponse, groupsResponse]) => {
handleTurnProjectToPublic = () => {
this.setState({ loading: true });
- return api.changeProjectVisibility(this.props.component.key, Visibility.Public).then(() => {
- this.props.onComponentChange({ visibility: Visibility.Public });
- this.loadHolders();
- });
+
+ api
+ .changeProjectVisibility(this.props.component.key, Visibility.Public)
+ .then(() => {
+ this.props.onComponentChange({ visibility: Visibility.Public });
+ this.loadHolders();
+ })
+ .catch(noop);
};
turnProjectToPrivate = () => {
this.setState({ loading: true });
- return api.changeProjectVisibility(this.props.component.key, Visibility.Private).then(() => {
- this.props.onComponentChange({ visibility: Visibility.Private });
- this.loadHolders();
- });
+
+ api
+ .changeProjectVisibility(this.props.component.key, Visibility.Private)
+ .then(() => {
+ this.props.onComponentChange({ visibility: Visibility.Private });
+ this.loadHolders();
+ })
+ .catch(noop);
};
openDisclaimer = () => {
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import { noop } from 'lodash';
import * as React from 'react';
import {
countBoundProjects,
});
};
- handleCheck = async (definitionKey: string, alertSuccess = true) => {
+ handleCheck = (definitionKey: string, alertSuccess = true) => {
this.setState(({ definitionStatus }) => {
definitionStatus[definitionKey] = {
...definitionStatus[definitionKey],
return { definitionStatus: { ...definitionStatus } };
});
- let type: AlmSettingsBindingStatusType;
- let failureMessage = '';
-
- try {
- failureMessage = await validateAlmSettings(definitionKey);
- type = failureMessage
- ? AlmSettingsBindingStatusType.Failure
- : AlmSettingsBindingStatusType.Success;
- } catch (_) {
- type = AlmSettingsBindingStatusType.Warning;
- }
-
- if (this.mounted) {
- this.setState(({ definitionStatus }) => {
- definitionStatus[definitionKey] = {
- alertSuccess,
- failureMessage,
- type,
- };
-
- return { definitionStatus: { ...definitionStatus } };
- });
- }
+ validateAlmSettings(definitionKey)
+ .then(
+ (failureMessage) => {
+ const type = failureMessage
+ ? AlmSettingsBindingStatusType.Failure
+ : AlmSettingsBindingStatusType.Success;
+
+ return { type, failureMessage };
+ },
+ () => ({ type: AlmSettingsBindingStatusType.Warning, failureMessage: '' })
+ )
+ .then(({ type, failureMessage }) => {
+ if (this.mounted) {
+ this.setState(({ definitionStatus }) => {
+ definitionStatus[definitionKey] = {
+ alertSuccess,
+ failureMessage,
+ type,
+ };
+
+ return { definitionStatus: { ...definitionStatus } };
+ });
+ }
+ })
+ .catch(noop);
};
render() {