feat(046): add include dependencies toggle
- Add modal toggle include_dependencies (default on)\n- Persist into selection payload deterministically\n- Update quickstart, tasks, and tests
This commit is contained in:
parent
cf66dc29b8
commit
926264c8d1
@ -16,6 +16,7 @@
|
|||||||
use Filament\Actions\Action as HintAction;
|
use Filament\Actions\Action as HintAction;
|
||||||
use Filament\Forms\Components\Hidden;
|
use Filament\Forms\Components\Hidden;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\Toggle;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Pages\Page;
|
use Filament\Pages\Page;
|
||||||
use Filament\Support\Enums\Size;
|
use Filament\Support\Enums\Size;
|
||||||
@ -89,6 +90,13 @@ protected function getHeaderActions(): array
|
|||||||
new \App\Rules\SupportedPolicyTypesRule,
|
new \App\Rules\SupportedPolicyTypesRule,
|
||||||
])
|
])
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
|
Toggle::make('include_dependencies')
|
||||||
|
->label('Include dependencies')
|
||||||
|
->helperText('Include dependency extraction where supported.')
|
||||||
|
->default(true)
|
||||||
|
->dehydrated()
|
||||||
|
->rules(['boolean'])
|
||||||
|
->columnSpanFull(),
|
||||||
Hidden::make('tenant_id')
|
Hidden::make('tenant_id')
|
||||||
->default(fn (): ?string => Tenant::current()?->getKey())
|
->default(fn (): ?string => Tenant::current()?->getKey())
|
||||||
->dehydrated(),
|
->dehydrated(),
|
||||||
@ -127,6 +135,9 @@ protected function getHeaderActions(): array
|
|||||||
if (array_key_exists('policy_types', $data)) {
|
if (array_key_exists('policy_types', $data)) {
|
||||||
$selectionPayload['policy_types'] = $data['policy_types'];
|
$selectionPayload['policy_types'] = $data['policy_types'];
|
||||||
}
|
}
|
||||||
|
if (array_key_exists('include_dependencies', $data)) {
|
||||||
|
$selectionPayload['include_dependencies'] = (bool) $data['include_dependencies'];
|
||||||
|
}
|
||||||
$computed = $inventorySyncService->normalizeAndHashSelection($selectionPayload);
|
$computed = $inventorySyncService->normalizeAndHashSelection($selectionPayload);
|
||||||
|
|
||||||
$existing = InventorySyncRun::query()
|
$existing = InventorySyncRun::query()
|
||||||
|
|||||||
@ -25,6 +25,7 @@ ## Run locally
|
|||||||
|
|
||||||
5. Click “Run Inventory Sync”:
|
5. Click “Run Inventory Sync”:
|
||||||
- Select which policy types to include (or click “Select all”).
|
- Select which policy types to include (or click “Select all”).
|
||||||
|
- (Optional) Toggle “Include dependencies” if you want dependency extraction where supported.
|
||||||
- You should see:
|
- You should see:
|
||||||
- A database notification (started)
|
- A database notification (started)
|
||||||
- A bottom-right progress widget entry for `Sync inventory`
|
- A bottom-right progress widget entry for `Sync inventory`
|
||||||
|
|||||||
@ -125,6 +125,7 @@ ## Phase 6: Polish & Cross-Cutting Concerns
|
|||||||
- [X] T034 Run targeted tests: `./vendor/bin/sail artisan test --filter=InventorySync` (or specific test files)
|
- [X] T034 Run targeted tests: `./vendor/bin/sail artisan test --filter=InventorySync` (or specific test files)
|
||||||
- [X] T035 Validate quickstart steps remain accurate in specs/046-inventory-sync-button/quickstart.md
|
- [X] T035 Validate quickstart steps remain accurate in specs/046-inventory-sync-button/quickstart.md
|
||||||
- [X] T036 Make BulkOperation progress reflect selected policy types (total_items = #types; per-type success/failure) in app/Filament/Pages/InventoryLanding.php and app/Jobs/RunInventorySyncJob.php
|
- [X] T036 Make BulkOperation progress reflect selected policy types (total_items = #types; per-type success/failure) in app/Filament/Pages/InventoryLanding.php and app/Jobs/RunInventorySyncJob.php
|
||||||
|
- [X] T037 Add `include_dependencies` toggle to the “Run Inventory Sync” modal in app/Filament/Pages/InventoryLanding.php and cover via tests/Feature/Inventory/InventorySyncButtonTest.php
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@ -70,6 +70,31 @@
|
|||||||
expect($run->selection_payload['policy_types'] ?? [])->toEqualCanonicalizing($selectedTypes);
|
expect($run->selection_payload['policy_types'] ?? [])->toEqualCanonicalizing($selectedTypes);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('persists include dependencies toggle into the run selection payload', function () {
|
||||||
|
Queue::fake();
|
||||||
|
|
||||||
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
||||||
|
$this->actingAs($user);
|
||||||
|
|
||||||
|
$tenant->makeCurrent();
|
||||||
|
Filament::setTenant($tenant, true);
|
||||||
|
|
||||||
|
$sync = app(InventorySyncService::class);
|
||||||
|
$allTypes = $sync->defaultSelectionPayload()['policy_types'];
|
||||||
|
$selectedTypes = array_slice($allTypes, 0, min(2, count($allTypes)));
|
||||||
|
|
||||||
|
Livewire::test(InventoryLanding::class)
|
||||||
|
->callAction('run_inventory_sync', data: [
|
||||||
|
'policy_types' => $selectedTypes,
|
||||||
|
'include_dependencies' => false,
|
||||||
|
])
|
||||||
|
->assertHasNoActionErrors();
|
||||||
|
|
||||||
|
$run = InventorySyncRun::query()->where('tenant_id', $tenant->id)->latest('id')->first();
|
||||||
|
expect($run)->not->toBeNull();
|
||||||
|
expect((bool) ($run->selection_payload['include_dependencies'] ?? true))->toBeFalse();
|
||||||
|
});
|
||||||
|
|
||||||
it('rejects cross-tenant initiation attempts (403) with no side effects', function () {
|
it('rejects cross-tenant initiation attempts (403) with no side effects', function () {
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user