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

Adding /setup to autocomplete (GitHub issue mattermost#892) #898

Merged
merged 11 commits into from
Jan 5, 2023
2 changes: 2 additions & 0 deletions docs/setup/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
2. At the top of the page set **Enable Plugin** to **True**.
3. Choose **Save** to enable the Jira plugin.

Once you have the plugin configured, you may continue the process by typing `/jira setup` in any channel. This will prompt a direct message from Jira bot, which will guide you through the next setup steps as described below.

### Step 2: Install the plugin as an application in Jira

To allow users to [create and manage Jira issues across Mattermost channels](../end-user-guide/using-jira-commands.md), install the plugin as an application in your Jira instance. For Jira Server or Data Center instances, post `/jira instance install server <your-jira-url>` to a Mattermost channel as a Mattermost System Admin, and follow the steps posted to the channel. For Jira Cloud, post `/jira instance install cloud <your-jira-url>`.
Expand Down
9 changes: 9 additions & 0 deletions server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func addSubCommands(jira *model.AutocompleteData, optInstance bool) {
// Admin commands
jira.AddCommand(createSubscribeCommand(optInstance))
jira.AddCommand(createWebhookCommand(optInstance))
jira.AddCommand(createSetupCommand(optInstance))

// Help and info
jira.AddCommand(model.NewAutocompleteData("info", "", "Display information about the current user and the Jira plug-in"))
Expand Down Expand Up @@ -320,6 +321,14 @@ func createWebhookCommand(optInstance bool) *model.AutocompleteData {
return webhook
}

func createSetupCommand(optInstance bool) *model.AutocompleteData {
setup := model.NewAutocompleteData(
"setup", "", "Start Jira plugin setup flow")
setup.RoleID = model.SystemAdminRoleId
withFlagInstance(setup, optInstance, routeAutocompleteInstalledInstanceWithAlias)
return setup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case if the /setup command, we actually don't want to include the instance flag. I think this should work along with changing the calling function:

Suggested change
func createSetupCommand(optInstance bool) *model.AutocompleteData {
setup := model.NewAutocompleteData(
"setup", "", "Start Jira plugin setup flow")
setup.RoleID = model.SystemAdminRoleId
withFlagInstance(setup, optInstance, routeAutocompleteInstalledInstanceWithAlias)
return setup
func createSetupCommand() *model.AutocompleteData {
setup := model.NewAutocompleteData(
"setup", "", "Start Jira plugin setup flow")
setup.RoleID = model.SystemAdminRoleId
return setup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, done!

}

type CommandHandlerFunc func(p *Plugin, c *plugin.Context, header *model.CommandArgs, args ...string) *model.CommandResponse

type CommandHandler struct {
Expand Down