Unverified Commit 0e835aa9 authored by Lijiaoa's avatar Lijiaoa Committed by GitHub
Browse files

upgrade react router to v6 (#4975)

parent 10c5abb2
...@@ -43,8 +43,7 @@ ...@@ -43,8 +43,7 @@
"react-monaco-editor": "^0.32.1", "react-monaco-editor": "^0.32.1",
"react-paginate": "^6.3.2", "react-paginate": "^6.3.2",
"react-responsive": "^8.1.1", "react-responsive": "^8.1.1",
"react-router": "^5.2.0", "react-router-dom": "^6.3.0",
"react-router-dom": "^5.2.0",
"react-table": "^7.0.0-rc.15", "react-table": "^7.0.0-rc.15",
"resolve": "^1.10.0", "resolve": "^1.10.0",
"sass-loader": "^12.1.0", "sass-loader": "^12.1.0",
......
import * as React from 'react'; import * as React from 'react';
import { Outlet } from 'react-router-dom';
import { Stack } from '@fluentui/react'; import { Stack } from '@fluentui/react';
import { SlideNavBtns } from '@components/nav/slideNav/SlideNavBtns'; import { SlideNavBtns } from '@components/nav/slideNav/SlideNavBtns';
import { EXPERIMENT, TRIALS } from '@static/datamodel'; import { EXPERIMENT, TRIALS } from '@static/datamodel';
...@@ -166,6 +167,7 @@ class App extends React.Component<{}, AppState> { ...@@ -166,6 +167,7 @@ class App extends React.Component<{}, AppState> {
closeTimer: this.closeTimer closeTimer: this.closeTimer
}} }}
> >
<Outlet />
{this.props.children} {this.props.children}
</AppContext.Provider> </AppContext.Provider>
</Stack> </Stack>
......
...@@ -118,7 +118,7 @@ class ChangeColumnComponent extends React.Component<ChangeColumnProps, ChangeCol ...@@ -118,7 +118,7 @@ class ChangeColumnComponent extends React.Component<ChangeColumnProps, ChangeCol
<PrimaryButton <PrimaryButton
text='Save' text='Save'
onClick={this.saveUserSelectColumn} onClick={this.saveUserSelectColumn}
disabled={currentSelected.length < (minSelected === undefined ? 1 : minSelected)} disabled={currentSelected.length < (minSelected ?? 1)}
/> />
<DefaultButton text='Cancel' onClick={this.cancelOption} /> <DefaultButton text='Cancel' onClick={this.cancelOption} />
</DialogFooter> </DialogFooter>
......
...@@ -2,16 +2,17 @@ import * as React from 'react'; ...@@ -2,16 +2,17 @@ import * as React from 'react';
import { NavLink } from 'react-router-dom'; import { NavLink } from 'react-router-dom';
import { getPrefix } from '@static/function'; import { getPrefix } from '@static/function';
const activeClassName = 'selected';
const OVERVIEWTABS = ( const OVERVIEWTABS = (
<NavLink to='/oview' activeClassName='selected' className='common-tabs'> <NavLink to='/oview' className={({ isActive }) => (isActive ? `${activeClassName} link` : 'link')}>
Overview <span className='common-tabs'>Overview</span>
</NavLink> </NavLink>
); );
const DETAILTABS = ( const DETAILTABS = (
<NavLink to='/detail' activeClassName='selected' className='common-tabs'> <NavLink to='/detail' className={({ isActive }) => (isActive ? `${activeClassName} link` : 'link')}>
Trials detail <span className='common-tabs'>Trials detail</span>
</NavLink> </NavLink>
); );
......
...@@ -2,7 +2,7 @@ import React, { lazy, Suspense } from 'react'; ...@@ -2,7 +2,7 @@ import React, { lazy, Suspense } from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import App from './App'; import App from './App';
import { getPrefix } from './static/function'; import { getPrefix } from './static/function';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
const Overview = lazy(() => import('./components/experiment/overview/Overview')); const Overview = lazy(() => import('./components/experiment/overview/Overview'));
const TrialsDetail = lazy(() => import('./components/experiment/trialdetail/TrialsDetail')); const TrialsDetail = lazy(() => import('./components/experiment/trialdetail/TrialsDetail'));
const ExperimentManagerIndex = lazy(() => import('./components/experimentManagement/ExperimentManagerIndex')); const ExperimentManagerIndex = lazy(() => import('./components/experimentManagement/ExperimentManagerIndex'));
...@@ -13,24 +13,24 @@ import * as serviceWorker from './serviceWorker'; ...@@ -13,24 +13,24 @@ import * as serviceWorker from './serviceWorker';
const path = getPrefix(); const path = getPrefix();
ReactDOM.render( ReactDOM.render(
<Router basename={path === undefined ? null : path}> <Suspense
<Suspense fallback={
fallback={ <div className='loading'>
<div className='loading'> <img title='loading-graph' src={(path ?? '') + '/loading.gif'} />
<img title='loading-graph' src={(path || '') + '/loading.gif'} /> </div>
</div> }
} >
> <Router basename={path ?? ''}>
<Route path='/experiment' component={ExperimentManagerIndex} exact /> <Routes>
<Switch> <Route path='/experiment' element={<ExperimentManagerIndex />} />
<App> <Route element={<App />}>
<Route path='/' component={Overview} exact /> <Route path='/oview' element={<Overview />} />
<Route path='/oview' component={Overview} /> <Route path='/detail' element={<TrialsDetail />} />
<Route path='/detail' component={TrialsDetail} /> <Route path='/*' element={<Navigate to='/oview' />} />
</App> </Route>
</Switch> </Routes>
</Suspense> </Router>
</Router>, </Suspense>,
document.getElementById('root') document.getElementById('root')
); );
......
...@@ -128,11 +128,11 @@ class Experiment { ...@@ -128,11 +128,11 @@ class Experiment {
} }
get profile(): ExperimentProfile { get profile(): ExperimentProfile {
return this.profileField === undefined ? emptyProfile : this.profileField; return this.profileField ?? emptyProfile;
} }
get metadata(): ExperimentMetadata { get metadata(): ExperimentMetadata {
return this.metadataField === undefined ? emptyMetadata : this.metadataField; return this.metadataField ?? emptyMetadata;
} }
get config(): ExperimentConfig { get config(): ExperimentConfig {
...@@ -146,7 +146,7 @@ class Experiment { ...@@ -146,7 +146,7 @@ class Experiment {
get maxTrialNumber(): number { get maxTrialNumber(): number {
const value = this.config.maxTrialNumber || (this.config as any).maxTrialNum; const value = this.config.maxTrialNumber || (this.config as any).maxTrialNum;
return value === undefined ? Infinity : value; return value ?? Infinity;
} }
get trialConcurrency(): number { get trialConcurrency(): number {
......
...@@ -20,9 +20,9 @@ $tableHeight: 432px; ...@@ -20,9 +20,9 @@ $tableHeight: 432px;
top: 50%; top: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
a { .common-tabs {
color: #0071bc;
font-weight: 500; font-weight: 500;
color: blue;
} }
} }
......
...@@ -72,25 +72,20 @@ $barHeight: 56px; ...@@ -72,25 +72,20 @@ $barHeight: 56px;
} }
/* overview and detail tabs common style */ /* overview and detail tabs common style */
a.common-tabs { .common-tabs {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 16px; font-size: 16px;
color: #b8c7ce; color: #b8c7ce;
text-decoration: none; text-decoration: none;
} }
.common-tabs:visited, .selected .common-tabs {
.selected:hover {
color: #fff;
text-decoration: none;
}
.common-tabs:hover,
.selected {
color: #fff; color: #fff;
padding-bottom: 2px;
border-bottom: 1px solid #fff; border-bottom: 1px solid #fff;
} }
.left-right-margin { .left-right-margin {
margin-left: 20px; margin-left: 20px;
margin-right: 20px; margin-right: 20px;
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment