mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 04:25:42 +00:00
[UI] Web Prefix (#9334)
* [UI] Change default web prefix - Adjust default from "platform" to "web" - Much more standard prefix * Cleanup * Fixes for playwright tests * Fix unit tests * Refactor base_url into getBaseUrl
This commit is contained in:
@ -23,7 +23,7 @@ import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||
import type { ModelType } from '../../enums/ModelType';
|
||||
import { navigateToLink } from '../../functions/navigation';
|
||||
import { getDetailUrl } from '../../functions/urls';
|
||||
import { base_url } from '../../main';
|
||||
import { getBaseUrl } from '../../main';
|
||||
import { apiUrl } from '../../states/ApiState';
|
||||
import { useUserState } from '../../states/UserState';
|
||||
import { Boundary } from '../Boundary';
|
||||
@ -67,7 +67,7 @@ function NotificationEntry({
|
||||
>
|
||||
<Stack gap={2}>
|
||||
<Anchor
|
||||
href={link ? `/${base_url}${link}` : '#'}
|
||||
href={link ? `/${getBaseUrl()}${link}` : '#'}
|
||||
underline='hover'
|
||||
target='_blank'
|
||||
onClick={(event: any) => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { base_url } from '../main';
|
||||
import { getBaseUrl } from '../main';
|
||||
import { cancelEvent } from './events';
|
||||
|
||||
/*
|
||||
@ -11,7 +11,7 @@ export const navigateToLink = (link: string, navigate: any, event: any) => {
|
||||
|
||||
if (event?.ctrlKey || event?.shiftKey) {
|
||||
// Open the link in a new tab
|
||||
const url = `/${base_url}${link}`;
|
||||
const url = `/${getBaseUrl()}${link}`;
|
||||
window.open(url, '_blank');
|
||||
} else {
|
||||
// Navigate internally
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ModelInformationDict } from '../components/render/ModelType';
|
||||
import type { ModelType } from '../enums/ModelType';
|
||||
import { base_url } from '../main';
|
||||
import { getBaseUrl } from '../main';
|
||||
import { useLocalState } from '../states/LocalState';
|
||||
|
||||
/**
|
||||
@ -19,7 +19,7 @@ export function getDetailUrl(
|
||||
|
||||
if (!!pk && modelInfo && modelInfo.url_detail) {
|
||||
const url = modelInfo.url_detail.replace(':pk', pk.toString());
|
||||
const base = base_url;
|
||||
const base = getBaseUrl();
|
||||
|
||||
if (absolute && base) {
|
||||
return `/${base}${url}`;
|
||||
|
@ -89,7 +89,8 @@ if (window.INVENTREE_SETTINGS.sentry_dsn) {
|
||||
});
|
||||
}
|
||||
|
||||
export const base_url = window.INVENTREE_SETTINGS.base_url || 'platform';
|
||||
export const getBaseUrl = (): string =>
|
||||
window.INVENTREE_SETTINGS?.base_url || 'web';
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
@ -99,7 +100,7 @@ ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||
|
||||
// Redirect to base url if on /
|
||||
if (window.location.pathname === '/') {
|
||||
window.location.replace(`/${base_url}`);
|
||||
window.location.replace(`/${getBaseUrl()}`);
|
||||
}
|
||||
|
||||
window.React = React;
|
||||
|
@ -5,7 +5,7 @@ import { api, queryClient } from '../App';
|
||||
import { ApiProvider } from '../contexts/ApiContext';
|
||||
import { ThemeContext } from '../contexts/ThemeContext';
|
||||
import { defaultHostList } from '../defaults/defaultHostList';
|
||||
import { base_url } from '../main';
|
||||
import { getBaseUrl } from '../main';
|
||||
import { routes } from '../router';
|
||||
import { useLocalState } from '../states/LocalState';
|
||||
|
||||
@ -21,7 +21,7 @@ export default function DesktopAppView() {
|
||||
return (
|
||||
<ApiProvider client={queryClient} api={api}>
|
||||
<ThemeContext>
|
||||
<BrowserRouter basename={base_url}>{routes}</BrowserRouter>
|
||||
<BrowserRouter basename={getBaseUrl()}>{routes}</BrowserRouter>
|
||||
</ThemeContext>
|
||||
</ApiProvider>
|
||||
);
|
||||
|
@ -23,7 +23,7 @@ export default function MobileAppView() {
|
||||
</Title>
|
||||
<Text>
|
||||
<Trans>
|
||||
Platform UI is optimized for Tablets and Desktops, you can use
|
||||
InvenTree UI is optimized for Tablets and Desktops, you can use
|
||||
the official app for a mobile experience.
|
||||
</Trans>
|
||||
</Text>
|
||||
|
@ -1,7 +1,7 @@
|
||||
export const classicUrl = 'http://127.0.0.1:8000';
|
||||
|
||||
export const apiUrl = `${classicUrl}/api`;
|
||||
export const baseUrl = './platform';
|
||||
export const baseUrl = './web';
|
||||
export const loginUrl = `${baseUrl}/login`;
|
||||
export const logoutUrl = `${baseUrl}/logout`;
|
||||
export const homeUrl = `${baseUrl}/home`;
|
||||
|
@ -11,11 +11,11 @@ export const doLogin = async (page, username?: string, password?: string) => {
|
||||
|
||||
await navigate(page, logoutUrl);
|
||||
await expect(page).toHaveTitle(/^InvenTree.*$/);
|
||||
await page.waitForURL('**/platform/login');
|
||||
await page.waitForURL('**/web/login');
|
||||
await page.getByLabel('username').fill(username);
|
||||
await page.getByLabel('password').fill(password);
|
||||
await page.getByRole('button', { name: 'Log in' }).click();
|
||||
await page.waitForURL('**/platform/home');
|
||||
await page.waitForURL('**/web/home');
|
||||
await page.waitForTimeout(250);
|
||||
};
|
||||
|
||||
@ -33,7 +33,7 @@ export const doQuickLogin = async (
|
||||
url = url ?? baseUrl;
|
||||
|
||||
await navigate(page, `${url}/login?login=${username}&password=${password}`);
|
||||
await page.waitForURL('**/platform/home');
|
||||
await page.waitForURL('**/web/home');
|
||||
|
||||
await page.getByLabel('navigation-menu').waitFor({ timeout: 5000 });
|
||||
await page.getByText(/InvenTree Demo Server -/).waitFor();
|
||||
@ -45,5 +45,5 @@ export const doQuickLogin = async (
|
||||
|
||||
export const doLogout = async (page) => {
|
||||
await navigate(page, 'logout');
|
||||
await page.waitForURL('**/platform/login');
|
||||
await page.waitForURL('**/web/login');
|
||||
};
|
||||
|
@ -14,7 +14,7 @@ test('Modals - Admin', async ({ page }) => {
|
||||
await page.getByRole('cell', { name: 'Instance Name' }).waitFor();
|
||||
await page.getByRole('button', { name: 'Close' }).click();
|
||||
|
||||
await page.waitForURL('**/platform/home');
|
||||
await page.waitForURL('**/web/home');
|
||||
|
||||
// use license info
|
||||
await page.getByLabel('open-spotlight').click();
|
||||
|
@ -416,7 +416,7 @@ test('Parts - Revision', async ({ page }) => {
|
||||
.getByRole('option', { name: 'Thumbnail Green Round Table No stock' })
|
||||
.click();
|
||||
|
||||
await page.waitForURL('**/platform/part/101/**');
|
||||
await page.waitForURL('**/web/part/101/**');
|
||||
await page.getByText('Select Part Revision').waitFor();
|
||||
});
|
||||
|
||||
|
@ -13,10 +13,10 @@ test('Sales Orders - Tabs', async ({ page }) => {
|
||||
await doQuickLogin(page);
|
||||
|
||||
await navigate(page, 'sales/index/');
|
||||
await page.waitForURL('**/platform/sales/**');
|
||||
await page.waitForURL('**/web/sales/**');
|
||||
|
||||
await loadTab(page, 'Sales Orders');
|
||||
await page.waitForURL('**/platform/sales/index/salesorders');
|
||||
await page.waitForURL('**/web/sales/index/salesorders');
|
||||
await loadTab(page, 'Return Orders');
|
||||
|
||||
// Customers
|
||||
|
@ -13,16 +13,16 @@ test('Stock - Basic Tests', async ({ page }) => {
|
||||
await doQuickLogin(page);
|
||||
|
||||
await navigate(page, 'stock/location/index/');
|
||||
await page.waitForURL('**/platform/stock/location/**');
|
||||
await page.waitForURL('**/web/stock/location/**');
|
||||
|
||||
await loadTab(page, 'Location Details');
|
||||
await page.waitForURL('**/platform/stock/location/index/details');
|
||||
await page.waitForURL('**/web/stock/location/index/details');
|
||||
|
||||
await loadTab(page, 'Stock Items');
|
||||
await page.getByText('1551ABK').first().click();
|
||||
|
||||
await page.getByRole('tab', { name: 'Stock', exact: true }).click();
|
||||
await page.waitForURL('**/platform/stock/**');
|
||||
await page.waitForURL('**/web/stock/**');
|
||||
await loadTab(page, 'Stock Locations');
|
||||
await page.getByRole('cell', { name: 'Electronics Lab' }).first().click();
|
||||
await loadTab(page, 'Default Parts');
|
||||
@ -43,7 +43,7 @@ test('Stock - Location Tree', async ({ page }) => {
|
||||
await doQuickLogin(page);
|
||||
|
||||
await navigate(page, 'stock/location/index/');
|
||||
await page.waitForURL('**/platform/stock/location/**');
|
||||
await page.waitForURL('**/web/stock/location/**');
|
||||
await loadTab(page, 'Location Details');
|
||||
|
||||
await page.getByLabel('nav-breadcrumb-action').click();
|
||||
|
@ -10,7 +10,7 @@ test('Quick Command', async ({ page }) => {
|
||||
await page.getByPlaceholder('Search...').fill('Dashboard');
|
||||
await page.getByPlaceholder('Search...').press('Tab');
|
||||
await page.getByPlaceholder('Search...').press('Enter');
|
||||
await page.waitForURL('**/platform/home');
|
||||
await page.waitForURL('**/web/home');
|
||||
});
|
||||
|
||||
test('Quick Command - No Keys', async ({ page }) => {
|
||||
@ -23,7 +23,7 @@ test('Quick Command - No Keys', async ({ page }) => {
|
||||
.click();
|
||||
|
||||
await page.getByText('InvenTree Demo Server - ').waitFor();
|
||||
await page.waitForURL('**/platform/home');
|
||||
await page.waitForURL('**/web/home');
|
||||
|
||||
// Use navigation menu
|
||||
await page.getByLabel('open-spotlight').click();
|
||||
@ -55,7 +55,7 @@ test('Quick Command - No Keys', async ({ page }) => {
|
||||
await page.getByRole('cell', { name: 'Instance Name' }).waitFor();
|
||||
await page.getByRole('button', { name: 'Close' }).click();
|
||||
|
||||
await page.waitForURL('**/platform/home');
|
||||
await page.waitForURL('**/web/home');
|
||||
|
||||
// use license info
|
||||
await page.getByLabel('open-spotlight').click();
|
||||
|
@ -6,7 +6,7 @@ import { doQuickLogin } from './login';
|
||||
test('Forms - Stock Item Validation', async ({ page }) => {
|
||||
await doQuickLogin(page, 'steven', 'wizardstaff');
|
||||
await navigate(page, 'stock/location/index/stock-items');
|
||||
await page.waitForURL('**/platform/stock/location/**');
|
||||
await page.waitForURL('**/web/stock/location/**');
|
||||
|
||||
// Create new stock item form
|
||||
await page.getByLabel('action-button-add-stock-item').click();
|
||||
|
@ -13,7 +13,7 @@ test('Login - Basic Test', async ({ page }) => {
|
||||
await page.getByRole('button', { name: 'Ally Access' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Logout' }).click();
|
||||
|
||||
await page.waitForURL('**/platform/login');
|
||||
await page.waitForURL('**/web/login');
|
||||
await page.getByLabel('username');
|
||||
});
|
||||
|
||||
@ -27,13 +27,13 @@ test('Login - Quick Test', async ({ page }) => {
|
||||
|
||||
// Go to the dashboard
|
||||
await navigate(page, '');
|
||||
await page.waitForURL('**/platform');
|
||||
await page.waitForURL('**/web');
|
||||
|
||||
await page.getByText('InvenTree Demo Server - ').waitFor();
|
||||
|
||||
// Logout (via URL)
|
||||
await navigate(page, 'logout');
|
||||
await page.waitForURL('**/platform/login');
|
||||
await page.waitForURL('**/web/login');
|
||||
await page.getByLabel('username');
|
||||
});
|
||||
|
||||
@ -51,7 +51,7 @@ test('Login - Failures', async ({ page }) => {
|
||||
// Navigate to the 'login' page
|
||||
await navigate(page, logoutUrl);
|
||||
await expect(page).toHaveTitle(/^InvenTree.*$/);
|
||||
await page.waitForURL('**/platform/login');
|
||||
await page.waitForURL('**/web/login');
|
||||
|
||||
// Attempt login with invalid credentials
|
||||
await page.getByLabel('login-username').fill('invalid user');
|
||||
|
@ -12,7 +12,7 @@ test('Label Printing', async ({ page }) => {
|
||||
await doQuickLogin(page);
|
||||
|
||||
await navigate(page, 'stock/location/index/');
|
||||
await page.waitForURL('**/platform/stock/location/**');
|
||||
await page.waitForURL('**/web/stock/location/**');
|
||||
|
||||
await loadTab(page, 'Stock Items');
|
||||
|
||||
@ -54,7 +54,7 @@ test('Report Printing', async ({ page }) => {
|
||||
await doQuickLogin(page);
|
||||
|
||||
await navigate(page, 'stock/location/index/');
|
||||
await page.waitForURL('**/platform/stock/location/**');
|
||||
await page.waitForURL('**/web/stock/location/**');
|
||||
|
||||
// Navigate to a specific PurchaseOrder
|
||||
await page.getByRole('tab', { name: 'Purchasing' }).click();
|
||||
|
@ -39,7 +39,7 @@ test('Settings - Language / Color', async ({ page }) => {
|
||||
// .click();
|
||||
|
||||
await page.getByRole('tab', { name: 'Dashboard' }).click();
|
||||
await page.waitForURL('**/platform/home');
|
||||
await page.waitForURL('**/web/home');
|
||||
});
|
||||
|
||||
test('Settings - User theme', async ({ page }) => {
|
||||
|
Reference in New Issue
Block a user