[OSF] Allows opening the work template modal from a slash command (#22246)
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
53
app/slashcommands/command_templates.go
Обычный файл
53
app/slashcommands/command_templates.go
Обычный файл
@@ -0,0 +1,53 @@
|
||||
// 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 TemplatesProvider struct {
|
||||
}
|
||||
|
||||
const (
|
||||
CmdTemplates = "templates"
|
||||
)
|
||||
|
||||
func init() {
|
||||
app.RegisterCommandProvider(&TemplatesProvider{})
|
||||
}
|
||||
|
||||
func (h *TemplatesProvider) GetTrigger() string {
|
||||
return CmdTemplates
|
||||
}
|
||||
|
||||
func (h *TemplatesProvider) GetCommand(a *app.App, T i18n.TranslateFunc) *model.Command {
|
||||
workTemplateEnabled := a.Config().FeatureFlags.WorkTemplate
|
||||
pbActive, err := a.IsPluginActive(model.PluginIdPlaybooks)
|
||||
if err != nil {
|
||||
pbActive = false
|
||||
}
|
||||
hasBoard, err := a.HasBoardProduct()
|
||||
if err != nil {
|
||||
hasBoard = false
|
||||
}
|
||||
|
||||
return &model.Command{
|
||||
Trigger: CmdTemplates,
|
||||
AutoComplete: hasBoard && pbActive && workTemplateEnabled,
|
||||
AutoCompleteDesc: T("api.command_templates.desc"),
|
||||
DisplayName: T("api.command_templates.name"),
|
||||
}
|
||||
}
|
||||
|
||||
func (h *TemplatesProvider) 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_templates.unsupported.app_error"),
|
||||
ResponseType: model.CommandResponseTypeEphemeral,
|
||||
}
|
||||
}
|
||||
12
i18n/en.json
12
i18n/en.json
@@ -1494,6 +1494,18 @@
|
||||
"id": "api.command_shrug.name",
|
||||
"translation": "shrug"
|
||||
},
|
||||
{
|
||||
"id": "api.command_templates.desc",
|
||||
"translation": "Open the create from template window"
|
||||
},
|
||||
{
|
||||
"id": "api.command_templates.name",
|
||||
"translation": "templates"
|
||||
},
|
||||
{
|
||||
"id": "api.command_templates.unsupported.app_error",
|
||||
"translation": "The templates command is not supported on your device."
|
||||
},
|
||||
{
|
||||
"id": "api.config.client.old_format.app_error",
|
||||
"translation": "New format for the client configuration is not supported yet. Please specify format=old in the query string."
|
||||
|
||||
Ссылка в новой задаче
Block a user