()
| 138 | } |
| 139 | |
| 140 | async handleAdd() { |
| 141 | const errors = {}; |
| 142 | if (this.state.user.name.trim() === '') { |
| 143 | errors.name = new Error(); |
| 144 | } |
| 145 | const validEmail = isValidAddress(this.state.user.email); |
| 146 | if (!validEmail) { |
| 147 | errors.email = {invalid: new Error()}; |
| 148 | } else { |
| 149 | if (this.state.userEmails.includes(this.state.user.email)) { |
| 150 | errors.email = {exists: new Error()}; |
| 151 | } |
| 152 | } |
| 153 | if (Object.keys(errors).length) { |
| 154 | this.setState({errors}); |
| 155 | return; |
| 156 | } |
| 157 | this.setState({processing: true}); |
| 158 | try { |
| 159 | await port.send('add-user', {fingerprint: this.state.keyDetails.fingerprint, user: this.state.user, keyringId: this.context.keyringId}); |
| 160 | this.setState({exit: true}, () => this.props.onKeyringChange()); |
| 161 | } catch (error) { |
| 162 | if (error.code !== 'PWD_DIALOG_CANCEL') { |
| 163 | throw error; |
| 164 | } |
| 165 | this.setState({processing: false}); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | async handleDelete() { |
| 170 | this.setState({processing: true}); |
nothing calls this directly
no test coverage detected