Skip to content

Organizations - Create Project and Group Buttons

Zack Cuddy requested to merge 410815-organization-owners-create-projects into master

What does this MR do and why?

Closes #410815 (closed)
Important: This change is behind a feature flag ui_for_organizations

This change adds two sharable components for the Organization scope. NewGroupButton and New ProjectButton. These buttons handle all their own logic internally to make them easily sharable as we expand the Organization UI.

Currently these two buttons are used in two areas of the Organization UI:

1. Groups and Projects page

This page is a view that shows a list of either Groups or Projects. These actions are found in the header. The empty state in this scope does not show the actions and defers to them in the header.

2. Organization Dashboard page

This is the root page for an Organization. It has a similar view of Groups and Projects, however, it does not have a header bar with actions. Instead the buttons will only appear when the empty state is shown.

Some important context

The goal of this change is to simply create the button links and direct the user to those global pages. The big picture is that GitLab will actively track which organization you are currently working under and the global pages will automatically put the Groups/Projects you create into their respective Organizations.

This is not currently working this way as there are still some ongoing discussions on how this will happen. At the time of this MR you will not see Projects and Groups being created in the organization you navigate from and thus we do not need to fully test the entire flow quite yet.

Screenshots or screen recordings

1. Groups and Projects page

Has Groups Does Not Have Groups
With All Permissions GP_-All_Perms-_Wtih_Groups GP_-All_Perms-_Without_Groups
Cannot create groups GP_-No_Group_Perm-_with_Groups GP_-No_Group_Perm-_Without_Groups
Cannot create projects GP_-No_Project_Perm-_with_Groups GP_-No_Project_Perm-_Without_Groups

2. Organization Dashboard page

Project Empty State w/ Groups Project Empty State w/o Groups
With All Permissions Dashboard_-All_Perms-Project_Empty_State-_With_Groups Dashboard_-All_Perms-Project_Empty_State-_No_Groups
Cannot create projects Dashboard_-No_Project_Perm-_Empty_State Dashboard_-No_Project_Perm-_Empty_State
Groups Empty State
With All Permissions Dashboard_-All_Perms-_Group_Empty_State
Cannot create groups Dashboard_-No_Group_Perm-_Empty_State

How to set up and validate locally

Setup Organizations

  1. Access rails c
  2. Enable Feature Flag Feature.enable(:ui_for_organizations)
  3. Create the default organization and add root to it
you = User.find_by_username('root')
default_organization = Organizations::Organization.default_organization
Organizations::OrganizationUser.create!(organization_id: default_organization.id, user_id: you.id)

Testing Active Buttons

  1. Navigate to the GDK home page ex: 127.0.0.1:3000/
  2. Click Organizations in the sidebar
  3. Click the Default Organization
  4. Click the Manage > Groups and projects in the sidebar
  5. Ensure both New group and New project buttons are in the top right
  6. Click New group should navigate to global new project page ex: http://127.0.0.1:3000/groups/new
  7. Click New project should navigate to the global new group page ex: http://127.0.0.1:3000/projects/new

Testing Disabled Project Button

  1. Navigate to the GDK home page ex: 127.0.0.1:3000/
  2. Click Organizations in the sidebar
  3. Click New organization in the top right
  4. Fill out form and save
  5. Click the Manage > Groups and projects in the sidebar
  6. Ensure New group is active but New project is disabled (and tooltip appears when you hover)

Testing Permissions

important: Currently there are no existing access levels for organization users that cannot create a group. For this test we will "spoof" the property to be false with one of the below patches.

User cannot create groups
diff --git a/app/helpers/organizations/organization_helper.rb b/app/helpers/organizations/organization_helper.rb
index 83c57e7b3be..036a80baef2 100644
--- a/app/helpers/organizations/organization_helper.rb
+++ b/app/helpers/organizations/organization_helper.rb
@@ -61,7 +61,7 @@ def shared_groups_and_projects_app_data(organization)
         groups_empty_state_svg_path: image_path('illustrations/empty-state/empty-groups-md.svg'),
         new_group_path: new_group_path,
         new_project_path: new_project_path,
-        can_create_group: can?(current_user, :create_group, organization),
+        can_create_group: false,
         can_create_project: current_user&.can_create_project?,
         has_groups: has_groups?(organization)
       }
User cannot create projects
diff --git a/app/helpers/organizations/organization_helper.rb b/app/helpers/organizations/organization_helper.rb
index 83c57e7b3be..8642d19e826 100644
--- a/app/helpers/organizations/organization_helper.rb
+++ b/app/helpers/organizations/organization_helper.rb
@@ -62,7 +62,7 @@ def shared_groups_and_projects_app_data(organization)
         new_group_path: new_group_path,
         new_project_path: new_project_path,
         can_create_group: can?(current_user, :create_group, organization),
-        can_create_project: current_user&.can_create_project?,
+        can_create_project: false,
         has_groups: has_groups?(organization)
       }
     end
User cannot create groups or projects
diff --git a/app/helpers/organizations/organization_helper.rb b/app/helpers/organizations/organization_helper.rb
index 83c57e7b3be..23b205c2765 100644
--- a/app/helpers/organizations/organization_helper.rb
+++ b/app/helpers/organizations/organization_helper.rb
@@ -61,8 +61,8 @@ def shared_groups_and_projects_app_data(organization)
         groups_empty_state_svg_path: image_path('illustrations/empty-state/empty-groups-md.svg'),
         new_group_path: new_group_path,
         new_project_path: new_project_path,
-        can_create_group: can?(current_user, :create_group, organization),
-        can_create_project: current_user&.can_create_project?,
+        can_create_group: false,
+        can_create_project: false,
         has_groups: has_groups?(organization)
       }
     end
  1. Apply one of the patches provided
  2. Navigate to the GDK home page ex: 127.0.0.1:3000/
  3. Click Organizations in the sidebar
  4. Click the Default Organization
  5. Click the Manage > Groups and projects in the sidebar
  6. Ensure the group buttons are hidden

Related to #410815 (closed)

Edited by Zack Cuddy

Merge request reports