Backend for new deploy tokens via ajax

Merged Amy Troschinetz requested to merge atroschinetz/new-deploy-token-via-ajax into master

What does this MR do?

Resolves the backend half of #22794 by changing the POST to an ajax request. This means that a reload of the page will no longer trigger the creation of a new deploy token.

These changes are behind a feature flag named :ajax_new_deploy_token. The flag exists at the group and project level.

When enabled:

  • Makes create_deploy_token actions of ci_cd controllers ajax
  • The JSON response matches the existing API schema

API Schema: https://docs.gitlab.com/ee/api/deploy_tokens.html

Frontend Followup Work

First, we have to initially hide new deploy token info-well.

Then, when we get JSON response:

  1. if data is good:
    • populate that data in the info-well
    • populate the data-clipboard-text fields too
    • un-hide the info-well
  2. otherwise, hide the info-well
  3. show the payload's message in either notice or alert
  4. re-enable the submit button

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Amy Troschinetz