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:
parent
cc773eb2aa
commit
9fbcb816d9
@ -46,6 +46,25 @@ public function table(Table $table): Table
|
|||||||
->label('Policy ID')
|
->label('Policy ID')
|
||||||
->copyable(),
|
->copyable(),
|
||||||
Tables\Columns\TextColumn::make('platform')->badge(),
|
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('captured_at')->dateTime(),
|
||||||
Tables\Columns\TextColumn::make('created_at')->since(),
|
Tables\Columns\TextColumn::make('created_at')->since(),
|
||||||
])
|
])
|
||||||
@ -70,6 +89,7 @@ public function table(Table $table): Table
|
|||||||
|
|
||||||
return Policy::query()
|
return Policy::query()
|
||||||
->where('tenant_id', $tenantId)
|
->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))
|
->when($existing, fn (Builder $query) => $query->whereNotIn('id', $existing))
|
||||||
->orderBy('display_name')
|
->orderBy('display_name')
|
||||||
->pluck('display_name', 'id');
|
->pluck('display_name', 'id');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user