diff options
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentAction.java | 3 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.js | 52 |
2 files changed, 30 insertions, 25 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentAction.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentAction.java index 82cebbd754c..c761ba3a480 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentAction.java @@ -247,6 +247,7 @@ public class ComponentAction implements NavigationWsAction { private void writeConfigPageAccess(JsonWriter json, boolean isProjectAdmin, ComponentDto component, OrganizationDto organization) { boolean isProject = Qualifiers.PROJECT.equals(component.qualifier()); boolean showManualMeasures = isProjectAdmin && !Qualifiers.DIRECTORY.equals(component.qualifier()); + boolean showBackgroundTasks = isProjectAdmin && (isProject || Qualifiers.VIEW.equals(component.qualifier())); boolean isQualityProfileAdmin = userSession.hasPermission(OrganizationPermission.ADMINISTER_QUALITY_PROFILES, component.getOrganizationUuid()); boolean isQualityGateAdmin = userSession.hasPermission(OrganizationPermission.ADMINISTER_QUALITY_GATES, component.getOrganizationUuid()); boolean isOrganizationAdmin = userSession.hasPermission(OrganizationPermission.ADMINISTER, component.getOrganizationUuid()); @@ -259,7 +260,7 @@ public class ComponentAction implements NavigationWsAction { json.prop("showPermissions", isProjectAdmin && componentTypeHasProperty(component, PROPERTY_HAS_ROLE_POLICY)); json.prop("showHistory", isProjectAdmin && componentTypeHasProperty(component, PROPERTY_MODIFIABLE_HISTORY)); json.prop("showUpdateKey", isProjectAdmin && componentTypeHasProperty(component, PROPERTY_UPDATABLE_KEY)); - json.prop("showBackgroundTasks", isProjectAdmin); + json.prop("showBackgroundTasks", showBackgroundTasks); json.prop("canApplyPermissionTemplate", isOrganizationAdmin); json.prop("canUpdateProjectVisibilityToPrivate", isProjectAdmin && billingValidations.canUpdateProjectVisibilityToPrivate(new BillingValidations.Organization(organization.getKey(), organization.getUuid()))); diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.js b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.js index eb43936221b..0903d35eaa9 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.js +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.js @@ -54,10 +54,6 @@ export default class ComponentNavMenu extends React.PureComponent { return qualifier === 'VW' || qualifier === 'SVW'; } - shouldShowAdministration() { - return Object.keys(this.props.conf).some(key => this.props.conf[key]); - } - renderDashboardLink() { const pathname = this.isView() ? '/view' : '/dashboard'; return ( @@ -129,9 +125,11 @@ export default class ComponentNavMenu extends React.PureComponent { } renderAdministration() { - if (!this.shouldShowAdministration()) { + const adminLinks = this.renderAdministrationLinks(); + if (!adminLinks.some(link => link != null)) { return null; } + const isSettingsActive = SETTINGS_URLS.some(url => window.location.href.indexOf(url) !== -1); const className = 'dropdown' + (isSettingsActive ? ' active' : ''); return ( @@ -145,27 +143,33 @@ export default class ComponentNavMenu extends React.PureComponent { <i className="icon-dropdown" /> </a> <ul className="dropdown-menu"> - {this.renderSettingsLink()} - {this.renderProfilesLink()} - {this.renderQualityGateLink()} - {this.renderCustomMeasuresLink()} - {this.renderLinksLink()} - {this.renderPermissionsLink()} - {this.renderBackgroundTasksLink()} - {this.renderUpdateKeyLink()} - {this.renderAdminExtensions()} - {this.renderDeletionLink()} + {adminLinks} </ul> </li> ); } + renderAdministrationLinks() { + return [ + this.renderSettingsLink(), + this.renderProfilesLink(), + this.renderQualityGateLink(), + this.renderCustomMeasuresLink(), + this.renderLinksLink(), + this.renderPermissionsLink(), + this.renderBackgroundTasksLink(), + this.renderUpdateKeyLink(), + ...this.renderAdminExtensions(), + this.renderDeletionLink() + ]; + } + renderSettingsLink() { if (!this.props.conf.showSettings) { return null; } return ( - <li> + <li key="settings"> <Link to={{ pathname: '/project/settings', query: { id: this.props.component.key } }} activeClassName="active"> @@ -180,7 +184,7 @@ export default class ComponentNavMenu extends React.PureComponent { return null; } return ( - <li> + <li key="profiles"> <Link to={{ pathname: '/project/quality_profiles', query: { id: this.props.component.key } }} activeClassName="active"> @@ -195,7 +199,7 @@ export default class ComponentNavMenu extends React.PureComponent { return null; } return ( - <li> + <li key="quality_gate"> <Link to={{ pathname: '/project/quality_gate', query: { id: this.props.component.key } }} activeClassName="active"> @@ -210,7 +214,7 @@ export default class ComponentNavMenu extends React.PureComponent { return null; } return ( - <li> + <li key="custom_measures"> <Link to={{ pathname: '/custom_measures', query: { id: this.props.component.key } }} activeClassName="active"> @@ -225,7 +229,7 @@ export default class ComponentNavMenu extends React.PureComponent { return null; } return ( - <li> + <li key="links"> <Link to={{ pathname: '/project/links', query: { id: this.props.component.key } }} activeClassName="active"> @@ -240,7 +244,7 @@ export default class ComponentNavMenu extends React.PureComponent { return null; } return ( - <li> + <li key="permissions"> <Link to={{ pathname: '/project_roles', query: { id: this.props.component.key } }} activeClassName="active"> @@ -255,7 +259,7 @@ export default class ComponentNavMenu extends React.PureComponent { return null; } return ( - <li> + <li key="background_tasks"> <Link to={{ pathname: '/project/background_tasks', query: { id: this.props.component.key } }} activeClassName="active"> @@ -270,7 +274,7 @@ export default class ComponentNavMenu extends React.PureComponent { return null; } return ( - <li> + <li key="update_key"> <Link to={{ pathname: '/project/key', query: { id: this.props.component.key } }} activeClassName="active"> @@ -292,7 +296,7 @@ export default class ComponentNavMenu extends React.PureComponent { } return ( - <li> + <li key="project_delete"> <Link to={{ pathname: '/project/deletion', query: { id: this.props.component.key } }} activeClassName="active"> |