Commit e1e40236 authored by Valeriy Panov's avatar Valeriy Panov
Browse files

#121. Display only Published Datasets and Descriptors on Browsers.

parent 7002eeb5
Pipeline #3543 passed with stages
in 3 minutes and 32 seconds
......@@ -18,6 +18,7 @@ interface IDatasetProps extends React.ClassAttributes<any> {
params: any;
classes: any;
location: any;
appMounted: boolean;
}
const styleSheet = (theme) => ({
......@@ -41,8 +42,8 @@ class DatasetStepper extends React.Component<IDatasetProps, any> {
protected static needs = [({uuid}) => getDatasetRequest(uuid)];
public componentDidMount() {
const {dataset, getDatasetRequest, params: {uuid}} = this.props;
if (!dataset) {
const {dataset, appMounted, getDatasetRequest, params: {uuid}} = this.props;
if (appMounted && !dataset) {
getDatasetRequest(uuid);
}
}
......@@ -50,26 +51,26 @@ class DatasetStepper extends React.Component<IDatasetProps, any> {
public render() {
const {children, classes, ...rest} = this.props;
return rest.dataset ? (
<Grid container spacing={ 0 }>
<TopSection />
<Grid item xs={ 12 } md={ 9 } xl={ 10 } className={ classes.leftColumn }>
<Grid container spacing={ 0 } className={ classes.contentWrapper }>
<StepNavigation showStepName bottomDivider { ...rest }/>
<Grid item xs={ 12 } className={ classes.content }>
<div className={ classes.greyBackground }>
{ React.cloneElement(children, rest) }
return (
<Grid container spacing={0}>
<TopSection/>
<Grid item xs={12} md={9} xl={10} className={classes.leftColumn}>
<Grid container spacing={0} className={classes.contentWrapper}>
<StepNavigation showStepName bottomDivider {...rest}/>
<Grid item xs={12} className={classes.content}>
<div className={classes.greyBackground}>
{React.cloneElement(children, rest)}
</div>
</Grid>
<StepNavigation topDivider { ...rest }/>
<StepNavigation topDivider {...rest}/>
</Grid>
</Grid>
<Grid item xs={ 12 } md={ 3 } xl={ 2 }>
<ProgressMenu { ...rest } />
<Grid item xs={12} md={3} xl={2}>
<ProgressMenu {...rest} />
</Grid>
<BottomSection />
<BottomSection/>
</Grid>
) : null;
)
};
}
......@@ -77,7 +78,8 @@ class DatasetStepper extends React.Component<IDatasetProps, any> {
const StyledComponent = withStyles(styleSheet)(DatasetStepper);
const mapStateToProps = (state, ownProps) => ({
dataset: ownProps.params.uuid === undefined ? null : state.datasets.byId[ownProps.params.uuid],
dataset: state.datasets.byId[ownProps.params.uuid],
appMounted: state.appMounted,
});
const mapDispatchToProps = (dispatch) => bindActionCreators({
......
......@@ -12,10 +12,11 @@ import ExpandFiltersComponent from '../../../common/filter/ExpandFiltersComponen
interface IDatasetSearchMenuProps extends React.ClassAttributes<any> {
classes: any;
loadDataset: (page?: number, results?: number, sortBy?: string, filter?: IDatasetFilter) => void;
loadDataset: (page?: number, results?: number, sortBy?: string, filter?: IDatasetFilter, order?: string) => void;
updateDatasetFilterModel: (filter: IDatasetFilter) => void;
paginationDatasetPage: Page<any>;
sortBy: string;
filter: IDatasetFilter;
}
const styles = (theme) => ({
......@@ -24,13 +25,14 @@ const styles = (theme) => ({
class DatasetSearchMenu extends React.Component<IDatasetSearchMenuProps, any> {
public constructor(props: any) {
super(props);
public componentDidMount() {
const {filter, updateDatasetFilterModel} = this.props;
updateDatasetFilterModel(filter);
}
private handleFilterFormSubmit = (e) => {
const {paginationDatasetPage: {size}, updateDatasetFilterModel, loadDataset, sortBy} = this.props;
const filters: IDatasetFilter = {...e};
const {paginationDatasetPage: {size}, updateDatasetFilterModel, loadDataset, sortBy, filter} = this.props;
const filters: IDatasetFilter = {...e, ...filter};
updateDatasetFilterModel(filters);
loadDataset(0, size, sortBy, filters);
}
......
......@@ -17,8 +17,9 @@ interface IDatasetList extends React.ClassAttributes<any> {
login: any;
classes: any;
createDatasetRequest: () => any;
listDatasetsRequest: (page?: number, results?: number, sortBy?: string, filter?: IDatasetFilter) => void;
listDatasetsRequest: (page?: number, results?: number, sortBy?: string, filter?: IDatasetFilter, order?: string) => void;
appMounted: boolean;
filter: IDatasetFilter;
}
const styles = (theme) => ({
......@@ -55,9 +56,9 @@ class DatasetList extends React.Component<IDatasetList, any> {
}
public componentDidMount() {
const {appMounted, listDatasetsRequest} = this.props;
const {appMounted, listDatasetsRequest, filter} = this.props;
if (appMounted) {
listDatasetsRequest();
listDatasetsRequest(0, 10, null, filter);
}
}
......@@ -68,7 +69,7 @@ class DatasetList extends React.Component<IDatasetList, any> {
public render() {
const {classes, datasetPage, listDatasetsRequest, createDatasetRequest, login} = this.props;
const {classes, datasetPage, listDatasetsRequest, createDatasetRequest, login, filter} = this.props;
return (
<div className={ classes.root }>
......@@ -76,7 +77,7 @@ class DatasetList extends React.Component<IDatasetList, any> {
subTitle="A Genesys Catalog of Phenotypic Dataset Linked to Genebank Accessions"
/>
<Grid container spacing={ 0 }>
<DatasetSearchMenu loadDataset={ listDatasetsRequest } sortBy={ this.state.sortBy }/>
<DatasetSearchMenu loadDataset={ listDatasetsRequest } sortBy={ this.state.sortBy } filter={ filter } />
<Grid item xs={ 12 } md={ 10 } className={ classes.listsWrapper }>
<Grid container spacing={ 0 }>
......
......@@ -12,18 +12,22 @@ interface IDatasetsProps extends React.ClassAttributes<any> {
datasetPage: Page<Dataset>;
login: any;
createDatasetRequest: () => void;
listDatasetsRequest: (page?: number, results?: number, sortBy?: string, filter?: IDatasetFilter) => void;
listDatasetsRequest: (page?: number, results?: number, sortBy?: string, filter?: IDatasetFilter, order?: string) => void;
appMounted: boolean;
}
const filter: IDatasetFilter = {
published: true,
};
class Datasets extends React.Component<IDatasetsProps, any> {
protected static needs = [() => listDatasetsRequest()];
protected static needs = [() => listDatasetsRequest(0, 10, null, {published: true})];
public render() {
return (
<div>
<DatasetList { ...this.props }/>
<DatasetList { ...this.props } filter={ filter }/>
</div>
);
}
......
......@@ -16,6 +16,7 @@ interface IDescriptorSearchMenuProps extends React.ClassAttributes<any> {
updateDescriptorFilterModel: (filter: IDescriptorFilter) => void;
paginationDescriptorPage: Page<any>;
sortBy: string;
filter: IDescriptorFilter;
}
const styles = (theme) => ({
......@@ -24,13 +25,14 @@ const styles = (theme) => ({
class DescriptorSearchMenu extends React.Component<IDescriptorSearchMenuProps, any> {
public constructor(props: any) {
super(props);
public componentDidMount() {
const {filter, updateDescriptorFilterModel} = this.props;
updateDescriptorFilterModel(filter);
}
private handleFilterFormSubmit = (e) => {
const {paginationDescriptorPage: {size}, updateDescriptorFilterModel, loadDescriptors, sortBy} = this.props;
const filters: IDescriptorFilter = {...e};
const {paginationDescriptorPage: {size}, updateDescriptorFilterModel, loadDescriptors, sortBy, filter} = this.props;
const filters: IDescriptorFilter = {...e, ...filter};
updateDescriptorFilterModel(filters);
loadDescriptors(0, size, sortBy, filters);
}
......
......@@ -18,6 +18,7 @@ interface IDescriptorListsPageProps extends React.ClassAttributes<any> {
classes: any;
descriptorPage: Page<Descriptor>;
loadDescriptors: (page?: number, results?: number, sortBy?: string, filter?: IDescriptorFilter) => void;
filter: IDescriptorFilter;
}
const styles = (theme) => ({
......@@ -56,7 +57,7 @@ class Descriptors extends React.Component<IDescriptorListsPageProps, any> {
}
public render() {
const {login, classes, loadDescriptors, descriptorPage} = this.props;
const {login, classes, loadDescriptors, descriptorPage, filter} = this.props;
return (
<div className={ classes.root }>
......@@ -64,7 +65,7 @@ class Descriptors extends React.Component<IDescriptorListsPageProps, any> {
subTitle="A Genesys Catalog of Published Descriptors"
/>
<Grid container spacing={ 0 }>
<DescriptorSearchMenu loadDescriptors={ loadDescriptors } sortBy={ this.state.sortBy }/>
<DescriptorSearchMenu loadDescriptors={ loadDescriptors } sortBy={ this.state.sortBy } filter={ filter }/>
<Grid item xs={ 12 } md={ 10 } className={ classes.listsWrapper }>
<Grid container spacing={ 0 }>
......
......@@ -15,14 +15,18 @@ interface IDescriptorListsPageProps extends React.ClassAttributes<any> {
appMounted: boolean;
}
const filter: IDescriptorFilter = {
published: true,
};
class DescriptorListsPage extends React.Component<IDescriptorListsPageProps, void> {
protected static needs = [() => loadDescriptors()];
protected static needs = [() => loadDescriptors(0, 10, null, filter)];
public componentDidMount() {
const {appMounted, loadDescriptors} = this.props;
if (appMounted) {
loadDescriptors();
loadDescriptors(0, 10, null, filter);
}
}
......@@ -35,6 +39,7 @@ class DescriptorListsPage extends React.Component<IDescriptorListsPageProps, voi
loadDescriptors={ loadDescriptors }
descriptorPage={ descriptorPage }
login={ login }
filter={ filter }
/>
</div>
);
......
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