fix: restore versions show assignments and scope tags
This commit is contained in:
parent
c7768e27fe
commit
19b3af483b
@ -296,7 +296,13 @@ private function hydrateGroupPolicyConfiguration(string $tenantIdentifier, Tenan
|
||||
}
|
||||
|
||||
$definitionValues = array_merge($definitionValues, $response->data['value'] ?? []);
|
||||
$nextPath = $response->data['@odata.nextLink'] ?? null;
|
||||
$nextLink = $response->data['@odata.nextLink'] ?? null;
|
||||
|
||||
if (! $nextLink) {
|
||||
break;
|
||||
}
|
||||
|
||||
$nextPath = $this->stripGraphBaseUrl((string) $nextLink);
|
||||
}
|
||||
|
||||
if ($hydrationStatus === 'failed') {
|
||||
@ -368,7 +374,13 @@ private function hydrateGroupPolicyConfiguration(string $tenantIdentifier, Tenan
|
||||
}
|
||||
|
||||
$presentationValues = array_merge($presentationValues, $pvResponse->data['value'] ?? []);
|
||||
$presentationNext = $pvResponse->data['@odata.nextLink'] ?? null;
|
||||
$presentationNextLink = $pvResponse->data['@odata.nextLink'] ?? null;
|
||||
|
||||
if (! $presentationNextLink) {
|
||||
break;
|
||||
}
|
||||
|
||||
$presentationNext = $this->stripGraphBaseUrl((string) $presentationNextLink);
|
||||
}
|
||||
|
||||
if ($presentationValues !== []) {
|
||||
|
||||
@ -627,7 +627,7 @@ public function execute(
|
||||
'restore_run_id' => $restoreRun->id,
|
||||
'backup_item_id' => $item->id,
|
||||
],
|
||||
assignments: $restoredAssignments,
|
||||
assignments: $item->assignments,
|
||||
scopeTags: $scopeTagsForVersion,
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,4 +1,19 @@
|
||||
<div class="space-y-4">
|
||||
@php
|
||||
$scopeTags = $version->scope_tags['names'] ?? [];
|
||||
@endphp
|
||||
@if(!empty($scopeTags))
|
||||
<x-filament::section heading="Scope Tags">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
@foreach($scopeTags as $tag)
|
||||
<span class="inline-flex items-center rounded-md bg-primary-50 px-2 py-1 text-xs font-medium text-primary-700 ring-1 ring-inset ring-primary-700/10 dark:bg-primary-400/10 dark:text-primary-400 dark:ring-primary-400/30">
|
||||
{{ $tag }}
|
||||
</span>
|
||||
@endforeach
|
||||
</div>
|
||||
</x-filament::section>
|
||||
@endif
|
||||
|
||||
@if($version->assignments && count($version->assignments) > 0)
|
||||
<x-filament::section
|
||||
heading="Assignments"
|
||||
@ -18,22 +33,6 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@php
|
||||
$scopeTags = $version->scope_tags['names'] ?? [];
|
||||
@endphp
|
||||
@if(!empty($scopeTags))
|
||||
<div>
|
||||
<h4 class="text-sm font-medium text-gray-950 dark:text-white">Scope Tags</h4>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
@foreach($scopeTags as $tag)
|
||||
<span class="inline-flex items-center rounded-md bg-primary-50 px-2 py-1 text-xs font-medium text-primary-700 ring-1 ring-inset ring-primary-700/10 dark:bg-primary-400/10 dark:text-primary-400 dark:ring-primary-400/30">
|
||||
{{ $tag }}
|
||||
</span>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div>
|
||||
<h4 class="text-sm font-medium text-gray-950 dark:text-white">Assignment Details</h4>
|
||||
<div class="mt-2 space-y-2">
|
||||
|
||||
59
tests/Feature/Filament/PolicyVersionScopeTagsDisplayTest.php
Normal file
59
tests/Feature/Filament/PolicyVersionScopeTagsDisplayTest.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use App\Filament\Resources\PolicyVersionResource;
|
||||
use App\Models\Policy;
|
||||
use App\Models\PolicyVersion;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
test('policy version view shows scope tags even when assignments are missing', function () {
|
||||
$tenant = Tenant::create([
|
||||
'tenant_id' => env('INTUNE_TENANT_ID', 'local-tenant'),
|
||||
'name' => 'Tenant One',
|
||||
'metadata' => [],
|
||||
'is_current' => true,
|
||||
]);
|
||||
|
||||
putenv('INTUNE_TENANT_ID='.$tenant->tenant_id);
|
||||
$tenant->makeCurrent();
|
||||
|
||||
$policy = Policy::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'external_id' => 'policy-1',
|
||||
'policy_type' => 'deviceConfiguration',
|
||||
'display_name' => 'Policy A',
|
||||
'platform' => 'windows',
|
||||
]);
|
||||
|
||||
$version = PolicyVersion::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'policy_id' => $policy->id,
|
||||
'version_number' => 1,
|
||||
'policy_type' => $policy->policy_type,
|
||||
'platform' => $policy->platform,
|
||||
'created_by' => 'tester@example.com',
|
||||
'captured_at' => CarbonImmutable::now(),
|
||||
'snapshot' => [
|
||||
'displayName' => 'Policy A',
|
||||
],
|
||||
'assignments' => null,
|
||||
'scope_tags' => [
|
||||
'ids' => ['0', 'scope-1'],
|
||||
'names' => ['Default', 'Verbund-1'],
|
||||
],
|
||||
]);
|
||||
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->get(PolicyVersionResource::getUrl('view', ['record' => $version]));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertSee('Scope Tags');
|
||||
$response->assertSee('Default');
|
||||
$response->assertSee('Verbund-1');
|
||||
});
|
||||
@ -49,6 +49,8 @@ public function getServicePrincipalPermissions(array $options = []): GraphRespon
|
||||
}
|
||||
});
|
||||
|
||||
config()->set('graph_contracts.types.deviceConfiguration.assignments_payload_key', 'assignments');
|
||||
|
||||
$tenant = Tenant::create([
|
||||
'tenant_id' => 'tenant-1',
|
||||
'name' => 'Tenant One',
|
||||
@ -85,6 +87,16 @@ public function getServicePrincipalPermissions(array $options = []): GraphRespon
|
||||
'scope_tag_ids' => ['0', 'scope-1'],
|
||||
'scope_tag_names' => ['Default', 'Verbund-1'],
|
||||
],
|
||||
'assignments' => [
|
||||
[
|
||||
'target' => [
|
||||
'@odata.type' => '#microsoft.graph.groupAssignmentTarget',
|
||||
'groupId' => 'group-1',
|
||||
'group_display_name' => 'Group One',
|
||||
],
|
||||
'intent' => 'apply',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$user = User::factory()->create(['email' => 'tester@example.com']);
|
||||
@ -116,6 +128,7 @@ public function getServicePrincipalPermissions(array $options = []): GraphRespon
|
||||
'ids' => ['0', 'scope-1'],
|
||||
'names' => ['Default', 'Verbund-1'],
|
||||
]);
|
||||
expect($version->assignments)->toBe($backupItem->assignments);
|
||||
});
|
||||
|
||||
test('restore execution records foundation mappings', function () {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user