diff options
-rw-r--r-- | api/command_shortcuts.go | 9 | ||||
-rw-r--r-- | api/command_shortcuts_test.go | 7 | ||||
-rw-r--r-- | i18n/en.json | 6 | ||||
-rw-r--r-- | webapp/actions/channel_actions.jsx | 8 |
4 files changed, 27 insertions, 3 deletions
diff --git a/api/command_shortcuts.go b/api/command_shortcuts.go index 77f9f4441..0cdf821c8 100644 --- a/api/command_shortcuts.go +++ b/api/command_shortcuts.go @@ -5,6 +5,7 @@ package api import ( "github.com/mattermost/platform/model" + "strings" ) type ShortcutsProvider struct { @@ -33,5 +34,11 @@ func (me *ShortcutsProvider) GetCommand(c *Context) *model.Command { } func (me *ShortcutsProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { - return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T("api.command_shortcuts.list")} + stringId := "api.command_shortcuts.list" + + if strings.Contains(message, "mac") { + stringId = "api.command_shortcuts.list_mac" + } + + return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T(stringId)} } diff --git a/api/command_shortcuts_test.go b/api/command_shortcuts_test.go index a00bd3440..01c56b465 100644 --- a/api/command_shortcuts_test.go +++ b/api/command_shortcuts_test.go @@ -15,7 +15,12 @@ func TestShortcutsCommand(t *testing.T) { channel := th.BasicChannel rs := Client.Must(Client.Command(channel.Id, "/shortcuts ", false)).Data.(*model.CommandResponse) - if !strings.Contains(rs.Text, "ALT") { + if !strings.Contains(rs.Text, "CTRL") { t.Fatal("failed to display shortcuts") } + + rs = Client.Must(Client.Command(channel.Id, "/shortcuts mac", false)).Data.(*model.CommandResponse) + if !strings.Contains(rs.Text, "CMD") { + t.Fatal("failed to display Mac shortcuts") + } } diff --git a/i18n/en.json b/i18n/en.json index ab6dd4f87..8ea570b11 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -556,8 +556,12 @@ "translation": "Displays a list of keyboard shortcuts" }, { + "id": "api.command_shortcuts.list_mac", + "translation": "### Keyboard Shortcuts\n\n#### Navigation\n\nALT+UP: Previous channel or direct message in left hand sidebar\nALT+DOWN: Next channel or direct message in left hand sidebar\nALT+SHIFT+UP: Previous channel or direct message in left hand sidebar with unread messages\nALT+SHIFT+DOWN: Next channel or direct message in left hand sidebar with unread messages\nCMD+K: Open a quick channel switcher dialog\nCMD+SHIFT+A: Open account settings\nCMD+SHIFT+M: Open recent mentions\n\n#### Files\n\nCMD+U: Upload file(s)\n\n#### Messages\n\nCMD+UP (in empty input field): Reprint the previous message or slash command you entered\nCMD+DOWN (in empty input field): Reprint the next message or slash command you entered\nUP (in empty input field): Edit your last message in the current channel\n@[character]+TAB: Autocomplete @username beginning with [character]\n:[character]+TAB: Autocomplete emoji beginning with [character]\n\n#### Built-in Browser Commands\n\nCMD+[: Previous channel in your history\nCMD+]: Next channel in your history\nCMD+PLUS: Increase font size (zoom in)\nCMD+MINUS: Decrease font size (zoom out)\nSHIFT+UP (in input field): Highlight text to the previous line\nSHIFT+DOWN (in input field): Highlight text to the next line\nSHIFT+ENTER (in input field): Create a new line\n" + }, + { "id": "api.command_shortcuts.list", - "translation": "### Keyboard Shortcuts\n\n#### Navigation\n\nALT+UP: Previous channel or direct message in left hand sidebar\nALT+DOWN: Next channel or direct message in left hand sidebar\nALT+SHIFT+UP: Previous channel or direct message in left hand sidebar with unread messages\nALT+SHIFT+DOWN: Next channel or direct message in left hand sidebar with unread messages\nCTRL/CMD+K: Open a quick channel switcher dialog\nCTRL/CMD+SHIFT+A: Open account settings\nCTRL/CMD+SHIFT+M: Open recent mentions\n\n#### Files\n\nCTRL/CMD+U: Upload file(s)\n\n#### Messages\n\nALT+Click: Set message as unread\nESC: Set all messages in channel as read\nCTRL/CMD+UP (in empty input field): Reprint the previous message or slash command you entered\nCTRL/CMD+DOWN (in empty input field): Reprint the next message or slash command you entered\nUP (in empty input field): Edit your last message in the current channel\n@[character]+TAB: Autocomplete @username beginning with [character]\n:[character]+TAB: Autocomplete emoji beginning with [character]\n\n#### Built-in Browser Commands\n\nALT+LEFT/CMD+[: Previous channel in your history\nALT+RIGHT/CMD+]: Next channel in your history\nCTRL/CMD+PLUS: Increase font size (zoom in)\nCTRL/CMD+MINUS: Decrease font size (zoom out)\nSHIFT+UP (in input field): Highlight text to the previous line\nSHIFT+DOWN (in input field): Highlight text to the next line\nSHIFT+ENTER (in input field): Create a new line\n" + "translation": "### Keyboard Shortcuts\n\n#### Navigation\n\nALT+UP: Previous channel or direct message in left hand sidebar\nALT+DOWN: Next channel or direct message in left hand sidebar\nALT+SHIFT+UP: Previous channel or direct message in left hand sidebar with unread messages\nALT+SHIFT+DOWN: Next channel or direct message in left hand sidebar with unread messages\nCTRL+K: Open a quick channel switcher dialog\nCTRL+SHIFT+A: Open account settings\nCTRL+SHIFT+M: Open recent mentions\n\n#### Files\n\nCTRL+U: Upload file(s)\n\n#### Messages\n\nCTRL+UP (in empty input field): Reprint the previous message or slash command you entered\nCTRL+DOWN (in empty input field): Reprint the next message or slash command you entered\nUP (in empty input field): Edit your last message in the current channel\n@[character]+TAB: Autocomplete @username beginning with [character]\n:[character]+TAB: Autocomplete emoji beginning with [character]\n\n#### Built-in Browser Commands\n\nALT+LEFT: Previous channel in your history\nALT+RIGHT: Next channel in your history\nCTRL+PLUS: Increase font size (zoom in)\nCTRL+MINUS: Decrease font size (zoom out)\nSHIFT+UP (in input field): Highlight text to the previous line\nSHIFT+DOWN (in input field): Highlight text to the next line\nSHIFT+ENTER (in input field): Create a new line\n" }, { "id": "api.command_shortcuts.name", diff --git a/webapp/actions/channel_actions.jsx b/webapp/actions/channel_actions.jsx index c02568043..a590f9a9b 100644 --- a/webapp/actions/channel_actions.jsx +++ b/webapp/actions/channel_actions.jsx @@ -28,6 +28,14 @@ export function executeCommand(channelId, message, suggest, success, error) { msg = msg.substring(0, msg.indexOf(' ')).toLowerCase() + msg.substring(msg.indexOf(' '), msg.length); + if (message.indexOf('/shortcuts') !== -1 && Utils.isMac()) { + msg += ' mac'; + } + + if (!Utils.isMac() && message.indexOf('/shortcuts') !== -1 && message.indexOf('mac') !== -1) { + msg = '/shortcuts'; + } + Client.executeCommand(channelId, msg, suggest, success, error); } |