Skip to content

Commit

Permalink
Use url_for instead of manually named path methods
Browse files Browse the repository at this point in the history
  • Loading branch information
klaustopher committed Jun 19, 2024
1 parent 8724a8a commit bd1df60
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if sharing_manageable?
primer_form_with(
model: new_share,
url: work_package_shares_path(@work_package),
url: url_for([@work_package, Member]),
data: { controller: 'user-limit ' \
'work-packages--share--user-selected',
'application-target': 'dynamic',
Expand Down
4 changes: 2 additions & 2 deletions app/components/work_packages/share/modal_body_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def role_filter_option_active?(_option)
end

def filter_url(type_option: nil, role_option: nil)
return work_package_shares_path(@work_package) if type_option.nil? && role_option.nil?
return url_for([@work_package, Member]) if type_option.nil? && role_option.nil?

args = {}
filter = []
Expand All @@ -118,7 +118,7 @@ def filter_url(type_option: nil, role_option: nil)

args[:filters] = filter.to_json unless filter.empty?

work_package_shares_path(@work_package, **args)
url_for([@work_package, Member, **args])
end

def apply_role_filter(_option)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def initialize(share:, **system_arguments)
# or be passive and work like a select inside a form.
def update_path
if share.persisted?
work_package_share_path(share.entity, share)
url_for([share.entity, share])
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
end

user_row_grid.with_area(:remove, tag: :div) do
form_with url: work_package_share_path(work_package, share), method: :delete do
form_with url: url_for([work_package, share]), method: :delete do
render(Primer::Beta::IconButton.new(icon: "trash",
type: :submit,
scheme: :danger,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def principal_show_path
end

def resend_invite_path
resend_invite_work_package_share_path(share.entity, share)
url_for([:resend_invite, share.entity, share])
end

def user_is_a_group?
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@
get "details/*state" => "work_packages#index", on: :collection, as: :details

# Rails managed sharing route
resources :shares, controller: "work_packages/shares", only: %i[index create update destroy] do
resources :members, path: :shares, controller: "work_packages/shares", only: %i[index create update destroy] do
member do
post "resend_invite" => "work_packages/shares#resend_invite"
end
Expand Down

0 comments on commit bd1df60

Please sign in to comment.