Commit e45b5a45 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '77-migrate-to-modular-layout' into 'master'

Resolve "Migrate to modular layout"

Closes #77

See merge request genesys-pgr/genesys-ui!73
parents 16ed72b9 a91b5653
import {loginAppRequest} from 'actions/login';
import {checkTokenRequest} from 'user/actions/root';
import {checkTokenRequest} from 'user/actions/public';
function checkAuthTokenRequest(req, dispatch) {
const token = req.cookies.access_token;
......
......@@ -8,8 +8,8 @@ import AccessionFilter from 'model/AccessionFilter';
import AccessionDetails from 'model/AccessionDetails';
import AccessionMapInfo from 'model/AccessionMapInfo';
import {list as listAccessions, getDetailsByUuid, getDetailsByDoi, listOverview as listAccessionOverview, toUUID, mapInfo} from 'actions/genesys/accessionService';
import {RECEIVE_ACCESSIONS, RECEIVE_ACCESSION, RECEIVE_ACCESSION_OVERVIEW, APPEND_ACCESSIONS, RECEIVE_ACCESSION_MAPINFO} from 'constants/accessions';
import {list as listAccessions, getDetailsByUuid, getDetailsByDoi, listOverview as listAccessionOverview, toUUID, mapInfo} from 'service/genesys/actions/accessionService';
import {RECEIVE_ACCESSIONS, RECEIVE_ACCESSION, RECEIVE_ACCESSION_OVERVIEW, APPEND_ACCESSIONS, RECEIVE_ACCESSION_MAPINFO} from 'accessions/constants';
const receiveAccessions = (paged: FilteredPage<Accession>, error = null) => ({
type: RECEIVE_ACCESSIONS,
......@@ -97,7 +97,7 @@ export const loadAccessionsMapInfo = (filters: string | AccessionFilter) => (dis
};
export const loadAccessionsPage = (page: IPageRequest) => (dispatch, getState) => {
const filterCode = getState().accessions.paged.filterCode;
const filterCode = getState().accessions.public.paged.filterCode;
return dispatch(listAccessions(filterCode, page))
.then((paged) => {
if (paged.number === 0) {
......
import { combineReducers } from 'redux';
import publicAccessions from './public';
const rootReducer = combineReducers({
public: publicAccessions,
});
export default rootReducer;
import update from 'immutability-helper';
import { IReducerAction } from 'model/common.model';
import {RECEIVE_ACCESSIONS, RECEIVE_ACCESSION, RECEIVE_ACCESSION_OVERVIEW, APPEND_ACCESSIONS, RECEIVE_ACCESSION_MAPINFO} from 'constants/accessions';
import {RECEIVE_ACCESSIONS, RECEIVE_ACCESSION, RECEIVE_ACCESSION_OVERVIEW, APPEND_ACCESSIONS, RECEIVE_ACCESSION_MAPINFO} from 'accessions/constants';
import FilteredPage from 'model/FilteredPage';
import Accession from 'model/Accession';
......@@ -24,7 +24,7 @@ const INITIAL_STATE: {
mapInfo: null,
};
function accessions(state = INITIAL_STATE, action: IReducerAction) {
function publicAccessions(state = INITIAL_STATE, action: IReducerAction) {
switch (action.type) {
......@@ -102,4 +102,4 @@ function accessions(state = INITIAL_STATE, action: IReducerAction) {
}
}
export default accessions;
export default publicAccessions;
import AccessionBrowsePage from 'accessions/ui/BrowsePage';
import MapBrowsePage from 'accessions/ui/MapPage';
import AccessionDisplayPage from 'accessions/ui/DisplayPage';
import AccessionOverviewPage from 'accessions/ui/OverviewPage';
const publicRoutes = [
{
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,
},
];
export {publicRoutes as accessionPublicRoutes};
......@@ -4,7 +4,7 @@ import {bindActionCreators} from 'redux';
import { parse } from 'query-string';
// Actions
import { applyFilters, loadAccessionsPage, updateRoute } from 'actions/accessions';
import { applyFilters, loadAccessionsPage, updateRoute } from 'accessions/actions/public';
// Models
import Accession from 'model/Accession';
......@@ -17,7 +17,7 @@ import Loading from 'ui/common/Loading';
import PagedLoader from 'ui/common/PagedLoader';
import PrettyFilters from 'ui/common/filter/PrettyFilters';
import PaginationComponent from 'ui/common/pagination';
import AccessionCard from 'ui/genesys/accession/AccessionCard';
import AccessionCard from 'accessions/ui/c/AccessionCard';
import Tabs, {Tab} from 'ui/common/Tabs';
import AccessionFilters from './c/Filters';
// TODO only for demo
......@@ -95,7 +95,7 @@ class BrowsePage extends BrowsePageTemplate<Accession> {
}
const mapStateToProps = (state, ownProps) => ({
paged: state.accessions.paged || undefined,
paged: state.accessions.public.paged || undefined,
filterCode: ownProps.match.params.filterCode,
currentTab: ownProps.match.params.tab || 'data', // current tab, or ownProps.location.pathname
});
......
......@@ -4,8 +4,8 @@ import {bindActionCreators} from 'redux';
import { translate } from 'react-i18next';
// Actions
import { loadAccession } from 'actions/accessions';
import {addAccessionToMyList, removeAccessionFromMyList} from 'user/actions/root';
import { loadAccession } from 'accessions/actions/public';
import {addAccessionToMyList, removeAccessionFromMyList} from 'user/actions/public';
// Models
import AccessionDetails from 'model/AccessionDetails';
......@@ -22,7 +22,7 @@ import { ExternalLink } from 'ui/common/Links';
import SciName from 'ui/genesys/SciName';
import { ScrollToTopOnMount } from 'ui/common/page/scrollers';
import ReduxCheckbox from 'ui/common/checkbox';
import CropChips from 'ui/genesys/crop/CropChips';
import CropChips from 'crop/ui/c/CropChips';
import LocationMap from 'ui/common/LocationMap';
import {CountryLink, DatasetLink, InstituteLink, SubsetLink} from 'ui/genesys/Links';
import PropertiesCard from 'ui/common/PropertiesCard';
......@@ -267,11 +267,11 @@ class BrowsePage extends React.Component<IBrowsePageProps, any> {
}
const mapStateToProps = (state, ownProps) => ({
accession: state.accessions.accession,
error: state.accessions.accessionError,
accession: state.accessions.public.accession,
error: state.accessions.public.accessionError,
uuid: ownProps.match.params.uuid,
doi: ownProps.match.params.doi,
accessions: state.user.root.myList.accessions,
accessions: state.user.public.myList.accessions,
});
const mapDispatchToProps = (dispatch) => bindActionCreators({
......
......@@ -2,7 +2,7 @@ import * as React from 'react';
import {connect} from 'react-redux';
import {withStyles} from '@material-ui/core/styles';
import {bindActionCreators} from 'redux';
import { loadAccessionsMapInfo } from 'actions/accessions';
import { loadAccessionsMapInfo } from 'accessions/actions/public';
import AccessionFilter from 'model/AccessionFilter';
import Loading from 'ui/common/Loading';
import AccessionMapInfo from 'model/AccessionMapInfo';
......@@ -129,7 +129,7 @@ class BrowsePage extends React.Component<IMapPageProps, any> {
}
const mapStateToProps = (state, ownProps) => ({
mapInfo: state.accessions.mapInfo || undefined,
mapInfo: state.accessions.public.mapInfo || undefined,
filterCode: ownProps.match.params.filterCode || '',
currentTab: ownProps.match.params.tab || 'map', // current tab, or ownProps.location.pathname
});
......
......@@ -6,7 +6,7 @@ import { translate } from 'react-i18next';
import * as _ from 'lodash';
// Actions
import {applyFilters, loadAccessionsPage, listAccessionsPromise, updateRoute, applyOverviewFilters, loadAccessionsOverviewPage} from 'actions/accessions';
import {applyFilters, loadAccessionsPage, listAccessionsPromise, updateRoute, applyOverviewFilters, loadAccessionsOverviewPage} from 'accessions/actions/public';
import { showSnackbar } from 'actions/snackbar';
// Models
......@@ -211,8 +211,8 @@ class BrowsePage extends React.Component<IOverviewPageProps, any> {
}
const mapStateToProps = (state, ownProps) => ({
paged: state.accessions.paged || undefined,
overview: state.accessions.overview,
paged: state.accessions.public.paged || undefined,
overview: state.accessions.public.overview,
filterCode: ownProps.match.params.filterCode,
currentTab: ownProps.match.params.tab || 'overview', // current tab, or ownProps.location.pathname
});
......
......@@ -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({
......
import * as React from 'react';
import { reduxForm } from 'redux-form';
import { ACCESSION_FILTERFORM } from 'constants/accessions';
import { ACCESSION_FILTERFORM } from 'accessions/constants';
import FiltersBlock from 'ui/common/filter/FiltersBlock';
import CollapsibleComponentSearch from 'ui/common/filter/CollapsibleComponentSearch';
......@@ -10,7 +10,7 @@ import NumberFilter from 'ui/common/filter/NumberFilter';
import StringFilter from 'ui/common/filter/StringFilter';
import StringArrFilter from 'ui/common/filter/StringArrFilter';
import Accession from 'model/Accession';
import DateFilter from '../../../common/filter/DateFilter';
import DateFilter from 'ui/common/filter/DateFilter';
const AccessionFilters = ({handleSubmit, initialValues, initialize, ...other}) => {
// console.log('AccessionFilters', initialValues);
......
......@@ -4,7 +4,7 @@ import * as cookies from 'es-cookie';
import { clearCookies, saveCookies } from 'utilities';
import { ROLE_CLIENT } from 'constants/userRoles';
import {log} from 'utilities/debug';
import {loginUser} from 'user/actions/root';
import {loginUser} from 'user/actions/public';
export function checkAccessTokens(dispatch) {
const cookieToken: string = typeof window !== 'undefined' && cookies.get('access_token');
......
import * as _ from 'lodash';
import {getRequest, listRequests, sendValidationEmail, recheckPid, validateRequest} from 'actions/genesys/requestService';
// constants
import {APPEND_MATERIAL_REQUESTS, RECEIVE_MATERIAL_REQUEST, RECEIVE_MATERIAL_REQUESTS} from 'constants/requests';
// models
import MaterialRequest from 'model/MaterialRequest';
import FilteredPage, {IPageRequest} from 'model/FilteredPage';
const receiveRequests = (paged: FilteredPage<MaterialRequest>, error = null) => ({
type: RECEIVE_MATERIAL_REQUESTS,
payload: { paged, error },
});
const appendRequests = (paged: FilteredPage<MaterialRequest>, error = null) => ({
type: APPEND_MATERIAL_REQUESTS,
payload: { paged, error },
});
const receiveRequest = (request: MaterialRequest, error = null) => ({
type: RECEIVE_MATERIAL_REQUEST,
payload: { request, error },
});
const refreshRequestPID = (request: MaterialRequest) => (dispatch, getState) => {
const page = getState().requests.paged;
if (page) {
const toUpdateIndex = _.findIndex(page.content, (contentItem) => contentItem.uuid === request.uuid);
if (toUpdateIndex !== -1) {
page.content[toUpdateIndex].body.pid = request.body.pid;
}
return dispatch(receiveRequests(page));
}
};
const refreshRequest = (request: MaterialRequest) => (dispatch, getState) => {
const page = getState().requests.paged;
if (page) {
const toUpdateIndex = _.findIndex(page.content, (contentItem) => contentItem.uuid === request.uuid);
if (toUpdateIndex !== -1) {
page.content[toUpdateIndex] = request;
}
return dispatch(receiveRequests(page));
}
};
export { listRequests as listMaterialRequestsPromise };
export const listMaterialRequests = (page: IPageRequest) => (dispatch) => {
return dispatch(listRequests(null, page))
.then((page) => {
if (page.number === 0) {
dispatch(receiveRequests(page));
} else {
dispatch(appendRequests(page));
}
})
.catch((error) => {
dispatch(receiveRequests(null, error));
});
};
export const loadMaterialRequest = (uuid: string) => (dispatch) => {
return dispatch(getRequest(uuid))
.then((request) => {
dispatch(receiveRequest(request));
})
.catch((error) => {
dispatch(receiveRequest(null, error));
});
};
export const recheckPidAction = (uuid: string) => (dispatch) => {
return dispatch(recheckPid(uuid))
.then((request) => {
dispatch(receiveRequest(request));
dispatch(refreshRequestPID(request));
})
.catch((error) => {
dispatch(receiveRequest(null, error));
});
};
export const validateRequestAction = (uuid: string) => (dispatch) => {
return dispatch(validateRequest(uuid))
.then((request) => {
dispatch(receiveRequest(request));
dispatch(refreshRequest(request));
})
.catch((error) => {
dispatch(receiveRequest(null, error));
});
};
export const sendValidationEmailAction = (uuid: string) => (dispatch) => {
return dispatch(sendValidationEmail(uuid))
.then((request) => {
dispatch(receiveRequest(request));
dispatch(refreshRequest(request));
})
.catch((error) => {
dispatch(receiveRequest(null, error));
});
};
......@@ -8,7 +8,7 @@ import Crop from 'model/Crop';
// UI
import PageLayout, { PageContents } from 'ui/layout/PageLayout';
import ContentHeader from 'ui/common/heading/ContentHeader';
import CropCard from 'ui/genesys/crop/CropCard';
import CropCard from 'crop/ui/c/CropCard';
import GridLayout from 'ui/layout/GridLayout';
interface IBrowsePageProps extends React.ClassAttributes<any> {
......
......@@ -7,7 +7,7 @@ import Crop from 'model/Crop';
// UI
import PageLayout, {PageContents} from 'ui/layout/PageLayout';
import CropCard from 'ui/genesys/crop/CropCard';
import CropCard from 'crop/ui/c/CropCard';
import ContentHeader from 'ui/common/heading/ContentHeader';
interface IDisplayPageProps extends React.ClassAttributes<any> {
......
......@@ -31,7 +31,7 @@ const styles = (theme) => ({
});
const CropChips = ({crops, availableCrops, classes}: ICropChipsProps) => {
console.log(`CropChips`, crops);
// console.log(`CropChips`, crops);
if (typeof crops === 'string') {
crops = [ crops ];
}
......
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