diff options
5 files changed, 67 insertions, 20 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(); }, diff --git a/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js b/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js index c567b9edb92..a3e81ef0dae 100644 --- a/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js +++ b/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js @@ -24,6 +24,7 @@ import Template from '../templates/issue-assign-form.hbs'; import OptionTemplate from '../templates/issue-assign-form-option.hbs'; import { translate } from '../../../helpers/l10n'; import getCurrentUserFromStore from '../../../app/utils/getCurrentUserFromStore'; +import { areThereCustomOrganizations } from '../../../store/organizations/utils'; export default ActionOptionsView.extend({ template: Template, @@ -41,6 +42,9 @@ export default ActionOptionsView.extend({ initialize() { ActionOptionsView.prototype.initialize.apply(this, arguments); this.assignees = null; + this.organizationKey = areThereCustomOrganizations() + ? this.model.get('projectOrganization') + : null; this.debouncedSearch = debounce(this.search, 250); }, @@ -124,7 +128,14 @@ export default ActionOptionsView.extend({ search(query) { const that = this; if (query.length > 1) { - $.get(window.baseUrl + '/api/users/search', { q: query }).done(data => { + const searchUrl = this.organizationKey != null + ? '/organizations/search_members' + : '/users/search'; + const queryData = { q: query }; + if (this.organizationKey != null) { + queryData.organization = this.organizationKey; + } + $.get(window.baseUrl + '/api' + searchUrl, queryData).done(data => { that.resetAssignees(data.users); }); } else { |