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
Leave the overview in full when its last right goes, and unmark the row the "+" closes
Guido Boyke14e2379a36f7
diff --git a/app/controllers/organisations/meetings_overview_controller.rb b/app/controllers/organisations/meetings_overview_controller.rbindex 3529cd6..f2e7438 100644--- a/app/controllers/organisations/meetings_overview_controller.rb+++ b/app/controllers/organisations/meetings_overview_controller.rb@@ -165,13 +165,26 @@ module Organisations# shell. Mirrors the "Zeiten" menu visibility, but a single .any? check# does not warrant its own service (accessible_project_ids already covers# admin/global-role/per-project).+ #+ # A frame of this page (the lane, the list, the sentence of the bar) asks+ # when the last right went while the page stayed open. The start page has+ # none of these frames, and Turbo threw on it ("Content missing"). Instead+ # it is told to visit the same address in full (turbo-visit-control+ # reload), and that visit takes the redirect below. The hint goes out with+ # 200: Turbo reloads only for a successful answer and renders any other one+ # as the page itself, here an empty one.def require_meetings_accessreturn if accessible_meeting_project_ids.any?+ return render_full_visit if turbo_frame_request?redirect_to organisation_root_path(organisation_id: @current_organisation.id),alert: t('shared.errors.not_authorized')end+ def render_full_visit+ render html: helpers.tag.meta(name: 'turbo-visit-control', content: 'reload'), layout: false+ end+# One redirect to the address the bar writes, so the chips show the old# filter and every later change carries it as a condition. A value that is# not a single string was no filter before either and is dropped.diff --git a/app/javascript/controllers/lane_link_controller.js b/app/javascript/controllers/lane_link_controller.jsindex 8000f08..e7539b3 100644--- a/app/javascript/controllers/lane_link_controller.js+++ b/app/javascript/controllers/lane_link_controller.js@@ -19,6 +19,11 @@ import { readLaneParams, laneParamNames, withLaneState } from "lane/params"// remove the lane state to take away (["preview"])// focus a selector to focus once the frame has loaded (the way back returns// the focus to the file name that opened the preview, D10)+//+// A link that removes a selection parameter (the "+" of "Alle Meetings" takes+// meeting_id away) leaves no row open, so it takes the mark off the row that+// was (.selected-row, list_row_controller). The address is the truth, and a+// full visit of the new address marks no row either.export default class extends Controller {static values = {url: String,@@ -43,6 +48,7 @@ export default class extends Controller {}window.history.pushState({ lane: true }, "", address.toString())+ if (this.removeValue.some(name => groups.selection.includes(name))) this.unmarkOpenRow()const frame = document.getElementById(this.frameValue)if (!frame) return@@ -50,6 +56,10 @@ export default class extends Controller {frame.setAttribute("src", detailAddress({ url: this.urlValue, current: address, frame: this.frameValue, params: laneParamNames(groups) }))}+ unmarkOpenRow() {+ document.querySelectorAll(".selected-row").forEach(row => row.classList.remove("selected-row"))+ }+focusAfterLoad(frame, selector) {const once = (event) => {if (event.target !== frame) returndiff --git a/app/views/organisations/meetings_overview/_new_meeting_denied.html.erb b/app/views/organisations/meetings_overview/_new_meeting_denied.html.erbindex 173fb81..7beadc1 100644--- a/app/views/organisations/meetings_overview/_new_meeting_denied.html.erb+++ b/app/views/organisations/meetings_overview/_new_meeting_denied.html.erb@@ -2,7 +2,7 @@<%# The "+" of "Alle Meetings" asked for the project select, and this person maywrite meetings nowhere (any more: the right can go while the page staysopen). 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). %>+ with the lane head to close it (MeetingsOverviewController#render_lane_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">diff --git a/spec/javascript/controllers/lane_link_controller.test.js b/spec/javascript/controllers/lane_link_controller.test.jsindex 9d377f0..b609268 100644--- a/spec/javascript/controllers/lane_link_controller.test.js+++ b/spec/javascript/controllers/lane_link_controller.test.js@@ -22,7 +22,8 @@ const ORIGIN = "http://lalabase.test"const INDEX = "/org/o1/projects/p1/knowledge"function fixture({ href, innerWidth = 1400, values }) {- const log = { history: [], frameSrc: null, location: null, listeners: [] }+ const log = { history: [], frameSrc: null, location: null, listeners: [], unmarked: [] }+ const markedRow = { classList: { remove: (...names) => log.unmarked.push(...names) } }const location = new URL(href, ORIGIN)const window = {innerWidth,@@ -35,6 +36,7 @@ function fixture({ href, innerWidth = 1400, values }) {const frame = { setAttribute: (name, value) => { if (name === "src") log.frameSrc = value }, querySelector: () => null }const document = {getElementById: (id) => (id === values.frame ? frame : null),+ querySelectorAll: (selector) => (selector === ".selected-row" ? [markedRow] : []),addEventListener: (name, fn) => log.listeners.push(name),removeEventListener: () => {}}@@ -95,3 +97,20 @@ test("a modified click (a new tab, a new window) is the browser's: nothing is prassert.equal(location.searchParams.has("preview"), false)}})++// The "+" of "Alle Meetings" takes meeting_id out of the address and loads the+// project select: no row is open any more, so none may stay marked (the full+// visit of that address marks none either).+test("a link that takes the selection out of the address clears the mark of the open row", () => {+ const plus = { url: INDEX, frame: "knowledge_display_frame", set: { new: "note" }, remove: ["document_id"], focus: "" }+ const { click, log, location } = fixture({ href: `${INDEX}?document_id=D`, values: plus })+ click()+ assert.equal(location.searchParams.get("document_id"), null)+ assert.deepEqual(log.unmarked, ["selected-row"])+})++test("a link that keeps the selection keeps the mark of the open row", () => {+ const { click, log } = fixture({ href: `${INDEX}?document_id=D&preview=V`, values: back })+ click()+ assert.deepEqual(log.unmarked, [])+})diff --git a/spec/requests/organisations/meetings_overview_new_access_spec.rb b/spec/requests/organisations/meetings_overview_new_access_spec.rbindex 48d152f..4c9fef1 100644--- a/spec/requests/organisations/meetings_overview_new_access_spec.rb+++ b/spec/requests/organisations/meetings_overview_new_access_spec.rb@@ -138,6 +138,42 @@ RSpec.describe 'Organisations::MeetingsOverview new meeting access', :ci_guard,endend+ # The last right to read meetings went while the page stayed open. The page+ # gate redirected every request, and the frames of the page (the lane after+ # the "+", the list after a filter) got the start page without their frame:+ # Turbo replaced the frame with "Content missing" and threw. A full visit goes+ # to the start page with a message, so a frame asks Turbo for a full visit of+ # the same address (turbo-visit-control reload), which then takes that way.+ describe 'after the last right to read meetings went' do+ let(:nobody) { member_with({}) }++ before { sign_in nobody }++ it 'sends a full visit to the start page with a message (the positive control)' do+ get overview_path, params: { new: 'meeting' }++ expect(response).to redirect_to(organisation_root_path(organisation_id: organisation.id))+ expect(flash[:alert]).to eq(I18n.t('shared.errors.not_authorized'))+ end++ {+ 'the lane' => Organisations::MeetingsController::DETAIL_FRAME_ID,+ 'the list' => Organisations::MeetingsController::OVERVIEW_LIST_FRAME_ID,+ 'the sentence of the bar' => "#{Organisations::MeetingsController::OVERVIEW_LIST_FRAME_ID}_sentence"+ }.each do |name, frame_id|+ it "asks Turbo for a full visit from #{name}, without a redirect and without a meeting" do+ get overview_path, params: { new: 'meeting' }, headers: { 'Turbo-Frame' => frame_id }++ # 200, not 403: Turbo reloads only for a successful answer.+ expect(response).to have_http_status(:ok)+ expect(response.location).to be_nil+ expect(page_body).to have_css('meta[name="turbo-visit-control"][content="reload"]', visible: :all)+ expect(page_body).to have_no_css('turbo-frame')+ expect(response.body).not_to include('Lesbar Kickoff')+ end+ end+ end+# A lane request to this address without new=meeting comes from a redirect:# a lane action MeetingsController refused (Pundit leads back to the Referer)# or could not finish (a meeting deleted meanwhile), and fetch keeps thediff --git a/spec/system/meetings_overview_spec.rb b/spec/system/meetings_overview_spec.rbindex 37b26f0..1847d4e 100644--- a/spec/system/meetings_overview_spec.rb+++ b/spec/system/meetings_overview_spec.rb@@ -176,6 +176,54 @@ RSpec.describe 'Meetings overview', type: :system doexpect(page).to have_select(select_label, selected: 'Projekt Beta')end+ # The last right to read meetings went while the page stayed open. The+ # lane got the start page without its frame, and Turbo left "Content+ # missing" in it; now the page goes where a full visit goes.+ it 'leaves the page for the start page when the last right went meanwhile' 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: 'no_access') }+ find(plus).click++ expect(page).to have_text(I18n.t('shared.errors.not_authorized'), wait: 10)+ expect(page).to have_no_current_path(organisation_meetings_path(organisation), ignore_query: true)+ expect(page).to have_no_css('#meetings_overview_results')+ expect(page).to have_no_text('Content missing')+ end++ # The "+" takes meeting_id out of the address: the meeting is no longer in+ # the lane, so its row may not stay marked.+ it 'takes the mark off the open row when the "+" opens the select' do+ page.driver.browser.manage.window.resize_to(1440, 1000)+ visit organisation_meetings_path(organisation)+ find('#meetings_overview_results tr[data-meeting-id]', text: 'Beta Retro').click+ expect(page).to have_css('#meetings_overview_results tr.selected-row', text: 'Beta Retro', wait: 5)+ expect(page).to have_css('#meeting_display_frame h2', text: 'Beta Retro', wait: 5)++ # The lane opens with a width transition (layout.css, --panel-width), and+ # the "+" moves with the list column until it ends: a click during it+ # landed beside the "+" (1 run in 10).+ page.document.synchronize(5) do+ left = -> { page.evaluate_script("document.querySelector(\"#{plus}\").getBoundingClientRect().left") }+ before = left.call+ sleep 0.15+ raise Capybara::ExpectationNotMet, 'the "+" is still moving' unless left.call == before+ end+ open_new_meeting++ expect(page).to have_no_css('#meetings_overview_results tr.selected-row')+ expect(page).to have_no_current_path(/meeting_id=/, url: true)+ end+# The options carry the list state from when the lane opened; the live one# comes from the address at submit (layout-toggle, the form's# data-lane-index-url). A search typed beside the open form has to survive