fix(ui): configuration changes modal values, colors and spacing
This commit is contained in:
parent
fcd63f40eb
commit
bd744eb8dd
7 changed files with 58 additions and 58 deletions
|
|
@ -1188,17 +1188,20 @@ public function pendingDeploymentConfigurationDiff(): ConfigurationDiff
|
||||||
$currentSnapshot = $this->deploymentConfigurationSnapshot();
|
$currentSnapshot = $this->deploymentConfigurationSnapshot();
|
||||||
$lastDeployment = $this->get_last_successful_deployment();
|
$lastDeployment = $this->get_last_successful_deployment();
|
||||||
|
|
||||||
if ($lastDeployment?->configuration_snapshot) {
|
$previousSnapshot = $lastDeployment?->configuration_snapshot;
|
||||||
return app(ConfigurationDiffer::class)->diff($lastDeployment->configuration_snapshot, $currentSnapshot);
|
|
||||||
|
if (! $previousSnapshot) {
|
||||||
|
$oldConfigHash = data_get($this, 'config_hash');
|
||||||
|
$hasLegacyChange = $oldConfigHash === null || $oldConfigHash !== $this->legacyConfigurationHash();
|
||||||
|
|
||||||
|
if (! $hasLegacyChange) {
|
||||||
|
return ConfigurationDiff::unchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
$previousSnapshot = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldConfigHash = data_get($this, 'config_hash');
|
return app(ConfigurationDiffer::class)->diff($previousSnapshot, $currentSnapshot);
|
||||||
|
|
||||||
if ($oldConfigHash === null) {
|
|
||||||
return ConfigurationDiff::legacy(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ConfigurationDiff::legacy($oldConfigHash !== $this->legacyConfigurationHash());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasPendingDeploymentConfigurationChanges(): bool
|
public function hasPendingDeploymentConfigurationChanges(): bool
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,7 @@ private function normalizeValue(mixed $value): mixed
|
||||||
private function displayValue(mixed $value): string
|
private function displayValue(mixed $value): string
|
||||||
{
|
{
|
||||||
if ($value === null) {
|
if ($value === null) {
|
||||||
return 'Not set';
|
return '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_bool($value)) {
|
if (is_bool($value)) {
|
||||||
|
|
@ -323,7 +323,7 @@ private function displayValue(mixed $value): string
|
||||||
private function summarizeText(?string $value): string
|
private function summarizeText(?string $value): string
|
||||||
{
|
{
|
||||||
if (blank($value)) {
|
if (blank($value)) {
|
||||||
return 'Not set';
|
return '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = trim((string) $value);
|
$value = trim((string) $value);
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ public function diff(array $previousSnapshot, array $currentSnapshot): Configura
|
||||||
'impact' => data_get($item, 'impact', 'redeploy'),
|
'impact' => data_get($item, 'impact', 'redeploy'),
|
||||||
'sensitive' => $sensitive,
|
'sensitive' => $sensitive,
|
||||||
'display_summary' => $displaySummary,
|
'display_summary' => $displaySummary,
|
||||||
'old_display_value' => $sensitive ? ($previous === null ? 'Not set' : 'Set') : data_get($previous, 'display_value', 'Not set'),
|
'old_display_value' => $sensitive ? ($previous === null ? '-' : '••••••••') : data_get($previous, 'display_value', '-'),
|
||||||
'new_display_value' => $sensitive ? ($current === null ? 'Removed' : 'Set') : data_get($current, 'display_value', 'Not set'),
|
'new_display_value' => $sensitive ? ($current === null ? '-' : '••••••••') : data_get($current, 'display_value', '-'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
])
|
])
|
||||||
|
|
||||||
@php
|
@php
|
||||||
$changes = data_get($diff, 'changes', []);
|
$changes = collect(data_get($diff, 'changes', []))->filter(fn ($change) => data_get($change, 'key') !== 'domains.custom_labels')->values()->all();
|
||||||
$count = data_get($diff, 'count', count($changes));
|
$count = count($changes);
|
||||||
$requiresBuild = data_get($diff, 'requires_build', false);
|
$requiresBuild = collect($changes)->contains(fn ($change) => data_get($change, 'impact') === 'build');
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
@if ($count > 0)
|
@if ($count > 0)
|
||||||
|
|
@ -21,45 +21,39 @@
|
||||||
'bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-300' => $requiresBuild,
|
'bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-300' => $requiresBuild,
|
||||||
'bg-blue-100 text-blue-700 dark:bg-blue-500/20 dark:text-blue-300' => ! $requiresBuild,
|
'bg-blue-100 text-blue-700 dark:bg-blue-500/20 dark:text-blue-300' => ! $requiresBuild,
|
||||||
])>
|
])>
|
||||||
{{ $requiresBuild ? 'Rebuild' : 'Redeploy' }}
|
{{ $requiresBuild ? 'Rebuild required' : 'Redeploy required' }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@unless ($compact)
|
@unless ($compact)
|
||||||
<div class="space-y-2">
|
<div class="space-y-4">
|
||||||
@foreach (collect($changes)->groupBy('section_label') as $sectionLabel => $sectionChanges)
|
@foreach (collect($changes)->groupBy('section_label') as $sectionLabel => $sectionChanges)
|
||||||
<div>
|
<div>
|
||||||
<div class="mb-0.5 text-[0.65rem] font-semibold uppercase tracking-wide text-neutral-600 dark:text-neutral-400">
|
<div class="mb-0.5 text-[0.65rem] font-semibold uppercase tracking-wide text-neutral-600 dark:text-neutral-400">
|
||||||
{{ $sectionLabel }}
|
{{ $sectionLabel }}
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-x-auto rounded-sm border border-neutral-300 dark:border-coolgray-200">
|
<div class="rounded-sm border border-neutral-300 dark:border-coolgray-200">
|
||||||
<div class="min-w-[44rem]">
|
<div class="grid grid-cols-[12rem_1fr_1.5rem_1fr] items-center gap-2 bg-neutral-100 px-3 py-1.5 text-[0.65rem] font-semibold uppercase tracking-wide text-neutral-500 dark:bg-coolgray-200 dark:text-neutral-400">
|
||||||
<div class="grid grid-cols-[minmax(12rem,1.4fr)_7rem_minmax(8rem,1fr)_1.5rem_minmax(8rem,1fr)] items-center gap-2 bg-neutral-100 px-3 py-1.5 text-[0.65rem] font-semibold uppercase tracking-wide text-neutral-500 dark:bg-coolgray-200 dark:text-neutral-400">
|
<div>Field</div>
|
||||||
<div>Field</div>
|
<div>From</div>
|
||||||
<div>Type</div>
|
<div></div>
|
||||||
<div>From</div>
|
<div>To</div>
|
||||||
<div></div>
|
</div>
|
||||||
<div>To</div>
|
<div class="divide-y divide-neutral-300 dark:divide-coolgray-200">
|
||||||
</div>
|
@foreach ($sectionChanges as $change)
|
||||||
<div class="divide-y divide-neutral-300 dark:divide-coolgray-200">
|
<div class="grid grid-cols-[12rem_1fr_1.5rem_1fr] items-start gap-2 px-3 py-1.5 text-neutral-700 dark:text-neutral-300">
|
||||||
@foreach ($sectionChanges as $change)
|
<div class="shrink-0 font-medium text-black dark:text-white">
|
||||||
<div class="grid grid-cols-[minmax(12rem,1.4fr)_7rem_minmax(8rem,1fr)_1.5rem_minmax(8rem,1fr)] items-center gap-2 px-3 py-1.5 text-neutral-700 dark:text-neutral-300">
|
{{ data_get($change, 'label') }}
|
||||||
<div class="truncate font-medium text-black dark:text-white" title="{{ data_get($change, 'label') }}">
|
|
||||||
{{ data_get($change, 'label') }}
|
|
||||||
</div>
|
|
||||||
<div class="text-neutral-500 dark:text-neutral-400">
|
|
||||||
{{ data_get($change, 'type') }}
|
|
||||||
</div>
|
|
||||||
<div class="truncate" title="{{ data_get($change, 'old_display_value') }}">
|
|
||||||
{{ data_get($change, 'old_display_value') }}
|
|
||||||
</div>
|
|
||||||
<div class="text-center text-neutral-500 dark:text-neutral-400">→</div>
|
|
||||||
<div class="truncate" title="{{ data_get($change, 'new_display_value') }}">
|
|
||||||
{{ data_get($change, 'new_display_value') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
<div class="truncate text-red-700 dark:text-red-400/80" title="{{ data_get($change, 'old_display_value') }}">
|
||||||
</div>
|
{{ data_get($change, 'old_display_value') }}
|
||||||
|
</div>
|
||||||
|
<div class="text-center text-neutral-500 dark:text-neutral-400">→</div>
|
||||||
|
<div class="truncate text-green-700 dark:text-green-500" title="{{ data_get($change, 'new_display_value') }}">
|
||||||
|
{{ data_get($change, 'new_display_value') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -80,11 +80,11 @@ function configurationChangedDeployment(Application $application): ApplicationDe
|
||||||
|
|
||||||
$diff = $application->pendingDeploymentConfigurationDiff();
|
$diff = $application->pendingDeploymentConfigurationDiff();
|
||||||
|
|
||||||
expect($diff->isLegacyFallback())->toBeTrue()
|
expect($diff->isChanged())->toBeTrue()
|
||||||
->and($diff->isChanged())->toBeTrue();
|
->and($diff->count())->toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('falls back to legacy configuration hash when no deployment snapshot exists', function () {
|
it('falls back to real diff against empty snapshot when no deployment snapshot exists', function () {
|
||||||
$application = configurationChangedTestApplication();
|
$application = configurationChangedTestApplication();
|
||||||
$application->isConfigurationChanged(save: true);
|
$application->isConfigurationChanged(save: true);
|
||||||
|
|
||||||
|
|
@ -92,6 +92,10 @@ function configurationChangedDeployment(Application $application): ApplicationDe
|
||||||
|
|
||||||
$application->update(['build_command' => 'pnpm build']);
|
$application->update(['build_command' => 'pnpm build']);
|
||||||
|
|
||||||
expect($application->refresh()->pendingDeploymentConfigurationDiff()->isLegacyFallback())->toBeTrue()
|
$diff = $application->refresh()->pendingDeploymentConfigurationDiff();
|
||||||
->and($application->pendingDeploymentConfigurationDiff()->isChanged())->toBeTrue();
|
|
||||||
|
expect($diff->isChanged())->toBeTrue()
|
||||||
|
->and($diff->isLegacyFallback())->toBeFalse()
|
||||||
|
->and($diff->count())->toBeGreaterThan(0)
|
||||||
|
->and(collect($diff->changes())->pluck('label')->toArray())->toContain('Build command');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -126,8 +126,7 @@ function markConfigurationCheckerApplicationDeployed(Application $application):
|
||||||
|
|
||||||
Livewire::test(ConfigurationChecker::class, ['resource' => $application->refresh()])
|
Livewire::test(ConfigurationChecker::class, ['resource' => $application->refresh()])
|
||||||
->assertSee('API_TOKEN')
|
->assertSee('API_TOKEN')
|
||||||
->assertSee('changed')
|
->assertSee('••••••••')
|
||||||
->assertSee('Set')
|
|
||||||
->assertDontSee('Hidden')
|
->assertDontSee('Hidden')
|
||||||
->assertDontSee('old-secret')
|
->assertDontSee('old-secret')
|
||||||
->assertDontSee('new-secret');
|
->assertDontSee('new-secret');
|
||||||
|
|
@ -150,9 +149,9 @@ function markConfigurationCheckerApplicationDeployed(Application $application):
|
||||||
Livewire::test(ConfigurationChecker::class, ['resource' => $application->refresh()])
|
Livewire::test(ConfigurationChecker::class, ['resource' => $application->refresh()])
|
||||||
->assertSee('API_TOKEN')
|
->assertSee('API_TOKEN')
|
||||||
->assertSee('From')
|
->assertSee('From')
|
||||||
->assertSee('Not set')
|
->assertSee('-')
|
||||||
->assertSee('To')
|
->assertSee('To')
|
||||||
->assertSee('Set')
|
->assertSee('••••••••')
|
||||||
->assertDontSee('Hidden')
|
->assertDontSee('Hidden')
|
||||||
->assertDontSee('new-secret');
|
->assertDontSee('new-secret');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -93,8 +93,8 @@ function markSnapshotTestApplicationDeployed(Application $application): Applicat
|
||||||
|
|
||||||
expect($change)->not->toBeNull()
|
expect($change)->not->toBeNull()
|
||||||
->and($change['display_summary'])->toBe('Changed')
|
->and($change['display_summary'])->toBe('Changed')
|
||||||
->and($change['old_display_value'])->toBe('Set')
|
->and($change['old_display_value'])->toBe('••••••••')
|
||||||
->and($change['new_display_value'])->toBe('Set')
|
->and($change['new_display_value'])->toBe('••••••••')
|
||||||
->and(json_encode($diff->toArray()))->not->toContain('old-secret')->not->toContain('new-secret');
|
->and(json_encode($diff->toArray()))->not->toContain('old-secret')->not->toContain('new-secret');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -117,7 +117,7 @@ function markSnapshotTestApplicationDeployed(Application $application): Applicat
|
||||||
|
|
||||||
expect($change)->not->toBeNull()
|
expect($change)->not->toBeNull()
|
||||||
->and($change['display_summary'])->toBeNull()
|
->and($change['display_summary'])->toBeNull()
|
||||||
->and($change['old_display_value'])->toBe('Not set')
|
->and($change['old_display_value'])->toBe('-')
|
||||||
->and($change['new_display_value'])->toBe('Set')
|
->and($change['new_display_value'])->toBe('••••••••')
|
||||||
->and(json_encode($diff->toArray()))->not->toContain('new-secret');
|
->and(json_encode($diff->toArray()))->not->toContain('new-secret');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue