refactor: group replace pairs in script diffs
This commit is contained in:
parent
f165bd059e
commit
a6b1a8913b
@ -253,56 +253,71 @@
|
||||
<div class="text-sm font-medium text-gray-900 dark:text-white">
|
||||
{{ (string) $name }}
|
||||
</div>
|
||||
<div class="text-sm text-gray-600 dark:text-gray-300">
|
||||
<span class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400">From</span>
|
||||
@if ($isScriptContent || $isExpandable($from))
|
||||
|
||||
@if ($isScriptContent)
|
||||
<div class="text-sm text-gray-600 dark:text-gray-300 sm:col-span-2">
|
||||
<span class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400">Diff</span>
|
||||
<details class="mt-1">
|
||||
<summary class="cursor-pointer text-sm text-gray-700 dark:text-gray-200">
|
||||
View
|
||||
</summary>
|
||||
@if ($isScriptContent)
|
||||
<pre class="mt-2 overflow-x-auto text-xs text-gray-800 dark:text-gray-200 whitespace-pre">
|
||||
@foreach ($ops as $op)
|
||||
@if ($op['type'] === 'equal')
|
||||
|
||||
<div class="mt-2 overflow-x-auto font-mono text-xs text-gray-800 dark:text-gray-200 whitespace-pre">
|
||||
@php
|
||||
$count = count($ops);
|
||||
@endphp
|
||||
|
||||
@for ($i = 0; $i < $count; $i++)
|
||||
@php
|
||||
$op = $ops[$i];
|
||||
$next = $ops[$i + 1] ?? null;
|
||||
@endphp
|
||||
|
||||
@if ($op['type'] === 'equal')
|
||||
{{ $op['line'] }}
|
||||
@elseif ($op['type'] === 'delete')
|
||||
@elseif ($op['type'] === 'delete' && is_array($next) && ($next['type'] ?? null) === 'insert')
|
||||
<span class="block bg-danger-50 text-danger-700 dark:bg-danger-950/40 dark:text-danger-200">- {{ $op['line'] }}</span>
|
||||
@endif
|
||||
@endforeach
|
||||
</pre>
|
||||
@else
|
||||
<pre class="mt-2 overflow-x-auto text-xs text-gray-800 dark:text-gray-200">{{ $fromText }}</pre>
|
||||
@endif
|
||||
</details>
|
||||
@else
|
||||
<div class="mt-1">{{ $fromText }}</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="text-sm text-gray-600 dark:text-gray-300">
|
||||
<span class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400">To</span>
|
||||
@if ($isScriptContent || $isExpandable($to))
|
||||
<details class="mt-1">
|
||||
<summary class="cursor-pointer text-sm text-gray-700 dark:text-gray-200">
|
||||
View
|
||||
</summary>
|
||||
@if ($isScriptContent)
|
||||
<pre class="mt-2 overflow-x-auto text-xs text-gray-800 dark:text-gray-200 whitespace-pre">
|
||||
@foreach ($ops as $op)
|
||||
@if ($op['type'] === 'equal')
|
||||
{{ $op['line'] }}
|
||||
@elseif ($op['type'] === 'insert')
|
||||
<span class="block bg-success-50 text-success-700 dark:bg-success-950/40 dark:text-success-200">+ {{ $next['line'] }}</span>
|
||||
@php
|
||||
$i++;
|
||||
@endphp
|
||||
@elseif ($op['type'] === 'delete')
|
||||
<span class="block bg-danger-50 text-danger-700 dark:bg-danger-950/40 dark:text-danger-200">- {{ $op['line'] }}</span>
|
||||
@elseif ($op['type'] === 'insert')
|
||||
<span class="block bg-success-50 text-success-700 dark:bg-success-950/40 dark:text-success-200">+ {{ $op['line'] }}</span>
|
||||
@endif
|
||||
@endforeach
|
||||
</pre>
|
||||
@else
|
||||
<pre class="mt-2 overflow-x-auto text-xs text-gray-800 dark:text-gray-200">{{ $toText }}</pre>
|
||||
@endif
|
||||
@endif
|
||||
@endfor
|
||||
</div>
|
||||
</details>
|
||||
@else
|
||||
<div class="mt-1">{{ $toText }}</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
<div class="text-sm text-gray-600 dark:text-gray-300">
|
||||
<span class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400">From</span>
|
||||
@if ($isExpandable($from))
|
||||
<details class="mt-1">
|
||||
<summary class="cursor-pointer text-sm text-gray-700 dark:text-gray-200">
|
||||
View
|
||||
</summary>
|
||||
<pre class="mt-2 overflow-x-auto text-xs text-gray-800 dark:text-gray-200">{{ $fromText }}</pre>
|
||||
</details>
|
||||
@else
|
||||
<div class="mt-1">{{ $fromText }}</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="text-sm text-gray-600 dark:text-gray-300">
|
||||
<span class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400">To</span>
|
||||
@if ($isExpandable($to))
|
||||
<details class="mt-1">
|
||||
<summary class="cursor-pointer text-sm text-gray-700 dark:text-gray-200">
|
||||
View
|
||||
</summary>
|
||||
<pre class="mt-2 overflow-x-auto text-xs text-gray-800 dark:text-gray-200">{{ $toText }}</pre>
|
||||
</details>
|
||||
@else
|
||||
<div class="mt-1">{{ $toText }}</div>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@else
|
||||
@php
|
||||
|
||||
Loading…
Reference in New Issue
Block a user