Skip to content

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.

Keep the list full width for a meeting_id the server could not open

Guido Boyked58f744d1d41
diff --git a/app/helpers/meetings_helper.rb b/app/helpers/meetings_helper.rb
index 2c65a78..9bb6b95 100644
--- a/app/helpers/meetings_helper.rb
+++ b/app/helpers/meetings_helper.rb
@@ -70,8 +70,9 @@ module MeetingsHelper
# (syncUrlFromFrame, the list state in list_filter_params); the row opener
# and the ✕ write the lane part. The column picker's wiring is merged in by
# the page (meeting_column_picker_data).
- def meeting_list_page_data(index_url:, list_frame_id:, viewport_mode:, lane_forms: [])
+ def meeting_list_page_data(index_url:, list_frame_id:, viewport_mode:, selected:, lane_forms: [], new_form_open: false)
detail_frame_id = Organisations::MeetingsController::DETAIL_FRAME_ID
+ unresolved = meeting_unresolved_lane_params(selected: selected, lane_forms: lane_forms, new_form_open: new_form_open)
# Which list the lane belongs to, added by layout-toggle to every request of
# the lane at click and submit: also to a link rendered without it (a
# broadcast, a section refresh). None on the project page.
@@ -88,6 +89,7 @@ module MeetingsHelper
layout_toggle_storage_key_value: 'layoutState:meetings',
layout_toggle_clear_detail_on_close_value: 'true',
layout_toggle_lane_context_value: (lane_context.to_json if lane_context.any?),
+ layout_toggle_unresolved_selection_value: (unresolved.to_json if unresolved.any?),
viewport_breakpoint_value: LANE_FULL_PAGE_BELOW_PX,
index_page_param_name_value: 'meeting_id',
index_page_frame_id_value: detail_frame_id,
@@ -104,6 +106,20 @@ module MeetingsHelper
}.compact
end
+ # The lane parameters of this visit the server did not open: a meeting_id it
+ # could not resolve (deleted, unknown, unreadable, another project's) and a
+ # new form it did not render. layout-toggle takes them out of the address
+ # before anything reads it, so the page stays the list instead of opening an
+ # empty lane. Name and value, so it never drops a selection made since.
+ def meeting_unresolved_lane_params(selected:, lane_forms:, new_form_open:)
+ unresolved = {}
+ meeting_id = params[:meeting_id]
+ unresolved['meeting_id'] = meeting_id if meeting_id.is_a?(String) && meeting_id.present? && selected.nil?
+ new_form = params[:new]
+ unresolved['new'] = new_form if lane_forms.include?('new') && new_form.is_a?(String) && new_form.present? && !new_form_open
+ unresolved
+ end
+
# The placeholders column_picker_controller fills in itself, passed through
# the translation as they are.
COLUMN_PICKER_NAME_TOKEN = '%{name}' # rubocop:disable Style/FormatStringToken
diff --git a/app/javascript/controllers/CLAUDE.md b/app/javascript/controllers/CLAUDE.md
index 1131af0..08a3c11 100644
--- a/app/javascript/controllers/CLAUDE.md
+++ b/app/javascript/controllers/CLAUDE.md
@@ -395,6 +395,11 @@ die Sidebar-Zeile liegt in der Navigation. Damit sind sie NICHT im selben Stimul
Broadcasts und Abschnitts-Aktualisierungen, die ohne Kontext gerendert wurden. Sonst lädt ein
Klick auf „aktualisieren“ die Bahn im Projektmodus, und das nächste Speichern zeichnet die
Liste der Übersicht nicht neu.
+ Die Adresse nennt nur, was der Server geöffnet hat: eine `meeting_id`, die er nicht auflösen
+ konnte, oder ein `new`, das er nicht gerendert hat, steht in `unresolvedSelection` (Name und
+ Wert, `meeting_list_page_data`). `layout_toggle#dropUnresolvedSelection` nimmt sie beim
+ Verbinden aus der Adresse, bevor `hasSelection()` und `index-page` sie lesen. Sonst öffnet
+ ein gelöschtes oder fremdes Meeting eine leere Bahn.
## Mobile Anwendung (PR #807)
diff --git a/app/javascript/controllers/layout_toggle_controller.js b/app/javascript/controllers/layout_toggle_controller.js
index b4837bd..f3c0090 100644
--- a/app/javascript/controllers/layout_toggle_controller.js
+++ b/app/javascript/controllers/layout_toggle_controller.js
@@ -47,10 +47,17 @@ export default class extends Controller {
// click and submit (syncFilterContext): "Alle Meetings" says
// list_context=organisation, so a save in its lane redraws that list, also
// from a link a broadcast or a section refresh rendered without it.
- laneContext: { type: Object, default: {} }
+ laneContext: { type: Object, default: {} },
+ // Lane parameters of this visit the server did not open ({ name: value }):
+ // a meeting_id it could not resolve, a new form it did not render.
+ unresolvedSelection: { type: Object, default: {} }
}
connect() {
+ // The address names only what the server opened; hasSelection() below and
+ // index-page trust it.
+ this.dropUnresolvedSelection()
+
// Check server-side state first
const layoutElement = this.hasLayoutTarget ? this.layoutTarget : document.querySelector('.layout')
const serverSaysHideContent = layoutElement && layoutElement.classList.contains('hide-content')
@@ -562,6 +569,19 @@ export default class extends Controller {
return this.layoutState.content || this.hasSelection()
}
+ // A rejected selection (deleted, unknown, unreadable) would open an empty
+ // lane. It leaves the address in the same history entry, only while the
+ // address still names the value the server rejected.
+ dropUnresolvedSelection() {
+ const address = new URL(window.location.href)
+ const rejected = Object.entries(this.unresolvedSelectionValue)
+ .filter(([name, value]) => address.searchParams.get(name) === value)
+ if (rejected.length === 0) return
+
+ rejected.forEach(([name]) => address.searchParams.delete(name))
+ window.history.replaceState(window.history.state, '', address.toString())
+ }
+
// === Selection/content (Values-based) ===
hasSelection() {
diff --git a/app/views/organisations/meetings/index.html.erb b/app/views/organisations/meetings/index.html.erb
index 36c5379..d86a1f2 100644
--- a/app/views/organisations/meetings/index.html.erb
+++ b/app/views/organisations/meetings/index.html.erb
@@ -15,7 +15,8 @@
<div class="labor-layout-view <%= 'show-content' if @selected_meeting || @new_meeting %> hide-panel"
<%= tag.attributes(data: meeting_list_page_data(index_url: organisation_project_meetings_path(@current_organisation, @project),
list_frame_id: Organisations::MeetingsController::LIST_FRAME_ID,
- viewport_mode: @viewport_mode, lane_forms: %w[new])
+ viewport_mode: @viewport_mode, selected: @selected_meeting,
+ lane_forms: %w[new], new_form_open: @new_meeting.present?)
.merge(meeting_column_picker_data(organisation: @current_organisation, project: @project, active_view: @active_smart_folder,
frame_id: Organisations::MeetingsController::LIST_FRAME_ID))) %>>
<% list = capture do %>
diff --git a/app/views/organisations/meetings_overview/index.html.erb b/app/views/organisations/meetings_overview/index.html.erb
index 4fee2a9..9ead5e9 100644
--- a/app/views/organisations/meetings_overview/index.html.erb
+++ b/app/views/organisations/meetings_overview/index.html.erb
@@ -22,7 +22,7 @@
<div class="labor-layout-view <%= 'show-content' if @selected_meeting %> hide-panel"
<%= tag.attributes(data: meeting_list_page_data(index_url: organisation_meetings_path(@current_organisation),
list_frame_id: Organisations::MeetingsOverviewController::LIST_FRAME_ID,
- viewport_mode: @viewport_mode)
+ viewport_mode: @viewport_mode, selected: @selected_meeting)
.merge(meeting_column_picker_data(organisation: @current_organisation, project: nil, active_view: @active_smart_folder,
frame_id: Organisations::MeetingsOverviewController::LIST_FRAME_ID))) %>>
<% list = capture do %>
diff --git a/spec/javascript/controllers/layout_toggle_controller.test.js b/spec/javascript/controllers/layout_toggle_controller.test.js
index 341cdc6..9d5b58b 100644
--- a/spec/javascript/controllers/layout_toggle_controller.test.js
+++ b/spec/javascript/controllers/layout_toggle_controller.test.js
@@ -21,6 +21,7 @@ function controllerWith(document, { window = {}, groups = null, element = null }
const controller = new Controller()
controller.listFilterParamsValue = []
controller.laneContextValue = {}
+ controller.unresolvedSelectionValue = {}
controller.element = element || { dataset: {}, dispatchEvent: () => {} }
return controller
}
@@ -363,6 +364,35 @@ test('every request of a lane of another list carries the lane context, also fro
assert.equal(new URL(own.href).searchParams.has('list_context'), false)
})
+test('a selection the server did not open leaves the address before anything reads it', () => {
+ const current = new URL('http://lalabase.test/org/o/meetings?search=x&meeting_id=GONE&new=meeting')
+ const calls = []
+ const window = {
+ location: current,
+ history: {
+ state: { lane: true },
+ replaceState: (state, _t, url) => { calls.push(state); current.href = url }
+ }
+ }
+ const controller = controllerWith({}, { window })
+ controller.unresolvedSelectionValue = { meeting_id: 'GONE', new: 'meeting' }
+
+ controller.dropUnresolvedSelection()
+
+ assert.equal(current.searchParams.has('meeting_id'), false)
+ assert.equal(current.searchParams.has('new'), false)
+ assert.equal(current.searchParams.get('search'), 'x')
+ // The same history entry, its state kept.
+ assert.equal(JSON.stringify(calls), JSON.stringify([{ lane: true }]))
+
+ // A selection made since (another value) stays; nothing to drop writes nothing.
+ current.href = 'http://lalabase.test/org/o/meetings?meeting_id=OPEN'
+ controller.unresolvedSelectionValue = { meeting_id: 'GONE' }
+ controller.dropUnresolvedSelection()
+ assert.equal(current.searchParams.get('meeting_id'), 'OPEN')
+ assert.equal(calls.length, 1)
+})
+
test('closing a lane whose object is gone takes it out of the address in the same entry', () => {
const current = new URL('http://lalabase.test/org/o/meetings?search=x&meeting_id=M')
const calls = []
diff --git a/spec/requests/organisations/meetings_overview_lane_spec.rb b/spec/requests/organisations/meetings_overview_lane_spec.rb
index b0d5847..f6c4e55 100644
--- a/spec/requests/organisations/meetings_overview_lane_spec.rb
+++ b/spec/requests/organisations/meetings_overview_lane_spec.rb
@@ -135,6 +135,41 @@ RSpec.describe 'Organisations::MeetingsOverview lane', type: :request do
expect(edit).to include('list_context' => 'organisation', 'search' => 'Kick', 'search_mode' => 'title_only')
end
+ # The address must only name what the server opened: a selection it could
+ # not resolve would make layout-toggle and index-page open an empty lane.
+ it 'names a meeting_id it could not resolve, so the page takes it out of the address' do
+ deleted_id = SecureRandom.uuid
+ get overview_path, params: { meeting_id: deleted_id, search: 'a' }
+
+ expect(response).to have_http_status(:ok)
+ wrapper = page_body.find('.labor-layout-view')
+ expect(wrapper[:class].split).not_to include('show-content')
+ expect(JSON.parse(wrapper['data-layout-toggle-unresolved-selection-value'])).to eq('meeting_id' => deleted_id)
+
+ get overview_path, params: { meeting_id: alpha.id }
+
+ wrapper = page_body.find('.labor-layout-view.show-content')
+ expect(wrapper['data-layout-toggle-unresolved-selection-value']).to be_nil
+ end
+
+ it 'does the same on the project page, for a meeting_id and for a new form it did not open' do
+ get organisation_project_meetings_path(organisation, project_a), params: { meeting_id: beta.id }
+
+ wrapper = page_body.find('.labor-layout-view')
+ expect(wrapper[:class].split).not_to include('show-content')
+ expect(JSON.parse(wrapper['data-layout-toggle-unresolved-selection-value'])).to eq('meeting_id' => beta.id)
+
+ get organisation_project_meetings_path(organisation, project_a), params: { meeting_id: alpha.id, new: 'meeting' }
+
+ wrapper = page_body.find('.labor-layout-view.show-content')
+ expect(JSON.parse(wrapper['data-layout-toggle-unresolved-selection-value'])).to eq('new' => 'meeting')
+
+ get organisation_project_meetings_path(organisation, project_a), params: { new: 'meeting' }
+
+ wrapper = page_body.find('.labor-layout-view.show-content')
+ expect(wrapper['data-layout-toggle-unresolved-selection-value']).to be_nil
+ end
+
it 'recovers a stuck ticket suggestion run as the project page does' do
allow(MeetingTicketSuggestionRun).to receive(:recover_for_meeting!).and_call_original
diff --git a/spec/system/meetings_overview_spec.rb b/spec/system/meetings_overview_spec.rb
index 9c47c66..fec201f 100644
--- a/spec/system/meetings_overview_spec.rb
+++ b/spec/system/meetings_overview_spec.rb
@@ -180,6 +180,16 @@ RSpec.describe 'Meetings overview', type: :system do
def lane_title = find('#meeting_display_frame h2', wait: 5)
+ # The lane decides on connect: a check before that sees only the server's markup.
+ def wait_for_layout_toggle
+ page.document.synchronize do
+ connected = page.evaluate_script(<<~JS)
+ Boolean(window.Stimulus?.getControllerForElementAndIdentifier(document.querySelector('.labor-layout-view'), 'layout-toggle'))
+ JS
+ raise Capybara::ExpectationNotMet, 'layout-toggle is not connected yet' unless connected
+ end
+ end
+
before do
ActsAsTenant.with_tenant(organisation) do
['Alpha Kickoff', 'Beta Retro'].each do |title|
@@ -213,6 +223,26 @@ RSpec.describe 'Meetings overview', type: :system do
expect(page).to have_current_path(/meeting_id=/)
end
+ it 'keeps the list full width for a meeting_id it could not open, here and on the project page' do
+ page.driver.browser.manage.window.resize_to(1440, 1000)
+ gone = SecureRandom.uuid
+
+ visit organisation_meetings_path(organisation, meeting_id: gone, search: 'Alpha')
+ expect(page).to have_css(overview_rows, count: 2, wait: 10)
+ wait_for_layout_toggle
+ expect(page).to have_no_css('.labor-layout-view.show-content')
+ expect(page).to have_no_css('#meeting_display_frame h2')
+ expect(page).to have_no_current_path(/meeting_id=/, wait: 5)
+ expect(page).to have_current_path(/search=Alpha/)
+
+ # Another project's meeting is not this project's page's to open.
+ visit organisation_project_meetings_path(organisation, alpha, meeting_id: meeting('Beta Retro').id)
+ expect(page).to have_css('#meetings_results tr[data-meeting-id]', count: 2, wait: 10)
+ wait_for_layout_toggle
+ expect(page).to have_no_css('.labor-layout-view.show-content')
+ expect(page).to have_no_current_path(/meeting_id=/, wait: 5)
+ end
+
it 'keeps the overview context through a link rendered without it' do
page.driver.browser.manage.window.resize_to(1440, 1000)
visit organisation_meetings_path(organisation)