Skip to content

A free open source IT asset/license management system

Layout tweaks

sniped416f323f3e9
diff --git a/resources/views/blade/input/field-map.blade.php b/resources/views/blade/input/field-map.blade.php
new file mode 100644
index 0000000000..3265349405
--- /dev/null
+++ b/resources/views/blade/input/field-map.blade.php
@@ -0,0 +1,183 @@
+{{-- Repeater-style picker for building a {snipe_field: vendor_path}
+ mapping. Renders one row per already-configured entry (label +
+ editable dot-path input + remove button), plus a picker row
+ below (dropdown of remaining options + input + Add button).
+ Values submit as $name[$snipeFieldKey]=$path so the server sees
+ an associative array on save.
+
+ Widget is self-contained: inline jQuery IIFE, no snipeit.js
+ changes required. Multiple instances on one page each get a
+ unique data-field-map-widget id so the handlers don't cross-
+ wire. --}}
+@props([
+ 'name',
+ 'options' => [],
+ 'stored' => [],
+])
+
+@php
+ $widgetId = 'field-map-'.\Illuminate\Support\Str::random(8);
+ $availableOptions = collect($options)->except(array_keys($stored))->all();
+@endphp
+
+<div class="field-map-widget" data-field-map-widget="{{ $widgetId }}">
+ <table class="table table-condensed" style="margin-bottom: 8px;">
+ <thead>
+ <tr>
+ <th style="width: 35%">{{ trans('admin/settings/sync_adapters.field_map_column_field') }}</th>
+ <th>{{ trans('admin/settings/sync_adapters.field_map_column_path') }}</th>
+ <th style="width: 60px"></th>
+ </tr>
+ </thead>
+ <tbody class="field-map-rows">
+ @foreach ($stored as $storedKey => $storedValue)
+ <tr data-field-key="{{ $storedKey }}">
+ <td>{{ $options[$storedKey] ?? $storedKey }}</td>
+ <td>
+ <input
+ type="text"
+ name="{{ $name }}[{{ $storedKey }}]"
+ value="{{ $storedValue }}"
+ class="form-control"
+ aria-label="{{ $options[$storedKey] ?? $storedKey }} dot-path"
+ >
+ </td>
+ <td>
+ <button
+ type="button"
+ class="btn btn-danger field-map-remove"
+ aria-label="{{ trans('button.delete') }}"
+ >
+ <x-icon type="x" />
+ </button>
+ </td>
+ </tr>
+ @endforeach
+ <tr class="field-map-empty" @if (count($stored) > 0) hidden @endif>
+ <td colspan="3" class="text-muted text-center">
+ <em>{{ trans('admin/settings/sync_adapters.field_map_empty') }}</em>
+ </td>
+ </tr>
+ </tbody>
+ <tfoot>
+ {{-- Picker row lives inside the same table so its three
+ cells inherit the header's column widths (35% / auto
+ / 60px). Puts the select where the "Snipe-IT Field"
+ label is, the new-value input where the "Vendor Dot-
+ Path" input is, and the Add button in the same slot
+ as the row remove buttons. --}}
+ <tr class="field-map-picker-row">
+ <td>
+ <label class="sr-only" for="{{ $widgetId }}-picker">{{ trans('admin/settings/sync_adapters.field_map_pick_field') }}</label>
+ <select
+ id="{{ $widgetId }}-picker"
+ class="select2 field-map-picker"
+ style="width: 100%"
+ data-placeholder="{{ trans('admin/settings/sync_adapters.field_map_pick_field') }}"
+ >
+ <option value=""></option>
+ @foreach ($availableOptions as $key => $label)
+ <option value="{{ $key }}">{{ $label }}</option>
+ @endforeach
+ </select>
+ </td>
+ <td>
+ <label class="sr-only" for="{{ $widgetId }}-value">{{ trans('admin/settings/sync_adapters.field_map_new_path') }}</label>
+ <input
+ id="{{ $widgetId }}-value"
+ type="text"
+ class="form-control field-map-new-value"
+ placeholder="{{ trans('admin/settings/sync_adapters.field_map_new_path') }}"
+ >
+ </td>
+ <td>
+ <button
+ type="button"
+ class="btn btn-primary field-map-add"
+ aria-label="{{ trans('button.add') }}"
+ >
+ <x-icon type="create" />
+ </button>
+ </td>
+ </tr>
+ </tfoot>
+ </table>
+</div>
+
+<script type="text/template" data-field-map-template="{{ $widgetId }}">
+ <tr data-field-key="__KEY__">
+ <td>__LABEL__</td>
+ <td>
+ <input type="text" name="{{ $name }}[__KEY__]" value="__VALUE__" class="form-control" aria-label="__LABEL__ dot-path">
+ </td>
+ <td>
+ <button type="button" class="btn btn-danger field-map-remove" aria-label="{{ trans('button.delete') }}">
+ <i class="fa fa-times" aria-hidden="true"></i>
+ </button>
+ </td>
+ </tr>
+</script>
+
+<script>
+// Defer to DOMContentLoaded so jQuery ($) is defined. Inline scripts
+// mid-body run before the tail-of-body <script src="jquery"> loads,
+// so referencing $ at parse time throws ReferenceError. Vanilla JS
+// wrapper here, jQuery inside.
+document.addEventListener('DOMContentLoaded', function () {
+ var widgetId = @json($widgetId);
+ var $widget = $('[data-field-map-widget="' + widgetId + '"]');
+ if ($widget.length === 0) { return; }
+
+ var $rows = $widget.find('.field-map-rows');
+ var $empty = $widget.find('.field-map-empty');
+ var $picker = $widget.find('.field-map-picker');
+ var $newValue = $widget.find('.field-map-new-value');
+ var $addBtn = $widget.find('.field-map-add');
+ var template = $('[data-field-map-template="' + widgetId + '"]').html();
+
+ function refreshEmptyState() {
+ var hasRows = $rows.find('tr:not(.field-map-empty)').length > 0;
+ $empty.attr('hidden', hasRows ? '' : null);
+ if (hasRows) { $empty.attr('hidden', ''); } else { $empty.removeAttr('hidden'); }
+ }
+
+ function encode(s) {
+ return String(s)
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;');
+ }
+
+ $addBtn.on('click', function () {
+ var key = $picker.val();
+ if (!key) { return; }
+ var $selected = $picker.find('option:selected');
+ var label = $selected.text();
+ var value = $newValue.val();
+
+ var html = template
+ .split('__KEY__').join(encode(key))
+ .split('__LABEL__').join(encode(label))
+ .split('__VALUE__').join(encode(value));
+
+ $empty.before(html);
+ $selected.remove();
+ $picker.val('').trigger('change'); // trigger('change') refreshes the select2 display after the option was pulled
+ $newValue.val('');
+ refreshEmptyState();
+ });
+
+ $rows.on('click', '.field-map-remove', function () {
+ var $row = $(this).closest('tr');
+ var key = $row.data('field-key');
+ var label = $row.find('td:first').text().trim();
+ $row.remove();
+ $picker.append($('<option>').val(key).text(label));
+ $picker.trigger('change'); // re-render select2 with the restored option
+ refreshEmptyState();
+ });
+
+ refreshEmptyState();
+});
+</script>
diff --git a/resources/views/blade/sync-adapter/credentials.blade.php b/resources/views/blade/sync-adapter/credentials.blade.php
index 7e2b94ba29..acaafed14d 100644
--- a/resources/views/blade/sync-adapter/credentials.blade.php
+++ b/resources/views/blade/sync-adapter/credentials.blade.php
@@ -1,15 +1,13 @@
-{{-- The one settings partial every ConfigurableAdapter uses.
- Iterates the adapter's credentialSchema() and renders each
+{{-- The settings partial EVERY ConfigurableAdapter uses.
+ Iterates the adapter's settingsSchema() and renders each
declared field as either plain text or a password (with show/hide
toggle) based on its `secret` flag. Everything ELSE on the form
(URL, active toggle, heartbeat toggle, per-field mapping) lives in
the shared form-shell component.
Field names AND ids are prefixed with the instance slug so each
- adapter's form has fully unique DOM identifiers. Without the
- prefix every tab-pane renders the same input id and browsers
- link them, causing typed values to visually propagate across
- tabs. --}}
+ adapter's form has fully unique DOM identifiers to avoid
+ entered values to visually propagate across tabs. --}}
@php
$slug = $adapter->name();
$locked = config('app.lock_passwords') === true;
@@ -59,15 +57,68 @@
</form>
@endif
-<x-sync-adapter-form :adapter="$adapter">
- @foreach ($adapter->credentialSchema() as $field)
+<x-sync-adapter.form :adapter="$adapter">
+ @php
+ $settingsSections = $adapter->settingsSections();
+ // Track section transitions across the loop so we can open
+ // and close <fieldset> wrappers around each contiguous run
+ // of same-sectioned schema entries. Un-fieldset-sectioned entries
+ // (section => null) render outside any fieldset.
+ //
+ // Starts at baseUrlSection() so if the shell already opened a
+ // fieldset around the Base URL row, the schema loop's first
+ // same-sectioned entries render into that fieldset instead of
+ // opening a duplicate. When the loop transitions to a
+ // different section, the close-then-open handles the switch.
+ $currentSection = $adapter->baseUrlSection();
+ @endphp
+ @foreach ($adapter->settingsSchema() as $field)
@php
$fieldName = $slug.'_'.$field['key'];
$fieldType = $field['type'] ?? 'text';
$isSecret = $field['secret'] ?? false;
$isRequired = $field['required'] ?? true;
$storedValue = $adapter->credentialForDisplay($field['key']);
+ // Optional conditional visibility. Schema entries declare
+ // visible_when: [source_key => value | [values]] and the
+ // rendered field gets wrapped in a data-driven div. Inline
+ // JS below the loop wires the show/hide logic.
+ $visibleWhen = $field['visible_when'] ?? null;
+ $section = $field['section'] ?? null;
@endphp
+ @if ($section !== $currentSection)
+ @if ($currentSection !== null)
+ </fieldset>
+ @endif
+ @if ($section !== null && isset($settingsSections[$section]))
+ @php
+ // Hoist the section-help lookup out of the Blade attribute
+ // to sidestep an operator-precedence trap: inside a
+ // `help_text="{!! ... !!}"` string attribute Blade compiles
+ // the `??` fallback as `'' . $arr['help'] ?? ''`, and the
+ // outer concat binds tighter than `??`, so PHP evaluates
+ // $arr['help'] unconditionally and warns on missing keys.
+ // Regular PHP `??` on its own line does the right thing.
+ $sectionHelp = $settingsSections[$section]['help'] ?? '';
+ @endphp
+ <fieldset>
+ <x-form.legend icon="tip" help_text="{!! $sectionHelp !!}">
+ {{ $settingsSections[$section]['title'] }}
+ </x-form.legend>
+ @endif
+ @php $currentSection = $section; @endphp
+ @endif
+ @if (is_array($visibleWhen))
+ @php
+ $depKey = array_key_first($visibleWhen);
+ $depValues = (array) $visibleWhen[$depKey];
+ @endphp
+ <div
+ class="adapter-conditional-field"
+ data-visible-when-field="{{ $slug.'_'.$depKey }}"
+ data-visible-when-value="{{ implode(',', $depValues) }}"
+ >
+ @endif
@if ($fieldType === 'checkbox')
<x-form.checkbox-row
:name="$fieldName"
@@ -89,12 +140,18 @@
:help_text="$field['help'] ?? null"
hideNewButton
/>
+ @elseif ($fieldType === 'field_map')
+ {{-- field_map entries are rendered by the shell's own
+ fieldset below the operational checkboxes, so they
+ sit alongside the standard mapping controls instead
+ of getting lost among the credential inputs. Nothing
+ to render here. --}}
@else
<x-form.row
:label="$field['label']"
:name="$fieldName"
input_div_class="col-md-8"
- :help_text="$field['help'] ?? null"
+ help_html="{!! $field['help'] ?? '' !!}"
:required="$isRequired"
>
<x-slot:input>
@@ -149,6 +206,27 @@
:required="$isRequired"
ignoreAutofill
/>
+ @elseif (! empty($field['url_prefix']))
+ {{-- Input-group that shows the current Base URL
+ as a prefix addon so admins see the full
+ URL that will be assembled at request
+ time. Marker class on the addon lets the
+ live-update JS at the bottom of this
+ partial sync new Base URL keystrokes into
+ this label without a page reload. --}}
+ <div class="input-group">
+ <span
+ class="input-group-addon js-adapter-url-prefix"
+ data-adapter-slug="{{ $slug }}"
+ data-placeholder="{{ trans('admin/settings/sync_adapters.custom_url_prefix_base_url_placeholder') }}"
+ >{{ $adapter->getUrl() ?: trans('admin/settings/sync_adapters.custom_url_prefix_base_url_placeholder') }}</span>
+ <x-input.text
+ :name="$fieldName"
+ :value="old($fieldName, $storedValue)"
+ :required="$isRequired"
+ :placeholder="$field['placeholder'] ?? null"
+ />
+ </div>
@else
<x-input.text
:name="$fieldName"
@@ -158,8 +236,20 @@
@endif
</x-slot:input>
</x-form.row>
+ @endif
+ @if (is_array($visibleWhen))
+ </div>
@endif
@endforeach
-</x-sync-adapter-form>
+ @if ($currentSection !== null)
+ {{-- Close the last section's fieldset when the schema loop exits inside one. --}}
+ </fieldset>
+ @endif
+</x-sync-adapter.form>
+
+<x-sync-adapter.panel :adapter="$adapter" />
-<x-sync-adapter-panel :adapter="$adapter" />
+{{-- JS handlers for [data-visible-when-field] conditional-visibility
+ and .js-adapter-url-prefix live-update live in
+ resources/assets/js/snipeit.js. Both are data-attribute driven
+ so nothing on this partial needs inline script anymore. --}}
diff --git a/resources/views/blade/sync-adapter/form.blade.php b/resources/views/blade/sync-adapter/form.blade.php
index c87fae8173..dfb6eca203 100644
--- a/resources/views/blade/sync-adapter/form.blade.php
+++ b/resources/views/blade/sync-adapter/form.blade.php
@@ -1,10 +1,10 @@
{{-- Shared form frame for a sync-adapter settings tab. The
- adapter_credentials partial drops its schema-driven credential
- inputs into the default slot. The URL row, active/heartbeat
- toggles, and mapping fieldset stay here because they're identical
- across every adapter regardless of credential shape.
+ credentials partial drops its schema-driven credential inputs
+ into the default slot. The URL row, active/heartbeat toggles,
+ and mapping fieldset stay here because they're identical across
+ every adapter regardless of credential shape.
- Called from resources/views/settings/adapters/adapter_credentials.blade.php
+ Called from resources/views/blade/sync-adapter/credentials.blade.php
which passes the hydrated adapter through the `adapter` prop
and puts the credential inputs in the default slot. --}}
@props(['adapter'])
@@ -20,6 +20,9 @@
:route="route('settings.adapters.save', $slug)"
data-sync-url="{{ route('settings.adapters.sync', $slug) }}"
data-enabled="{{ $adapter->isEnabled() ? '1' : '0' }}"
+ data-adapter-slug="{{ $slug }}"
+ data-dirty-guard
+ data-dirty-guard-warning="{{ trans('admin/settings/sync_adapters.unsaved_changes_before_sync') }}"
>
<x-demo-callout/>
@@ -48,7 +51,6 @@
:name="$activeField"
:checked="$adapter->isActive()"
:label="trans('admin/settings/sync_adapters.active_label')"
- :help_text="trans('admin/settings/sync_adapters.active_help')"
:disabled="$locked"
/>
@@ -61,37 +63,72 @@
/>
@if ($adapter->usesConfigurableUrl())
- <x-form.row
- :label="trans('admin/settings/sync_adapters.base_url')"
- :name="$urlField"
- input_div_class="col-md-8"
- :help_text="trans('admin/settings/sync_adapters.base_url_help', ['type' => $adapter::typeLabel()])"
- required
- >
- <x-slot:input>
- <x-input.text
- type="url"
- :name="$urlField"
- :value="old($urlField, $adapter->getUrl())"
- :disabled="$locked"
- :placeholder="$adapter->baseUrlPlaceholder()"
- input_icon="link"
- input_group_addon="right"
- required
- />
- </x-slot:input>
- </x-form.row>
+ @php
+ // Optional: adapters can pull the Base URL row into a
+ // settingsSections() group so it renders inside the
+ // relevant fieldset (typically "auth"). The credentials
+ // partial's schema loop tracks currentSection starting
+ // at this value and won't re-open the fieldset for its
+ // first same-sectioned schema entries.
+ $urlSection = $adapter->baseUrlSection();
+ $urlSectionData = $urlSection
+ ? ($adapter->settingsSections()[$urlSection] ?? null)
+ : null;
+ @endphp
+ @if ($urlSectionData)
+ <fieldset>
+ <x-form.legend icon="tip" help_text="{!! $urlSectionData['help'] ?? '' !!}">
+ {{ $urlSectionData['title'] }}
+ </x-form.legend>
+ @endif
+ <x-form.row
+ :label="trans('admin/settings/sync_adapters.base_url')"
+ :name="$urlField"
+ input_div_class="col-md-8"
+ :help_text="trans('admin/settings/sync_adapters.base_url_help', ['type' => $adapter::typeLabel()])"
+ required
+ >
+ <x-slot:input>
+ <x-input.text
+ type="url"
+ :name="$urlField"
+ :value="old($urlField, $adapter->getUrl())"
+ :disabled="$locked"
+ :placeholder="$adapter->baseUrlPlaceholder()"
+ input_icon="link"
+ input_group_addon="right"
+ required
+ />
+ </x-slot:input>
+ </x-form.row>
+ {{-- We deliberately do NOT close the fieldset here even when
+ we opened one above. The credentials partial's schema
+ loop starts with $currentSection = $urlSection, so its
+ first section transition (to any section other than
+ $urlSection) closes this fieldset. --}}
@endif
{{ $slot }}
+ {{-- Everything from Model Category down through "Check assets
+ in when the vendor reports no assigned user" is grouped in a
+ single fieldset so it visually separates from whatever the
+ previous section left open (on the Custom HTTP adapter the
+ "Custom Extras" section sits directly above this block, and
+ without the wrapper these controls read as if they were part
+ of Custom Extras). Applies to every adapter for consistency. --}}
+ <fieldset>
+ <x-form.legend icon="tip" help_text="{{ trans('admin/settings/sync_adapters.defaults_section_intro') }}">
+ {{ trans('admin/settings/sync_adapters.defaults_section_title') }}
+ </x-form.legend>
+
{{-- Default category for AssetModels auto-created from this
adapter. Vendors don't send Snipe-IT's category concept but
every AssetModel needs one. --}}
<x-input.category-select
:name="$slug . '_default_category_id'"
:label="trans('admin/settings/sync_adapters.default_category')"
- :selected="$adapter->defaultCategoryId()"
+ :selected="old($slug . '_default_category_id', $adapter->defaultCategoryId())"
categoryType="asset"
:help_text="trans('admin/settings/sync_adapters.default_category_help')"
required
@@ -113,7 +150,7 @@
:name="$slug . '_default_status_id'"
:id="$slug . '_default_status_id'"
:options="\App\Models\Statuslabel::orderBy('name')->pluck('name', 'id')->all()"
- :selected="$adapter->defaultStatusId()"
+ :selected="old($slug . '_default_status_id', $adapter->defaultStatusId())"
:includeEmpty="true"
style="width: 100%"
:disabled="$locked"
@@ -167,6 +204,12 @@
this page, but the option pool is a fixed 3-value enum
so the built-in search box is hidden via
data-minimum-results-for-search. --}}
+ @php
+ // On a validation-error redisplay, old() carries the submitted
+ // value so the admin does not have to re-pick. Falls back to
+ // the stored value on the first render.
+ $userMatchSelected = old($slug.'_user_match_strategy', $adapter->userMatchStrategy());
+ @endphp
<select
name="{{ $slug }}_user_match_strategy"
class="select2 form-control"
@@ -180,7 +223,7 @@
'username' => trans('admin/settings/sync_adapters.user_match_username'),
'email' => trans('admin/settings/sync_adapters.user_match_email'),
] as $value => $label)
- <option value="{{ $value }}" @selected($adapter->userMatchStrategy() === $value)>{{ $label }}</option>
+ <option value="{{ $value }}" @selected($userMatchSelected === $value)>{{ $label }}</option>
@endforeach
</select>
</x-slot:input>
@@ -208,6 +251,41 @@
:help_text="trans('admin/settings/sync_adapters.checkin_on_null_user_help')"
:disabled="$locked"
/>
+ </fieldset>
+
+ {{-- Any type: field_map entries from the adapter's credential
+ schema render here in their own fieldset. Keeps them
+ grouped alongside the standard mapping controls below and
+ out of the credential-input section above, since they
+ define WHERE fields live in the vendor payload rather than
+ auth credentials. --}}
+ @foreach ($adapter->settingsSchema() as $fmField)
+ @if (($fmField['type'] ?? '') === 'field_map')
+ @php
+ $fmName = $slug.'_'.$fmField['key'];
+ $fmStored = $adapter->credentialForDisplay($fmField['key']);
+ $fmMap = is_string($fmStored) && $fmStored !== ''
+ ? (json_decode($fmStored, true) ?: [])
+ : [];
+ $fmMap = old($fmName, is_array($fmMap) ? $fmMap : []);
+ $fmMap = is_array($fmMap) ? $fmMap : [];
+ @endphp
+ <fieldset>
+ <x-form.legend icon="tip" help_text="{!! $fmField['help'] ?? '' !!}">
+ {{ $fmField['label'] }}
+ </x-form.legend>
+ <div class="form-group">
+ <div class="col-md-8 col-md-offset-3">
+ <x-input.field-map
+ :name="$fmName"
+ :options="$fmField['options'] ?? []"
+ :stored="$fmMap"
+ />
+ </div>
+ </div>
+ </fieldset>
+ @endif
+ @endforeach
{{-- Push dry-run only shows for adapters that actually support
push. Turning it on makes push() log the payload instead of
@@ -356,13 +434,44 @@
input_div_class="col-md-8"
>
<x-slot:input>
- <x-input.select
- :name="$slug . '_mapping[' . $extraKey . ']'"
- :options="\App\SyncAdapters\Support\MappingTargets::optionsForExtra($extraType, $extraAdminDefined)"
- :selected="$adapter->mappingFor($extraKey)"
- style="width: 100%"
- :disabled="$locked"
- />
+ @if ($supportsPush)
+ {{-- Same two-column shape as the standard
+ fields above so admins can pick a
+ target column AND a direction per
+ extra. Framework already respects
+ directionFor() on extras via
+ pushDirectedFields(), but the UI was
+ only exposing the target dropdown. --}}
+ <div class="row">
+ <div class="col-md-8">
+ <x-input.select
+ :name="$slug . '_mapping[' . $extraKey . ']'"
+ :options="\App\SyncAdapters\Support\MappingTargets::optionsForExtra($extraType, $extraAdminDefined)"
+ :selected="$adapter->mappingFor($extraKey)"
+ style="width: 100%"
+ :disabled="$locked"
+ />
+ </div>
+ <div class="col-md-4">
+ <x-input.select
+ :name="$slug . '_direction[' . $extraKey . ']'"
+ :options="$directionOptions"
+ :selected="$adapter->directionFor($extraKey)"
+ style="width: 100%"
+ data-minimum-results-for-search="Infinity"
+ :disabled="$locked"
+ />
+ </div>
+ </div>
+ @else
+ <x-input.select
+ :name="$slug . '_mapping[' . $extraKey . ']'"
+ :options="\App\SyncAdapters\Support\MappingTargets::optionsForExtra($extraType, $extraAdminDefined)"
+ :selected="$adapter->mappingFor($extraKey)"
+ style="width: 100%"
+ :disabled="$locked"
+ />
+ @endif
</x-slot:input>
</x-form.row>
@endforeach
diff --git a/resources/views/blade/sync-adapter/panel.blade.php b/resources/views/blade/sync-adapter/panel.blade.php
index 878bff8ed5..d6fb4453a8 100644
--- a/resources/views/blade/sync-adapter/panel.blade.php
+++ b/resources/views/blade/sync-adapter/panel.blade.php
@@ -30,41 +30,52 @@
<form
method="POST"
action="{{ route('settings.adapters.sync', $slug) }}"
+ class="js-sync-action-form"
style="display: inline;"
>
@csrf
<button
type="submit"
- class="btn btn-primary"
+ class="btn btn-primary js-sync-action-button"
+ data-dirty-guarded-by="adapter-form-{{ $slug }}"
@disabled(! $canSync)
>
- <i class="fa-solid fa-cloud-arrow-down" aria-hidden="true"></i>
- {{ trans('admin/settings/sync_adapters.pull_now') }}
+ <i class="fa-solid fa-cloud-arrow-down js-sync-action-icon" aria-hidden="true"></i>
+ <span class="js-sync-action-label">{{ trans('admin/settings/sync_adapters.pull_now') }}</span>
</button>
</form>
- {{-- Push Now button only renders for adapters that implement
- PushableAdapter. Same sibling-form pattern as Pull Now
- above. Pushes every asset already linked to this
- instance via asset_external_sources. --}}
- @if ($adapter instanceof \App\SyncAdapters\PushableAdapter)
+ {{-- Push Now button renders for adapters that implement
+ PushableAdapter AND report canPush() true at runtime
+ (Fleet Free returns false because its label writes are
+ Premium-only. CustomHttpAdapter returns false when the
+ admin hasn't set a push endpoint yet). --}}
+ @if ($adapter instanceof \App\SyncAdapters\PushableAdapter && $adapter->canPush())
<form
method="POST"
action="{{ route('settings.adapters.push', $slug) }}"
+ class="js-sync-action-form"
style="display: inline; margin-left: 8px;"
>
@csrf
<button
type="submit"
- class="btn btn-default"
+ class="btn btn-default js-sync-action-button"
+ data-dirty-guarded-by="adapter-form-{{ $slug }}"
@disabled(! $canSync)
>
- <i class="fa-solid fa-cloud-arrow-up" aria-hidden="true"></i>
- {{ trans('admin/settings/sync_adapters.push_now') }}
+ <i class="fa-solid fa-cloud-arrow-up js-sync-action-icon" aria-hidden="true"></i>
+ <span class="js-sync-action-label">{{ trans('admin/settings/sync_adapters.push_now') }}</span>
</button>
</form>
@endif
+ {{-- The submit handler that swaps the icon for a spinner
+ and disables sibling sync-action buttons lives in
+ resources/assets/js/snipeit.js. Fully driven by the
+ .js-sync-action-form / .js-sync-action-button classes
+ above so nothing on this partial needs inline JS. --}}
+
<p class="help-block" style="margin-top: 10px;">
{{-- Show both commands when this adapter supports push
(Kandji, Jamf, Mosyle, WS1, Ninja, Intune). Pull-only
diff --git a/resources/views/settings/adapters.blade.php b/resources/views/settings/adapters.blade.php
index 4e4086f3b1..59b0bb94cd 100644
--- a/resources/views/settings/adapters.blade.php
+++ b/resources/views/settings/adapters.blade.php
@@ -12,7 +12,7 @@
<x-box>
<x-slot:header>
<i class="fa-solid fa-network-wired" aria-hidden="true"></i>
- {{ trans('admin/settings/sync_adapters.title') }}
+ {{ trans('admin/settings/sync_adapters.title') }} <span class="label label-warning">beta</span>
</x-slot:header>
{{-- Company filter. Reloads the page with ?company=blah so only
@@ -92,7 +92,7 @@
id="adapter-pane-{{ $adapter->name() }}"
@class(['tab-pane fade', 'active in' => $selected?->name() === $adapter->name()])
>
- @include($adapter->settingsView(), ['adapter' => $adapter])
+ <x-sync-adapter.credentials :adapter="$adapter" />
</div>
@endforeach
</div>