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
Send a link to another ticket out of the inbox pane
Guido Boyke677e45d03ad1
diff --git a/app/helpers/ticket_relations_helper.rb b/app/helpers/ticket_relations_helper.rbindex 8a2a014..c70ba73 100644--- a/app/helpers/ticket_relations_helper.rb+++ b/app/helpers/ticket_relations_helper.rb@@ -50,9 +50,11 @@ module TicketRelationsHelper# A link to a related ticket. Within the same project it stays in the ticket frame, the way# a sub-task link does. Into another project it leaves the frame (_top): the lane of project# A would otherwise show B while the list and the navigation stay on A (plan §8.2, review 5).+ # data-ticket-link: in the inbox pane it leaves in any case (ticket_pane_links_controller).def ticket_relation_link(other, from:, **options, &)url = organisation_project_tickets_path(current_organisation, other.project, ticket_id: other.id)- options[:data] = (options[:data] || {}).merge(turbo_frame: '_top') if other.project_id != from.project_id+ options[:data] = (options[:data] || {}).merge(ticket_link: true)+ options[:data][:turbo_frame] = '_top' if other.project_id != from.project_idlink_to(url, options, &)enddiff --git a/app/javascript/controllers/ticket_pane_links_controller.js b/app/javascript/controllers/ticket_pane_links_controller.jsnew file mode 100644index 0000000..15bec09--- /dev/null+++ b/app/javascript/controllers/ticket_pane_links_controller.js@@ -0,0 +1,19 @@+import { Controller } from "@hotwired/stimulus"++// Sends a link to another ticket out of the inbox pane.+//+// The pane is a quick look at ONE notification. Its head (who assigned you, read and archive,+// "open in ticket") belongs to that notification, and only the part below it is a frame. A+// link that stays in the frame swaps that part and leaves the head naming the old ticket, so+// a click on "open in ticket" lands on another ticket than the one on screen.+//+// A controller rather than a target on each link: the timeline, which holds the sub-task+// list, loads apart and cannot know that it sits in the pane. Links mark themselves with+// data-ticket-link; on every other page nothing listens. The click bubbles here before it+// reaches Turbo on the document, so the target is in place when Turbo reads it.+export default class extends Controller {+ leave(event) {+ const link = event.target.closest("a[data-ticket-link]")+ if (link) link.dataset.turboFrame = "_top"+ }+}diff --git a/app/views/organisations/notifications/_pane_ticket.html.erb b/app/views/organisations/notifications/_pane_ticket.html.erbindex 2939934..532c71c 100644--- a/app/views/organisations/notifications/_pane_ticket.html.erb+++ b/app/views/organisations/notifications/_pane_ticket.html.erb@@ -33,7 +33,9 @@data-pane-mark-read-delay-delay-value="5000"></div><% end %>- <div class="p-4 sm:p-6">+ <%# ticket-pane-links: a link to another ticket leaves the pane, the head here names this one.+ On this div, not on the frame: a frame load does not copy the frame's own attributes. %>+ <div class="p-4 sm:p-6" data-controller="ticket-pane-links" data-action="click->ticket-pane-links#leave"><%# Inbox pane header: project eyebrow + status-pills partial.The pills are extracted as a separate partial (stable IDdiff --git a/app/views/organisations/tickets/_subtask_row.html.erb b/app/views/organisations/tickets/_subtask_row.html.erbindex f424006..a8165bd 100644--- a/app/views/organisations/tickets/_subtask_row.html.erb+++ b/app/views/organisations/tickets/_subtask_row.html.erb@@ -1,14 +1,14 @@<%# One sub-task row. Shared by the section's list AND the quick-add Turbo Stream (append) so theappended row is byte-identical to a page-rendered one. Locals: child, project, org, status_def.The link names the detail frame: the section sits inside the timeline's frame, and without a- target it stays there, where the answer holds no such frame ("Content missing"). The inbox- pane has a detail frame of its own, so the sub-task opens there too, below the pane's header. %>+ target it stays there, where the answer holds no such frame ("Content missing"). In the inbox+ pane data-ticket-link sends it out instead (ticket_pane_links_controller). %><li class="flex items-center gap-3 px-3 py-2"><span class="font-mono text-xs text-cream-500 tabular-nums">#<%= child.number %></span><%= link_to child.title,organisation_project_tickets_path(org, project, ticket_id: child.id),class: "flex-1 truncate text-sm text-cream-900 hover:underline",- data: { turbo_frame: 'ticket_display_frame' } %>+ data: { turbo_frame: 'ticket_display_frame', ticket_link: true } %><% status_value = child.get_custom_attribute('status') %><% if status_value.present? %><span class="h-6 shrink-0 rounded-full border border-cream-300 px-2 text-xs leading-6 text-cream-700">diff --git a/app/views/organisations/tickets/_ticket_breadcrumbs.html.erb b/app/views/organisations/tickets/_ticket_breadcrumbs.html.erbindex f840f8e..d1c5be1 100644--- a/app/views/organisations/tickets/_ticket_breadcrumbs.html.erb+++ b/app/views/organisations/tickets/_ticket_breadcrumbs.html.erb@@ -12,7 +12,8 @@<li class="inline-flex items-center gap-1"><%= link_to "##{ancestor.number}",organisation_project_tickets_path(current_organisation, project, ticket_id: ancestor.id),- class: "inline-flex h-6 items-center rounded-full border border-cream-300 px-2 font-mono tabular-nums hover:bg-cream-100" %>+ class: "inline-flex h-6 items-center rounded-full border border-cream-300 px-2 font-mono tabular-nums hover:bg-cream-100",+ data: { ticket_link: true } %><span class="text-cream-500" aria-hidden="true">›</span></li><% end %>diff --git a/spec/javascript/controllers/ticket_pane_links_controller.test.js b/spec/javascript/controllers/ticket_pane_links_controller.test.jsnew file mode 100644index 0000000..8d35805--- /dev/null+++ b/spec/javascript/controllers/ticket_pane_links_controller.test.js@@ -0,0 +1,30 @@+import { test } from "node:test"+import assert from "node:assert/strict"+import { readFileSync } from "node:fs"+import { runInNewContext } from "node:vm"++const source = readFileSync(new URL("../../../app/javascript/controllers/ticket_pane_links_controller.js", import.meta.url), "utf8")+ .replace(/^import .*\n/gm, "")+ .replace("export default class", "class TicketPaneLinksController")++function controller() {+ const Controller = runInNewContext(`${source}\nTicketPaneLinksController`, { Controller: class {} })+ return new Controller()+}++// A click lands on whatever sits inside the link; closest finds the link.+function clickOn(link) {+ return { target: { closest: selector => (selector === "a[data-ticket-link]" ? link : null) } }+}++test("a link to another ticket leaves the pane", () => {+ const link = { dataset: { ticketLink: "", turboFrame: "ticket_display_frame" } }++ controller().leave(clickOn(link))++ assert.equal(link.dataset.turboFrame, "_top")+})++test("a click on anything else changes nothing", () => {+ assert.doesNotThrow(() => controller().leave(clickOn(null)))+})diff --git a/spec/requests/inbox_pane_flow_spec.rb b/spec/requests/inbox_pane_flow_spec.rbindex 59166bf..4eb3470 100644--- a/spec/requests/inbox_pane_flow_spec.rb+++ b/spec/requests/inbox_pane_flow_spec.rb@@ -143,6 +143,25 @@ RSpec.describe 'Inbox pane flow', type: :request doendend+ # The pane is a quick look at ONE notification: its head names that ticket, so a link to+ # another ticket leaves the pane instead of swapping only the part below the head. The+ # timeline loads apart and cannot know where it sits, hence a controller here, not a target+ # on each link. It sits inside the frame: a frame load does not copy the frame's attributes.+ describe 'links to other tickets from the pane' do+ it 'wires the controller that sends them out, inside the pane' do+ get organisation_notifications_path(organisation),+ params: { notification: ticket_notification.id },+ headers: { 'Turbo-Frame' => 'ticket_pane' }++ expect(response).to have_http_status(:ok)+ document = Nokogiri::HTML(response.body)+ wrapper = document.at_css("turbo-frame#ticket_pane [data-controller~='ticket-pane-links']")+ expect(wrapper).to be_present+ expect(wrapper['data-action']).to include('click->ticket-pane-links#leave')+ expect(wrapper.at_css('turbo-frame#ticket_display_frame')).to be_present+ end+ end+describe 'editing a ticket from the pane' do# The pane carries ticket_display_frame like the standalone ticket view# (_index_desktop.html.erb): the status pills and inline edits target it, anddiff --git a/spec/requests/organisations/ticket_relations_section_spec.rb b/spec/requests/organisations/ticket_relations_section_spec.rbindex 660eae2..b63642b 100644--- a/spec/requests/organisations/ticket_relations_section_spec.rb+++ b/spec/requests/organisations/ticket_relations_section_spec.rb@@ -155,6 +155,7 @@ RSpec.describe 'Ticket relations section and waiting hint', :ci_guard, type: :reother_link = section.at_css(%(a[href="#{organisation_project_tickets_path(organisation, other_project, ticket_id: elsewhere.id)}"]))expect(same_link['data-turbo-frame']).to be_nilexpect(other_link['data-turbo-frame']).to eq('_top')+ expect(same_link.key?('data-ticket-link')).to be(true)endit 'renders for a sub-task as well' dodiff --git a/spec/requests/organisations/tickets_subtasks_render_spec.rb b/spec/requests/organisations/tickets_subtasks_render_spec.rbindex 3bc012f..ee9ea77 100644--- a/spec/requests/organisations/tickets_subtasks_render_spec.rb+++ b/spec/requests/organisations/tickets_subtasks_render_spec.rb@@ -68,6 +68,7 @@ RSpec.describe 'Tickets sub-tasks (detail rendering)', type: :request doexpect(response).to have_http_status(:ok)expect(link).to be_presentexpect(link['data-turbo-frame']).to eq('ticket_display_frame')+ expect(link.key?('data-ticket-link')).to be(true)endit 'shows only the compact right-aligned quick-add when there are no sub-tasks (no heading/hint/hero)' do@@ -100,6 +101,7 @@ RSpec.describe 'Tickets sub-tasks (detail rendering)', type: :request dolink = nav.at_css('ol li a')expect(link.text.strip).to eq("##{parent.number}")expect(link['href']).to eq(organisation_project_tickets_path(organisation, project, ticket_id: parent.id))+ expect(link.key?('data-ticket-link')).to be(true)expect(response.body).not_to include('Teil von')end