Commit 0800bfef authored by Viacheslav Pavlov's avatar Viacheslav Pavlov
Browse files

Merge branch '193-reduce-ssr-needs' into 'master'

Resolve "Reduce SSR `needs`"

Closes #193

See merge request genesys-pgr/genesys-ui!198
parents e184cb12 3ab486b7
......@@ -2,13 +2,11 @@ import * as React from 'react';
import { translate } from 'react-i18next';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { parse } from 'query-string';
// Actions
import { applyFilters, loadMoreAccessions, updateRoute } from 'accessions/actions/public';
// Models
import Page from 'model/Page';
import Accession from 'model/accession/Accession';
// UI
......@@ -26,12 +24,6 @@ import ButtonBar from 'ui/common/buttons/ButtonBar';
import DownloadDialog, { DOWNLOAD_LIMIT } from 'ui/common/download-dialog';
class BrowsePage extends BrowsePageTemplate<Accession> {
protected static needs = [
({ search, params: { filterCode } }) => {
const qs = parse(search || '');
return applyFilters(filterCode || '', Page.fromQueryString(qs));
},
];
constructor(props: IBrowsePageProps<Accession>, context: any) {
super(props, context);
......
......@@ -3,13 +3,11 @@ import { Link } from 'react-router-dom';
import { translate } from 'react-i18next';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { parse } from 'query-string';
// Actions
import { activityPostApplyFilters, loadMoreActivityPosts, activityPostUpdateRoute } from 'cms/actions/admin';
// Models
import Page from 'model/Page';
import ActivityPost from 'model/cms/ActivityPost';
// UI
......@@ -24,12 +22,6 @@ import Button from '@material-ui/core/Button/Button';
import ActivityPostCard from './c/ActivityPostCard';
class ActivityPostBrowsePage extends BrowsePageTemplate<ActivityPost> {
protected static needs = [
({ search, params: { filterCode } }) => {
const qs = parse(search || '');
return activityPostApplyFilters(filterCode || '', Page.fromQueryString(qs));
},
];
constructor(props: IBrowsePageProps<ActivityPost>, context: any) {
super(props, context);
......
......@@ -3,13 +3,11 @@ import { Link } from 'react-router-dom';
import { translate } from 'react-i18next';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { parse } from 'query-string';
// Actions
import { applyFilters, loadMoreArticles, updateRoute } from 'cms/actions/admin';
// Models
import Page from 'model/Page';
import Article from 'model/cms/Article';
// UI
......@@ -24,12 +22,6 @@ import ContentHeaderWithButton from 'ui/common/heading/ContentHeaderWithButton';
import Button from '@material-ui/core/Button/Button';
class BrowsePage extends BrowsePageTemplate<Article> {
protected static needs = [
({ search, params: { filterCode } }) => {
const qs = parse(search || '');
return applyFilters(filterCode || '', Page.fromQueryString(qs));
},
];
constructor(props: IBrowsePageProps<Article>, context: any) {
super(props, context);
......
......@@ -2,8 +2,6 @@ import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { parse } from 'query-string';
import { filterCodeToUrl } from 'actions/filterCode';
import { loadCrops } from 'crop/actions/public';
import { applyFilters, loadMoreDatasets, updateRoute } from 'datasets/actions/public';
......@@ -21,18 +19,10 @@ import DatasetCard from './c/Card';
import ContentHeader from 'ui/common/heading/ContentHeader';
import { ScrollToTopOnMount } from 'ui/common/page/scrollers';
import BrowsePageTemplate from 'ui/pages/_base/BrowsePage';
import Page from 'model/Page';
import { translate } from 'react-i18next';
class BrowsePage extends BrowsePageTemplate<Dataset> {
public static needs = [
({ search, params: { filterCode } }) => {
const qs = parse(search || '');
return applyFilters(filterCode || '', Page.fromQueryString(qs));
},
];
protected renderDataset = (d: Dataset) => <DatasetCard dataset={ d } key={ d.uuid }/>;
public render() {
......
import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { parse } from 'query-string';
import BaseMyDataPage from 'ui/catalog/dashboard/MyDataPage';
import { approveDataset, deleteDataset, loadMoreDatasets, unpublishDataset, publishDataset } from 'datasets/actions/dashboard';
......@@ -11,13 +10,7 @@ import { PublishState } from 'model/common.model';
const renderDataLink = ({ row, children }) => (<DatasetLink to={ row } edit={ row.state === PublishState.DRAFT && row._permissions.write }>{ children }</DatasetLink>);
class DashboardPage extends BaseMyDataPage<Dataset> {
protected static needs = [
({ search , params: { filterCode } }) => loadMoreDatasets({ sort: [{ property: parse(search || '').s, direction: parse(search || '').d }], filterCode }),
];
}
class DashboardPage extends BaseMyDataPage<Dataset> {}
const mapStateToProps = (state, ownProps) => ({
paged: state.datasets.dashboard.paged,
......
......@@ -15,7 +15,6 @@ import ListOfAccessions from './ListOfAccessions';
import StepperTemplate from 'ui/common/stepper/StepperTemplate';
import Loading from 'ui/common/Loading';
interface IAccessionsListStep extends React.ClassAttributes<any> {
item: Dataset;
accessionRefs: Page<AccessionRef>;
......@@ -33,10 +32,6 @@ interface IAccessionsListStep extends React.ClassAttributes<any> {
class AccessionsListStep extends StepperTemplate<IAccessionsListStep> {
protected static needs = [
({ params: { uuid } }) => loadMoreAccessions(uuid),
];
private loadMoreAccessions = (paged: Page<AccessionRef>) => {
const { loadMore, item } = this.props;
loadMore(item.uuid, paged);
......
......@@ -3,8 +3,6 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { translate } from 'react-i18next';
import { parse } from 'query-string';
import { filterCodeToUrl } from 'actions/filterCode';
import { applyFilters, loadMoreDescriptorLists, updateRoute } from 'descriptorlists/actions/public';
import { loadCrops } from 'crop/actions/public';
......@@ -22,18 +20,10 @@ import PrettyFilters from 'ui/common/filter/PrettyFilters';
import PageLayout, { PageContents } from 'ui/layout/PageLayout';
import ContentHeader from 'ui/common/heading/ContentHeader';
import BrowsePageTemplate from 'ui/pages/_base/BrowsePage';
import Page from 'model/Page';
// Page to browse and filter descriptor lists
class BrowsePage extends BrowsePageTemplate<DescriptorList> {
public static needs = [
({ search, params: { filterCode } }) => {
const qs = parse(search || '');
return applyFilters(filterCode || '', Page.fromQueryString(qs));
},
];
protected renderDescriptorList = (d: DescriptorList) => (
<DescriptorListCard descriptorList={ d } key={ d.uuid }/>
)
......
import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { parse } from 'query-string';
import BaseMyDataPage from 'ui/catalog/dashboard/MyDataPage';
import { loadMoreDescriptorLists, approveDescriptorList, deleteDescriptorList, unpublishDescriptorList, publishDescriptorList } from 'descriptorlists/actions/dashboard';
......@@ -11,11 +10,7 @@ import DescriptorList from 'model/catalog/DescriptorList';
const renderDataLink = ({ row, children }) => (<DescriptorListLink to={ row } edit={ row.state === PublishState.DRAFT && row._permissions.write }>{ children }</DescriptorListLink>);
class DashboardPage extends BaseMyDataPage<any> {
protected static needs = [
({ search , params: { filterCode } }) => loadMoreDescriptorLists({ sort: [{ property: parse(search || '').s, direction: parse(search || '').d }], filterCode }),
];
}
class DashboardPage extends BaseMyDataPage<any> {}
const mapStateToProps = (state, ownProps) => ({
paged: state.descriptorList.dashboard.paged,
......
......@@ -3,8 +3,6 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { translate } from 'react-i18next';
import { parse } from 'query-string';
import { filterCodeToUrl } from 'actions/filterCode';
import { applyFilters, loadMoreDescriptors, updateRoute } from 'descriptors/actions/public';
......@@ -20,17 +18,9 @@ import PrettyFilters from 'ui/common/filter/PrettyFilters';
import PageLayout, { PageContents } from 'ui/layout/PageLayout';
import ContentHeader from 'ui/common/heading/ContentHeader';
import BrowsePageTemplate from 'ui/pages/_base/BrowsePage';
import Page from 'model/Page';
class BrowsePage extends BrowsePageTemplate<Descriptor> {
public static needs = [
({ search, params: { filterCode } }) => {
const qs = parse(search || '');
return applyFilters(filterCode || '', Page.fromQueryString(qs));
},
];
public render() {
const { paged, t, loadMoreData } = this.props;
......
import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { parse } from 'query-string';
import BaseMyDataPage from 'ui/catalog/dashboard/MyDataPage';
import { approveDescriptor, deleteDescriptor, unpublishDescriptor, publishDescriptor, loadMoreDescriptors } from 'descriptors/actions/dashboard';
......@@ -10,14 +9,9 @@ import { DescriptorLink } from 'ui/catalog/Links';
import { PublishState } from 'model/common.model';
import DashboardDescriptorFilters from './c/DashboardFilters';
const renderDataLink = ({ row, children }) => (<DescriptorLink to={ row } edit={ row.state === PublishState.DRAFT && row._permissions.write }>{ children }</DescriptorLink>);
class DashboardPage extends BaseMyDataPage<Descriptor> {
protected static needs = [
({ search , params: { filterCode } }) => loadMoreDescriptors({ sort: [{ property: parse(search || '').s, direction: parse(search || '').d }], filterCode }),
];
}
class DashboardPage extends BaseMyDataPage<Descriptor> {}
const mapStateToProps = (state, ownProps) => ({
paged: state.descriptors.dashboard.paged,
......
import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { parse } from 'query-string';
import { translate } from 'react-i18next';
// Actions
import { applyFilters, loadMoreInstitutes, updateRoute } from 'institutes/actions/public';
// Models
import Page from 'model/Page';
import FaoInstitute from 'model/genesys/FaoInstitute';
// UI
......@@ -23,12 +21,6 @@ import InstituteCard from 'institutes/ui/с/InstituteCard';
import InstituteFilters from './с/Filters';
class BrowsePage extends BrowsePageTemplate<FaoInstitute> {
protected static needs = [
({ search, params: { filterCode } }) => {
const qs = parse(search || '');
return applyFilters(filterCode || '', Page.fromQueryString(qs));
},
];
constructor(props: IBrowsePageProps<FaoInstitute>, context: any) {
super(props, context);
......
......@@ -3,8 +3,6 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { translate } from 'react-i18next';
import { parse } from 'query-string';
import { filterCodeToUrl } from 'actions/filterCode';
import Partner from 'model/genesys/Partner';
import { applyFilters, loadMorePartners, updateRoute } from 'partners/actions/public';
......@@ -22,19 +20,11 @@ import PageLayout, { PageContents } from 'ui/layout/PageLayout';
import { ScrollToTopOnMount } from 'ui/common/page/scrollers';
import ContentHeader from 'ui/common/heading/ContentHeader';
import BrowsePageTemplate from 'ui/pages/_base/BrowsePage';
import Page from 'model/Page';
import ActionButton from 'ui/common/buttons/ActionButton';
import ButtonBar from 'ui/common/buttons/ButtonBar';
class PartnerListPage extends BrowsePageTemplate<Partner> {
public static needs = [
({ search, params: { filterCode } }) => {
const qs = parse(search || '');
return applyFilters(filterCode || '', Page.fromQueryString(qs));
},
];
protected renderPartner = (p: Partner) => (
<PartnerCard partner={ p } key={ p.uuid }/>
)
......
......@@ -49,10 +49,6 @@ interface IRepositoryBrowserProps extends React.ClassAttributes<any> {
class RepositoryBrowser extends React.Component<IRepositoryBrowserProps, any> {
protected static needs = [
({ ownProps }) => getFolder(normalize((ownProps.route.root || '/') + (ownProps.match.params.path || '/')).replace(/^(.+)\/$/, '$1')),
];
public componentWillMount() {
const { folder, folderPath, getFolder } = this.props;
// console.log(`RepositoryBrowser.cwm...`, folderPath);
......
......@@ -2,14 +2,12 @@ import * as React from 'react';
import { translate } from 'react-i18next';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { parse } from 'query-string';
// Actions
import { applyFilters, updateRoute, loadMoreRequests } from 'requests/actions/admin';
// Models
import MaterialRequest from 'model/request/MaterialRequest';
import FilteredPage from 'model/FilteredPage';
// UI
import BrowsePageTemplate from 'ui/pages/_base/BrowsePage';
......@@ -25,13 +23,6 @@ import PaginationComponent from 'ui/common/pagination';
class BrowsePage extends BrowsePageTemplate<any> {
protected static needs = [
({ search, params: { filterCode } }) => {
const qs = parse(search || '');
return applyFilters(filterCode || '', FilteredPage.fromQueryString(qs));
},
];
public componentWillMount() {
const { paged, applyFilters, filterCode } = this.props;
if (!paged) {
......
......@@ -2,13 +2,11 @@ import * as React from 'react';
import { translate } from 'react-i18next';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import { parse } from 'query-string';
// Actions
import { applyFilters, loadMoreSubsets, updateRoute } from 'subsets/actions/public';
// Models
import Page from 'model/Page';
import Subset from 'model/subset/Subset';
// UI
......@@ -24,13 +22,6 @@ import SubsetFilters from './c/Filters';
class BrowsePage extends BrowsePageTemplate<Subset> {
protected static needs = [
({ search, params: { filterCode } }) => {
const qs = parse(search || '');
return applyFilters(filterCode || '', Page.fromQueryString(qs));
},
];
constructor(props: IBrowsePageProps<Subset>, context: any) {
super(props, context);
}
......
......@@ -27,12 +27,6 @@ interface IAccessionsListStep extends React.ClassAttributes<any> {
class AccessionsListStep extends StepperTemplate<IAccessionsListStep> {
protected static needs = [
({ params: { uuid } }) => {
return uuid ? loadMoreAccessions(uuid) : null;
},
];
public componentWillMount() {
const { loadMore, uuid, accessionRefs, item } = this.props;
if (! accessionRefs || (item && item.uuid !== uuid)) {
......
......@@ -2,13 +2,11 @@ import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { translate } from 'react-i18next';
import { parse } from 'query-string';
// Actions
import { applyFilters, updateRoute, loadMoreUsers } from 'user/actions/admin';
// Models
import FilteredPage from 'model/FilteredPage';
import { User } from 'model/user/User';
// UI
......@@ -29,13 +27,6 @@ const mobile = ['xs'] as Breakpoint[];
class BrowsePage extends BrowsePageTemplate<User> {
protected static needs = [
({ search, params: { filterCode } }) => {
const qs = parse(search || '');
return applyFilters(filterCode || '', FilteredPage.fromQueryString(qs));
},
];
public componentWillMount() {
const { paged, applyFilters, filterCode } = this.props;
if (!paged) {
......
......@@ -31,13 +31,8 @@ const styles = (theme) => ({
},
});
class BrowsePage extends BrowsePageTemplate<Vocabulary> {
protected static needs = [
({ search }) => listVocabularies({ page: parse(search).p, size: parse(search).l, properties: parse(search).s, direction: parse(search).d }),
];
protected autoUpdateVocabularies = () => {
const { autoUpdateVocabularies, loadMoreData } = this.props;
autoUpdateVocabularies()
......@@ -47,7 +42,6 @@ class BrowsePage extends BrowsePageTemplate<Vocabulary> {
});
}
public render() {
const { classes, paged, createVocabulary, loadMoreData, t } = this.props;
......
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