From ecb6fd8769df164774662863258b382d42aad9eb Mon Sep 17 00:00:00 2001 From: David Lu Date: Mon, 22 Aug 2016 15:19:29 -0400 Subject: Split /shortcuts programmatically (#3850) --- api/command.go | 1 + api/command_shortcuts.go | 22 ++++++++++++++++++---- i18n/en.json | 32 ++++++++++++++++++++++++++++---- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/api/command.go b/api/command.go index 45355f092..7e0708a4d 100644 --- a/api/command.go +++ b/api/command.go @@ -254,6 +254,7 @@ func handleResponse(c *Context, w http.ResponseWriter, response *model.CommandRe } else if response.ResponseType == model.COMMAND_RESPONSE_TYPE_EPHEMERAL && response.Text != "" { post.Message = response.Text post.CreateAt = model.GetMillis() + post.UserId = c.Session.UserId SendEphemeralPost( c.TeamId, c.Session.UserId, diff --git a/api/command_shortcuts.go b/api/command_shortcuts.go index 0cdf821c8..dfbb7071d 100644 --- a/api/command_shortcuts.go +++ b/api/command_shortcuts.go @@ -4,8 +4,10 @@ package api import ( - "github.com/mattermost/platform/model" + "bytes" "strings" + + "github.com/mattermost/platform/model" ) type ShortcutsProvider struct { @@ -34,11 +36,23 @@ func (me *ShortcutsProvider) GetCommand(c *Context) *model.Command { } func (me *ShortcutsProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { - stringId := "api.command_shortcuts.list" + shortcutIds := [4]string{ + "api.command_shortcuts.nav", + "api.command_shortcuts.files", + "api.command_shortcuts.msgs", + "api.command_shortcuts.browser", + } + var buffer bytes.Buffer if strings.Contains(message, "mac") { - stringId = "api.command_shortcuts.list_mac" + for _, element := range shortcutIds { + buffer.WriteString(c.T(element + "_mac")) + } + } else { + for _, element := range shortcutIds { + buffer.WriteString(c.T(element)) + } } - return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T(stringId)} + return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: buffer.String()} } diff --git a/i18n/en.json b/i18n/en.json index a4d01239b..f0f09fd1b 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -560,12 +560,36 @@ "translation": "Displays a list of keyboard shortcuts" }, { - "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+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\nESC: Mark all messages in the current channel as read\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.nav", + "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" }, { - "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\nESC: Mark all messages in the current channel as read\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.files", + "translation": "#### Files\n\nCTRL+U: Upload file(s)\n\n" + }, + { + "id": "api.command_shortcuts.msgs", + "translation": "#### Messages\n\nESC: Mark all messages in the current channel as read\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" + }, + { + "id": "api.command_shortcuts.browser", + "translation": "#### 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.nav_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" + }, + { + "id": "api.command_shortcuts.files_mac", + "translation": "#### Files\n\nCMD+U: Upload file(s)\n\n" + }, + { + "id": "api.command_shortcuts.msgs_mac", + "translation": "#### Messages\n\nESC: Mark all messages in the current channel as read\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" + }, + { + "id": "api.command_shortcuts.browser_mac", + "translation": "#### 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.name", -- cgit v1.2.3-1-g7c22