Commit f3706c8c authored by Viacheslav Pavlov's avatar Viacheslav Pavlov Committed by Matija Obreza
Browse files

Upgraded to modular code layout

- move requestService actions in service folder
- user root actions and reducer renamed to public, some fixes related to getState() func
- fixed stepper view, fixed subset editor actions, now stepper routes declared only in steps.ts
- Migrate to modular layout merged
- added module for accessions
- added module for institute
- added module for subsets
parent 16ed72b9
......@@ -79,7 +79,7 @@ class StepNavigation extends React.Component<IStepNavigationProps, any> {
protected getStepId = (location) => {
const {steps} = this.props;
const path = location.pathname.split('/').pop();
return steps.find((e) => e.link.endsWith(path)).id;
return steps.find((e) => e.path.endsWith(path)).id;
}
protected getItemActionButtons = () => {
......
......@@ -5,7 +5,7 @@ import {PublishState} from 'model/common.model';
import Grid from '@material-ui/core/Grid';
import Loading from 'ui/common/Loading';
import PageLayout from 'ui/layout/PageLayout';
// import PageLayout from 'ui/layout/PageLayout';
import StepNavigation from './StepNavigation';
import ProgressMenu from './progress-menu';
import TopSection from './TopSection';
......@@ -66,11 +66,10 @@ class StepperTemplate<T> extends React.Component<T & IStepperTemplateProps> {
const child = this.renderContent();
const stepNavigation = this.getStepNavigation();
return (
<PageLayout sidebar={ <ProgressMenu disabled={ disabled } onGotoStep={ this.gotoStep } steps={ steps } location={ location } /> }>
<Grid container spacing={ 0 }>
<TopSection pageTitle={ pageTitle } backTarget={ `/dashboard/${path}` }/>
<Grid container spacing={ 0 }>
<Grid item xs={ 12 } md={ 12 } xl={ 12 } className="back-gray p-20">
<Grid item xs={ 12 } md={ 9 } xl={ 10 } className="back-gray p-20">
<Grid container spacing={ 0 } className="back-white">
{ stepNavigation }
<Grid item xs={ 12 }>
......@@ -79,10 +78,12 @@ class StepperTemplate<T> extends React.Component<T & IStepperTemplateProps> {
{ stepNavigation }
</Grid>
</Grid>
<Grid item xs={ 12 } md={ 3 } xl={ 2 }>
<ProgressMenu disabled={ disabled } onGotoStep={ this.gotoStep } steps={ steps } location={ location } />
</Grid>
</Grid>
<BottomSection/>
</Grid>
</PageLayout>
);
}
}
......
......@@ -17,8 +17,10 @@ interface IProgressMenuProps extends React.ClassAttributes<any> {
const styleSheet = (theme) => ({
/* tslint:disable */
root: {
position: 'sticky' as 'sticky',
top: '6rem',
width: '100%',
height: '100%',
// height: '100%',
background: theme.palette.background.paper,
fontFamily: 'Roboto-Medium',
padding: '0',
......@@ -47,7 +49,7 @@ class ProgressMenu extends React.Component<IProgressMenuProps, any> {
key={ i }
disabled={ disabled }
onClick={ () => onGotoStep(i + 1) }
active={ step.link.endsWith(link) }
active={ step.path.endsWith(link) }
index={ i }
name = { step.name }
/>
......
......@@ -14,7 +14,7 @@ function SubsetLink({ to: subset, edit = false, children = null }
if (subset) {
if (edit) {
return (
<Link to={ `/subsets/${subset.uuid}/edit` }>
<Link to={ `/dashboard/subsets/${subset.uuid}/edit` }>
{ children || <Markdown basic source={ subset.title } /> }
</Link>
);
......
......@@ -9,7 +9,7 @@ import Card, {CardContent, CardActions} from 'ui/common/Card';
import DOI from 'ui/common/DOI';
import SciName from 'ui/genesys/SciName';
// import CropChips from 'ui/genesys/crop/CropChips';
import {addAccessionToMyList, removeAccessionFromMyList} from 'user/actions/root';
import {addAccessionToMyList, removeAccessionFromMyList} from 'user/actions/public';
const styles = (theme) => ({
firstRow: {
......@@ -81,7 +81,7 @@ const AccessionCard = ({ accession, classes, index, addAccessionToMyList, remove
};
const mapStateToProps = (state, ownProps) => ({
accessions: state.user.root.myList.accessions,
accessions: state.user.public.myList.accessions,
});
const mapDispatchToProps = (dispatch) => bindActionCreators({
......
......@@ -16,7 +16,7 @@ const DashboardMenu = () => (
</MenuItem>
<MenuItem label="Subsets" to="/dashboard/subsets" icon={ <DescriptorListIcon/> }>
<MenuItem label="List subsets" to="/dashboard/subsets"/>
<MenuItem label="Create subset" to="/subsets/edit" />
<MenuItem label="Create subset" to="/dashboard/subsets/edit" />
</MenuItem>
</div>
);
......
......@@ -5,7 +5,7 @@ import { NavLink, Link, withRouter } from 'react-router-dom';
import { translate } from 'react-i18next';
import {loginAppRequest} from 'actions/login';
import {logoutRequest} from 'user/actions/root';
import {logoutRequest} from 'user/actions/public';
import AppBar from '@material-ui/core/AppBar';
import { withStyles } from '@material-ui/core/styles';
......
......@@ -203,7 +203,7 @@ class SidebarWrapper extends React.Component<ISidebarProps, any> {
}
const mapStateToProps = (state, ownProps) => ({
isOpen: state.user.root.sidebarOpen,
isOpen: state.user.public.sidebarOpen,
});
const mapDispatchToProps = (dispatch) => bindActionCreators({
......
......@@ -34,10 +34,10 @@ class StepperTemplate<T> extends React.Component<IStepperProps<T>, any> {
protected gotoStep = (id) => {
const {item, uuid, navigateTo, steps, path} = this.props;
const stepPath = steps.find((e) => e.id === id).link;
const stepPath = steps.find((e) => e.id === id).path;
log('Go to step', stepPath);
if (uuid || (item && item.uuid)) {
navigateTo(`/${path}/${item ? item.uuid : uuid}/${stepPath}`);
navigateTo(`/dashboard/${path}/${item ? item.uuid : uuid}/${stepPath}`);
this.setState({step: id});
} else {
// no navigation!
......
......@@ -14,29 +14,17 @@ import { adminRoutes as repositoryAdminRoutes } from 'repository/routes';
import DashboardPage from 'ui/pages/dashboard/DashboardPage';
// import AccessionsBrowsePage from 'ui/pages/genesys/BrowsePage';
// Subsets
import SubsetBrowsePage from 'ui/pages/subsets/BrowsePage';
import SubsetDisplayPage from 'ui/pages/subsets/DisplayPage';
import SubsetDashboardPage from 'ui/pages/dashboard/subsets/DashboardPage';
import SubsetStepper from 'ui/pages/dashboard/subsets/StepperPage';
import BasicInfoStep from 'ui/pages/dashboard/subsets/subset-stepper/steps/basic-info';
import AccessionsListStep from 'ui/pages/dashboard/subsets/subset-stepper/steps/accessions-list';
import CreatorsStep from 'ui/pages/dashboard/subsets/subset-stepper/steps/creators';
import ReviewStep from 'ui/pages/dashboard/subsets/subset-stepper/steps/review';
import {subsetDashboardRoutes, subsetPublicRoutes} from 'subsets/routes';
// Accession
import AccessionBrowsePage from 'ui/pages/accessions/BrowsePage';
import MapBrowsePage from 'ui/pages/accessions/MapPage';
import AccessionDisplayPage from 'ui/pages/accessions/DisplayPage';
import AccessionOverviewPage from 'ui/pages/accessions/OverviewPage';
import {accessionPublicRoutes} from 'accessions/routes';
// Institute
import InstituteBrowsePage from 'ui/pages/institutes/BrowsePage';
import InstituteDisplayPage from 'ui/pages/institutes/DisplayPage';
import {instituteDashboardRoutes, institutePublicRoutes} from 'institutes/routes';
// Requests
import {requestsAdminRoutes} from 'requests/routes';
import NotFound from 'ui/common/not-found'; // TODO Move to ui/pages!
import AdminDashboardPage from 'ui/pages/admin/DashboardPage';
import RequestBrowsePage from 'ui/pages/admin/requests/BrowsePage';
import RequestDisplayPage from 'ui/pages/admin/requests/DisplayPage';
import {ROLE_ADMINISTRATOR, ROLE_USER} from 'constants/userRoles';
......@@ -65,107 +53,11 @@ const routes = [
// },
// },
// Subsets
{
path: '/subsets/edit',
component: SubsetStepper,
auth: [ROLE_USER, ROLE_ADMINISTRATOR],
extraProps: {
title: 'Subset create',
},
routes: [
{
path: '/',
component: BasicInfoStep,
exact: true,
},
],
},
{
path: '/subsets/:uuid?/edit',
component: SubsetStepper,
auth: [ROLE_USER, ROLE_ADMINISTRATOR],
extraProps: {
title: 'Subset create',
},
routes: [
{
path: '/list-of-accessions',
component: AccessionsListStep,
exact: true,
},
{
path: '/creators',
component: CreatorsStep,
exact: true,
},
{
path: '/review-and-publish',
component: ReviewStep,
exact: true,
},
{
path: '/',
component: BasicInfoStep,
exact: true,
},
],
},
{
path: '/subsets/:filterCode(v.+)?',
component: SubsetBrowsePage,
exact: true,
extraProps: {
title: 'Collection subsets',
subtitle: 'Browse subsets',
},
},
{
path: '/subsets/:uuid([a-z\\-0-9]+)',
component: SubsetDisplayPage,
exact: true,
extraProps: {
title: 'Iiik',
subtitle: 'Oook',
},
},
...subsetPublicRoutes,
// Accessions
{
path: '/a/:filterCode(v.+)?',
component: AccessionBrowsePage,
exact: true,
},
{
path: '/a/overview/:filterCode(v.+)?',
component: AccessionOverviewPage,
exact: true,
},
{
path: '/a/map/:filterCode(v.+)?',
component: MapBrowsePage,
exact: true,
},
{
path: '/a/:uuid([a-z\\-0-9]+)',
component: AccessionDisplayPage,
exact: true,
},
{
// We need to take out the '10.' prefix for matching to work
path: '/10.:doi(\\d+\/.+)',
component: AccessionDisplayPage,
exact: true,
},
...accessionPublicRoutes,
// Institutes
{
path: '/wiews/:filterCode(v.+)?',
component: InstituteBrowsePage,
exact: true,
},
{
path: '/wiews/:wiewsCode([a-z\\-0-9]+)',
component: InstituteDisplayPage,
exact: true,
},
...institutePublicRoutes,
// Dashboard
{
path: '/dashboard',
......@@ -177,14 +69,8 @@ const routes = [
auth: [ROLE_USER, ROLE_ADMINISTRATOR],
routes: [
...userDashboardRoutes,
{
path: '/subsets',
component: SubsetDashboardPage,
exact: true,
extraProps: {
title: 'My Dashboard',
},
},
...subsetDashboardRoutes,
...instituteDashboardRoutes,
{
path: '/:tab?',
component: DashboardPage,
......@@ -206,23 +92,8 @@ const routes = [
auth: [ROLE_ADMINISTRATOR],
routes: [
...userAdminRoutes,
...requestsAdminRoutes,
...repositoryAdminRoutes,
{
path: '/requests',
component: RequestBrowsePage,
exact: true,
extraProps: {
title: 'Requests',
},
},
{
path: '/requests/:uuid',
component: RequestDisplayPage,
exact: true,
extraProps: {
title: 'Request info',
},
},
{
path: '/',
component: AdminDashboardPage,
......
......@@ -28,20 +28,20 @@ const removeAccession = (accUUID: string) => ({
});
export const addAccessionToMyList = (accUUID: string) => (dispatch, getState) => {
const myList = getState().user.root.myList;
const myList = getState().user.public.myList;
if (!myList.accessions.includes(accUUID)) {
dispatch(addAccession(accUUID));
window.localStorage.setItem('myList', JSON.stringify(getState().user.root.myList));
window.localStorage.setItem('myList', JSON.stringify(getState().user.public.myList));
} else {
console.log(`Can't add accession ${accUUID}. Already in myList`);
}
};
export const removeAccessionFromMyList = (accUUID: string) => (dispatch, getState) => {
const myList = getState().user.root.myList;
const myList = getState().user.public.myList;
if (myList.accessions.includes(accUUID)) {
dispatch(removeAccession(accUUID));
window.localStorage.setItem('myList', JSON.stringify(getState().user.root.myList));
window.localStorage.setItem('myList', JSON.stringify(getState().user.public.myList));
} else {
console.log(`Can't remove accession ${accUUID}. Not in myList`);
}
......
import { combineReducers } from 'redux';
import admin from './admin';
import dashboard from './dashboard';
import root from './root';
import userPublic from './public';
const rootReducer = combineReducers({
admin,
dashboard,
root,
public: userPublic,
});
export default rootReducer;
......@@ -6,7 +6,7 @@ import * as _ from 'lodash';
import {log} from 'utilities/debug';
import {loginRequest, checkTokenRequest, verifyGoogleTokenRequest} from 'user/actions/root';
import {loginRequest, checkTokenRequest, verifyGoogleTokenRequest} from 'user/actions/public';
import ContentHeader from 'ui/common/heading/ContentHeader';
......
......@@ -3,7 +3,7 @@ import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
// Actions
import {registrationRequest} from 'user/actions/root';
import {registrationRequest} from 'user/actions/public';
// Util
import {log} from 'utilities/debug';
......
Supports Markdown
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