Skip to content

Jira Connect create branch page: Alert when lacking permissions

Tom Quirk requested to merge 337274-jira-connect-better-empty-states into master

What does this MR do and why?

On the Jira Connect New Branch page, we add an alert when a user selects a project that don't have the push_code permission for.

Related to #337274 (closed)

Screenshots or screen recordings

demo_alert

How to set up and validate locally

  1. On a given GitLab project, set your user permission such you don't have push_code permission for the project.

    Tip 👉 apply this diff to "force" set the pushCode permission to false for the Gitlab Test project.

diff --git a/app/assets/javascripts/jira_connect/branches/components/new_branch_form.vue b/app/assets/javascripts/jira_connect/branches/components/new_branch_form.vue
index 94cf4dd2748..2ab7e09c2f8 100644
--- a/app/assets/javascripts/jira_connect/branches/components/new_branch_form.vue
+++ b/app/assets/javascripts/jira_connect/branches/components/new_branch_form.vue
@@ -93,6 +93,9 @@ export default {
       this.selectedProject = project;
       this.selectedSourceBranchName = null; // reset branch selection
       this.hasPermission = this.selectedProject.userPermissions.pushCode;
+      if (this.selectedProject.name === 'Gitlab Test') {
+        this.hasPermission = false;
+      }
 
       if (!this.hasPermission) {
         this.setPermissionAlert();
  1. Navigate to http://gdk.test:3000/-/jira_connect/branches/new
  2. Select the project for which you don't have permission (if using the patch provided, select the Gitlab test project).
  3. Observe. An alert should appear.
  4. Select a different project. You should have push_code permission for this project.
  5. Observe, the form should expand and no alert should appear.

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 Tom Quirk

Merge request reports

Loading