Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.
Ruby agplai-assistantdockerdsgvogdprhotwireissue-trackerjira-alternativeknowledge-basellmmcp-servermeeting-notesopen-sourceproject-managementredmine-alternativeruby-on-railsself-hostedticketingtime-tracking
Refuse the lane's project select inside the frame instead of redirecting
Guido Boykecce0a2267360
diff --git a/app/controllers/organisations/meetings_overview_controller.rb b/app/controllers/organisations/meetings_overview_controller.rbindex fcce8a8..03fd033 100644--- a/app/controllers/organisations/meetings_overview_controller.rb+++ b/app/controllers/organisations/meetings_overview_controller.rb@@ -89,15 +89,22 @@ module Organisations# The project select alone, for the lane. It reads no meeting, so there is no# scope to apply: what it names comes from writable_meeting_projects, the- # write reach of AccessCheck::ProjectAccessService. Without that reach, or- # for any other request into the lane, the answer is the usual refusal.+ # write reach of AccessCheck::ProjectAccessService.+ #+ # Without that reach, or for any other request into the lane, the refusal+ # answers INSIDE the frame (as TimeSessionGroupsController#entries does). The+ # shared one redirects back to this page, fetch keeps the Turbo-Frame header+ # on the redirected request, and that request lands here again: a right+ # taken away while the page stays open ended in "too many redirects".def render_new_meeting_frameskip_policy_scope- raise Pundit::NotAuthorizedError unless new_meeting_requested?+ allowed = new_meeting_requested?+ partial = allowed ? 'new_meeting_lane' : 'new_meeting_denied'+ locals = allowed ? { projects: writable_meeting_projects } : {}render html: helpers.turbo_frame_tag(MeetingsController::DETAIL_FRAME_ID) {- helpers.render(partial: 'organisations/meetings_overview/new_meeting_lane', locals: { projects: writable_meeting_projects })- }, layout: false+ helpers.render(partial: "organisations/meetings_overview/#{partial}", locals: locals)+ }, layout: false, status: (allowed ? :ok : :forbidden)end# ?new=meeting, from someone who may write meetings somewhere. Otherwise thediff --git a/app/views/organisations/meetings_overview/_new_meeting_denied.html.erb b/app/views/organisations/meetings_overview/_new_meeting_denied.html.erbnew file mode 100644index 0000000..173fb81--- /dev/null+++ b/app/views/organisations/meetings_overview/_new_meeting_denied.html.erb@@ -0,0 +1,14 @@+<%# locals: () %>+<%# The "+" of "Alle Meetings" asked for the project select, and this person may+ write meetings nowhere (any more: the right can go while the page stays+ open). A normal outcome, so it answers in the lane like the select would,+ with the lane head to close it (MeetingsOverviewController#render_new_meeting_frame). %>+<div class="meeting-content min-w-0 relative">+ <%= render 'organisations/meetings/form_lane_head', new_form: true, project: nil %>+ <h2 class="text-[22px] leading-snug font-bold text-cream-900 mb-6">+ <%= t('views.organisations.meetings.index.new_meeting') %>+ </h2>+ <p class="py-10 text-center text-sm text-cream-500">+ <%= t('views.organisations.meetings_overview.new_meeting.denied') %>+ </p>+</div>diff --git a/config/locales/views/meetings.de.yml b/config/locales/views/meetings.de.ymlindex 3f31d5e..8cb4825 100644--- a/config/locales/views/meetings.de.yml+++ b/config/locales/views/meetings.de.yml@@ -200,6 +200,7 @@ de:project_label: Projektproject_prompt: Projekt wählen …select_project_first: Wähle zuerst ein Projekt.+ denied: Du darfst in keinem Projekt Meetings anlegen.models:view_configuration:meeting_columns:diff --git a/config/locales/views/meetings.en.yml b/config/locales/views/meetings.en.ymlindex 908a606..0771151 100644--- a/config/locales/views/meetings.en.yml+++ b/config/locales/views/meetings.en.yml@@ -199,6 +199,7 @@ en:project_label: Projectproject_prompt: Choose a project …select_project_first: Choose a project first.+ denied: You may not create meetings in any project.models:view_configuration:meeting_columns:diff --git a/spec/requests/organisations/meetings_overview_new_access_spec.rb b/spec/requests/organisations/meetings_overview_new_access_spec.rbindex f3d845c..e2e8c49 100644--- a/spec/requests/organisations/meetings_overview_new_access_spec.rb+++ b/spec/requests/organisations/meetings_overview_new_access_spec.rb@@ -111,6 +111,30 @@ RSpec.describe 'Organisations::MeetingsOverview new meeting access', :ci_guard,expect(response.body).not_to include('meeting-new-project')expect(response.body).not_to include('Projekt Alpha')end++ # A right taken away while the page stays open: the "+" still stands there.+ # The shared refusal redirected back to the overview, fetch kept the+ # Turbo-Frame header, and the redirected request was refused again, until+ # the browser gave up on too many redirects. The refusal answers in the frame.+ it 'refuses the lane frame inside the frame, with a message and no redirect' do+ get overview_path, params: { new: 'meeting' }, headers: lane_frame.merge('Referer' => "http://www.example.com#{overview_path}")++ expect(response).to have_http_status(:forbidden)+ expect(response.location).to be_nil+ expect(page_body).to have_css('turbo-frame#meeting_display_frame',+ text: I18n.t('views.organisations.meetings_overview.new_meeting.denied'))+ expect(page_body).to have_css('turbo-frame#meeting_display_frame [data-lane-close]')+ expect(page_body).to have_no_css('#meeting-new-project')+ end++ it 'refuses a lane frame request without new=meeting the same way, the one the redirect sent' do+ get overview_path, headers: lane_frame.merge('Referer' => "http://www.example.com#{overview_path}")++ expect(response).to have_http_status(:forbidden)+ expect(response.location).to be_nil+ expect(page_body).to have_css('turbo-frame#meeting_display_frame',+ text: I18n.t('views.organisations.meetings_overview.new_meeting.denied'))+ endenddescribe 'the form behind the select (MeetingsController#new, frame: content)' dodiff --git a/spec/system/meetings_overview_spec.rb b/spec/system/meetings_overview_spec.rbindex 03e96ef..83239af 100644--- a/spec/system/meetings_overview_spec.rb+++ b/spec/system/meetings_overview_spec.rb@@ -210,6 +210,28 @@ RSpec.describe 'Meetings overview', type: :system doexpect_titles('Alpha Kickoff')end+ # The refusal of the lane frame redirected back to this page with the frame+ # header kept, and the browser followed it until it gave up.+ it 'says so in the lane when the right to write went while the page stayed open' do+ writer = create(:user)+ permission = ActsAsTenant.with_tenant(organisation) do+ role = create(:role, title: 'Schreiber', organisation: organisation)+ create(:membership, user: writer, organisation: organisation, role: role, active: true)+ create(:project_permission, user: writer, project: alpha, meetings_access: 'read_write')+ end+ sign_in writer+ page.driver.browser.manage.window.resize_to(1440, 1000)+ visit organisation_meetings_path(organisation)+ expect_titles('Alpha Kickoff')++ ActsAsTenant.with_tenant(organisation) { permission.update!(meetings_access: 'read_only') }+ find(plus).click++ expect(page).to have_css('#meeting_display_frame', text: I18n.t('views.organisations.meetings_overview.new_meeting.denied'), wait: 5)+ expect(page).to have_no_css('#meeting-new-project')+ expect_titles('Alpha Kickoff')+ end+it 'opens the select on a full visit with ?new=meeting' dopage.driver.browser.manage.window.resize_to(1440, 1000)visit organisation_meetings_path(organisation, new: 'meeting', search: 'Alpha')