• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mac-s-g / react-json-view / #1222

pending completion
#1222

push

web-flow
Merge pull request #342 from mac-s-g/bump-patch

bump patch version

229 of 349 branches covered (65.62%)

Branch coverage included in aggregate %.

396 of 597 relevant lines covered (66.33%)

25.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/js/components/ObjectKeyModal/ObjectKeyModal.js
1
import React from 'react';
2
import dispatcher from './../../helpers/dispatcher';
3

4
import { CheckCircle, Add as Cancel } from './../icons';
5

6
//global theme
7
import Theme from './../../themes/getStyle';
8

9
//this input appears when adding a new value to an object
10
export default class extends React.PureComponent {
11
    constructor(props) {
12
        super(props);
×
13
        this.state = {
×
14
            input: props.input ? props.input : ''
×
15
        };
16
    }
17

18
    render() {
19
        const { theme, rjvId, isValid } = this.props;
×
20
        const { input } = this.state;
×
21

22
        const valid = isValid(input);
×
23

24
        return (
×
25
            <div
26
                class="key-modal-request"
27
                {...Theme(theme, 'key-modal-request')}
28
                onClick={this.closeModal}
29
            >
30
                <div
31
                    {...Theme(theme, 'key-modal')}
32
                    onClick={e => {
33
                        e.stopPropagation();
×
34
                    }}
35
                >
36
                    <div {...Theme(theme, 'key-modal-label')}>Key Name:</div>
37
                    <div style={{ position: 'relative' }}>
38
                        <input
39
                            {...Theme(theme, 'key-modal-input')}
40
                            class="key-modal-input"
41
                            ref={el => el && el.focus()}
×
42
                            spellCheck={false}
43
                            value={input}
44
                            placeholder="..."
45
                            onChange={e => {
46
                                this.setState({
×
47
                                    input: e.target.value
48
                                });
49
                            }}
50
                            onKeyPress={e => {
51
                                if (valid && e.key === 'Enter') {
×
52
                                    this.submit();
×
53
                                } else if (e.key === 'Escape') {
×
54
                                    this.closeModal();
×
55
                                }
56
                            }}
57
                        />
58
                        {valid ? (
×
59
                            <CheckCircle
60
                                {...Theme(theme, 'key-modal-submit')}
61
                                class="key-modal-submit"
62
                                onClick={e => this.submit()}
×
63
                            />
64
                        ) : null}
65
                    </div>
66
                    <span {...Theme(theme, 'key-modal-cancel')}>
67
                        <Cancel
68
                            {...Theme(theme, 'key-modal-cancel-icon')}
69
                            class="key-modal-cancel"
70
                            onClick={() => {
71
                                dispatcher.dispatch({
×
72
                                    rjvId: rjvId,
73
                                    name: 'RESET'
74
                                });
75
                            }}
76
                        />
77
                    </span>
78
                </div>
79
            </div>
80
        );
81
    }
82

83
    closeModal = () => {
×
84
        dispatcher.dispatch({
×
85
            rjvId: this.props.rjvId,
86
            name: 'RESET'
87
        });
88
    };
89

90
    submit = () => {
×
91
        this.props.submit(this.state.input);
×
92
    };
93
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc