diff options
Diffstat (limited to 'server')
5 files changed, 34 insertions, 38 deletions
diff --git a/server/sonar-web/src/main/js/api/organizations.ts b/server/sonar-web/src/main/js/api/organizations.ts index cc321f31678..b793d7412c3 100644 --- a/server/sonar-web/src/main/js/api/organizations.ts +++ b/server/sonar-web/src/main/js/api/organizations.ts @@ -98,13 +98,6 @@ export function removeMember(data: { login: string; organization: string }): Pro return post('/api/organizations/remove_member', data); } -export function changeProjectVisibility( - organization: string, - projectVisibility: string -): Promise<void> { - return post('/api/organizations/update_project_visibility', { organization, projectVisibility }); -} - export interface OrganizationBilling { nclocCount: number; subscription: { diff --git a/server/sonar-web/src/main/js/api/permissions.ts b/server/sonar-web/src/main/js/api/permissions.ts index 465d4fedea3..189ed4ca8de 100644 --- a/server/sonar-web/src/main/js/api/permissions.ts +++ b/server/sonar-web/src/main/js/api/permissions.ts @@ -189,7 +189,7 @@ export function getPermissionsUsersForComponent( if (organization) { data.organization = organization; } - return getJSON('/api/permissions/users', data).then(r => r.users); + return getJSON('/api/permissions/users', data).then(r => r.users, throwGlobalError); } export interface PermissionGroup { @@ -215,7 +215,7 @@ export function getPermissionsGroupsForComponent( if (organization) { data.organization = organization; } - return getJSON('/api/permissions/groups', data).then(r => r.groups); + return getJSON('/api/permissions/groups', data).then(r => r.groups, throwGlobalError); } export function getGlobalPermissionsUsers( @@ -292,6 +292,18 @@ export function getPermissionTemplateGroups( return getJSON('/api/permissions/template_groups', data).then(r => r.groups); } -export function changeProjectVisibility(project: string, visibility: string): Promise<void> { - return post('/api/projects/update_visibility', { project, visibility }); +export function changeProjectVisibility( + project: string, + visibility: string +): Promise<void | Response> { + return post('/api/projects/update_visibility', { project, visibility }).catch(throwGlobalError); +} + +export function changeProjectDefaultVisibility( + organization: string, + projectVisibility: string +): Promise<void | Response> { + return post('/api/projects/update_default_visibility', { organization, projectVisibility }).catch( + throwGlobalError + ); } diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/App.js b/server/sonar-web/src/main/js/apps/permissions/project/components/App.js index feb65a7220a..5815264b6a4 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/App.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/App.js @@ -127,19 +127,11 @@ export default class App extends React.PureComponent { ) : Promise.resolve([]); - Promise.all([getUsers, getGroups]).then( - responses => { - if (this.mounted) { - this.setState({ loading: false, groups: responses[1], users: responses[0] }); - } - }, - error => { - if (this.mounted) { - this.props.onRequestFail(error); - this.setState({ loading: false }); - } + Promise.all([getUsers, getGroups]).then(responses => { + if (this.mounted) { + this.setState({ loading: false, groups: responses[1], users: responses[0] }); } - ); + }, this.stopLoading); } }; @@ -307,7 +299,6 @@ export default class App extends React.PureComponent { }, error => { this.props.onComponentChange({ visibility: 'private' }); - this.props.onRequestFail(error); } ); }; @@ -320,7 +311,6 @@ export default class App extends React.PureComponent { }, error => { this.props.onComponentChange({ visibility: 'public' }); - this.props.onRequestFail(error); } ); }; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/AppContainer.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/AppContainer.tsx index 1ad68ed7e8a..26fb48fa1c8 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/AppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/AppContainer.tsx @@ -22,10 +22,9 @@ import { connect } from 'react-redux'; import App from './App'; import forSingleOrganization from '../organizations/forSingleOrganization'; import { Organization, LoggedInUser } from '../../app/types'; -import { onFail } from '../../store/rootActions'; import { getAppState, getOrganizationByKey, getCurrentUser } from '../../store/rootReducer'; import { receiveOrganizations } from '../../store/organizations/duck'; -import { changeProjectVisibility } from '../../api/organizations'; +import { changeProjectDefaultVisibility } from '../../api/permissions'; import { fetchOrganization } from '../../apps/organizations/actions'; interface StateProps { @@ -91,8 +90,7 @@ const onVisibilityChange = (organization: Organization, visibility: string) => ( ) => { const currentVisibility = organization.projectVisibility; dispatch(receiveOrganizations([{ ...organization, projectVisibility: visibility }])); - changeProjectVisibility(organization.key, visibility).catch(error => { - onFail(dispatch)(error); + changeProjectDefaultVisibility(organization.key, visibility).catch(() => { dispatch(receiveOrganizations([{ ...organization, projectVisibility: currentVisibility }])); }); }; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx index 90015c3cf5d..2e5411384af 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx @@ -22,6 +22,7 @@ import ChangeVisibilityForm from './ChangeVisibilityForm'; import { Organization, Visibility } from '../../app/types'; import { EditButton, Button } from '../../components/ui/buttons'; import { translate } from '../../helpers/l10n'; +import { isSonarCloud } from '../../helpers/system'; export interface Props { hasProvisionPermission?: boolean; @@ -53,16 +54,18 @@ export default class Header extends React.PureComponent<Props, State> { <h1 className="page-title">{translate('projects_management')}</h1> <div className="page-actions"> - <span className="big-spacer-right"> - <span className="text-middle"> - {translate('organization.default_visibility_of_new_projects')}{' '} - <strong>{translate('visibility', organization.projectVisibility)}</strong> + {!isSonarCloud() && ( + <span className="big-spacer-right"> + <span className="text-middle"> + {translate('organization.default_visibility_of_new_projects')}{' '} + <strong>{translate('visibility', organization.projectVisibility)}</strong> + </span> + <EditButton + className="js-change-visibility spacer-left button-small" + onClick={this.handleChangeVisibilityClick} + /> </span> - <EditButton - className="js-change-visibility spacer-left button-small" - onClick={this.handleChangeVisibilityClick} - /> - </span> + )} {this.props.hasProvisionPermission && ( <Button id="create-project" onClick={this.props.onProjectCreate}> {translate('qualifiers.create.TRK')} |