From a0cc072533589f308d3a79c84863c0e7104d6982 Mon Sep 17 00:00:00 2001 From: bobf Date: Sun, 11 Dec 2022 18:11:47 +0000 Subject: [PATCH 01/11] Adding /setup to autocomplete (GitHub issue #892) --- server/command.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/command.go b/server/command.go index 0b5d8f94c..f87b1ff07 100644 --- a/server/command.go +++ b/server/command.go @@ -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")) @@ -211,6 +212,7 @@ func withFlagInstance(cmd *model.AutocompleteData, optInstance bool, route strin } func withParamIssueKey(cmd *model.AutocompleteData) { + setup // TODO: Implement dynamic autocomplete for Jira issue (search) cmd.AddTextArgument("Jira issue key", "", "") } @@ -320,6 +322,12 @@ func createWebhookCommand(optInstance bool) *model.AutocompleteData { return webhook } +func createSetupCommand(optInstance bool) *model.AutocompleteData { + setup := model.NewAutocompleteData( + "Setup", "", "Start Jira Plugin setup assistant") + return setup +} + type CommandHandlerFunc func(p *Plugin, c *plugin.Context, header *model.CommandArgs, args ...string) *model.CommandResponse type CommandHandler struct { From 4089ca1d60b87a0881c28998a5d1036804517350 Mon Sep 17 00:00:00 2001 From: bobf Date: Sun, 11 Dec 2022 19:51:32 +0000 Subject: [PATCH 02/11] adding /jira setup autocomplete --- server/command.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/command.go b/server/command.go index f87b1ff07..67cf4a4e1 100644 --- a/server/command.go +++ b/server/command.go @@ -148,7 +148,7 @@ func addSubCommands(jira *model.AutocompleteData, optInstance bool) { // Admin commands jira.AddCommand(createSubscribeCommand(optInstance)) jira.AddCommand(createWebhookCommand(optInstance)) - Jira.AddCommand(createSetupCommand(optInstance)) + jira.AddCommand(createSetupCommand(optInstance)) // Help and info jira.AddCommand(model.NewAutocompleteData("info", "", "Display information about the current user and the Jira plug-in")) @@ -212,7 +212,6 @@ func withFlagInstance(cmd *model.AutocompleteData, optInstance bool, route strin } func withParamIssueKey(cmd *model.AutocompleteData) { - setup // TODO: Implement dynamic autocomplete for Jira issue (search) cmd.AddTextArgument("Jira issue key", "", "") } From 1d58b4a0eace6592fbc6b93c6004de674559d3ce Mon Sep 17 00:00:00 2001 From: bobf Date: Wed, 14 Dec 2022 21:45:52 +0000 Subject: [PATCH 03/11] Adding /setup to autocomplete (GitHub issue mattermost#892) --- server/command.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/server/command.go b/server/command.go index 67cf4a4e1..9c8fa00b6 100644 --- a/server/command.go +++ b/server/command.go @@ -148,9 +148,9 @@ 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("setup", "", "Start Jira plugin setup assistant")) jira.AddCommand(model.NewAutocompleteData("info", "", "Display information about the current user and the Jira plug-in")) jira.AddCommand(model.NewAutocompleteData("help", "", "Display help for `/jira` command")) } @@ -321,12 +321,6 @@ func createWebhookCommand(optInstance bool) *model.AutocompleteData { return webhook } -func createSetupCommand(optInstance bool) *model.AutocompleteData { - setup := model.NewAutocompleteData( - "Setup", "", "Start Jira Plugin setup assistant") - return setup -} - type CommandHandlerFunc func(p *Plugin, c *plugin.Context, header *model.CommandArgs, args ...string) *model.CommandResponse type CommandHandler struct { From f623817831deb371b2eadecab0d252b6ceae4b8a Mon Sep 17 00:00:00 2001 From: bobf Date: Wed, 14 Dec 2022 22:09:07 +0000 Subject: [PATCH 04/11] Adding a mention to /jira setup (GitHub issue mattermost#892) --- docs/setup/configuration.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/setup/configuration.md b/docs/setup/configuration.md index 8bf1c498d..36083c138 100644 --- a/docs/setup/configuration.md +++ b/docs/setup/configuration.md @@ -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` on 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 ` 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 `. From 8d9602a1f4136a6b359b14d94d6582e4b1848350 Mon Sep 17 00:00:00 2001 From: bobf7 <120138722+bobf7@users.noreply.github.com> Date: Wed, 4 Jan 2023 23:52:57 +0000 Subject: [PATCH 05/11] Update docs/setup/configuration.md changing to suggested correct spelling Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com> --- docs/setup/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/setup/configuration.md b/docs/setup/configuration.md index 36083c138..cdf7055a9 100644 --- a/docs/setup/configuration.md +++ b/docs/setup/configuration.md @@ -10,7 +10,7 @@ 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` on any channel. This will prompt a direct message from jira bot, which will guide you through the next setup steps as described below. +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 From daf7a224bdb3746c38f3edad01cdba37da7fab7c Mon Sep 17 00:00:00 2001 From: bobf7 <120138722+bobf7@users.noreply.github.com> Date: Wed, 4 Jan 2023 23:53:43 +0000 Subject: [PATCH 06/11] Update server/command.go Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com> --- server/command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/command.go b/server/command.go index 9c8fa00b6..4fe620e8b 100644 --- a/server/command.go +++ b/server/command.go @@ -150,7 +150,7 @@ func addSubCommands(jira *model.AutocompleteData, optInstance bool) { jira.AddCommand(createWebhookCommand(optInstance)) // Help and info - jira.AddCommand(model.NewAutocompleteData("setup", "", "Start Jira plugin setup assistant")) + jira.AddCommand(model.NewAutocompleteData("setup", "", "Start Jira plugin setup flow")) jira.AddCommand(model.NewAutocompleteData("info", "", "Display information about the current user and the Jira plug-in")) jira.AddCommand(model.NewAutocompleteData("help", "", "Display help for `/jira` command")) } From ce1ee3bf01742a8731c4378f1622738aa33d7810 Mon Sep 17 00:00:00 2001 From: bobf7 <120138722+bobf7@users.noreply.github.com> Date: Thu, 5 Jan 2023 00:33:37 +0000 Subject: [PATCH 07/11] Update server/command.go Make command show for system admins Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com> --- server/command.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/command.go b/server/command.go index 4fe620e8b..d1ef47211 100644 --- a/server/command.go +++ b/server/command.go @@ -150,7 +150,8 @@ func addSubCommands(jira *model.AutocompleteData, optInstance bool) { jira.AddCommand(createWebhookCommand(optInstance)) // Help and info - jira.AddCommand(model.NewAutocompleteData("setup", "", "Start Jira plugin setup flow")) + setup := jira.AddCommand(model.NewAutocompleteData("setup", "", "Start Jira plugin setup flow")) + setup.RoleID = model.SystemAdminRoleId jira.AddCommand(model.NewAutocompleteData("info", "", "Display information about the current user and the Jira plug-in")) jira.AddCommand(model.NewAutocompleteData("help", "", "Display help for `/jira` command")) } From 0e13af4a01b2880e7e0f86f28b1b77d8ab191746 Mon Sep 17 00:00:00 2001 From: bobf7 Date: Thu, 5 Jan 2023 00:50:50 +0000 Subject: [PATCH 08/11] moving /setup to admin commands --- server/command.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/command.go b/server/command.go index d1ef47211..11f9233b9 100644 --- a/server/command.go +++ b/server/command.go @@ -148,10 +148,10 @@ func addSubCommands(jira *model.AutocompleteData, optInstance bool) { // Admin commands jira.AddCommand(createSubscribeCommand(optInstance)) jira.AddCommand(createWebhookCommand(optInstance)) - - // Help and info setup := jira.AddCommand(model.NewAutocompleteData("setup", "", "Start Jira plugin setup flow")) setup.RoleID = model.SystemAdminRoleId + + // Help and info jira.AddCommand(model.NewAutocompleteData("info", "", "Display information about the current user and the Jira plug-in")) jira.AddCommand(model.NewAutocompleteData("help", "", "Display help for `/jira` command")) } From e2401d85eb576423d5255efb74419d6abe1e04a7 Mon Sep 17 00:00:00 2001 From: bobf Date: Thu, 5 Jan 2023 03:14:43 +0000 Subject: [PATCH 09/11] fix /setup for admins only --- server/command.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server/command.go b/server/command.go index 11f9233b9..570d7426a 100644 --- a/server/command.go +++ b/server/command.go @@ -148,8 +148,10 @@ func addSubCommands(jira *model.AutocompleteData, optInstance bool) { // Admin commands jira.AddCommand(createSubscribeCommand(optInstance)) jira.AddCommand(createWebhookCommand(optInstance)) - setup := jira.AddCommand(model.NewAutocompleteData("setup", "", "Start Jira plugin setup flow")) - setup.RoleID = model.SystemAdminRoleId + jira.AddCommand(createSetupCommand(optInstance)) + + //setup := jira.AddCommand(model.NewAutocompleteData("setup", "", "Start Jira plugin setup flow")) + //setup.RoleID = model.SystemAdminRoleId // Help and info jira.AddCommand(model.NewAutocompleteData("info", "", "Display information about the current user and the Jira plug-in")) @@ -322,6 +324,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 +} + type CommandHandlerFunc func(p *Plugin, c *plugin.Context, header *model.CommandArgs, args ...string) *model.CommandResponse type CommandHandler struct { From b705e54d901a142e3b82322a747e41d19ea50592 Mon Sep 17 00:00:00 2001 From: bobf Date: Thu, 5 Jan 2023 03:23:30 +0000 Subject: [PATCH 10/11] remove commented code --- server/command.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/server/command.go b/server/command.go index 570d7426a..0813420d9 100644 --- a/server/command.go +++ b/server/command.go @@ -150,9 +150,6 @@ func addSubCommands(jira *model.AutocompleteData, optInstance bool) { jira.AddCommand(createWebhookCommand(optInstance)) jira.AddCommand(createSetupCommand(optInstance)) - //setup := jira.AddCommand(model.NewAutocompleteData("setup", "", "Start Jira plugin setup flow")) - //setup.RoleID = model.SystemAdminRoleId - // Help and info jira.AddCommand(model.NewAutocompleteData("info", "", "Display information about the current user and the Jira plug-in")) jira.AddCommand(model.NewAutocompleteData("help", "", "Display help for `/jira` command")) From e3a9024d11338ae885a6f81e5ce08371f7298bb6 Mon Sep 17 00:00:00 2001 From: bobf Date: Thu, 5 Jan 2023 21:20:32 +0000 Subject: [PATCH 11/11] removing the call to withFlagInstance for the /setup command --- server/command.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/server/command.go b/server/command.go index 0813420d9..7f5819758 100644 --- a/server/command.go +++ b/server/command.go @@ -148,7 +148,7 @@ func addSubCommands(jira *model.AutocompleteData, optInstance bool) { // Admin commands jira.AddCommand(createSubscribeCommand(optInstance)) jira.AddCommand(createWebhookCommand(optInstance)) - jira.AddCommand(createSetupCommand(optInstance)) + jira.AddCommand(createSetupCommand()) // Help and info jira.AddCommand(model.NewAutocompleteData("info", "", "Display information about the current user and the Jira plug-in")) @@ -321,11 +321,10 @@ func createWebhookCommand(optInstance bool) *model.AutocompleteData { return webhook } -func createSetupCommand(optInstance bool) *model.AutocompleteData { +func createSetupCommand() *model.AutocompleteData { setup := model.NewAutocompleteData( "setup", "", "Start Jira plugin setup flow") setup.RoleID = model.SystemAdminRoleId - withFlagInstance(setup, optInstance, routeAutocompleteInstalledInstanceWithAlias) return setup }