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">
|
<div class="text-sm font-medium text-gray-900 dark:text-white">
|
||||||
{{ (string) $name }}
|
{{ (string) $name }}
|
||||||
</div>
|
</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)
|
||||||
@if ($isScriptContent || $isExpandable($from))
|
<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">
|
<details class="mt-1">
|
||||||
<summary class="cursor-pointer text-sm text-gray-700 dark:text-gray-200">
|
<summary class="cursor-pointer text-sm text-gray-700 dark:text-gray-200">
|
||||||
View
|
View
|
||||||
</summary>
|
</summary>
|
||||||
@if ($isScriptContent)
|
|
||||||
<pre class="mt-2 overflow-x-auto text-xs text-gray-800 dark:text-gray-200 whitespace-pre">
|
<div class="mt-2 overflow-x-auto font-mono text-xs text-gray-800 dark:text-gray-200 whitespace-pre">
|
||||||
@foreach ($ops as $op)
|
@php
|
||||||
@if ($op['type'] === 'equal')
|
$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'] }}
|
{{ $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>
|
<span class="block bg-danger-50 text-danger-700 dark:bg-danger-950/40 dark:text-danger-200">- {{ $op['line'] }}</span>
|
||||||
@endif
|
<span class="block bg-success-50 text-success-700 dark:bg-success-950/40 dark:text-success-200">+ {{ $next['line'] }}</span>
|
||||||
@endforeach
|
@php
|
||||||
</pre>
|
$i++;
|
||||||
@else
|
@endphp
|
||||||
<pre class="mt-2 overflow-x-auto text-xs text-gray-800 dark:text-gray-200">{{ $fromText }}</pre>
|
@elseif ($op['type'] === 'delete')
|
||||||
@endif
|
<span class="block bg-danger-50 text-danger-700 dark:bg-danger-950/40 dark:text-danger-200">- {{ $op['line'] }}</span>
|
||||||
</details>
|
@elseif ($op['type'] === 'insert')
|
||||||
@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">+ {{ $op['line'] }}</span>
|
<span class="block bg-success-50 text-success-700 dark:bg-success-950/40 dark:text-success-200">+ {{ $op['line'] }}</span>
|
||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endfor
|
||||||
</pre>
|
</div>
|
||||||
@else
|
|
||||||
<pre class="mt-2 overflow-x-auto text-xs text-gray-800 dark:text-gray-200">{{ $toText }}</pre>
|
|
||||||
@endif
|
|
||||||
</details>
|
</details>
|
||||||
@else
|
</div>
|
||||||
<div class="mt-1">{{ $toText }}</div>
|
@else
|
||||||
@endif
|
<div class="text-sm text-gray-600 dark:text-gray-300">
|
||||||
</div>
|
<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>
|
</div>
|
||||||
@else
|
@else
|
||||||
@php
|
@php
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user