{{-- "Last sync + Pull Now / Push Now buttons + CLI note" panel. Rendered as a sibling of the config-form shell rather than nested inside it because HTML disallows nested form elements and the sync trigger POSTs to a different route than the config save. Every auth-shape partial under resources/views/settings/adapters/ picks up the sync UI by rendering this component alongside the config-form shell. --}} @props(['adapter']) @php $slug = $adapter->name(); $locked = config('app.lock_passwords') === true; $canSync = $adapter->isEnabled() && ! $locked; // Download-link gating. We render the link only when BOTH the // persistent session pointer AND the cache entry it points at are // live - a reload after a cache-TTL expiry (10 min) or after the // download endpoint consumed the entry would otherwise show a dead // link. $runLogToken = session('sync_run_log_last_token'); $runLogAvailable = is_string($runLogToken) && $runLogToken !== '' && \Illuminate\Support\Facades\Cache::has('sync_run_log:'.$runLogToken); @endphp
{{-- content_class="col-md-8" overrides the default col-md-6 so this row's content column matches the width of the input rows above it in the config form. The download-run-log link appended at the end can then sit on the same line as the "Last synced" message without wrapping prematurely. --}} @if ($adapter->lastSyncedAt()) {{ $adapter->lastSyncedAt()->diffForHumans() }}. {{ $adapter->lastSyncResult() }} @else {{ trans('admin/settings/sync_adapters.never_synced') }} @endif {{-- Download-run-log link, scoped to the one run the admin just triggered, cached for 10 min under a random token, deleted on first download. The link persists across reloads for the full TTL (not just the next render) by reading the persistent session pointer rather than a flash key. --}} @if ($runLogAvailable) {{ trans('admin/settings/sync_adapters.download_sync_run_log_button') }} @endif {{-- Dry-run checkboxes sit just above the Pull/Push buttons they govern. The `form` attribute binds each input back to the config-save form so toggle+Save persists. Pull Now / Push Now submit their OWN forms and pick up the current checkbox state via the js-sync-dry-run-mirror hidden input below. --}}
@if ($adapter instanceof \App\SyncAdapters\PushableAdapter && $adapter->canPush()) @endif
{{-- Single shared Limit input scoped to this adapter panel. Both the Pull Now and Push Now form submits read its current value via the js-sync-limit-source handler in snipeit.js, which injects a hidden name="limit" input into whichever action form was submitted. Blank means "no limit". --}}
{{ trans('admin/settings/sync_adapters.run_limit_help') }}
@csrf
@if ($adapter instanceof \App\SyncAdapters\PushableAdapter && $adapter->canPush())
@csrf
@endif {{-- Test 1 Push / Test 1 Pull / Preview payload sit inside the config-form fieldset under the composed-notes section, since they're diagnostic affordances for field-mapping work. --}}
{{-- Full-width tip callout --}} @if ($adapter instanceof \App\SyncAdapters\PushableAdapter && $adapter->canPush()) {!! trans('admin/settings/sync_adapters.large_fleet_note', [ 'pull_command' => 'php artisan snipeit:pull-inventory '.e($slug).'', 'push_command' => 'php artisan snipeit:push-inventory '.e($slug).'', ]) !!} @else {!! trans('admin/settings/sync_adapters.large_fleet_note_pull_only', [ 'pull_command' => 'php artisan snipeit:pull-inventory '.e($slug).'', ]) !!} @endif