Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

[MM-19193] Fix basename in paths to System Console #3885

Merged
merged 9 commits into from
Oct 15, 2019

Conversation

mickmister
Copy link
Member

@mickmister mickmister commented Oct 7, 2019

Summary

This PR fixes an issue where links to the System Console do not take into account the basename of the MM server. So servers serving only from subpaths would result in a 404.

Ticket Link

https://mattermost.atlassian.net/browse/MM-19193

This PR has changes to en.json

@mickmister mickmister added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester labels Oct 7, 2019
Copy link
Contributor

@lindalumitchell lindalumitchell left a comment

Choose a reason for hiding this comment

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

QA will test this after it's merged.

@lindalumitchell lindalumitchell added QA Review Done and removed 3: QA Review Requires review by a QA tester labels Oct 8, 2019
Copy link
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

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

Makes sense -- just a request to use getBasePath throughout below.

}

const siteURLMessage = formatMessage({id, defaultMessage});
let basename = window.basename;
Copy link
Member

Choose a reason for hiding this comment

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

Can we avoid using window.basename (i.e. the global) directly? And instead bind the result of getBasePath into the component?

Copy link
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

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

Thanks!!

@lindalumitchell
Copy link
Contributor

lindalumitchell commented Oct 9, 2019

@mickmister I just inadvertently found a System Console link I hadn't seen before, but this one has a different problem. Should the following be a separate ticket, or should it be fixed along with these?

  1. On a server that does not have Bot Accounts enabled (System Console > Integrations > Bot Accounts)
  2. Go to main menu > Integrations > Bot Accounts, and click the System Console link in the helper text at the top
    Observed: Just loads blank integrations page. Note the URL on hover shows superfluous %siteURL%7D between the actual site URL and /admin_console/integrations/bot_accounts
    Expected: Opens Bot Accounts page in System Console

Screen Shot 2019-10-09 at 3 28 12 PM

Screen Shot 2019-10-09 at 3 37 21 PM

@jasonblais
Copy link
Contributor

May be caused by #3632

@jfrerich wondering if it's due to the extra siteURL that was added to the System Console link?

@jfrerich
Copy link
Contributor

@jasonblais, Just looking at this, I would assume this is an issue related to the PR I merged last night. It seems that {siteURL} must not be necessary afterall, although I found other instances of the same usage. I'll check this first thing tomorrow.

@mickmister
Copy link
Member Author

mickmister commented Oct 10, 2019

I added a fix for the bot account link @jfrerich @lindalumitchell

It seems that {siteURL} must not be necessary afterall, although I found other instances of the same usage.

Since we need to take subpaths into account, we need to either explicitly include the basename (what this PR does), or include the siteURL. Both methods are essentially trying to form a URL the browser can process properly.

It turns out that getSiteURL doesn't even take the configured SiteURL into account. It's basically just origin + basename.

export function getSiteURL() {
return getSiteURLFromWindowObject(window);
}

@mickmister
Copy link
Member Author

After seeing the usage of siteURL over basename in en.json, I've decided to change the translations to use siteURL instead, as it is cleaner and less error-prone.

@jfrerich jfrerich added this to the v5.16.0 milestone Oct 10, 2019
@jfrerich jfrerich added the CherryPick/Approved Meant for the quality or patch release tracked in the milestone label Oct 10, 2019
@jfrerich
Copy link
Contributor

jfrerich commented Oct 10, 2019

@mickmister. This was also cherry-picked into the release-5.16. Can you cherry-pick after this merge?

@lindalumitchell, @jasonblais I applied v5.16.0 milestone and CherryPick/Approved labels. This will need to be added to fix this commit 100e9dd in the release-5.16 branch.

@@ -10,7 +10,7 @@ exports[`components/MarketplaceModal should match the snapshot, error banner is
className="error-bar"
dangerouslySetInnerHTML={
Object {
"__html": "<p>Error connecting to the marketplace server. Please check your settings in the <a class=\\"theme markdown__link\\" href=\\"/admin_console/plugins/plugin_management\\" rel=\\"noreferrer\\" data-link=\\"/admin_console/plugins/plugin_management\\">System Console</a>.</p>",
"__html": "<p>Error connecting to the marketplace server. Please check your settings in the <a class=\\"theme markdown__link\\" href=\\"http:https://example.com/admin_console/plugins/plugin_management\\" rel=\\"noreferrer\\" target=\\"_blank\\">System Console</a>.</p>",
Copy link
Member

Choose a reason for hiding this comment

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

Just one comment re: change to target here, but otherwise looks good.

@amyblais amyblais removed this from the v5.16.0 milestone Oct 15, 2019
@amyblais amyblais added this to the v5.17.0 milestone Oct 15, 2019
@mickmister mickmister added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels Oct 15, 2019
@mickmister mickmister merged commit b4b04d9 into master Oct 15, 2019
@mickmister mickmister deleted the MM-19193-fix-admin-console-basename branch October 15, 2019 14:52
@mattermod
Copy link
Contributor

@mickmister
Error trying doing the automated Cherry picking. Please do this manually

+++ Updating remotes...
Fetching upstream
Fetching origin
+++ Updating remotes done...
!!! 'upstream/release-5.17' not found. The second argument should be something like upstream/release-0.21.
    (In particular, it needs to be a valid, existing remote branch that I can 'git checkout'.)

@mickmister mickmister self-assigned this Oct 15, 2019
@mickmister
Copy link
Member Author

/cherry-pick release-1.25

@mattermod
Copy link
Contributor

Error trying doing the automated Cherry picking. Please do this manually

+++ Updating remotes...
Fetching upstream
Fetching origin
+++ Updating remotes done...
!!! 'upstream/release-1.25' not found. The second argument should be something like upstream/release-0.21.
    (In particular, it needs to be a valid, existing remote branch that I can 'git checkout'.)

@mickmister
Copy link
Member Author

/cherry-pick release-5.17

@mattermod
Copy link
Contributor

Error trying doing the automated Cherry picking. Please do this manually

+++ Updating remotes...
Fetching upstream
Fetching origin
+++ Updating remotes done...
+++ Creating local branch automated-cherry-pick-of-#3885-upstream-release-5.17-1571324232
Branch 'automated-cherry-pick-of-#3885-upstream-release-5.17-1571324232' set up to track remote branch 'release-5.17' from 'upstream'.
+++ Downloading patch to /tmp/3885.patch (in case you need to do this again)

+++ About to attempt cherry pick of PR. To reattempt:
  $ git am -3 /tmp/3885.patch

Applying: fix basename in paths to System Console
Applying: update to use getBasePath
Applying: fix bot account i18n site url
Using index info to reconstruct a base tree...
M	components/integrations/bots/bots.jsx
Falling back to patching base and 3-way merge...
Auto-merging components/integrations/bots/bots.jsx
CONFLICT (content): Merge conflict in components/integrations/bots/bots.jsx
Patch failed at 0003 fix bot account i18n site url
Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

+++ Conflicts detected:

UU components/integrations/bots/bots.jsx

+++ Aborting in-progress git am.

+++ Returning you to the master branch and cleaning up.

@mickmister mickmister added CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone and removed CherryPick/Approved Meant for the quality or patch release tracked in the milestone labels Oct 17, 2019
mickmister added a commit that referenced this pull request Oct 17, 2019
* Clarify bot account creation flow

* fix basename in paths to System Console
@amyblais amyblais added Changelog/Done Required changelog entry has been written Docs/Not Needed Does not require documentation labels Oct 17, 2019
@lindy65 lindy65 added the Tests/Done Release tests have been written label Oct 21, 2019
brewsterbhg pushed a commit to brewsterbhg/mattermost-webapp that referenced this pull request Nov 11, 2019
* fix basename in paths to System Console

* update to use getBasePath

* fix bot account i18n site url

* prefer siteURL over basename

* update tests

* use FormattedMarkdownMessage

* remove unnecessary import
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Done Required changelog entry has been written CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone Docs/Not Needed Does not require documentation QA Review Done Tests/Done Release tests have been written
Projects
None yet
9 participants