onSubmit = async () => { const { dispatch, id } = this.props; const { ttl, textvalue, textname } = this.state; this.setState({ errors: {}, saving: true }); try { const ids = [this.props.zone.id, id].filter(Boolean); await dispatch(dnszones.records[id ? 'put' : 'post']({ ttl_sec: +ttl, target: textvalue, // '' is the default and will track the zone name: textname === this.props.zone.dnszone ? '' : textname, type: 'TXT', }, ...ids)); this.setState({ saving: false }); this.props.close(); } catch (response) { if (!response.json) { // eslint-disable-next-line no-console return console.error(response); } const errors = await reduceErrors(response); this.setState({ errors, saving: false }); } }
onSubmit = async () => { const { dispatch, id } = this.props; const { ttl, hostname, alias } = this.state; this.setState({ errors: {}, saving: true }); try { const ids = [this.props.zone.id, id].filter(Boolean); await dispatch(dnszones.records[id ? 'put' : 'post']({ ttl_sec: +ttl, name: hostname, target: alias, type: 'CNAME', }, ...ids)); this.setState({ saving: false }); this.props.close(); } catch (response) { if (!response.json) { // eslint-disable-next-line no-console return console.error(response); } const errors = await reduceErrors(response); this.setState({ errors, saving: false }); } }
async revokeApp(id) { const { dispatch } = this.props; try { await dispatch(tokens.delete(id)); } catch (response) { const errors = await reduceErrors(response); this.setState({ errors }); } }
async takeSnapshot() { const { id, label } = this.getLinode(); const { dispatch } = this.props; try { const backup = await dispatch(takeBackup(id)); dispatch(push(`/linodes/${label}/backups/${backup.id}`)); } catch (response) { const errors = await reduceErrors(response); this.setState({ errors }); } }
async enableBackups(e) { e.preventDefault(); const { dispatch } = this.props; try { await dispatch(enableBackup(this.getLinode().id)); } catch (response) { const errors = await reduceErrors(response); // Promisify result for tests. await new Promise(resolve => this.setState({ errors }, resolve)); } }
async onSubmit() { const { dispatch } = this.props; const { id, label: oldLabel, group: oldGroup } = this.getLinode(); const { group, label } = this.state; this.setState({ loading: true, errors: {} }); try { await dispatch(linodes.put({ group, label }, id)); if (oldLabel !== label || oldGroup !== group) { await dispatch(push(`/linodes/${label}/settings`)); } } catch (response) { const errors = await reduceErrors(response); this.setState({ errors }); } this.setState({ loading: false }); }
async onSubmit() { const { dispatch, params: { linodeLabel } } = this.props; const { id: linodeId } = this.getLinode(); this.setState({ loading: true, errors: {} }); try { await dispatch(rebuildLinode(linodeId, { distribution: this.state.distribution, root_pass: this.state.password, })); dispatch(push(`/linodes/${linodeLabel}`)); } catch (response) { const errors = await reduceErrors(response); errors._.concat(errors.distribution); this.setState({ errors }); } this.setState({ loading: false }); }
onSubmit = async () => { const { dispatch, ip: { linode_id: linodeId, address } } = this.props; const { hostname } = this.state; this.setState({ errors: {}, saving: true }); try { await dispatch(setRDNS(linodeId, address, hostname)); this.setState({ saving: false }); this.props.close(); } catch (response) { if (!response.json) { // eslint-disable-next-line no-console return console.error(response); } const errors = await reduceErrors(response); this.setState({ errors, saving: false }); } }
async createDisk() { const { dispatch, linode } = this.props; const { label, size, distro, password, filesystem } = this.state; this.setState({ loading: true, errors: {} }); try { await dispatch(linodes.disks.post({ label, size, filesystem, distribution: distro === '' ? null : distro, root_pass: password, }, linode.id)); dispatch(hideModal()); } catch (response) { const errors = await reduceErrors(response); this.setState({ errors }); } this.setState({ loading: false }); }