Skip to content

Commit

Permalink
[GH-768]: Fixed Issue /Jira Connect doesn't open mattermost's subpath…
Browse files Browse the repository at this point in the history
… url (#870)

* [MI-2154]:Fixed issue(768) /Jira Connect doesn't open mattermost's subpath url (#3)

* Fixes #768

* Update webapp/src/actions/index.ts

updated the url to use string interpolation syntax.

Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>

* updated with feedback from Michael

* removed the unwanted styles changes

* removed the unwanted styles changes

* removed the unwanted styles changes

* resolved comments

* resolved comments

* plugin now adds the entire url from the config

* connect to cloud with subpath now working

* fixed styling and linting issues

* fixed linting issue

* Update server/user_cloud.go

Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>

* updated method to call the site url with a sub path

* updated method to call the site url with a sub path

* updated logic based on lev's comments

* added a method in plugin.go that will generate the final path

* updated based on feedback from levb

* added method to generate full path

* fixed conflicts

* updated and tested connect

* Update index.ts

removed whitespace

* Update webpack.config.js

* updated SiteURL handler

* [MI-2154]:fixed lint errors

* [MI-2154]:fixed review fixes

Co-authored-by: Sanjay <sanjaymj@12345>
Co-authored-by: Maisnam Raju Singh <85172229+maisnamrajusingh@users.noreply.github.com>
Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>
Co-authored-by: maisnamrajusingh <raju.s@demansol.com>

* [MM-768]:fixed CI error

* Improved code quality (#5)

* Review fixes done

* [MI-2182]: Review fixes done
1. Improved code quality

* [MI:2182]:Review fixes done
1.Improved code quality

* Review fixes done of #870 (#13)

* Review fixes done

* [MI-2182]: Review fixes done
1. Improved code quality

* [MI:2182]:Review fixes done
1.Improved code quality

* [MI-2182]: Review fixes done
1.Improved code quality

* [MI-2182]:Fixed CI errors

* [MM-768]:Fixed review comment

* [MI-2839]: Done the review fixes of a Jira PR #870 (#41)

* [MI-2839]: Done the review fixes of a Jira PR #887

* [MI-2839]: Review fixes done
1.Changed the way to create a full URL path

---------

Co-authored-by: Sanjay <sanjaymj@12345>
Co-authored-by: Maisnam Raju Singh <85172229+maisnamrajusingh@users.noreply.github.com>
Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>
Co-authored-by: maisnamrajusingh <raju.s@demansol.com>
Co-authored-by: Nityanand Rai <107465508+Nityanand13@users.noreply.github.com>
Co-authored-by: Nityanand Rai <nityanand.rai@brightscout.com>
Co-authored-by: raghavaggarwal2308 <raghav.aggarwal@brightscout.com>
  • Loading branch information
8 people authored Mar 8, 2024
1 parent 8a1f5b5 commit d08f7f7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 4 additions & 0 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ func (p *Plugin) GetSiteURL() string {
return p.getConfig().mattermostSiteURL
}

func (p *Plugin) CreateFullURLPath(extensionPath string) string {
return fmt.Sprintf("%s%s%s", p.GetSiteURL(), p.GetPluginURLPath(), extensionPath)
}

func (p *Plugin) debugf(f string, args ...interface{}) {
p.client.Log.Debug(fmt.Sprintf(f, args...))
}
Expand Down
7 changes: 3 additions & 4 deletions server/user_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package main

import (
"net/http"
"path"
"strings"

jira "github.com/andygrunwald/go-jira"
Expand Down Expand Up @@ -39,7 +38,7 @@ func (p *Plugin) httpACUserRedirect(w http.ResponseWriter, r *http.Request, inst
return respondErr(w, http.StatusBadRequest, err)
}

submitURL := path.Join(ci.Plugin.GetPluginURLPath(), instancePath(routeACUserConfirm, instanceID))
submitURL := p.CreateFullURLPath(instancePath(routeACUserConfirm, instanceID))

return ci.Plugin.respondTemplate(w, r, ContentTypeHTML, struct {
SubmitURL string
Expand Down Expand Up @@ -164,8 +163,8 @@ func (p *Plugin) httpACUserInteractive(w http.ResponseWriter, r *http.Request, i
}

// This set of props should work for all relevant routes/templates
connectSubmitURL := path.Join(p.GetPluginURLPath(), instancePath(routeACUserConnected, instanceID))
disconnectSubmitURL := path.Join(p.GetPluginURLPath(), instancePath(routeACUserDisconnected, instanceID))
connectSubmitURL := p.CreateFullURLPath(instancePath(routeACUserConnected, instanceID))
disconnectSubmitURL := p.CreateFullURLPath(instancePath(routeACUserDisconnected, instanceID))
return ci.Plugin.respondTemplate(w, r, ContentTypeHTML, struct {
ConnectSubmitURL string
DisconnectSubmitURL string
Expand Down
3 changes: 1 addition & 2 deletions server/user_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"crypto/x509"
"encoding/pem"
"net/http"
"path"
"strings"

"github.com/dghubble/oauth1"
Expand Down Expand Up @@ -115,7 +114,7 @@ func (p *Plugin) httpOAuth1aComplete(w http.ResponseWriter, r *http.Request, ins
}{
JiraDisplayName: juser.DisplayName + " (" + juser.Name + ")",
MattermostDisplayName: mmuser.GetDisplayName(model.ShowNicknameFullName),
RevokeURL: path.Join(p.GetPluginURLPath(), instancePath(routeUserDisconnect, instance.GetID())),
RevokeURL: p.CreateFullURLPath(instancePath(routeUserDisconnect, instance.GetID())),
})
}

Expand Down
1 change: 1 addition & 0 deletions webapp/src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ export function handleConnectFlow(instanceID?: string) {

export function redirectConnect(instanceID: string) {
return async (dispatch, getState) => {
const serverUrl = getPluginServerRoute(getState());
const instancePrefix = '/instance/' + btoa(instanceID);
const target = '/plugins/' + manifest.id + instancePrefix + '/user/connect';
window.open(target, '_blank');
Expand Down
1 change: 0 additions & 1 deletion webapp/src/selectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const getPluginState = (state) => state['plugins-' + manifest.id] || {};

export const getPluginServerRoute = (state) => {
const config = getConfig(state);

let basePath = '';
if (config && config.SiteURL) {
basePath = new URL(config.SiteURL).pathname;
Expand Down

0 comments on commit d08f7f7

Please sign in to comment.