Skip to content

Commit 7cf0792

Browse files
Fix: Table::configureUsing() with recordUrl(null) is ignored (#19319)
* refactor(tables): add support for detecting custom record URLs Introduce `isRecordUrlCustom` property to determine if a custom record URL is set. Refactor related logic in resources and relationship tables to respect this property, ensuring consistent URL handling. * naming --------- Co-authored-by: Dan Harrin <git@danharrin.com>
1 parent cd3920f commit 7cf0792

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

packages/panels/src/Resources/Concerns/InteractsWithRelationshipTable.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@ protected function makeTable(): Table
141141
}
142142

143143
return null;
144-
})
145-
->recordUrl(function (Model $record, Table $table): ?string {
144+
});
145+
146+
if (! $table->hasCustomRecordUrl()) {
147+
$table->recordUrl(function (Model $record, Table $table): ?string {
146148
foreach (['view', 'edit'] as $action) {
147149
$action = $table->getAction($action);
148150

@@ -174,8 +176,10 @@ protected function makeTable(): Table
174176
}
175177

176178
return null;
177-
})
178-
->authorizeReorder(fn (): bool => $this->canReorder());
179+
});
180+
}
181+
182+
$table->authorizeReorder(fn (): bool => $this->canReorder());
179183

180184
if ($relatedResource = static::getRelatedResource()) {
181185
$table->modelLabel($relatedResource::getModelLabel());

packages/panels/src/Resources/Pages/ListRecords.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,10 @@ protected function makeTable(): Table
156156
}
157157

158158
return null;
159-
})
160-
->recordUrl(function (Model $record, Table $table): ?string {
159+
});
160+
161+
if (! $table->hasCustomRecordUrl()) {
162+
$table->recordUrl(function (Model $record, Table $table): ?string {
161163
foreach (['view', 'edit'] as $action) {
162164
$action = $table->getAction($action);
163165

@@ -206,6 +208,7 @@ protected function makeTable(): Table
206208

207209
return null;
208210
});
211+
}
209212

210213
static::getResource()::configureTable($table);
211214

packages/tables/src/Table/Concerns/HasRecordUrl.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ trait HasRecordUrl
1212

1313
protected string | Closure | null $recordUrl = null;
1414

15+
protected bool $hasCustomRecordUrl = false;
16+
1517
/**
1618
* @var array<array<mixed> | Closure>
1719
*/
@@ -31,10 +33,16 @@ public function recordUrl(string | Closure | null $url, bool | Closure | null $s
3133
}
3234

3335
$this->recordUrl = $url;
36+
$this->hasCustomRecordUrl = true;
3437

3538
return $this;
3639
}
3740

41+
public function hasCustomRecordUrl(): bool
42+
{
43+
return $this->hasCustomRecordUrl;
44+
}
45+
3846
/**
3947
* @param Model | array<string, mixed> $record
4048
*/

0 commit comments

Comments
 (0)