Skip to content

Commit

Permalink
made /shortcuts separate for mac (#3571)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLu1997 authored and coreyhulen committed Jul 14, 2016
1 parent 0b200cc commit 34077a4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
9 changes: 8 additions & 1 deletion api/command_shortcuts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package api

import (
"github.com/mattermost/platform/model"
"strings"
)

type ShortcutsProvider struct {
Expand Down Expand Up @@ -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)}
}
7 changes: 6 additions & 1 deletion api/command_shortcuts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
6 changes: 5 additions & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,13 @@
"id": "api.command_shortcuts.desc",
"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",
Expand Down
8 changes: 8 additions & 0 deletions webapp/actions/channel_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 34077a4

Please sign in to comment.