console: oss and pro console updates for team-console

Related work: **https://github.com/hasura/lux/pull/1335**

##### NOTE: These changes are split across both the oss-console and the pro-console.

- So we need these changes to make sure that the team console uses the `projectEndpoint` env var to load the console and execute the correct requests.

- The other item that was updated in this PR was that we, now, have hidden/removed all of the logout buttons on the Pro console(for Cloud alone).

Co-authored-by: Ikechukwu Eze <22247592+iykekings@users.noreply.github.com>
Co-authored-by: Aleksandra Sikora <9019397+beerose@users.noreply.github.com>
GitOrigin-RevId: 7319f49de4b7369b58c1261b7dd3c41cff9b858d
This commit is contained in:
Sameer Kolhar 2021-02-11 00:00:11 +05:30 committed by hasura-bot
parent 76844835c1
commit f5c0eb2c7d

View File

@ -56,16 +56,29 @@ const globals = {
isProduction,
};
if (globals.consoleMode === SERVER_CONSOLE_MODE) {
if (!window.__env.dataApiUrl) {
globals.dataApiUrl = stripTrailingSlash(window.location.href);
}
if (isProduction) {
const consolePath = window.__env.consolePath;
if (consolePath) {
const currentUrl = stripTrailingSlash(window.location.href);
let currentUrl = stripTrailingSlash(window.location.href);
let slicePath = true;
if (window.__env.dataApiUrl) {
currentUrl = stripTrailingSlash(window.__env.dataApiUrl);
slicePath = false;
}
const currentPath = stripTrailingSlash(window.location.pathname);
globals.dataApiUrl = currentUrl.slice(
0,
currentUrl.lastIndexOf(consolePath)
);
// NOTE: perform the slice if not on team console
// as on team console, we're using the server
// endpoint directly to load the assets of the console
if (slicePath) {
globals.dataApiUrl = currentUrl.slice(
0,
currentUrl.lastIndexOf(consolePath)
);
}
globals.urlPrefix = `${currentPath.slice(
0,
@ -73,7 +86,6 @@ if (globals.consoleMode === SERVER_CONSOLE_MODE) {
)}/console`;
} else {
const windowHostUrl = `${window.location.protocol}//${window.location.host}`;
globals.dataApiUrl = windowHostUrl;
}
}