Skip to content

Commit

Permalink
made create subproject from within the project level possible
Browse files Browse the repository at this point in the history
  • Loading branch information
hgw77 committed Nov 19, 2024
1 parent 90fc44b commit 68d7133
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ class CreateWizardController < DashboardController
def new
@project = services.identity.new_project
@project.cost_control = {}
# this is only set if the user is in the project context and creates a new sub project
if params[:parent_id] && params[:parent_name]
@project.parent_id = params[:parent_id]
@project.parent_name = params[:parent_name]
end
return unless @inquiry

@project.attributes = @inquiry.payload
Expand All @@ -17,10 +22,9 @@ def create
params.fetch(:project, {}).merge(domain_id: @scoped_domain_id)
cost_params = project_params.delete(:cost_control)

# user is not allowed to create a project (maybe)
# so use admin identity for that!
@project = services.identity.new_project
@project.attributes = project_params
@project.parent_id = @scoped_project_id if @scoped_project_id

@project.enabled = @project.enabled == 'true'

Expand Down Expand Up @@ -51,7 +55,7 @@ def create
)
render 'identity/domains/create_wizard/create', formats: :js
else
# there is no requiry -> current user is the creator of this
# there is no inquiry -> current user is the creator of this
# project. give current user all needed roles
assign_needed_roles(@project.id, current_user.id)

Expand Down Expand Up @@ -88,6 +92,8 @@ def load_and_authorize_inquiry

def assign_needed_roles(project_id, user_id)
%w[admin member network_admin resource_admin].each do |role_name|
# everyone can create projects but not everyone can add the admin roles to the project
# so we need to use the service user to assign the basic admin roles
service_user.identity.grant_project_user_role_by_role_name(
project_id,
user_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,15 @@
%td
= javascript_include_tag :identity_prodel_widget, data: {base_url: plugin('identity').root_path}

- if current_user.is_allowed?('identity:project_request')
%h4.action-heading
Sub Projects
-# Todo - This is not working because user is always project scoped and can't do domain based actions
- if current_user.is_allowed?('identity:project_create',{project: {domain_id: @scoped_domain_id}})
= link_to plugin('identity').domains_create_project_path(), class: "header-action" , title: "Request new Subproject", data: {modal: true, toggle: "tooltip", placement: "left"} do
%i.fa.fa-plus-square-o
- else
= link_to plugin('identity').projects_request_project_path(), class: "header-action" , title: "Request new Subproject", data: {modal: true, toggle: "tooltip", placement: "left"} do
%i.fa.fa-plus-square-o

%h4.action-heading
Sub Projects
- if current_user.is_allowed?('identity:project_create',{project: {domain_id: @scoped_domain_id}})
= link_to plugin('identity').domains_create_project_path(parent_id:@project_id, parent_name:@project.name), class: "header-action" , title: "Create new Subproject", data: {modal: true, toggle: "tooltip", placement: "left"} do
%i.fa.fa-plus-square-o
- else
= link_to plugin('identity').projects_request_project_path(), class: "header-action" , title: "Request new Subproject", data: {modal: true, toggle: "tooltip", placement: "left"} do
%i.fa.fa-plus-square-o

%div{data: {react_auth_projects: true, root: @scoped_project_id, title: 'false' } }

Expand Down

0 comments on commit 68d7133

Please sign in to comment.