Repository: hashicorp/vault
File: ui/app/components/database-role-edit.js (JavaScript)

Code before:
        } catch (e) {
          console.debug(e); // eslint-disable-line
        }
      })
      .catch((e) => {
        this.flashMessages.danger(e.errors?.join('. '));
      });
  }

  handleCreateEditRole = task(
    waitFor(async (evt) => {
      evt.preventDefault();
      this.resetErrors();
      const { mode, model } = this.args;
      if (!this.isValid()) return;

      // if we're creating and rotating a static role immediately, warn user
      if (!model.skip_import_rotation && model.type === 'static' && mode === 'create') {
        this.saveIssuerWarning =
          "You have enabled 'Rotate immediately' for this static role. \n Vault will update the password immediately after you save. \n \n NOTE: This will disrupt any active use of this role outside of Vault.";
        return;
      }
      await this.saveRole.perform();
    })
  );

  saveRole = task(
    waitFor(async () => {
      const { mode, model } = this.args;

      if (mode === 'create') {
        model.id = model.name;
        const path = model.type === 'static' ? 'static-roles' : 'roles';
        model.path = path;
      }
      try {
        await model.save();
        this.router.transitionTo(SHOW_ROUTE, `role/${model.name}`);
      } catch (e) {
        this.errorMessage = errorMessage(e);
        this.flashMessages.danger(
          this.errorMessage || 'Could not save the role. Please check Vault logs for more information.'
        );
      }
    })
  );

  @action
  rotateRoleCred(id) {
    const backend = this.args.model?.backend;
    const adapter = this.store.adapterFor('database/credential');

Review comment (suggestion):
now that the save task has been separated, `handleCreateEditRole` should probably be converted to just an async action unless we need any concurrent behaviors from the method. 

Code after:
        } catch (e) {
          console.debug(e); // eslint-disable-line
        }
      })
      .catch((e) => {
        this.flashMessages.danger(e.errors?.join('. '));
      });
  }

  @action
  async handleCreateEditRole(evt) {
    evt.preventDefault();
    this.resetErrors();
    const { mode, model } = this.args;
    if (!this.isValid()) return;

    // if we're creating and rotating a static role immediately, warn user
    if (!model.skip_import_rotation && model.type === 'static' && mode === 'create') {
      this.saveIssuerWarning =
        "You have enabled 'Rotate immediately' for this static role. Vault will update the password immediately after you save. NOTE: This will disrupt any active use of this role outside of Vault.";
      return;
    }
    await this.saveRole.perform();
  }

  saveRole = task(
    waitFor(async () => {
      const { mode, model } = this.args;

      if (mode === 'create') {
        model.id = model.name;
        const path = model.type === 'static' ? 'static-roles' : 'roles';
        model.path = path;
      }
      try {
        await model.save();
        this.router.transitionTo(SHOW_ROUTE, `role/${model.name}`);
      } catch (e) {
        this.errorMessage = errorMessage(e);
        this.flashMessages.danger(
          this.errorMessage || 'Could not save the role. Please check Vault logs for more information.'
        );
      }
    })
  );

  @action
  rotateRoleCred(id) {
    const backend = this.args.model?.backend;
    const adapter = this.store.adapterFor('database/credential');
    return adapter