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

Code before:
    return secret
      .destroyRecord()
      .then(() => {
        try {
          this.router.transitionTo(LIST_ROOT_ROUTE, backend, { queryParams: { tab: 'role' } });
        } 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.'
        );
      }
    })
  );

Review comment (suggestion):
Probably a question for design, but IMO we don't need these line breaks and this could just render wrapped naturally in the modal. (Avoiding the need for a one-off css class)

Code after:
    return secret
      .destroyRecord()
      .then(() => {
        try {
          this.router.transitionTo(LIST_ROOT_ROUTE, backend, { queryParams: { tab: 'role' } });
        } 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.'
        );
      }
    })
  );