From: Stas Vilchik Date: Wed, 30 Sep 2015 13:12:03 +0000 (+0200) Subject: SONAR-6801 apply feedback X-Git-Tag: 5.2-RC1~181 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=378241ddb2f0fc4f566a37fb932887ed0739ce8f;p=sonarqube.git SONAR-6801 apply feedback --- diff --git a/server/sonar-web/src/main/js/apps/permission-templates/groups-view.js b/server/sonar-web/src/main/js/apps/permission-templates/groups-view.js index 21831f45c31..c13d978d9d3 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/groups-view.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/groups-view.js @@ -1,9 +1,10 @@ +import _ from 'underscore'; import Modal from '../../components/common/modals'; import '../../components/common/select-list'; import './templates'; function getSearchUrl (permission, permissionTemplate) { - return baseUrl + '/api/permissions/template_groups?ps=100&permission=' + permission + + return baseUrl + '/api/permissions/template_groups?ps=100&permission=' + permission.key + '&templateId=' + permissionTemplate.id; } @@ -25,7 +26,7 @@ export default Modal.extend({ selectUrl: baseUrl + '/api/permissions/add_group_to_template', deselectUrl: baseUrl + '/api/permissions/remove_group_from_template', extra: { - permission: this.options.permission, + permission: this.options.permission.key, templateId: this.options.permissionTemplate.id }, selectParameter: 'groupName', @@ -46,6 +47,7 @@ export default Modal.extend({ serializeData: function () { return _.extend(Modal.prototype.serializeData.apply(this, arguments), { + permissionName: this.options.permission.name, permissionTemplateName: this.options.permissionTemplate.name }); } diff --git a/server/sonar-web/src/main/js/apps/permission-templates/permission-template-defaults.jsx b/server/sonar-web/src/main/js/apps/permission-templates/permission-template-defaults.jsx index 2cfb51b4123..39b9ec52021 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/permission-template-defaults.jsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/permission-template-defaults.jsx @@ -4,13 +4,19 @@ import QualifierIcon from '../../components/shared/qualifier-icon'; export default React.createClass({ propTypes: { - permissionTemplate: React.PropTypes.object.isRequired + permissionTemplate: React.PropTypes.object.isRequired, + topQualifiers: React.PropTypes.array.isRequired }, - render() { - if (_.size(this.props.permissionTemplate.defaultFor) === 0) { - return null; - } + renderIfSingleTopQualifier() { + return ( + + ); + }, + + renderIfMultipleTopQualifiers() { let defaults = this.props.permissionTemplate.defaultFor.map(qualifier => { return
  •  {window.t('qualifier', qualifier)}
  • ; }); @@ -20,5 +26,14 @@ export default React.createClass({ {defaults} ); + }, + + render() { + if (_.size(this.props.permissionTemplate.defaultFor) === 0) { + return null; + } + return this.props.topQualifiers.length === 1 ? + this.renderIfSingleTopQualifier() : + this.renderIfMultipleTopQualifiers(); } }); diff --git a/server/sonar-web/src/main/js/apps/permission-templates/permission-template-set-defaults.jsx b/server/sonar-web/src/main/js/apps/permission-templates/permission-template-set-defaults.jsx index 6bda07a46b2..87a75de168b 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/permission-template-set-defaults.jsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/permission-template-set-defaults.jsx @@ -19,12 +19,19 @@ export default React.createClass({ setDefaultPermissionTemplate(this.props.permissionTemplate.id, qualifier).done(() => this.props.refresh()); }, - render() { - let availableQualifiers = this.getAvailableQualifiers(); - if (availableQualifiers.length === 0) { - return null; - } + renderIfSingleTopQualifier(availableQualifiers) { + let qualifiers = availableQualifiers.map(qualifier => { + return ( + + Set Default + + ); + }); + return {qualifiers}; + }, + + renderIfMultipleTopQualifiers(availableQualifiers) { let qualifiers = availableQualifiers.map(qualifier => { return (
  • @@ -43,5 +50,16 @@ export default React.createClass({ ); + }, + + render() { + let availableQualifiers = this.getAvailableQualifiers(); + if (availableQualifiers.length === 0) { + return null; + } + + return this.props.topQualifiers.length === 1 ? + this.renderIfSingleTopQualifier(availableQualifiers) : + this.renderIfMultipleTopQualifiers(availableQualifiers); } }); diff --git a/server/sonar-web/src/main/js/apps/permission-templates/permission-template.jsx b/server/sonar-web/src/main/js/apps/permission-templates/permission-template.jsx index 71645b34d75..ced79afd895 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/permission-template.jsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/permission-template.jsx @@ -72,7 +72,7 @@ export default React.createClass({ Users {p.usersCount} - @@ -80,7 +80,7 @@ export default React.createClass({ Groups {p.groupsCount} - @@ -97,7 +97,9 @@ export default React.createClass({ {permissions} {this.renderAssociation()} - +
    -

    Update Groups of "{{permissionTemplateName}}"

    +

    Update Groups for "{{permissionName}}" Permission of "{{permissionTemplateName}}" Template