index.tsx 2.28 KB
Newer Older
1
2
3
4
import * as React from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';

5
import {Dataset, AccessionIdentifier} from 'model/dataset.model';
6
import {updateDatasetAccessionIdentifiers} from 'actions/dataset';
7
import ListOfAccesion from './ListOfAccesion';
Maxym Borodenko's avatar
Maxym Borodenko committed
8
import steps from '../../steps';
9
import NavigationWrapper from 'ui/common/stepper/NavigationWrapper';
10
11
12

interface IAccessionsListStep extends React.ClassAttributes<any> {
    dataset: Dataset;
13
    updateDatasetAccessionIdentifiers: (dataset: Dataset, accessionIdentifiers: AccessionIdentifier[]) => Promise<Dataset>;
Maxym Borodenko's avatar
Maxym Borodenko committed
14
15
16
17
18
    stillLoading: boolean;
    onDelete: () => void;
    onPublish: () => void;
    onGotoStep: (id: number) => () => void;
    location: any;
19
20
21
22
23
24
25
26
}

class AccessionsListStep extends React.Component<IAccessionsListStep, any> {

    public constructor(props: any) {
        super(props);
    }

27
    protected updateAccessionIdentifiers = (accessionIdentifiers: AccessionIdentifier[]) => {
Maxym Borodenko's avatar
Maxym Borodenko committed
28
29
30
31
32
33
        const {dataset, updateDatasetAccessionIdentifiers} = this.props;
        updateDatasetAccessionIdentifiers(dataset, accessionIdentifiers);
    }

    protected gotoStep = (id) => () => {
        this.props.onGotoStep(id);
34
35
36
    }

    public render() {
37
        const {dataset, stillLoading, onDelete, onPublish, location} = this.props;
38

39
        return (
40
            <NavigationWrapper location={ location } stillLoading={ stillLoading } disabledNext={ false }
Maxym Borodenko's avatar
Maxym Borodenko committed
41
42
43
44
45
46
                disabled={ false } steps={ steps }
                gotoStep={ this.gotoStep } onDelete={ onDelete } onPublish={ onPublish }>
                <ListOfAccesion
                    accessionIdentifiers={ dataset.accessionIdentifiers }
                    onAccessionsUpdated={ this.updateAccessionIdentifiers }
                />
47
            </NavigationWrapper>
48
        );
Matija Obreza's avatar
Matija Obreza committed
49
    }
50
51
52
}

const mapStateToProps = (state, ownProps) => ({
Matija Obreza's avatar
Matija Obreza committed
53
    dataset: state.datasets.currentDataset,
Maxym Borodenko's avatar
Maxym Borodenko committed
54
55
56
57
58
    stillLoading: ownProps.stillLoading,
    location: ownProps.location,
    onDelete: ownProps.onDelete,
    onPublish: ownProps.onPublish,
    onGotoStep: ownProps.onGotoStep,
59
60
61
});

const mapDispatchToProps = (dispatch) => bindActionCreators({
62
    updateDatasetAccessionIdentifiers,
63
64
65
66
67
}, dispatch);

export default connect(
    mapStateToProps, mapDispatchToProps,
)(AccessionsListStep);