Skip to content

Commit

Permalink
refactor: set default page to start instead of summary page
Browse files Browse the repository at this point in the history
  • Loading branch information
lizable authored and agatha197 committed Aug 30, 2024
1 parent 0de6318 commit dbe62aa
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 24 deletions.
14 changes: 7 additions & 7 deletions react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ const InteractiveLoginPage = React.lazy(
);
const ImportAndRunPage = React.lazy(() => import('./pages/ImportAndRunPage'));

const RedirectToSummary = () => {
const RedirectToStart = () => {
useSuspendedBackendaiClient();
const pathName = '/summary';
const pathName = '/start';
document.dispatchEvent(
new CustomEvent('move-to-from-react', {
detail: {
Expand All @@ -73,7 +73,7 @@ const RedirectToSummary = () => {
},
}),
);
return <Navigate to="/summary" replace />;
return <Navigate to="/start" replace />;
};

const router = createBrowserRouter([
Expand Down Expand Up @@ -110,17 +110,17 @@ const router = createBrowserRouter([
children: [
{
path: '/',
element: <RedirectToSummary />,
element: <RedirectToStart />,
},
{
//for electron dev mode
path: '/build/electron-app/app/index.html',
element: <RedirectToSummary />,
element: <RedirectToStart />,
},
{
//for electron prod mode
path: '/app/index.html',
element: <RedirectToSummary />,
element: <RedirectToStart />,
},
{
path: '/start',
Expand All @@ -140,7 +140,7 @@ const router = createBrowserRouter([
</>
);
},
handle: { labelKey: 'webui.menu.Summary' },
handle: { labelKey: 'start' },
},
{
path: '/job',
Expand Down
2 changes: 1 addition & 1 deletion react/src/components/MainLayout/WebUISider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ const WebUISider: React.FC<WebUISiderProps> = (props) => {
>
<BAIMenu
selectedKeys={[
location.pathname.split('/')[1] || 'summary',
location.pathname.split('/')[1] || 'start',
// TODO: After matching first path of 'storage-settings' and 'agent', remove this code
location.pathname.split('/')[1] === 'storage-settings' ? 'agent' : '',
// TODO: After 'SessionListPage' is completed and used as the main page, remove this code
Expand Down
5 changes: 1 addition & 4 deletions react/src/pages/StartPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ const StartPage: React.FC<StartPageProps> = (props) => {
secondary
icon={
// FIXME: workaround for displaying proper icon
<img
src="react/src/components/icons/URLStart.svg"
alt="URL start"
></img>
<img src="/resources/icons/URLStart.svg" alt="URL start"></img>
// <URLStartIcon />
}
title={
Expand Down
7 changes: 7 additions & 0 deletions resources/icons/URLStart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/backend-ai-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const navigate =
}
let page;
if (['/', 'build', '/build', 'app', '/app'].includes(path)) {
page = 'summary';
page = 'start';
} else if (path[0] === '/') {
page = path.slice(1);
} else {
Expand Down Expand Up @@ -85,7 +85,7 @@ const loadPage =
(page, params: Record<string, unknown> = {}) =>
(dispatch) => {
switch (page) {
case 'summary':
case 'start':
import('./components/backend-ai-summary-view.js').then((module) => {
// TODO: after page changing?
});
Expand Down
6 changes: 3 additions & 3 deletions src/components/backend-ai-error-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export default class BackendAIErrorView extends BackendAIPage {
* @param {string} url - page to redirect from the current page.
*/
_moveTo(url = '') {
const page = url !== '' ? url : 'summary';
globalThis.history.pushState({}, '', '/summary');
const page = url !== '' ? url : 'start';
globalThis.history.pushState({}, '', '/start');
store.dispatch(navigate(decodeURIComponent('/' + page), {}));
document.dispatchEvent(
new CustomEvent('react-navigate', {
Expand All @@ -98,7 +98,7 @@ export default class BackendAIErrorView extends BackendAIPage {
fullwidth
id="go-to-summary"
label="${_t('button.GoBackToSummaryPage')}"
@click="${() => this._moveTo('summary')}"
@click="${() => this._moveTo('start')}"
></mwc-button>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/backend-ai-permission-denied-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class BackendAIPermissionDeniedView extends BackendAIPage {
* @param {string} url - page to redirect from the current page.
*/
_moveTo(url = '') {
const page = url !== '' ? url : 'summary';
const page = url !== '' ? url : 'start';
globalThis.history.pushState({}, '', '/summary');
store.dispatch(navigate(decodeURIComponent('/' + page), {}));
}
Expand All @@ -135,7 +135,7 @@ export default class BackendAIPermissionDeniedView extends BackendAIPage {
fullwidth
id="go-to-summary"
label="${_t('button.GoBackToSummaryPage')}"
@click="${() => this._moveTo('summary')}"
@click="${() => this._moveTo('start')}"
></mwc-button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/backend-ai-storage-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ export default class BackendAiStorageList extends BackendAIPage {
* @param {string} url - page to redirect from the current page.
*/
_moveTo(url = '') {
const page = url !== '' ? url : 'summary';
const page = url !== '' ? url : 'start';
// globalThis.history.pushState({}, '', page);
store.dispatch(navigate(decodeURIComponent(page), {}));

Expand Down
2 changes: 1 addition & 1 deletion src/components/backend-ai-storage-proxy-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export default class BackendAIStorageProxyList extends BackendAIPage {
* @param {string} url - page to redirect from the current page.
*/
_moveTo(url = '') {
const page = url !== '' ? url : 'summary';
const page = url !== '' ? url : 'start';
// globalThis.history.pushState({}, '', page);
store.dispatch(navigate(decodeURIComponent(page), {}));

Expand Down
2 changes: 1 addition & 1 deletion src/components/backend-ai-summary-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ export default class BackendAISummary extends BackendAIPage {
* @param {string} search
*/
_moveTo(url = '', search: string | undefined = undefined) {
const page = url !== '' ? url : 'summary';
const page = url !== '' ? url : 'start';
// globalThis.history.pushState({}, '', page);
store.dispatch(navigate(decodeURIComponent(page), {}));

Expand Down
5 changes: 3 additions & 2 deletions src/components/backend-ai-webui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ export default class BackendAIWebUI extends connect(store)(LitElement) {
@property({ type: Number }) sidepanelWidth = 250;
@property({ type: Object }) supports = Object();
@property({ type: Array }) availablePages = [
'summary',
// 'summary',
'start',
'verify-email',
'change-password',
'job',
Expand Down Expand Up @@ -719,7 +720,7 @@ export default class BackendAIWebUI extends connect(store)(LitElement) {
*/
_loadPageElement() {
if (this._page === 'index.html' || this._page === '') {
this._page = 'summary';
this._page = 'start';
navigate(decodeURIComponent('/'));
}
}
Expand Down

0 comments on commit dbe62aa

Please sign in to comment.