summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/src/nfvo-components/table/SelectActionTable.jsx
blob: 1baf0484d2860f7e1bc9d83261665a77ab25ff7a (plain)
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
import React from 'react';
import i18n from 'nfvo-utils/i18n/i18n.js';
import { SVGIcon, Button } from 'onap-ui-react';
import uuid from 'uuid-js';

export default class SelectActionTable extends React.Component {
    render() {
        let {
            columns,
            onAdd,
            isReadOnlyMode,
            children,
            onAddItem,
            numOfIcons
        } = this.props;
        return (
            <div
                className={`select-action-table-view ${
                    isReadOnlyMode ? 'disabled' : ''
                }`}>
                <div className="select-action-table-controllers">
                    {onAdd &&
                        onAddItem && (
                            <Button
                                btnType="link"
                                disabled={isReadOnlyMode === true}
                                color="primary"
                                iconName="plus"
                                data-test-id="select-action-table-add"
                                onClick={onAdd}>
                                {onAddItem}
                            </Button>
                        )}
                    <SVGIcon name="trashO" className="dummy-icon" />
                </div>
                <div className="select-action-table">
                    <div className="select-action-table-headers">
                        {columns.map(column => (
                            <div
                                key={uuid.create()}
                                className="select-action-table-header">
                                {i18n(column)}
                            </div>
                        ))}
                        {Array(numOfIcons)
                            .fill()
                            .map((e, i) => (
                                <SVGIcon
                                    name="trash-o"
                                    key={i}
                                    className="dummy-icon"
                                />
                            ))}
                    </div>
                    <div className="select-action-table-body">{children}</div>
                </div>
            </div>
        );
    }
}