diff --git a/app/builders/better_together/navigation_builder.rb b/app/builders/better_together/navigation_builder.rb index ec7e577b4..3e1693633 100644 --- a/app/builders/better_together/navigation_builder.rb +++ b/app/builders/better_together/navigation_builder.rb @@ -219,56 +219,56 @@ def build_host # rubocop:todo Metrics/MethodLength slug_en: 'host-dashboard', position: 0, item_type: 'link', - route_name: 'host_dashboard_url' + route_name: 'host_root_url' }, { title_en: 'Communities', slug_en: 'communities', position: 1, item_type: 'link', - route_name: 'communities_url' + route_name: 'host_communities_url' }, { title_en: 'Navigation Areas', slug_en: 'navigation-areas', position: 2, item_type: 'link', - route_name: 'navigation_areas_url' + route_name: 'host_navigation_areas_url' }, { title_en: 'Pages', slug_en: 'pages', position: 3, item_type: 'link', - route_name: 'pages_url' + route_name: 'host_pages_url' }, { title_en: 'People', slug_en: 'people', position: 4, item_type: 'link', - route_name: 'people_url' + route_name: 'host_people_url' }, { title_en: 'Platforms', slug_en: 'platforms', position: 5, item_type: 'link', - route_name: 'platforms_url' + route_name: 'host_platforms_url' }, { title_en: 'Roles', slug_en: 'roles', position: 6, item_type: 'link', - route_name: 'roles_url' + route_name: 'host_roles_url' }, { title_en: 'Resource Permissions', slug_en: 'resource_permissions', position: 7, item_type: 'link', - route_name: 'resource_permissions_url' + route_name: 'host_resource_permissions_url' } ] diff --git a/app/controllers/better_together/application_controller.rb b/app/controllers/better_together/application_controller.rb index e4f34e798..a817ae147 100644 --- a/app/controllers/better_together/application_controller.rb +++ b/app/controllers/better_together/application_controller.rb @@ -228,7 +228,7 @@ def store_user_location! def after_sign_in_path_for(resource) stored_location_for(resource) || if resource.permitted_to?('manage_platform') - host_dashboard_path + host_root_path else BetterTogether.base_path_with_locale end diff --git a/app/controllers/better_together/navigation_areas_controller.rb b/app/controllers/better_together/navigation_areas_controller.rb index 95f5ede79..1ec5d049e 100644 --- a/app/controllers/better_together/navigation_areas_controller.rb +++ b/app/controllers/better_together/navigation_areas_controller.rb @@ -49,8 +49,8 @@ def create @navigation_area = resource_class.new(navigation_area_params) authorize @navigation_area - if @navigation_area.save - redirect_to @navigation_area, only_path: true, notice: 'Navigation area was successfully created.' + if @navigation_area.save + redirect_to [:host, @navigation_area], only_path: true, notice: 'Navigation area was successfully created.' else render :new end @@ -59,8 +59,8 @@ def create def update authorize @navigation_area - if @navigation_area.update(navigation_area_params) - redirect_to @navigation_area, only_path: true, notice: 'Navigation area was successfully updated.' + if @navigation_area.update(navigation_area_params) + redirect_to [:host, @navigation_area], only_path: true, notice: 'Navigation area was successfully updated.' else render :edit end @@ -69,7 +69,7 @@ def update def destroy authorize @navigation_area @navigation_area.destroy - redirect_to navigation_areas_url, notice: 'Navigation area was successfully destroyed.' + redirect_to host_navigation_areas_url, notice: 'Navigation area was successfully destroyed.' end private diff --git a/app/controllers/better_together/navigation_items_controller.rb b/app/controllers/better_together/navigation_items_controller.rb index 615d93c0b..cb5eb3781 100644 --- a/app/controllers/better_together/navigation_items_controller.rb +++ b/app/controllers/better_together/navigation_items_controller.rb @@ -37,8 +37,8 @@ def create @navigation_item.assign_attributes(navigation_item_params) authorize @navigation_item - if @navigation_item.save - redirect_to @navigation_area, only_path: true, notice: 'Navigation item was successfully created.' + if @navigation_item.save + redirect_to [:host, @navigation_area], only_path: true, notice: 'Navigation item was successfully created.' else render :new end @@ -49,11 +49,11 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength respond_to do |format| if @navigation_item.update(navigation_item_params) - flash[:notice] = t('navigation_item.updated') - format.html { redirect_to @navigation_area, notice: t('navigation_item.updated') } - format.turbo_stream do - redirect_to @navigation_area, only_path: true - end + flash[:notice] = t('navigation_item.updated') + format.html { redirect_to [:host, @navigation_area], notice: t('navigation_item.updated') } + format.turbo_stream do + redirect_to [:host, @navigation_area], only_path: true + end else flash.now[:alert] = t('navigation_item.update_failed') format.html { render :edit, status: :unprocessable_entity } @@ -73,9 +73,9 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength def destroy authorize @navigation_item - @navigation_item.destroy - redirect_to navigation_area_navigation_items_url(@navigation_area), - notice: 'Navigation item was successfully destroyed.' + @navigation_item.destroy + redirect_to host_navigation_area_navigation_items_url(@navigation_area), + notice: 'Navigation item was successfully destroyed.' end private diff --git a/app/controllers/better_together/pages_controller.rb b/app/controllers/better_together/pages_controller.rb index 7962e3f8e..7d5984e1d 100644 --- a/app/controllers/better_together/pages_controller.rb +++ b/app/controllers/better_together/pages_controller.rb @@ -36,8 +36,8 @@ def create @page = resource_class.new(page_params) authorize @page - if @page.save - redirect_to edit_page_path(@page), notice: 'Page was successfully created.' + if @page.save + redirect_to edit_host_page_path(@page), notice: 'Page was successfully created.' else render :new end @@ -52,10 +52,10 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength respond_to do |format| if @page.update(page_params) - format.html do - flash[:notice] = 'Page was successfully updated.' - redirect_to edit_page_path(@page), notice: 'Page was successfully updated.' - end + format.html do + flash[:notice] = 'Page was successfully updated.' + redirect_to edit_host_page_path(@page), notice: 'Page was successfully updated.' + end format.turbo_stream do flash.now[:notice] = 'Page was successfully updated.' render turbo_stream: [ @@ -76,8 +76,8 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength def destroy authorize @page - @page.destroy - redirect_to pages_url, notice: 'Page was successfully destroyed.' + @page.destroy + redirect_to host_pages_url, notice: 'Page was successfully destroyed.' end protected diff --git a/app/controllers/better_together/people_controller.rb b/app/controllers/better_together/people_controller.rb index c846f4c86..561d2304b 100644 --- a/app/controllers/better_together/people_controller.rb +++ b/app/controllers/better_together/people_controller.rb @@ -24,7 +24,7 @@ def create authorize_person if @person.save - redirect_to @person, only_path: true, notice: 'Person was successfully created.', status: :see_other + redirect_to [:host, @person], only_path: true, notice: 'Person was successfully created.', status: :see_other else render :new, status: :unprocessable_entity end @@ -37,7 +37,7 @@ def edit; end def update ActiveRecord::Base.transaction do if @person.update(person_params) - redirect_to @person, only_path: true, notice: 'Profile was successfully updated.', status: :see_other + redirect_to (me? ? @person : [:host, @person]), only_path: true, notice: 'Profile was successfully updated.', status: :see_other else flash.now[:alert] = 'Please address the errors below.' render :edit, status: :unprocessable_entity @@ -48,7 +48,7 @@ def update # DELETE /people/1 def destroy @person.destroy - redirect_to people_url, notice: 'Person was successfully deleted.', status: :see_other + redirect_to host_people_url, notice: 'Person was successfully deleted.', status: :see_other end protected diff --git a/app/controllers/better_together/platforms_controller.rb b/app/controllers/better_together/platforms_controller.rb index 0f43fa3f3..87887b546 100644 --- a/app/controllers/better_together/platforms_controller.rb +++ b/app/controllers/better_together/platforms_controller.rb @@ -41,7 +41,7 @@ def create authorize_platform if @platform.save - redirect_to @platform, notice: 'Platform was successfully created.' + redirect_to [:host, @platform], notice: 'Platform was successfully created.' else render :new, status: :unprocessable_entity end @@ -51,7 +51,7 @@ def create def update authorize @platform if @platform.update(platform_params) - redirect_to @platform, notice: 'Platform was successfully updated.', status: :see_other + redirect_to [:host, @platform], notice: 'Platform was successfully updated.', status: :see_other else render :edit, status: :unprocessable_entity end @@ -61,7 +61,7 @@ def update def destroy authorize @platform @platform.destroy - redirect_to platforms_url, notice: 'Platform was successfully destroyed.', status: :see_other + redirect_to host_platforms_url, notice: 'Platform was successfully destroyed.', status: :see_other end private diff --git a/app/controllers/better_together/resource_permissions_controller.rb b/app/controllers/better_together/resource_permissions_controller.rb index 5226ab2e8..d34c7e5bb 100644 --- a/app/controllers/better_together/resource_permissions_controller.rb +++ b/app/controllers/better_together/resource_permissions_controller.rb @@ -32,8 +32,8 @@ def create @resource_permission = resource_class.new(resource_permission_params) authorize @resource_permission - if @resource_permission.save - redirect_to @resource_permission, only_path: true, notice: 'Resource permission was successfully created.' + if @resource_permission.save + redirect_to [:host, @resource_permission], only_path: true, notice: 'Resource permission was successfully created.' else render :new, status: :unprocessable_entity end @@ -43,9 +43,9 @@ def create def update authorize @resource_permission - if @resource_permission.update(resource_permission_params) - redirect_to @resource_permission, only_path: true, notice: 'Resource permission was successfully updated.', - status: :see_other + if @resource_permission.update(resource_permission_params) + redirect_to [:host, @resource_permission], only_path: true, notice: 'Resource permission was successfully updated.', + status: :see_other else render :edit, status: :unprocessable_entity end @@ -54,9 +54,9 @@ def update # DELETE /resource_permissions/1 def destroy authorize @resource_permission - @resource_permission.destroy - redirect_to resource_permissions_url, notice: 'Resource permission was successfully destroyed.', - status: :see_other + @resource_permission.destroy + redirect_to host_resource_permissions_url, notice: 'Resource permission was successfully destroyed.', + status: :see_other end private diff --git a/app/controllers/better_together/roles_controller.rb b/app/controllers/better_together/roles_controller.rb index a8b8b8fc2..93e036cdf 100644 --- a/app/controllers/better_together/roles_controller.rb +++ b/app/controllers/better_together/roles_controller.rb @@ -33,8 +33,8 @@ def create @role = resource_class.new(role_params) authorize @role # Add authorization check - if @role.save - redirect_to @role, only_path: true, notice: 'Role was successfully created.' + if @role.save + redirect_to [:host, @role], only_path: true, notice: 'Role was successfully created.' else render :new, status: :unprocessable_entity end @@ -44,8 +44,8 @@ def create def update authorize @role # Add authorization check - if @role.update(role_params) - redirect_to @role, only_path: true, notice: 'Role was successfully updated.', status: :see_other + if @role.update(role_params) + redirect_to [:host, @role], only_path: true, notice: 'Role was successfully updated.', status: :see_other else render :edit, status: :unprocessable_entity end @@ -54,8 +54,8 @@ def update # DELETE /roles/1 def destroy authorize @role # Add authorization check - @role.destroy - redirect_to roles_url, notice: 'Role was successfully destroyed.', status: :see_other + @role.destroy + redirect_to host_roles_url, notice: 'Role was successfully destroyed.', status: :see_other end private diff --git a/app/controllers/better_together/users_controller.rb b/app/controllers/better_together/users_controller.rb index 28d325698..efa3e6377 100644 --- a/app/controllers/better_together/users_controller.rb +++ b/app/controllers/better_together/users_controller.rb @@ -26,8 +26,8 @@ def create @user = resource_class.new(user_params) authorize_user - if @user.save - redirect_to @user, only_path: true, notice: 'User was successfully created.', status: :see_other + if @user.save + redirect_to [:host, @user], only_path: true, notice: 'User was successfully created.', status: :see_other else render :new, status: :unprocessable_entity end @@ -39,8 +39,8 @@ def edit; end # PATCH/PUT /users/1 def update ActiveRecord::Base.transaction do - if @user.update(user_params) - redirect_to @user, only_path: true, notice: 'Profile was successfully updated.', status: :see_other + if @user.update(user_params) + redirect_to [:host, @user], only_path: true, notice: 'Profile was successfully updated.', status: :see_other else flash.now[:alert] = 'Please address the errors below.' render :edit, status: :unprocessable_entity @@ -50,8 +50,8 @@ def update # DELETE /users/1 def destroy - @user.destroy - redirect_to users_url, notice: 'User was successfully deleted.', status: :see_other + @user.destroy + redirect_to host_users_url, notice: 'User was successfully deleted.', status: :see_other end private diff --git a/app/models/better_together/navigation_item.rb b/app/models/better_together/navigation_item.rb index c40eb48e1..ac9b96a31 100644 --- a/app/models/better_together/navigation_item.rb +++ b/app/models/better_together/navigation_item.rb @@ -8,28 +8,28 @@ class NavigationItem < ApplicationRecord # rubocop:todo Metrics/ClassLength include Protected class_attribute :route_names, default: { - calls_for_interest: 'calls_for_interest_url', - calendars: 'calendars_url', - content_blocks: 'content_blocks_url', - communities: 'communities_url', - events: 'events_url', - geography_continents: 'geography_continents_url', - geography_countries: 'geography_countries_url', - geography_maps: 'geography_maps_url', - geography_states: 'geography_states_url', - geography_regions: 'geography_regions_url', - geography_settlements: 'geography_settlements_url', - host_dashboard: 'host_dashboard_url', - hub: 'hub_url', - metrics_reports: 'metrics_reports_url', - navigation_areas: 'navigation_areas_url', - pages: 'pages_url', - people: 'people_url', - platforms: 'platforms_url', - resource_permissions: 'resource_permissions_url', - roles: 'roles_url', - users: 'users_url' - } + calls_for_interest: 'calls_for_interest_url', + calendars: 'calendars_url', + content_blocks: 'host_content_blocks_url', + communities: 'host_communities_url', + events: 'events_url', + geography_continents: 'host_geography_continents_url', + geography_countries: 'host_geography_countries_url', + geography_maps: 'geography_maps_url', + geography_states: 'host_geography_states_url', + geography_regions: 'host_geography_regions_url', + geography_settlements: 'host_geography_settlements_url', + host_dashboard: 'host_root_url', + hub: 'hub_url', + metrics_reports: 'host_metrics_reports_url', + navigation_areas: 'host_navigation_areas_url', + pages: 'host_pages_url', + people: 'host_people_url', + platforms: 'host_platforms_url', + resource_permissions: 'host_resource_permissions_url', + roles: 'host_roles_url', + users: 'host_users_url' + } belongs_to :navigation_area, touch: true belongs_to :linkable, polymorphic: true, optional: true, autosave: true diff --git a/app/views/better_together/categories/_form.html.erb b/app/views/better_together/categories/_form.html.erb index 56e0eaafd..58c2fde9c 100644 --- a/app/views/better_together/categories/_form.html.erb +++ b/app/views/better_together/categories/_form.html.erb @@ -1,15 +1,15 @@ -<%= form_with(model: category.as_category, class: 'form', data: { controller: "better_together--form-validation better_together--tabs" }) do |form| %> +<%= form_with(model: [:host, category.as_category], class: 'form', data: { controller: "better_together--form-validation better_together--tabs" }) do |form| %> <% content_for :resource_toolbar do %> diff --git a/app/views/better_together/categories/index.html.erb b/app/views/better_together/categories/index.html.erb index e60d037a5..a9f027bef 100644 --- a/app/views/better_together/categories/index.html.erb +++ b/app/views/better_together/categories/index.html.erb @@ -5,11 +5,11 @@

<%= resource_class.model_name.human.pluralize %>

- <% if policy(resource_class).create? %> - <%= link_to new_category_path, class: 'btn btn-primary', 'aria-label' => 'Add Category' do %> - <%= t('.new_btn_text', default: 'New Category') %> + <% if policy(resource_class).create? %> + <%= link_to new_host_category_path, class: 'btn btn-primary', 'aria-label' => 'Add Category' do %> + <%= t('.new_btn_text', default: 'New Category') %> + <% end %> <% end %> - <% end %>
diff --git a/app/views/better_together/categories/show.html.erb b/app/views/better_together/categories/show.html.erb index 1042efc63..ba0c962cb 100644 --- a/app/views/better_together/categories/show.html.erb +++ b/app/views/better_together/categories/show.html.erb @@ -9,16 +9,16 @@ <%= render partial: 'better_together/categories/category', object: @category %>
- <% if policy(resource_class).index? %> - <%= link_to t('better_together.categories.back_to_categories'), categories_path, class: 'btn btn-sm btn-outline-secondary' %> - <% end %> - <% if policy(@resource).edit? %> - <%= link_to edit_category_path(@resource), class: 'btn btn-outline-primary btn-sm me-2', 'aria-label' => 'Edit Partner' do %> + <% if policy(resource_class).index? %> + <%= link_to t('better_together.categories.back_to_categories'), host_categories_path, class: 'btn btn-sm btn-outline-secondary' %> + <% end %> + <% if policy(@resource).edit? %> + <%= link_to edit_host_category_path(@resource), class: 'btn btn-outline-primary btn-sm me-2', 'aria-label' => 'Edit Partner' do %> <%= t('globals.edit') %> <% end %> <% end %> - <% if policy(@resource).destroy? %> - <%= link_to category_path(@resource), data: { turbo_method: :delete, turbo_confirm: t('globals.confirm_delete') }, class: 'btn btn-outline-danger btn-sm', 'aria-label' => 'Delete Record' do %> + <% if policy(@resource).destroy? %> + <%= link_to host_category_path(@resource), data: { turbo_method: :delete, turbo_confirm: t('globals.confirm_delete') }, class: 'btn btn-outline-danger btn-sm', 'aria-label' => 'Delete Record' do %> <%= t('globals.delete') %> <% end %> <% end %> diff --git a/app/views/better_together/host_dashboard/_resource_card.html.erb b/app/views/better_together/host_dashboard/_resource_card.html.erb index cb696beac..33359c013 100644 --- a/app/views/better_together/host_dashboard/_resource_card.html.erb +++ b/app/views/better_together/host_dashboard/_resource_card.html.erb @@ -1,14 +1,14 @@ -<%# locals: (collection:, model_class: collection.model, model_name: model_class.model_name, count:, url_helper: :url_for) -%> +<%# locals: (collection:, model_class: collection.model, model_name: model_class.model_name, count:, url_helper: :url_for, index_url_helper: :url_for) -%>
- <% if policy(model_class).index? %> - <%= link_to model_class, class: "h6 text-decoration-none" do %> - <%= model_name.human.pluralize(2, I18n.locale) %> - <% end %> + <% if policy(model_class).index? %> + <%= link_to public_send(index_url_helper), class: "h6 text-decoration-none" do %> + <%= model_name.human.pluralize(2, I18n.locale) %> + <% end %> <% else %> <%= model_name.human.pluralize(2, I18n.locale) %> <% end %> @@ -38,10 +38,10 @@
<% end %>
- <% if policy(model_class).index? %> - - <% end %> + <% if policy(model_class).index? %> + + <% end %>
diff --git a/app/views/better_together/host_dashboard/index.html.erb b/app/views/better_together/host_dashboard/index.html.erb index 7f4f142f1..354eedb70 100644 --- a/app/views/better_together/host_dashboard/index.html.erb +++ b/app/views/better_together/host_dashboard/index.html.erb @@ -13,49 +13,49 @@

<%= t('.better_together') %>

- <%= render partial: 'resource_card', locals: { collection: @communities, count: @community_count, url_helper: :community_path } %> + <%= render partial: 'resource_card', locals: { collection: @communities, count: @community_count, url_helper: :host_community_path, index_url_helper: :host_communities_path } %> - <%= render partial: 'resource_card', locals: { collection: @navigation_areas, count: @navigation_area_count, url_helper: :navigation_area_path } %> + <%= render partial: 'resource_card', locals: { collection: @navigation_areas, count: @navigation_area_count, url_helper: :host_navigation_area_path, index_url_helper: :host_navigation_areas_path } %> - <%= render partial: 'resource_card', locals: { collection: @pages, count: @page_count, url_helper: :page_path } %> + <%= render partial: 'resource_card', locals: { collection: @pages, count: @page_count, url_helper: :host_page_path, index_url_helper: :host_pages_path } %> - <%= render partial: 'resource_card', locals: { collection: @platforms, count: @platform_count, url_helper: :platform_path } %> + <%= render partial: 'resource_card', locals: { collection: @platforms, count: @platform_count, url_helper: :host_platform_path, index_url_helper: :host_platforms_path } %> - <%= render partial: 'resource_card', locals: { collection: @people, count: @person_count, url_helper: :person_path } %> + <%= render partial: 'resource_card', locals: { collection: @people, count: @person_count, url_helper: :host_person_path, index_url_helper: :host_people_path } %> - <%= render partial: 'resource_card', locals: { collection: @roles, count: @role_count, url_helper: :role_path } %> + <%= render partial: 'resource_card', locals: { collection: @roles, count: @role_count, url_helper: :host_role_path, index_url_helper: :host_roles_path } %> - <%= render partial: 'resource_card', locals: { collection: @resource_permissions, count: @resource_permission_count, url_helper: :resource_permission_path } %> + <%= render partial: 'resource_card', locals: { collection: @resource_permissions, count: @resource_permission_count, url_helper: :host_resource_permission_path, index_url_helper: :host_resource_permissions_path } %> - <%= render partial: 'resource_card', locals: { collection: @users, count: @user_count, url_helper: :user_path } %> + <%= render partial: 'resource_card', locals: { collection: @users, count: @user_count, url_helper: :host_user_path, index_url_helper: :host_users_path } %> <%= render partial: 'resource_card', locals: { collection: @conversations, count: @conversation_count, url_helper: :conversation_path } %> <%= render partial: 'resource_card', locals: { collection: @messages, count: @message_count, url_helper: :message_path } %> - <%= render partial: 'resource_card', locals: { collection: @categories, count: @category_count, url_helper: :category_path } %> + <%= render partial: 'resource_card', locals: { collection: @categories, count: @category_count, url_helper: :host_category_path, index_url_helper: :host_categories_path } %>

<%= t('.content') %>

- <%= render partial: 'resource_card', locals: { model_class: ::BetterTogether::Content::Block, collection: @content_blocks, count: @content_block_count, url_helper: :content_block_path } %> + <%= render partial: 'resource_card', locals: { model_class: ::BetterTogether::Content::Block, collection: @content_blocks, count: @content_block_count, url_helper: :host_content_block_path, index_url_helper: :host_content_blocks_path } %>

<%= t('.geography') %>

- <%= render partial: 'resource_card', locals: {collection: @geography_continents, count: @geography_continent_count, url_helper: :geography_continent_path } %> - <%= render partial: 'resource_card', locals: {collection: @geography_countries, count: @geography_country_count, url_helper: :geography_country_path } %> - <%= render partial: 'resource_card', locals: {collection: @geography_states, count: @geography_state_count, url_helper: :geography_state_path } %> - <%= render partial: 'resource_card', locals: {collection: @geography_regions, count: @geography_region_count, url_helper: :geography_region_path } %> - <%= render partial: 'resource_card', locals: {collection: @geography_settlements, count: @geography_settlement_count, url_helper: :geography_settlement_path } %> + <%= render partial: 'resource_card', locals: {collection: @geography_continents, count: @geography_continent_count, url_helper: :host_geography_continent_path, index_url_helper: :host_geography_continents_path } %> + <%= render partial: 'resource_card', locals: {collection: @geography_countries, count: @geography_country_count, url_helper: :host_geography_country_path, index_url_helper: :host_geography_countries_path } %> + <%= render partial: 'resource_card', locals: {collection: @geography_states, count: @geography_state_count, url_helper: :host_geography_state_path, index_url_helper: :host_geography_states_path } %> + <%= render partial: 'resource_card', locals: {collection: @geography_regions, count: @geography_region_count, url_helper: :host_geography_region_path, index_url_helper: :host_geography_regions_path } %> + <%= render partial: 'resource_card', locals: {collection: @geography_settlements, count: @geography_settlement_count, url_helper: :host_geography_settlement_path, index_url_helper: :host_geography_settlements_path } %>
diff --git a/app/views/better_together/navigation_areas/edit.html.erb b/app/views/better_together/navigation_areas/edit.html.erb index 48185c9bf..ec795a210 100644 --- a/app/views/better_together/navigation_areas/edit.html.erb +++ b/app/views/better_together/navigation_areas/edit.html.erb @@ -3,5 +3,5 @@

<%= t('better_together.navigation_areas.edit.title') %>

<%= render 'form', navigation_area: @navigation_area %> - <%= link_to t('shared.links.back'), navigation_areas_path, class: 'btn btn-secondary' %> + <%= link_to t('shared.links.back'), host_navigation_areas_path, class: 'btn btn-secondary' %>
diff --git a/app/views/better_together/navigation_areas/index.html.erb b/app/views/better_together/navigation_areas/index.html.erb index c26ade6a5..80079172f 100644 --- a/app/views/better_together/navigation_areas/index.html.erb +++ b/app/views/better_together/navigation_areas/index.html.erb @@ -4,8 +4,8 @@
-

<%= resource_class.model_name.human.pluralize %>

- <%= link_to new_navigation_area_path, class: 'btn btn-primary d-flex align-items-center' do %> +

<%= resource_class.model_name.human.pluralize %>

+ <%= link_to new_host_navigation_area_path, class: 'btn btn-primary d-flex align-items-center' do %> <%= t('.new_navigation_area') %> <% end %>
@@ -26,18 +26,18 @@ <%= navigation_area.slug %> <%= navigation_area.visible ? t('globals.visible') : t('globals.hidden') %> - <% if policy(navigation_area).show? %> - <%= link_to navigation_area_path(navigation_area), class: 'btn btn-outline-info btn-sm me-1', 'aria-label' => t('.items') do %> + <% if policy(navigation_area).show? %> + <%= link_to host_navigation_area_path(navigation_area), class: 'btn btn-outline-info btn-sm me-1', 'aria-label' => t('.items') do %> <%= t('.items') %> <% end %> <% end %> - <% if policy(navigation_area).edit? %> - <%= link_to edit_navigation_area_path(navigation_area), class: 'btn btn-outline-secondary btn-sm me-1', 'aria-label' => t('globals.edit') do %> + <% if policy(navigation_area).edit? %> + <%= link_to edit_host_navigation_area_path(navigation_area), class: 'btn btn-outline-secondary btn-sm me-1', 'aria-label' => t('globals.edit') do %> <%= t('globals.edit') %> <% end %> <% end %> - <% if policy(navigation_area).destroy? %> - <%= link_to navigation_area_path(navigation_area), method: :delete, data: { turbo_confirm: t('globals.confirm_delete'), turbo_method: :delete }, class: 'btn btn-outline-danger btn-sm', 'aria-label' => t('globals.delete') do %> + <% if policy(navigation_area).destroy? %> + <%= link_to host_navigation_area_path(navigation_area), method: :delete, data: { turbo_confirm: t('globals.confirm_delete'), turbo_method: :delete }, class: 'btn btn-outline-danger btn-sm', 'aria-label' => t('globals.delete') do %> <%= t('globals.delete') %> <% end %> <% end %> diff --git a/app/views/better_together/navigation_areas/new.html.erb b/app/views/better_together/navigation_areas/new.html.erb index 5952c0194..149c648ff 100644 --- a/app/views/better_together/navigation_areas/new.html.erb +++ b/app/views/better_together/navigation_areas/new.html.erb @@ -3,5 +3,5 @@

<%= t('better_together.navigation_areas.new.title') %>

<%= render 'form', navigation_area: @navigation_area %> - <%= link_to t('shared.links.back'), navigation_areas_path, class: 'btn btn-secondary' %> + <%= link_to t('shared.links.back'), host_navigation_areas_path, class: 'btn btn-secondary' %>
diff --git a/app/views/better_together/navigation_areas/show.html.erb b/app/views/better_together/navigation_areas/show.html.erb index af3684829..c0641355e 100644 --- a/app/views/better_together/navigation_areas/show.html.erb +++ b/app/views/better_together/navigation_areas/show.html.erb @@ -5,15 +5,15 @@

<%= @navigation_area.name %>

- <% if policy(BetterTogether::NavigationItem).create? %> - <%= link_to new_navigation_area_navigation_item_path(@navigation_area), class: 'btn btn-primary', 'aria-label' => 'Add Navigation Item' do %> - <%= t('.new_navigation_item') %> + <% if policy(BetterTogether::NavigationItem).create? %> + <%= link_to new_host_navigation_area_navigation_item_path(@navigation_area), class: 'btn btn-primary', 'aria-label' => 'Add Navigation Item' do %> + <%= t('.new_navigation_item') %> + <% end %> <% end %> - <% end %>
- <% if policy(@navigation_area).edit? %> - <%= link_to edit_navigation_area_path(@navigation_area), class: 'btn btn-outline-secondary btn-sm me-1 mb-2', 'aria-label' => t('globals.edit') do %> + <% if policy(@navigation_area).edit? %> + <%= link_to edit_host_navigation_area_path(@navigation_area), class: 'btn btn-outline-secondary btn-sm me-1 mb-2', 'aria-label' => t('globals.edit') do %> <%= t('globals.edit') %> <% end %> <% end %> @@ -21,9 +21,9 @@

<%= resource_class.human_attribute_name(:visible) %>: <%= @navigation_area.visible ? 'Yes' : 'No' %>

<%= resource_class.human_attribute_name(:slug) %>: <%= @navigation_area.slug %>

- <% if @navigation_item&.child? %> -

<%= resource_class.human_attribute_name(:parent) %>: <%= link_to @navigation_item.parent, [@navigation_area, @navigation_item.parent] %>

- <% end %> + <% if @navigation_item&.child? %> +

<%= resource_class.human_attribute_name(:parent) %>: <%= link_to @navigation_item.parent, [:host, @navigation_area, @navigation_item.parent] %>

+ <% end %>

<%= BetterTogether::NavigationItem.model_name.human.pluralize %>

<%= render partial: 'better_together/navigation_items/navigation_items_table', locals: { navigation_items: @navigation_items } %>
diff --git a/app/views/better_together/navigation_items/_form.html.erb b/app/views/better_together/navigation_items/_form.html.erb index 614d91f68..47137f690 100644 --- a/app/views/better_together/navigation_items/_form.html.erb +++ b/app/views/better_together/navigation_items/_form.html.erb @@ -1,11 +1,11 @@ -<%= content_tag :div, id: 'navigation_item_form' do %> - <%= form_with(model: [@navigation_area, @navigation_item], local: false, class: 'form', data: { turbo: false, controller: "better_together--form-validation better_together--dependent-fields" }) do |form| %> + <%= content_tag :div, id: 'navigation_item_form' do %> + <%= form_with(model: [:host, @navigation_area, @navigation_item], local: false, class: 'form', data: { turbo: false, controller: "better_together--form-validation better_together--dependent-fields" }) do |form| %> <% content_for :action_toolbar do %> diff --git a/app/views/better_together/roles/_role.html.erb b/app/views/better_together/roles/_role.html.erb index 011a43ecd..4bd64be3a 100644 --- a/app/views/better_together/roles/_role.html.erb +++ b/app/views/better_together/roles/_role.html.erb @@ -6,22 +6,22 @@ <%= role.position %> <%= role.protected ? t('globals.yes') : t('globals.no') %> - <%= link_to role_path(role), class: 'btn btn-outline-info btn-sm me-1', 'aria-label' => t('globals.show') do %> + <%= link_to host_role_path(role), class: 'btn btn-outline-info btn-sm me-1', 'aria-label' => t('globals.show') do %> <%= t('globals.show') %> <% end %> - <% if policy(role).edit? %> - <%= link_to edit_role_path(role), class: 'btn btn-outline-secondary btn-sm me-1', 'aria-label' => t('globals.edit') do %> + <% if policy(role).edit? %> + <%= link_to edit_host_role_path(role), class: 'btn btn-outline-secondary btn-sm me-1', 'aria-label' => t('globals.edit') do %> <%= t('globals.edit') %> <% end %> <% end %> - <% if policy(role).destroy? %> - <%= link_to role_path(role), - method: :delete, - data: { turbo_method: :delete, turbo_confirm: t('roles.confirm_destroy') }, - class: 'btn btn-outline-danger btn-sm', - 'aria-label' => t('globals.destroy') do %> + <% if policy(role).destroy? %> + <%= link_to host_role_path(role), + method: :delete, + data: { turbo_method: :delete, turbo_confirm: t('roles.confirm_destroy') }, + class: 'btn btn-outline-danger btn-sm', + 'aria-label' => t('globals.destroy') do %> <%= t('globals.destroy') %> <% end %> <% end %> diff --git a/app/views/better_together/roles/edit.html.erb b/app/views/better_together/roles/edit.html.erb index 9b3b1e624..a930f6730 100644 --- a/app/views/better_together/roles/edit.html.erb +++ b/app/views/better_together/roles/edit.html.erb @@ -4,11 +4,11 @@ <%= render "form", role: @role %>
- <% if policy(@role).show? %> - <%= link_to "Show this Role", @role, class: "btn btn-secondary me-2" %> - <% end %> - <% if policy(::BetterTogether::Role).index? %> - <%= link_to "Back to Roles", roles_path, class: "btn btn-secondary" %> - <% end %> + <% if policy(@role).show? %> + <%= link_to "Show this Role", [:host, @role], class: "btn btn-secondary me-2" %> + <% end %> + <% if policy(::BetterTogether::Role).index? %> + <%= link_to "Back to Roles", host_roles_path, class: "btn btn-secondary" %> + <% end %>
diff --git a/app/views/better_together/roles/index.html.erb b/app/views/better_together/roles/index.html.erb index 39a1bd0ca..1d48bbc72 100644 --- a/app/views/better_together/roles/index.html.erb +++ b/app/views/better_together/roles/index.html.erb @@ -6,11 +6,11 @@

<%= resource_class.model_name.human.pluralize %>

- <% if policy(resource_class).create? %> - <%= link_to new_role_path, class: 'btn btn-primary' do %> - <%= t('.new_role') %> + <% if policy(resource_class).create? %> + <%= link_to new_host_role_path, class: 'btn btn-primary' do %> + <%= t('.new_role') %> + <% end %> <% end %> - <% end %>
diff --git a/app/views/better_together/roles/new.html.erb b/app/views/better_together/roles/new.html.erb index 4ea234e90..861088614 100644 --- a/app/views/better_together/roles/new.html.erb +++ b/app/views/better_together/roles/new.html.erb @@ -4,6 +4,6 @@ <%= render "form", role: @role %>
- <%= link_to "Back to Roles", roles_path, class: "btn btn-secondary" %> + <%= link_to "Back to Roles", host_roles_path, class: "btn btn-secondary" %>
diff --git a/app/views/better_together/roles/show.html.erb b/app/views/better_together/roles/show.html.erb index 0eb957cd1..d345efe59 100644 --- a/app/views/better_together/roles/show.html.erb +++ b/app/views/better_together/roles/show.html.erb @@ -36,20 +36,20 @@
- <% if policy(@role).edit? %> - <%= link_to edit_role_path(@role), class: "btn btn-outline-secondary me-2", 'aria-label' => t('globals.edit') do %> - <%= t('globals.edit') %> + <% if policy(@role).edit? %> + <%= link_to edit_host_role_path(@role), class: "btn btn-outline-secondary me-2", 'aria-label' => t('globals.edit') do %> + <%= t('globals.edit') %> + <% end %> <% end %> - <% end %> - - <%= link_to roles_path, class: "btn btn-outline-info me-2", 'aria-label' => t('globals.back_to_list') do %> - <%= t('globals.back_to_list') %> - <% end %> - - <% if policy(@role).destroy? %> - <%= button_to @role, data: { turbo_method: :delete, turbo_confirm: t('roles.confirm_destroy') }, class: "btn btn-outline-danger", 'aria-label' => t('globals.destroy') do %> - <%= t('globals.destroy') %> + + <%= link_to host_roles_path, class: "btn btn-outline-info me-2", 'aria-label' => t('globals.back_to_list') do %> + <%= t('globals.back_to_list') %> + <% end %> + + <% if policy(@role).destroy? %> + <%= button_to [:host, @role], data: { turbo_method: :delete, turbo_confirm: t('roles.confirm_destroy') }, class: "btn btn-outline-danger", 'aria-label' => t('globals.destroy') do %> + <%= t('globals.destroy') %> + <% end %> <% end %> - <% end %>
diff --git a/app/views/better_together/users/_user.html.erb b/app/views/better_together/users/_user.html.erb index 773fcf7fd..77db6c4c8 100644 --- a/app/views/better_together/users/_user.html.erb +++ b/app/views/better_together/users/_user.html.erb @@ -1,12 +1,12 @@ <%= user.email %> - <%= link_to 'Show', user_path(user), class: 'btn btn-primary btn-sm' %> + <%= link_to 'Show', host_user_path(user), class: 'btn btn-primary btn-sm' %> <% if policy(user).edit? %> - <%= link_to 'Edit', edit_user_path(user), class: 'btn btn-secondary btn-sm' %> + <%= link_to 'Edit', edit_host_user_path(user), class: 'btn btn-secondary btn-sm' %> <% end %> <% if policy(user).destroy? %> - <%= link_to 'Destroy', user_path(user), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-sm' %> + <%= link_to 'Destroy', host_user_path(user), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-sm' %> <% end %> diff --git a/app/views/better_together/users/edit.html.erb b/app/views/better_together/users/edit.html.erb index bed5b3517..1c06d6efa 100644 --- a/app/views/better_together/users/edit.html.erb +++ b/app/views/better_together/users/edit.html.erb @@ -4,11 +4,11 @@ <%= render "form", user: @user %>
- <% if policy(@user).show? %> - <%= link_to "Show this User", @user, class: "btn btn-secondary me-2" %> - <% end %> - <% if policy(::BetterTogether::User).index? %> - <%= link_to "Back to Users", users_path, class: "btn btn-secondary" %> - <% end %> + <% if policy(@user).show? %> + <%= link_to "Show this User", [:host, @user], class: "btn btn-secondary me-2" %> + <% end %> + <% if policy(::BetterTogether::User).index? %> + <%= link_to "Back to Users", host_users_path, class: "btn btn-secondary" %> + <% end %>
diff --git a/app/views/better_together/users/index.html.erb b/app/views/better_together/users/index.html.erb index 8ec27c797..f5c3a9121 100644 --- a/app/views/better_together/users/index.html.erb +++ b/app/views/better_together/users/index.html.erb @@ -4,9 +4,9 @@

<%= ::BetterTogether::User.model_name.human.pluralize(2, I18n.locale) %>

- <% if policy(::BetterTogether::User.new).create? %> - <%= link_to 'New User', new_user_path, class: 'btn btn-success' %> - <% end %> + <% if policy(::BetterTogether::User.new).create? %> + <%= link_to 'New User', new_host_user_path, class: 'btn btn-success' %> + <% end %>
diff --git a/app/views/better_together/users/new.html.erb b/app/views/better_together/users/new.html.erb index e6266be8a..e3e328a9e 100644 --- a/app/views/better_together/users/new.html.erb +++ b/app/views/better_together/users/new.html.erb @@ -4,6 +4,6 @@ <%= render "form", user: @user %>
- <%= link_to "Back to Users", users_path, class: "btn btn-secondary" %> + <%= link_to "Back to Users", host_users_path, class: "btn btn-secondary" %>
diff --git a/app/views/better_together/users/show.html.erb b/app/views/better_together/users/show.html.erb index a391d3e28..5504ad205 100644 --- a/app/views/better_together/users/show.html.erb +++ b/app/views/better_together/users/show.html.erb @@ -6,14 +6,14 @@
- <% if policy(@user).edit? %> - <%= link_to "Edit this user", edit_user_path(@user), class: "btn btn-primary me-2" %> - <% end %> + <% if policy(@user).edit? %> + <%= link_to "Edit this user", edit_host_user_path(@user), class: "btn btn-primary me-2" %> + <% end %> - <%= link_to "Back to users", users_path, class: "btn btn-secondary me-2" %> + <%= link_to "Back to users", host_users_path, class: "btn btn-secondary me-2" %> - <% if policy(@user).destroy? %> - <%= button_to "Destroy this user", @user, method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-danger", style: "margin-right: 10px;" %> - <% end %> + <% if policy(@user).destroy? %> + <%= button_to "Destroy this user", [:host, @user], method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-danger", style: "margin-right: 10px;" %> + <% end %>
diff --git a/config/routes.rb b/config/routes.rb index 15c4f61e1..07fcce615 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -74,18 +74,9 @@ get 'me/edit', to: 'people#edit', as: 'edit_my_profile' end - resources :platforms, only: %i[index show edit update] do - resources :platform_invitations, only: %i[create destroy] do - member do - put :resend - end - end - end - authenticated :user, ->(u) { u.permitted_to?('manage_platform') } do # rubocop:todo Metrics/BlockLength - scope path: 'host' do # rubocop:todo Metrics/BlockLength - # Add route for the host dashboard - get '/', to: 'host_dashboard#index', as: 'host_dashboard' + namespace :host, module: nil do # rubocop:todo Metrics/BlockLength + root to: 'host_dashboard#index' resources :categories diff --git a/spec/features/invitations/platform_invitation_create_spec.rb b/spec/features/invitations/platform_invitation_create_spec.rb index 873b119d1..d3b40bff3 100644 --- a/spec/features/invitations/platform_invitation_create_spec.rb +++ b/spec/features/invitations/platform_invitation_create_spec.rb @@ -15,7 +15,7 @@ end scenario 'with valid inputs' do - visit platform_path(host_platform, locale: I18n.default_locale) + visit host_platform_path(host_platform, locale: I18n.default_locale) within '#newInvitationModal' do select 'Platform Invitation', from: 'platform_invitation[type]' select 'Community Facilitator', from: 'platform_invitation[community_role_id]'