示例#1
0
  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 });
    }
  }
示例#2
0
  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 });
    }
  }
示例#4
0
 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 });
   }
 }
示例#5
0
 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));
   }
 }
示例#6
0
  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 });
  }
示例#7
0
  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 });
  }
示例#8
0
  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 });
    }
  }
示例#9
0
  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 });
  }