fix(004): Apply 7-day policy filter to backup policy selector

Prevents selection of policies that haven't been synced in the last 7 days
(likely deleted in Intune). Aligns with PolicyResource table filter.

This is a workaround until Feature 005 (Policy Lifecycle) is implemented
with proper soft delete detection during sync.
This commit is contained in:
Ahmed Darrazi 2025-12-22 15:57:47 +01:00
parent cc773eb2aa
commit 9fbcb816d9

View File

@ -46,6 +46,25 @@ public function table(Table $table): Table
->label('Policy ID')
->copyable(),
Tables\Columns\TextColumn::make('platform')->badge(),
Tables\Columns\TextColumn::make('metadata.assignment_count')
->label('Assignments')
->default('0')
->badge()
->color('info'),
Tables\Columns\TextColumn::make('metadata.scope_tag_names')
->label('Scope Tags')
->badge()
->separator(',')
->default('—')
->formatStateUsing(function ($state) {
if (empty($state)) {
return '—';
}
if (is_array($state)) {
return implode(', ', $state);
}
return $state;
}),
Tables\Columns\TextColumn::make('captured_at')->dateTime(),
Tables\Columns\TextColumn::make('created_at')->since(),
])
@ -70,6 +89,7 @@ public function table(Table $table): Table
return Policy::query()
->where('tenant_id', $tenantId)
->where('last_synced_at', '>', now()->subDays(7)) // Hide deleted policies (Feature 005 workaround)
->when($existing, fn (Builder $query) => $query->whereNotIn('id', $existing))
->orderBy('display_name')
->pluck('display_name', 'id');