From 5e2596598f97e318f1e4e8bd835b08a011fa0b60 Mon Sep 17 00:00:00 2001 From: Nicolas Clerc Date: Mon, 15 Feb 2016 09:11:35 +0100 Subject: add external slashcommands management --- webapp/utils/async_client.jsx | 9 ++++++--- webapp/utils/client.jsx | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'webapp/utils') diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx index 9c40311cf..3e2a706d4 100644 --- a/webapp/utils/async_client.jsx +++ b/webapp/utils/async_client.jsx @@ -755,12 +755,15 @@ export function savePreferences(preferences, success, error) { ); } -export function getSuggestedCommands(command, suggestionId, component) { - client.listCommands( +export function getSuggestedCommands(command, channelId, suggestionId, component) { + client.listCommands({ + command: command, + channelId: channelId + }, (data) => { var matches = []; data.forEach((cmd) => { - if (('/' + cmd.trigger).indexOf(command) === 0) { + if (('/' + cmd.trigger).indexOf(command) === 0 || cmd.external_management) { let s = '/' + cmd.trigger; let hint = ''; if (cmd.auto_complete_hint && cmd.auto_complete_hint.length !== 0) { diff --git a/webapp/utils/client.jsx b/webapp/utils/client.jsx index 9bd62e22d..ef6d496a2 100644 --- a/webapp/utils/client.jsx +++ b/webapp/utils/client.jsx @@ -1002,12 +1002,13 @@ export function regenCommandToken(data, success, error) { }); } -export function listCommands(success, error) { +export function listCommands(data, success, error) { $.ajax({ url: '/api/v1/commands/list', dataType: 'json', contentType: 'application/json', - type: 'GET', + type: 'POST', + data: JSON.stringify(data), success, error: function onError(xhr, status, err) { var e = handleError('listCommands', xhr, status, err); -- cgit v1.2.3-1-g7c22 From 55a054ab0a55a269965f6baf227a4b4029459d0f Mon Sep 17 00:00:00 2001 From: Nicolas Clerc Date: Mon, 15 Feb 2016 09:15:31 +0100 Subject: fix eslint errors --- webapp/utils/async_client.jsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'webapp/utils') diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx index 3e2a706d4..9a5869f9a 100644 --- a/webapp/utils/async_client.jsx +++ b/webapp/utils/async_client.jsx @@ -756,10 +756,7 @@ export function savePreferences(preferences, success, error) { } export function getSuggestedCommands(command, channelId, suggestionId, component) { - client.listCommands({ - command: command, - channelId: channelId - }, + client.listCommands({command: command, channelId: channelId}, (data) => { var matches = []; data.forEach((cmd) => { -- cgit v1.2.3-1-g7c22 From 81366cd5e528ae10902436a472b479e83521e70c Mon Sep 17 00:00:00 2001 From: Nicolas Clerc Date: Mon, 7 Mar 2016 23:54:08 +0100 Subject: use pre-released features --- webapp/utils/constants.jsx | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'webapp/utils') diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index 32123e369..c1e527702 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -560,6 +560,10 @@ export default { EMBED_TOGGLE: { label: 'embed_toggle', description: 'Show toggle for all embed previews' + }, + SLASHCMD_AUTOCMP: { + label: 'slashCmd_autocmp', + description: 'Enable external application to offer slash command autocomplete' } }, OVERLAY_TIME_DELAY: 400, -- cgit v1.2.3-1-g7c22