feat/004-assignments-scope-tags #4

Merged
ahmido merged 41 commits from feat/004-assignments-scope-tags into dev 2025-12-23 21:49:59 +00:00
Showing only changes of commit a7f3293689 - Show all commits

View File

@ -51,19 +51,26 @@ public function table(Table $table): Table
->label('Assignments') ->label('Assignments')
->badge() ->badge()
->color('info') ->color('info')
->formatStateUsing(fn ($state) => is_array($state) ? count($state) : 0), ->getStateUsing(function (BackupItem $record): int {
$assignments = $record->policyVersion?->assignments ?? $record->assignments ?? [];
return is_array($assignments) ? count($assignments) : 0;
}),
Tables\Columns\TextColumn::make('scope_tags') Tables\Columns\TextColumn::make('scope_tags')
->label('Scope Tags') ->label('Scope Tags')
->badge()
->separator(',')
->default('—') ->default('—')
->formatStateUsing(function ($state, BackupItem $record) { ->getStateUsing(function (BackupItem $record): array {
// Get scope tags from PolicyVersion if available $tags = $record->policyVersion?->scope_tags['names'] ?? [];
if ($record->policyVersion && ! empty($record->policyVersion->scope_tags)) {
$tags = $record->policyVersion->scope_tags; return is_array($tags) ? $tags : [];
if (is_array($tags) && isset($tags['names'])) { })
return implode(', ', $tags['names']); ->formatStateUsing(function ($state): string {
if (is_array($state)) {
return $state === [] ? '—' : implode(', ', $state);
} }
if (is_string($state) && $state !== '') {
return $state;
} }
return '—'; return '—';