Skip to content

Do not show revoke button if revoke_path is absent

Eduardo Sanz García requested to merge eduardosanz/optional-revoke-path into master

What does this MR do and why?

AccessTokenTableApp component assumed that revoke_path in the access token is always present. However, the property revoke_path is optional.

When the revoke_path is absent or falsy, it doesn't display the revoke button action.

Screenshots or screen recordings

Before

image

After

image

How to set up and validate locally

  1. Create a personal access token:
  2. See the revoke button is present
  3. Apply patch:
diff --git a/app/assets/javascripts/access_tokens/index.js b/app/assets/javascripts/access_tokens/index.js
index f0c1b415157..c12b45bf2b1 100644
--- a/app/assets/javascripts/access_tokens/index.js
+++ b/app/assets/javascripts/access_tokens/index.js
@@ -43,7 +43,7 @@ export const initAccessTokenTableApp = () => {
     provide: {
       accessTokenType,
       accessTokenTypePlural,
-      initialActiveAccessTokens,
+      initialActiveAccessTokens: initialActiveAccessTokens.map(({ revokePath, ...rest }) => rest),
       noActiveTokensMessage,
       showRole,
     },
  1. Reload the page and observe that the button is not present.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Eduardo Sanz García

Merge request reports

Loading