Skip to content

Commit

Permalink
Proposed text updates for /jira slash commands (#41)
Browse files Browse the repository at this point in the history
* Proposed text updates for /jira slash commands

Feedback welcome

* Address review feedback on command.go
  • Loading branch information
jasonblais authored and crspeller committed May 21, 2019
1 parent cfead81 commit 0c6d60a
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ import (
"github.com/mattermost/mattermost-server/plugin"
)

const helpText = "###### Mattermost JIRA Plugin - Slash Command Help\n" +
"* `/jira connect` - Connect your Mattermost account to your JIRA account\n" +
"* `/jira disconnect` - Disonnect your Mattermost account to your JIRA account\n" +
"* `/jira instance` - Manage JIRA instances connected to Mattermost\n" +
" * `list` - List known JIRA instances\n" +
" * `select <key or number>` - Select a known instance as current\n" +
" * `add server <URL>` - Add a JIRA Server instance\n" +
" * `add cloud` - Add a JIRA Cloud instance\n" +
const helpText = "###### Mattermost Jira Plugin - Slash Command Help\n" +
"* `/jira connect` - Connect your Mattermost account to your Jira account and subscribe to events\n" +
"* `/jira disconnect` - Disonnect your Mattermost account from your Jira account\n" +
"* `/jira instance [add/list/select]` - Manage connected Jira instances\n" +
" * `/jira instance add server <URL>` - Connect a Jira Server instance to Mattermost\n" +
" * `/jira instance add cloud` - Connect a Jira Cloud instance to Mattermost\n" +
" * `/jira instance list` - List connected Jira instances\n" +
" * `/jira instance select <number or URL>` - Select the active Jira instance. At most one active Jira instance is currently supported\n" +
""

func getCommand() *model.Command {
return &model.Command{
Trigger: "jira",
DisplayName: "JIRA",
Description: "Integration with JIRA.",
DisplayName: "Jira",
Description: "Integration with Jira.",
AutoComplete: true,
AutoCompleteDesc: "Available commands: connect, disconnect, help",
AutoCompleteHint: "[command]",
Expand Down Expand Up @@ -54,18 +54,18 @@ func (p *Plugin) ExecuteCommand(c *plugin.Context, commandArgs *model.CommandArg
}

func executeConnect(p *Plugin, c *plugin.Context, args []string) *model.CommandResponse {
return responsef("[Click here to link your JIRA account.](%s/%s)",
return responsef("[Click here to link your Jira account.](%s/%s)",
p.GetPluginURL(), routeUserConnect)
}

func executeDisconnect(p *Plugin, c *plugin.Context, args []string) *model.CommandResponse {
return responsef("[Click here to unlink your JIRA account.](%s/%s)",
return responsef("[Click here to unlink your Jira account.](%s/%s)",
p.GetPluginURL(), routeUserDisconnect)
}

func executeInstance(p *Plugin, c *plugin.Context, args []string) *model.CommandResponse {
if len(args) < 1 {
return responsef("Usage: /jira instance [add,list,select,delete]")
return responsef("Please specify a parameter in the form `/jira instance [add,list,select]")
}
action := args[0]
args = args[1:]
Expand All @@ -78,29 +78,29 @@ func executeInstance(p *Plugin, c *plugin.Context, args []string) *model.Command
case "select":
return executeInstanceSelect(p, c, args)
}
return responsef("Usage: /jira instance [add,list,select,delete]")
return responsef("Please specify a parameter in the form `/jira instance [add,list,select]")
}

func executeInstanceList(p *Plugin, c *plugin.Context, args []string) *model.CommandResponse {
known, err := p.LoadKnownJIRAInstances()
if err != nil {
return responsef("Failed to load known JIRA instances: %v", err)
return responsef("Failed to load known Jira instances: %v", err)
}
if len(known) == 0 {
return responsef("(none installed)\n")
}

current, err := p.LoadCurrentJIRAInstance()
if err != nil {
return responsef("Failed to load current JIRA instance: %v", err)
return responsef("Failed to load current Jira instance: %v", err)
}

keys := []string{}
for key := range known {
keys = append(keys, key)
}
sort.Strings(keys)
text := "Known JIRA instances (selected instance is **bold**)\n\n| |Key|Type|\n|--|--|--|\n"
text := "Known Jira instances (selected instance is **bold**)\n\n| |URL|Type|\n|--|--|--|\n"
for i, key := range keys {
typ := known[key]
if key == current.GetURL() {
Expand All @@ -114,14 +114,14 @@ func executeInstanceList(p *Plugin, c *plugin.Context, args []string) *model.Com

func executeInstanceAdd(p *Plugin, c *plugin.Context, args []string) *model.CommandResponse {
if len(args) < 1 {
return responsef("Usage: `/jira instance add server {URL}` or `/jira instance add cloud`")
return responsef("Please specify a parameter in the form `/jira instance add server {URL}` or `/jira instance add cloud`")
}
typ := args[0]

switch typ {
case JIRATypeServer:
if len(args) < 2 {
return responsef("Usage: `/jira instance add server {URL}`")
return responsef("Please specify the server URL in the form `/jira instance add server {URL}`")
}
jiraURL := args[1]

Expand All @@ -134,11 +134,11 @@ func executeInstanceAdd(p *Plugin, c *plugin.Context, args []string) *model.Comm

case JIRATypeCloud:
// TODO the exact group membership in JIRA?
return responsef(`As an admin, upload an application from %s/%s. The link can be found in "JIRA Settings/Applications/Manage"`,
return responsef(`As an admin, upload an application from %s/%s. The link can be found in **JIRA Settings > Applications > Manage**`,
p.GetPluginURL(), routeACJSON)
}

return responsef("Usage: `/jira instance add server {URL}` or `/jira instance add cloud`")
return responsef("Please specify a parameter in the form `/jira instance add server {URL}` or `/jira instance add cloud`")
}

func executeInstanceSelect(p *Plugin, c *plugin.Context, args []string) *model.CommandResponse {
Expand Down Expand Up @@ -166,11 +166,11 @@ func executeInstanceSelect(p *Plugin, c *plugin.Context, args []string) *model.C

ji, err := p.LoadJIRAInstance(instanceKey)
if err != nil {
return responsef("failed to load JIRA instance %s: %v", instanceKey, err)
return responsef("Failed to load Jira instance %s: %v", instanceKey, err)
}
err = p.StoreJIRAInstance(ji, true)
if err != nil {
return responsef("failed to store JIRA instance %s: %v", instanceKey, err)
return responsef("Failed to store Jira instance %s: %v", instanceKey, err)
}

return executeInstanceList(p, c, args)
Expand Down

0 comments on commit 0c6d60a

Please sign in to comment.