File size: 1,670 Bytes
6bcb42f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import PropTypes from 'prop-types';
import React from 'react';
import bindAll from 'lodash.bindall';
import ExtensionModal from '../components/pm-extension-modals/extension-modals.jsx';

class ExtensionModals extends React.Component {
    constructor (props) {
        super(props);
        bindAll(this, [
            'handleOk',
            'handleCancel'
        ]);
        this.state = {
            updateId: 0
        };
    }
    shouldComponentUpdate () {
        const vm = this.props.vm;
        if (!vm) return false;
        if (!vm.runtime) return false;
        if (!vm.runtime.modalManager) return false;
        return vm.runtime.modalManager._updateId !== this.state.updateId;
    }
    componentDidUpdate () {
        const vm = this.props.vm;
        if (!vm) return;
        if (!vm.runtime) return;
        if (!vm.runtime.modalManager) return;
        this.setState({
            updateId: vm.runtime.modalManager._updateId
        });
    }
    handleOk () {
        
    }
    handleCancel () {
        
    }
    render () {
        const vm = this.props.vm;
        if (!vm) return;
        if (!vm.runtime) return;
        if (!vm.runtime.modalManager) return;
        const modals = vm.runtime.modalManager.modals;
        return (<>
            {Object.keys(modals).map((modalId) => {
                const modal = modals[modalId];
                return (
                    <ExtensionModal
                        {...modal}
                        vm={this.props.vm}
                    />
                );
            })}
        </>);
    }
}

ExtensionModals.propTypes = {
    vm: PropTypes.any
};

export default ExtensionModals;