diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-03-30 08:37:36 +0200 |
---|---|---|
committer | Grégoire Aubert <gregaubert@users.noreply.github.com> | 2017-03-31 10:29:27 +0200 |
commit | ad273cfcd1f1dd402e42d1e33cb34f27f5f9aaac (patch) | |
tree | 73ff8cbf734dab83af3f921c95383ac1c9987025 /server/sonar-web/src/main/js/apps | |
parent | f94f052f7eb90d1031b05b55b4b72ea433762860 (diff) | |
download | sonarqube-ad273cfcd1f1dd402e42d1e33cb34f27f5f9aaac.tar.gz sonarqube-ad273cfcd1f1dd402e42d1e33cb34f27f5f9aaac.zip |
SONAR-8996 Restrict the issue assign action to members
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
4 files changed, 55 insertions, 19 deletions
diff --git a/server/sonar-web/src/main/js/apps/component-issues/init.js b/server/sonar-web/src/main/js/apps/component-issues/init.js index 038c2cdd78d..4b5abd4eb72 100644 --- a/server/sonar-web/src/main/js/apps/component-issues/init.js +++ b/server/sonar-web/src/main/js/apps/component-issues/init.js @@ -45,7 +45,8 @@ const init = function({ el, component, currentUser }) { contextQuery: { componentUuids: this.config.resource }, contextComponentUuid: this.config.resource, contextComponentName: this.config.resourceName, - contextComponentQualifier: this.config.resourceQualifier + contextComponentQualifier: this.config.resourceQualifier, + contextOrganization: component.organization }); this.updateContextFacets(); this.list = new Issues(); diff --git a/server/sonar-web/src/main/js/apps/issues/BulkChangeForm.js b/server/sonar-web/src/main/js/apps/issues/BulkChangeForm.js index 92e51cb2d7c..1c9b447b231 100644 --- a/server/sonar-web/src/main/js/apps/issues/BulkChangeForm.js +++ b/server/sonar-web/src/main/js/apps/issues/BulkChangeForm.js @@ -18,12 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // @flow -import { sortBy } from 'lodash'; +import { debounce, sortBy } from 'lodash'; import ModalForm from '../../components/common/modal-form'; import Template from './templates/BulkChangeForm.hbs'; import getCurrentUserFromStore from '../../app/utils/getCurrentUserFromStore'; import { searchIssues, searchIssueTags, bulkChangeIssues } from '../../api/issues'; import { searchUsers } from '../../api/users'; +import { searchMembers } from '../../api/organizations'; import { translate, translateWithParameters } from '../../helpers/l10n'; const LIMIT = 500; @@ -71,6 +72,32 @@ export default ModalForm.extend({ }); }, + assigneeSearch(defaultOptions) { + const { context } = this.options; + return debounce( + query => { + if (query.term.length === 0) { + query.callback({ results: defaultOptions }); + } else if (query.term.length >= MINIMUM_QUERY_LENGTH) { + const onSuccess = r => { + query.callback({ + results: r.users.map(user => ({ + id: user.login, + text: `${user.name} (${user.login})` + })) + }); + }; + if (context.isContext) { + searchMembers({ organization: context.organization, q: query.term }).then(onSuccess); + } else { + searchUsers(query.term).then(onSuccess); + } + } + }, + 250 + ); + }, + prepareAssigneeSelect() { const input = this.$('#assignee'); if (input.length) { @@ -96,20 +123,7 @@ export default ModalForm.extend({ formatSearching: () => translate('select2.searching'), formatInputTooShort: () => translateWithParameters('select2.tooShort', MINIMUM_QUERY_LENGTH), - query: query => { - if (query.term.length === 0) { - query.callback({ results: defaultOptions }); - } else if (query.term.length >= MINIMUM_QUERY_LENGTH) { - searchUsers(query.term).then(r => { - query.callback({ - results: r.users.map(user => ({ - id: user.login, - text: `${user.name} (${user.login})` - })) - }); - }); - } - } + query: this.assigneeSearch(defaultOptions) }); input.on('change', () => this.$('#assign-action').prop('checked', true)); diff --git a/server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js index 0df30cbced8..597afcaee47 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js @@ -25,16 +25,28 @@ import Template from '../templates/facets/issues-assignee-facet.hbs'; export default CustomValuesFacet.extend({ template: Template, + initialize() { + this.context = { + isContext: this.options.app.state.get('isContext'), + organization: this.options.app.state.get('contextOrganization') + }; + }, + getUrl() { - return window.baseUrl + '/api/users/search'; + return window.baseUrl + + (this.context.isContext ? '/api/organizations/search_members' : '/api/users/search'); }, prepareAjaxSearch() { return { quietMillis: 300, url: this.getUrl(), - data(term, page) { - return { q: term, p: page }; + data: (term, page) => { + if (this.context.isContext && this.context.organization) { + return { q: term, p: page, organization: this.context.organization }; + } else { + return { q: term, p: page }; + } }, results: window.usersToSelect2 }; diff --git a/server/sonar-web/src/main/js/apps/issues/workspace-header-view.js b/server/sonar-web/src/main/js/apps/issues/workspace-header-view.js index 877ace41d16..0fccbb3ab65 100644 --- a/server/sonar-web/src/main/js/apps/issues/workspace-header-view.js +++ b/server/sonar-web/src/main/js/apps/issues/workspace-header-view.js @@ -25,6 +25,13 @@ import { getOrganization, areThereCustomOrganizations } from '../../store/organi export default WorkspaceHeaderView.extend({ template: Template, + initialize() { + this.context = { + isContext: this.options.app.state.get('isContext'), + organization: this.options.app.state.get('contextOrganization') + }; + }, + events() { return { ...WorkspaceHeaderView.prototype.events.apply(this, arguments), @@ -95,6 +102,7 @@ export default WorkspaceHeaderView.extend({ const query = this.options.app.controller.getQueryAsObject(); new BulkChangeForm({ query, + context: this.context, onChange: () => this.afterBulkChange() }).render(); }, @@ -105,6 +113,7 @@ export default WorkspaceHeaderView.extend({ const query = { issues: selectedKeys.join() }; new BulkChangeForm({ query, + context: this.context, onChange: () => this.afterBulkChange() }).render(); }, |