[MM-46468] Change /help and add /marketplace (#20850)

This commit is contained in:
Julien Tant
2022-08-23 08:37:06 -07:00
committed by GitHub
parent 492a3c0669
commit 3138543d10
4 changed files with 68 additions and 4 deletions

View File

@@ -25,11 +25,11 @@ func TestHelpCommand(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.SupportSettings.HelpLink = "" })
rs1, _, _ := client.ExecuteCommand(channel.Id, "/help ")
assert.Equal(t, rs1.GotoLocation, model.SupportSettingsDefaultHelpLink, "failed to default help link")
assert.Contains(t, rs1.Text, model.SupportSettingsDefaultHelpLink, "failed to default help link")
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.SupportSettings.HelpLink = "https://docs.mattermost.com/guides/user.html"
})
rs2, _, _ := client.ExecuteCommand(channel.Id, "/help ")
assert.Equal(t, rs2.GotoLocation, "https://docs.mattermost.com/guides/user.html", "failed to help link")
assert.Contains(t, rs2.Text, "https://docs.mattermost.com/guides/user.html", "failed to help link")
}

View File

@@ -41,5 +41,10 @@ func (h *HelpProvider) DoCommand(a *app.App, c request.CTX, args *model.CommandA
helpLink = model.SupportSettingsDefaultHelpLink
}
return &model.CommandResponse{GotoLocation: helpLink}
return &model.CommandResponse{
ResponseType: model.CommandResponseTypeEphemeral,
Text: args.T("api.command_help.success", map[string]any{
"HelpLink": helpLink,
}),
}
}

View File

@@ -0,0 +1,43 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package slashcommands
import (
"github.com/mattermost/mattermost-server/v6/app"
"github.com/mattermost/mattermost-server/v6/app/request"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/i18n"
)
type MarketplaceProvider struct {
}
const (
CmdMarketplace = "marketplace"
)
func init() {
app.RegisterCommandProvider(&MarketplaceProvider{})
}
func (h *MarketplaceProvider) GetTrigger() string {
return CmdMarketplace
}
func (h *MarketplaceProvider) GetCommand(a *app.App, T i18n.TranslateFunc) *model.Command {
return &model.Command{
Trigger: CmdMarketplace,
AutoComplete: true,
AutoCompleteDesc: T("api.command_marketplace.desc"),
DisplayName: T("api.command_marketplace.name"),
}
}
func (h *MarketplaceProvider) DoCommand(a *app.App, c request.CTX, args *model.CommandArgs, message string) *model.CommandResponse {
// This command is handled client-side and shouldn't hit the server.
return &model.CommandResponse{
Text: args.T("api.command_marketplace.unsupported.app_error"),
ResponseType: model.CommandResponseTypeEphemeral,
}
}

View File

@@ -856,12 +856,16 @@
},
{
"id": "api.command_help.desc",
"translation": "Open the Mattermost help page"
"translation": "Show Mattermost help message"
},
{
"id": "api.command_help.name",
"translation": "help"
},
{
"id": "api.command_help.success",
"translation": "Mattermost is an open source platform for secure communication, collaboration, and orchestration of work across tools and teams.\r\nMattermost contains three key tools:\r\n\r\n**Channels** - Stay connected with your team via 1:1 and group messaging.\r\n**[Playbooks](/playbooks)** - Build and configure repeatable processes to achieve specific and predictable outcomes.\r\n**[Boards](/boards)** - Manage projects and tasks in a Kanban board structure to help your team hit key milestones.\r\n\r\n[View documentation and guides]({{.HelpLink}})"
},
{
"id": "api.command_invite.channel.app_error",
"translation": "Error to retrieve the current channel."
@@ -974,6 +978,18 @@
"id": "api.command_logout.name",
"translation": "logout"
},
{
"id": "api.command_marketplace.desc",
"translation": "Open the Marketplace"
},
{
"id": "api.command_marketplace.name",
"translation": "marketplace"
},
{
"id": "api.command_marketplace.unsupported.app_error",
"translation": "The marketplace command is not supported on your device."
},
{
"id": "api.command_me.desc",
"translation": "Do an action"