Files
Jesse Hallam e8e1219ddd MM-10368: react-router subpath (#1348)
* use Link in Textbox

Introduce react-router-enzyme-context to enable unit testing of same
with `mount` vs. `shallow`.

* leverage browserHistory in SystemUsersDropdown

Note that the demotion modal isn't actually being shown at present: the
transition of self from system admin to regular member is done without
confirmation after a partial refactor last year.

* leverage browserHistory in Authorize

* leverage Link in SignupController

* leverage browserHistory in UserSettingsSecurity

* extract base path from config's SiteURL on logout

* move __webpack_public_path__ into entry.js

This ensures that the other imports aren't hoisted above the definition.
Additionally re-export the public path back onto window.publicPath to
cover development environments.

* rely on window.basename in autolinkChannelMentions

While globals should generally be avoided, this is one of only two
places where `window.basename` is used. Moving it into the store and
rewriting the text rendering to pass down (or wrap) the necessary state
may be premature, given the pre-existing need for this variable to be
global.

* update getSiteURL to respect subpath

Additionally leverage getSiteURL over accessing window.* directly.

* strip any trailing slash before appending the ws pathname

* lint fixes

* use window.location.originw when SiteURL not defined
2018-06-22 22:23:05 +05:30

16 lines
1.0 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// Allow overriding the path used by webpack to dynamically resolve assets. This is driven by
// an environment variable in development, or by a window variable defined in root.html in
// production. The window variable is updated by the server after configuring SiteURL and
// restarting or by running the `mattermost config subpath` command.
window.publicPath = process.env.PUBLIC_PATH || window.publicPath || '/static/'; // eslint-disable-line no-process-env
__webpack_public_path__ = window.publicPath; // eslint-disable-line camelcase, no-undef
// Define the subpath at which Mattermost is running. Extract this from the publicPath above to
// avoid depending on Redux state before it is even loaded. This actual global export is used
// in a minimum of places, as it is preferred to leverage react-router, configured to use this
// basename accordingly.
window.basename = window.publicPath.substr(0, window.publicPath.length - '/static/'.length);