Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autocomplete suggestions #40

Merged
merged 5 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/deploy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"
"path/filepath"

"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mholt/archiver/v3"
"github.com/pkg/errors"
)
Expand Down
2 changes: 1 addition & 1 deletion build/manifest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"io/ioutil"
"os"

"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/pkg/errors"
)

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.12

require (
github.com/blang/semver v3.6.1+incompatible // indirect
github.com/mattermost/mattermost-server v1.4.1-0.20191016162522-6597fdb40134 // Mattermost Server 5.16.0
github.com/mattermost/mattermost-server/v5 v5.24.0
github.com/mholt/archiver/v3 v3.3.0
github.com/pkg/errors v0.8.1
github.com/stretchr/testify v1.3.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.5.1
)
426 changes: 339 additions & 87 deletions go.sum

Large diffs are not rendered by default.

56 changes: 48 additions & 8 deletions server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"strings"

"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/plugin"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin"
"github.com/pkg/errors"
)

Expand All @@ -21,12 +21,7 @@ const helpCommandText = "###### Mattermost Agenda Plugin - Slash Command Help\n"
"* `/agenda setting <field> <value>` - Update the setting with the given value. Field can be one of `schedule` or `hashtag` \n"

func (p *Plugin) registerCommands() error {
if err := p.API.RegisterCommand(&model.Command{
Trigger: commandTriggerAgenda,
AutoComplete: true,
AutoCompleteHint: "[command]",
AutoCompleteDesc: "Available commands: list, queue, setting, help",
}); err != nil {
if err := p.API.RegisterCommand(createAgendaCommand()); err != nil {
return errors.Wrapf(err, "failed to register %s command", commandTriggerAgenda)
}

Expand Down Expand Up @@ -177,3 +172,48 @@ func responsef(format string, args ...interface{}) *model.CommandResponse {
Type: model.POST_DEFAULT,
}
}

func createAgendaCommand() *model.Command {
agenda := model.NewAutocompleteData(commandTriggerAgenda, "[command]", "Available commands: list, queue, setting, help")

list := model.NewAutocompleteData("list", "", "Show a list of items queued for the next meeting")
optionalListNextWeek := model.NewAutocompleteData("next-week", "(optional)", "If `next-week` is provided, it will list the agenda for the next calendar week.")
list.AddCommand(optionalListNextWeek)
agenda.AddCommand(list)

queue := model.NewAutocompleteData("queue", "", "Queue `message` as a topic on the next meeting.")
queue.AddStaticListArgument("If `next-week` is provided, it will queue for the meeting in the next calendar week.", false, []model.AutocompleteListItem{{
HelpText: "If `next-week` is provided, it will queue for the meeting in the next calendar week.",
Hint: "(optional)",
Item: "next-week",
}})
queue.AddTextArgument("Message for the next meeting date.", "[message]", "")
agenda.AddCommand(queue)

setting := model.NewAutocompleteData("setting", "", "Update the setting.")
schedule := model.NewAutocompleteData("schedule", "", "Update schedule.")
schedule.AddStaticListArgument("weekday", true, []model.AutocompleteListItem{
{Item: "Monday"},
{Item: "Tuesday"},
{Item: "Wednesday"},
{Item: "Thursday"},
{Item: "Friday"},
{Item: "Saturday"},
{Item: "Sunday"},
})
setting.AddCommand(schedule)
hashtag := model.NewAutocompleteData("hashtag", "", "Update hastag.")
hashtag.AddTextArgument("input hashtag", "Default: Jan02", "")
setting.AddCommand(hashtag)
agenda.AddCommand(setting)

help := model.NewAutocompleteData("help", "", "Mattermost Agenda plugin slash command help")
agenda.AddCommand(help)
return &model.Command{
Trigger: commandTriggerAgenda,
AutoComplete: true,
AutoCompleteDesc: "Available commands: list, queue, setting, help",
AutoCompleteHint: "[command]",
AutocompleteData: agenda,
}
}
2 changes: 1 addition & 1 deletion server/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/mattermost/mattermost-server/plugin"
"github.com/mattermost/mattermost-server/v5/plugin"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/pkg/errors"

"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/plugin"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin"
)

// Plugin implements the interface expected by the Mattermost server to communicate between the server and plugin processes.
Expand Down
2 changes: 1 addition & 1 deletion server/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
"time"

"github.com/mattermost/mattermost-server/plugin/plugintest"
"github.com/mattermost/mattermost-server/v5/plugin/plugintest"
"github.com/stretchr/testify/assert"
)

Expand Down