PLT-4697 Update channel switcher to autocomplete all users on the system (#4624)
* Add autocomplete API for system-wide users * Update channel switcher to autocomplete all users on the system
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
ad52183248
Коммит
02d581c159
@@ -318,6 +318,24 @@ export function autocompleteUsersInTeam(username, success, error) {
|
||||
);
|
||||
}
|
||||
|
||||
export function autocompleteUsers(username, success, error) {
|
||||
Client.autocompleteUsers(
|
||||
username,
|
||||
(data) => {
|
||||
if (success) {
|
||||
success(data);
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
AsyncClient.dispatchError(err, 'autocompleteUsers');
|
||||
|
||||
if (error) {
|
||||
error(err);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function updateUser(username, success, error) {
|
||||
Client.updateUser(
|
||||
username,
|
||||
|
||||
@@ -1112,7 +1112,7 @@ export default class Client {
|
||||
set(this.defaultHeaders).
|
||||
type('application/json').
|
||||
accept('application/json').
|
||||
end(this.handleResponse.bind(this, 'autocompleteUsers', success, error));
|
||||
end(this.handleResponse.bind(this, 'autocompleteUsersInChannel', success, error));
|
||||
}
|
||||
|
||||
autocompleteUsersInTeam(term, success, error) {
|
||||
@@ -1121,6 +1121,15 @@ export default class Client {
|
||||
set(this.defaultHeaders).
|
||||
type('application/json').
|
||||
accept('application/json').
|
||||
end(this.handleResponse.bind(this, 'autocompleteUsersInTeam', success, error));
|
||||
}
|
||||
|
||||
autocompleteUsers(term, success, error) {
|
||||
request.
|
||||
get(`${this.getUsersRoute()}/autocomplete?term=${encodeURIComponent(term)}`).
|
||||
set(this.defaultHeaders).
|
||||
type('application/json').
|
||||
accept('application/json').
|
||||
end(this.handleResponse.bind(this, 'autocompleteUsers', success, error));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import Suggestion from './suggestion.jsx';
|
||||
import ChannelStore from 'stores/channel_store.jsx';
|
||||
import UserStore from 'stores/user_store.jsx';
|
||||
|
||||
import {autocompleteUsersInTeam} from 'actions/user_actions.jsx';
|
||||
import {autocompleteUsers} from 'actions/user_actions.jsx';
|
||||
|
||||
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
|
||||
import {Constants, ActionTypes} from 'utils/constants.jsx';
|
||||
@@ -64,10 +64,9 @@ export default class SwitchChannelProvider {
|
||||
const channels = [];
|
||||
|
||||
function autocomplete() {
|
||||
autocompleteUsersInTeam(
|
||||
autocompleteUsers(
|
||||
channelPrefix,
|
||||
(data) => {
|
||||
const users = data.in_team;
|
||||
(users) => {
|
||||
const currentId = UserStore.getCurrentId();
|
||||
|
||||
for (const id of Object.keys(allChannels)) {
|
||||
|
||||
@@ -602,6 +602,21 @@ describe('Client.User', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('autocompleteUsers', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
TestHelper.basicClient().autocompleteUsers(
|
||||
'uid',
|
||||
function(data) {
|
||||
assert.equal(data != null, true);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getStatusesByIds', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
var ids = [];
|
||||
|
||||
Ссылка в новой задаче
Block a user