Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions config/laravel-brain.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,29 @@
'enabled' => env('LARAVEL_BRAIN_TRANSACTIONS_ENABLED', true),
],

// -------------------------------------------------------------------------
// Broadcasting
// -------------------------------------------------------------------------
// Which events broadcast, and onto which channels. An event advertises this
// itself by implementing ShouldBroadcast, and broadcastOn() names the
// channels — so this is read from the class, not from a call chain, and an
// event nobody dispatches from a traced path still shows what it broadcasts.
//
// The channels are matched by shape against the ones routes/channels.php
// authorises: `orders.{id}` from the event and `orders.{orderId}` from the
// route are the same channel. A channel built from a value only known at
// runtime is reported as computed rather than guessed at.
//
// Override via the LARAVEL_BRAIN_BROADCASTING_ENABLED env variable.
//
'broadcasting' => [
'enabled' => env('LARAVEL_BRAIN_BROADCASTING_ENABLED', true),

'paths' => [
'app/Events',
],
],

'observers' => [
'model_paths' => [
'app/Models',
Expand Down
33 changes: 33 additions & 0 deletions frontend/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ export function Sidebar({ selectedId, graphData, theme, onClose, onStressChange
key !== 'deferredDefectMessage' &&
key !== 'note' &&
key !== 'unfollowableReferences' &&
key !== 'broadcast' &&
!(Array.isArray(val) && val.length === 0)
)

Expand All @@ -359,6 +360,7 @@ export function Sidebar({ selectedId, graphData, theme, onClose, onStressChange
const event = node.data?.event as import('../types/graph').EventNodeData | undefined
const listener = node.data?.listener as import('../types/graph').ListenerNodeData | undefined
const job = node.data?.job as import('../types/graph').JobNodeData | undefined
const broadcast = node.data?.broadcast as import('../types/graph').BroadcastData | undefined

// The Reachability tab's caveat, rendered next to the class rather than left in a heading
// three levels up the tree. A reader who clicks a class and is told only that nothing
Expand Down Expand Up @@ -1057,6 +1059,37 @@ export function Sidebar({ selectedId, graphData, theme, onClose, onStressChange
</div>
)}

{broadcast && (
<div className="sidebar-section">
<h3>Broadcasts</h3>
<div className="prop-row">
<span className="prop-key">delivery</span>
<span className="prop-value">{broadcast.queued ? 'queued' : 'immediately'}</span>
</div>
{broadcast.alias && (
<div className="prop-row"><span className="prop-key">listen for</span><span className="prop-value">{broadcast.alias}</span></div>
)}
{broadcast.queue && (
<div className="prop-row"><span className="prop-key">queue</span><span className="prop-value">{broadcast.queue}</span></div>
)}
{broadcast.conditional && (
<div className="prop-row"><span className="prop-key">condition</span><span className="prop-value">broadcastWhen() decides</span></div>
)}
{broadcast.customPayload && (
<div className="prop-row"><span className="prop-key">payload</span><span className="prop-value">broadcastWith(), not the public properties</span></div>
)}
{broadcast.channels.map((channel) => (
<div className="prop-row" key={`${channel.kind}:${channel.name}`}>
<span className="prop-key">{channel.kind}</span>
<span className="prop-value">
{channel.computed ? 'name decided at runtime' : channel.name}
{!channel.computed && !channel.declared && ' — no channel route here names it'}
</span>
</div>
))}
</div>
)}

{erd && (
<div className="sidebar-section">
<h3>Model Schema</h3>
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/types/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,27 @@ export interface TableSchemaData {
}

/** Shape of `node.data.erd` for model nodes in the Model ERD tab. */
/** What an event promises when it broadcasts, as read from the event class itself. */
export interface BroadcastChannelData {
name: string
kind: 'public' | 'private' | 'presence'
/** Every segment of the name came from a value, so which channel it is cannot be known. */
computed: boolean
/** A channel route in this application names the same channel. */
declared: boolean
}

export interface BroadcastData {
/** ShouldBroadcast goes through the queue; ShouldBroadcastNow does not. */
queued: boolean
/** The name subscribers listen for, when broadcastAs() renames it. */
alias: string | null
customPayload: boolean
conditional: boolean
queue: string | null
channels: BroadcastChannelData[]
}

export interface ErdModelData {
table: string
primaryKey: string
Expand Down
10 changes: 10 additions & 0 deletions resources/assets/assets/index-Cfm8-0ay.js

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions resources/assets/assets/index-X7dpiz5p.js

This file was deleted.

2 changes: 1 addition & 1 deletion resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" />
<script type="module" crossorigin src="/_laravel-brain/assets/index-X7dpiz5p.js"></script>
<script type="module" crossorigin src="/_laravel-brain/assets/index-Cfm8-0ay.js"></script>
<link rel="modulepreload" crossorigin href="/_laravel-brain/assets/rolldown-runtime-BHe-jwch.js">
<link rel="modulepreload" crossorigin href="/_laravel-brain/assets/vendor-CsjAK7B8.js">
<link rel="modulepreload" crossorigin href="/_laravel-brain/assets/vendor-react-CNktMmef.js">
Expand Down
Loading
Loading