Skip to content

A free open source IT asset/license management system

Renamed credentialSchema() to settingsSchema() since it affects more than credentials now

snipe0a13e05cf0f5
diff --git a/app/SyncAdapters/Addigy/AddigyAdapter.php b/app/SyncAdapters/Addigy/AddigyAdapter.php
index 948d916c5c..f31bb81ec4 100644
--- a/app/SyncAdapters/Addigy/AddigyAdapter.php
+++ b/app/SyncAdapters/Addigy/AddigyAdapter.php
@@ -24,17 +24,17 @@ class AddigyAdapter extends ConfigurableAdapter
return 'https://prod.addigy.com';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'key_id',
- 'label' => 'Client ID',
+ 'label' => trans('admin/settings/sync_adapters.label_client_id'),
'help' => trans('admin/settings/sync_adapters.addigy_key_id_help'),
],
[
'key' => 'key_secret',
- 'label' => 'Client Secret',
+ 'label' => trans('admin/settings/sync_adapters.label_client_secret'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.addigy_key_secret_help'),
],
diff --git a/app/SyncAdapters/AppleBusinessManager/AppleBusinessManagerAdapter.php b/app/SyncAdapters/AppleBusinessManager/AppleBusinessManagerAdapter.php
index bb149d8e1f..c374cabefb 100644
--- a/app/SyncAdapters/AppleBusinessManager/AppleBusinessManagerAdapter.php
+++ b/app/SyncAdapters/AppleBusinessManager/AppleBusinessManagerAdapter.php
@@ -87,32 +87,32 @@ class AppleBusinessManagerAdapter extends ConfigurableAdapter
return false;
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
$schema = [
[
'key' => 'mode',
- 'label' => 'Portal',
+ 'label' => trans('admin/settings/sync_adapters.abm_label_portal'),
'type' => 'select',
'options' => [
- 'business' => 'Apple Business Manager',
- 'school' => 'Apple School Manager',
+ 'business' => trans('admin/settings/sync_adapters.abm_option_mode_business'),
+ 'school' => trans('admin/settings/sync_adapters.abm_option_mode_school'),
],
'help' => trans('admin/settings/sync_adapters.abm_mode_help'),
],
[
'key' => 'client_id',
- 'label' => 'Client ID',
+ 'label' => trans('admin/settings/sync_adapters.label_client_id'),
'help' => trans('admin/settings/sync_adapters.abm_client_id_help'),
],
[
'key' => 'key_id',
- 'label' => 'Key ID',
+ 'label' => trans('admin/settings/sync_adapters.abm_label_key_id'),
'help' => trans('admin/settings/sync_adapters.abm_key_id_help'),
],
[
'key' => 'private_key',
- 'label' => 'Private Key (PEM)',
+ 'label' => trans('admin/settings/sync_adapters.abm_label_private_key'),
'type' => 'textarea',
'secret' => true,
'help' => trans('admin/settings/sync_adapters.abm_private_key_help'),
@@ -120,7 +120,7 @@ class AppleBusinessManagerAdapter extends ConfigurableAdapter
],
[
'key' => 'product_family_filter',
- 'label' => 'Product Families',
+ 'label' => trans('admin/settings/sync_adapters.abm_label_product_families'),
'type' => 'multiselect',
'options' => self::PRODUCT_FAMILIES,
'default' => array_keys(self::PRODUCT_FAMILIES),
@@ -129,7 +129,7 @@ class AppleBusinessManagerAdapter extends ConfigurableAdapter
],
[
'key' => 'pull_model_images',
- 'label' => 'Pull model images from appledb.dev',
+ 'label' => trans('admin/settings/sync_adapters.abm_label_pull_model_images'),
'type' => 'checkbox',
'required' => false,
'help' => trans('admin/settings/sync_adapters.abm_pull_model_images_help'),
@@ -150,6 +150,7 @@ class AppleBusinessManagerAdapter extends ConfigurableAdapter
'label' => trans('admin/settings/sync_adapters.abm_category_family_label', ['family' => $displayName]),
'type' => 'category',
'required' => false,
+ 'section' => 'categories',
'help' => trans('admin/settings/sync_adapters.abm_category_family_help', ['family' => $displayName]),
];
}
@@ -157,19 +158,34 @@ class AppleBusinessManagerAdapter extends ConfigurableAdapter
return $schema;
}
+ /**
+ * Section titles for the credential schema. The category
+ * selectors are the only grouped block here. Everything else
+ * (auth + toggles) stays flat above them because there are only
+ * a handful of top-level fields.
+ */
+ public function settingsSections(): array
+ {
+ return [
+ 'categories' => [
+ 'title' => trans('admin/settings/sync_adapters.abm_section_categories_title'),
+ ],
+ ];
+ }
+
public function extraFields(): array
{
return [
- 'abm_product_family' => ['label_key' => 'admin/settings/sync_adapters.extra_product_family'],
- 'abm_model_marketing_name' => ['label_key' => 'admin/settings/sync_adapters.extra_model_marketing_name'],
- 'abm_product_type' => ['label_key' => 'admin/settings/sync_adapters.extra_product_type'],
- 'abm_part_number' => ['label_key' => 'admin/settings/sync_adapters.extra_part_number'],
- 'abm_color' => ['label_key' => 'admin/settings/sync_adapters.extra_color'],
- 'abm_order_number' => ['label_key' => 'admin/settings/sync_adapters.extra_order_number'],
- 'abm_order_date' => ['label_key' => 'admin/settings/sync_adapters.extra_order_date'],
- 'abm_purchase_source_type' => ['label_key' => 'admin/settings/sync_adapters.extra_purchase_source_type'],
- 'abm_purchase_source_id' => ['label_key' => 'admin/settings/sync_adapters.extra_purchase_source_id'],
- 'abm_mdm_server' => ['label_key' => 'admin/settings/sync_adapters.extra_mdm_server'],
+ 'abm_product_family' => ['label_key' => 'admin/settings/sync_adapters.abm_extra_product_family'],
+ 'abm_model_marketing_name' => ['label_key' => 'admin/settings/sync_adapters.abm_extra_model_marketing_name'],
+ 'abm_product_type' => ['label_key' => 'admin/settings/sync_adapters.abm_extra_product_type'],
+ 'abm_part_number' => ['label_key' => 'admin/settings/sync_adapters.abm_extra_part_number'],
+ 'abm_color' => ['label_key' => 'admin/settings/sync_adapters.abm_extra_color'],
+ 'abm_order_number' => ['label_key' => 'admin/settings/sync_adapters.abm_extra_order_number'],
+ 'abm_order_date' => ['label_key' => 'admin/settings/sync_adapters.abm_extra_order_date'],
+ 'abm_purchase_source_type' => ['label_key' => 'admin/settings/sync_adapters.abm_extra_purchase_source_type'],
+ 'abm_purchase_source_id' => ['label_key' => 'admin/settings/sync_adapters.abm_extra_purchase_source_id'],
+ 'abm_mdm_server' => ['label_key' => 'admin/settings/sync_adapters.abm_extra_mdm_server'],
'abm_applecare_agreement_number' => ['label_key' => 'admin/settings/sync_adapters.extra_applecare_agreement_number'],
'abm_applecare_status' => ['label_key' => 'admin/settings/sync_adapters.extra_applecare_status'],
'abm_applecare_payment_type' => ['label_key' => 'admin/settings/sync_adapters.extra_applecare_payment_type'],
@@ -679,7 +695,7 @@ class AppleBusinessManagerAdapter extends ConfigurableAdapter
/**
* Which mode we're operating in: 'business' or 'school'. Stored
- * plain-text as a credential value so credentialSchema() renders
+ * plain-text as a credential value so settingsSchema() renders
* a normal text input. Anything other than 'school' resolves to
* 'business' (the safer default that keeps admins from typoing
* their way into the wrong host).
diff --git a/app/SyncAdapters/Fleet/FleetAdapter.php b/app/SyncAdapters/Fleet/FleetAdapter.php
index ef4670c4a7..dbf49b4245 100644
--- a/app/SyncAdapters/Fleet/FleetAdapter.php
+++ b/app/SyncAdapters/Fleet/FleetAdapter.php
@@ -26,12 +26,12 @@ class FleetAdapter extends ConfigurableAdapter
return 'Fleet';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'token',
- 'label' => 'API Token',
+ 'label' => trans('admin/settings/sync_adapters.label_api_token'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.fleet_token_help'),
],
@@ -109,7 +109,7 @@ class FleetAdapter extends ConfigurableAdapter
public function vendorGroupLabel(): string
{
- return 'Fleet Team';
+ return trans('admin/settings/sync_adapters.vendor_group_fleet_team');
}
public function fetchGroups(): array
diff --git a/app/SyncAdapters/HostInventoryAdapter.php b/app/SyncAdapters/HostInventoryAdapter.php
index 1250f3876a..17a480e740 100644
--- a/app/SyncAdapters/HostInventoryAdapter.php
+++ b/app/SyncAdapters/HostInventoryAdapter.php
@@ -69,14 +69,6 @@ interface HostInventoryAdapter
*/
public function isBuiltIn(): bool;
- /**
- * View name for the adapter's settings section, rendered inside a
- * tab-pane on the shared /admin/adapters page. The view is included
- * with the current adapter instance available so it can read its own
- * state (e.g. getUrl(), credentialForDisplay(), isActive(), etc.).
- */
- public function settingsView(): string;
-
/**
* Validation rules the controller runs against the save request
* BEFORE handing it to saveConfig. Adapters declare their own
diff --git a/app/SyncAdapters/Intune/IntuneAdapter.php b/app/SyncAdapters/Intune/IntuneAdapter.php
index 56ec90c1c0..50c295dc7c 100644
--- a/app/SyncAdapters/Intune/IntuneAdapter.php
+++ b/app/SyncAdapters/Intune/IntuneAdapter.php
@@ -40,22 +40,22 @@ class IntuneAdapter extends ConfigurableAdapter implements PushableAdapter
return 'https://graph.microsoft.com';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'tenant_id',
- 'label' => 'Tenant ID',
+ 'label' => trans('admin/settings/sync_adapters.label_tenant_id'),
'help' => trans('admin/settings/sync_adapters.intune_tenant_id_help'),
],
[
'key' => 'client_id',
- 'label' => 'Client ID',
+ 'label' => trans('admin/settings/sync_adapters.label_client_id'),
'help' => trans('admin/settings/sync_adapters.intune_client_id_help'),
],
[
'key' => 'client_secret',
- 'label' => 'Client Secret',
+ 'label' => trans('admin/settings/sync_adapters.label_client_secret'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.intune_client_secret_help'),
],
diff --git a/app/SyncAdapters/Jamf/JamfAdapter.php b/app/SyncAdapters/Jamf/JamfAdapter.php
index 0916837a39..2820df315e 100644
--- a/app/SyncAdapters/Jamf/JamfAdapter.php
+++ b/app/SyncAdapters/Jamf/JamfAdapter.php
@@ -29,12 +29,12 @@ class JamfAdapter extends ConfigurableAdapter implements PushableAdapter
return 'https://your-subdomain.jamfcloud.com';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'token',
- 'label' => 'API Token',
+ 'label' => trans('admin/settings/sync_adapters.label_api_token'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.jamf_token_help'),
],
@@ -57,7 +57,7 @@ class JamfAdapter extends ConfigurableAdapter implements PushableAdapter
public function vendorGroupLabel(): string
{
- return 'Jamf Site';
+ return trans('admin/settings/sync_adapters.vendor_group_jamf_site');
}
public function fetchGroups(): array
diff --git a/app/SyncAdapters/JamfSchool/JamfSchoolAdapter.php b/app/SyncAdapters/JamfSchool/JamfSchoolAdapter.php
index f4d6a5af17..ae958ba3a4 100644
--- a/app/SyncAdapters/JamfSchool/JamfSchoolAdapter.php
+++ b/app/SyncAdapters/JamfSchool/JamfSchoolAdapter.php
@@ -26,17 +26,17 @@ class JamfSchoolAdapter extends ConfigurableAdapter
return 'https://your-subdomain.jamfcloud.com/api';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'network_id',
- 'label' => 'Network ID',
+ 'label' => trans('admin/settings/sync_adapters.label_network_id'),
'help' => trans('admin/settings/sync_adapters.jamf_school_network_id_help'),
],
[
'key' => 'api_key',
- 'label' => 'API Key',
+ 'label' => trans('admin/settings/sync_adapters.label_api_key'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.jamf_school_api_key_help'),
],
@@ -59,7 +59,7 @@ class JamfSchoolAdapter extends ConfigurableAdapter
public function vendorGroupLabel(): string
{
- return 'Jamf School Location';
+ return trans('admin/settings/sync_adapters.vendor_group_jamf_school_location');
}
public function fetchGroups(): array
diff --git a/app/SyncAdapters/JumpCloud/JumpCloudAdapter.php b/app/SyncAdapters/JumpCloud/JumpCloudAdapter.php
index 81739e430c..6554453198 100644
--- a/app/SyncAdapters/JumpCloud/JumpCloudAdapter.php
+++ b/app/SyncAdapters/JumpCloud/JumpCloudAdapter.php
@@ -25,12 +25,12 @@ class JumpCloudAdapter extends ConfigurableAdapter
return 'https://console.jumpcloud.com/api';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'token',
- 'label' => 'API Key',
+ 'label' => trans('admin/settings/sync_adapters.label_api_key'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.jumpcloud_token_help'),
],
diff --git a/app/SyncAdapters/Kandji/KandjiAdapter.php b/app/SyncAdapters/Kandji/KandjiAdapter.php
index 82975b261b..86bd0c3001 100644
--- a/app/SyncAdapters/Kandji/KandjiAdapter.php
+++ b/app/SyncAdapters/Kandji/KandjiAdapter.php
@@ -28,12 +28,12 @@ class KandjiAdapter extends ConfigurableAdapter implements PushableAdapter
return 'https://your-subdomain.api.kandji.io';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'token',
- 'label' => 'API Token',
+ 'label' => trans('admin/settings/sync_adapters.label_api_token'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.kandji_token_help'),
],
@@ -56,7 +56,7 @@ class KandjiAdapter extends ConfigurableAdapter implements PushableAdapter
public function vendorGroupLabel(): string
{
- return 'Kandji Blueprint';
+ return trans('admin/settings/sync_adapters.vendor_group_kandji_blueprint');
}
public function fetchGroups(): array
diff --git a/app/SyncAdapters/KaseyaVsa10/KaseyaVsa10Adapter.php b/app/SyncAdapters/KaseyaVsa10/KaseyaVsa10Adapter.php
index 0946ba4a98..a500249070 100644
--- a/app/SyncAdapters/KaseyaVsa10/KaseyaVsa10Adapter.php
+++ b/app/SyncAdapters/KaseyaVsa10/KaseyaVsa10Adapter.php
@@ -45,18 +45,18 @@ class KaseyaVsa10Adapter extends ConfigurableAdapter
return 'https://your-tenant.vsax.net';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'token_id',
- 'label' => 'Token ID',
+ 'label' => trans('admin/settings/sync_adapters.label_token_id'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.kaseya_vsa10_token_id_help'),
],
[
'key' => 'token_secret',
- 'label' => 'Token Secret',
+ 'label' => trans('admin/settings/sync_adapters.label_token_secret'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.kaseya_vsa10_token_secret_help'),
],
@@ -87,7 +87,7 @@ class KaseyaVsa10Adapter extends ConfigurableAdapter
continue;
}
$extras[$key] = [
- 'label' => 'Kaseya: '.$field['name'],
+ 'label' => trans('admin/settings/sync_adapters.kaseya_vsa10_custom_field_label', ['name' => $field['name']]),
'type' => self::translateVendorType($field['type']),
'admin_defined' => true,
];
@@ -169,7 +169,7 @@ class KaseyaVsa10Adapter extends ConfigurableAdapter
public function vendorGroupLabel(): string
{
- return 'Kaseya Organization';
+ return trans('admin/settings/sync_adapters.vendor_group_kaseya_organization');
}
public function fetchGroups(): array
diff --git a/app/SyncAdapters/MerakiSystemsManager/MerakiSystemsManagerAdapter.php b/app/SyncAdapters/MerakiSystemsManager/MerakiSystemsManagerAdapter.php
index 032a370bea..2237256c46 100644
--- a/app/SyncAdapters/MerakiSystemsManager/MerakiSystemsManagerAdapter.php
+++ b/app/SyncAdapters/MerakiSystemsManager/MerakiSystemsManagerAdapter.php
@@ -29,18 +29,18 @@ class MerakiSystemsManagerAdapter extends ConfigurableAdapter
return 'https://api.meraki.com/api/v1';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'api_key',
- 'label' => 'API Key',
+ 'label' => trans('admin/settings/sync_adapters.label_api_key'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.meraki_sm_api_key_help'),
],
[
'key' => 'organization_id',
- 'label' => 'Organization ID',
+ 'label' => trans('admin/settings/sync_adapters.label_organization_id'),
'help' => trans('admin/settings/sync_adapters.meraki_sm_organization_id_help'),
],
];
diff --git a/app/SyncAdapters/Mosyle/MosyleAdapter.php b/app/SyncAdapters/Mosyle/MosyleAdapter.php
index 094618b105..9b54ddeeaf 100644
--- a/app/SyncAdapters/Mosyle/MosyleAdapter.php
+++ b/app/SyncAdapters/Mosyle/MosyleAdapter.php
@@ -30,12 +30,12 @@ class MosyleAdapter extends ConfigurableAdapter implements PushableAdapter
return 'https://managerapi.mosyle.com/v2';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'token',
- 'label' => 'Access Token',
+ 'label' => trans('admin/settings/sync_adapters.label_access_token'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.mosyle_token_help'),
],
@@ -57,7 +57,7 @@ class MosyleAdapter extends ConfigurableAdapter implements PushableAdapter
public function vendorGroupLabel(): string
{
- return 'Mosyle Location';
+ return trans('admin/settings/sync_adapters.vendor_group_mosyle_location');
}
public function fetchGroups(): array
diff --git a/app/SyncAdapters/NinjaOne/NinjaOneAdapter.php b/app/SyncAdapters/NinjaOne/NinjaOneAdapter.php
index 853adc9ed9..425d818e76 100644
--- a/app/SyncAdapters/NinjaOne/NinjaOneAdapter.php
+++ b/app/SyncAdapters/NinjaOne/NinjaOneAdapter.php
@@ -43,23 +43,23 @@ class NinjaOneAdapter extends ConfigurableAdapter implements PushableAdapter
return 'https://app.ninjarmm.com';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'client_id',
- 'label' => 'Client ID',
+ 'label' => trans('admin/settings/sync_adapters.label_client_id'),
'help' => trans('admin/settings/sync_adapters.ninjaone_client_id_help'),
],
[
'key' => 'client_secret',
- 'label' => 'Client Secret',
+ 'label' => trans('admin/settings/sync_adapters.label_client_secret'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.ninjaone_client_secret_help'),
],
[
'key' => 'asset_tag_custom_field',
- 'label' => 'Asset Tag Custom Field Name',
+ 'label' => trans('admin/settings/sync_adapters.label_asset_tag_custom_field_name'),
'required' => false,
'help' => trans('admin/settings/sync_adapters.ninjaone_asset_tag_field_help'),
],
diff --git a/app/SyncAdapters/Osctrl/OsctrlAdapter.php b/app/SyncAdapters/Osctrl/OsctrlAdapter.php
index 507e9e446b..e6d4f8a828 100644
--- a/app/SyncAdapters/Osctrl/OsctrlAdapter.php
+++ b/app/SyncAdapters/Osctrl/OsctrlAdapter.php
@@ -23,18 +23,18 @@ class OsctrlAdapter extends ConfigurableAdapter
return 'osctrl';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'token',
- 'label' => 'API Token',
+ 'label' => trans('admin/settings/sync_adapters.label_api_token'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.osctrl_token_help'),
],
[
'key' => 'environment',
- 'label' => 'Environment',
+ 'label' => trans('admin/settings/sync_adapters.label_environment'),
'help' => trans('admin/settings/sync_adapters.osctrl_environment_help'),
],
];
diff --git a/app/SyncAdapters/Support/ConfigurableAdapter.php b/app/SyncAdapters/Support/ConfigurableAdapter.php
index 4bee851c62..f839068e8e 100644
--- a/app/SyncAdapters/Support/ConfigurableAdapter.php
+++ b/app/SyncAdapters/Support/ConfigurableAdapter.php
@@ -16,7 +16,7 @@ use Illuminate\Support\Facades\Crypt;
* secret storage, blank-preserves-existing save semantics, active +
* heartbeat toggles, per-field target mapping, isEnabled().
*
- * The one thing subclasses declare is their credentialSchema(): a
+ * The one thing subclasses declare is their settingsSchema(): a
* list of the auth fields the vendor requires and whether each is a
* secret (masked with a show/hide toggle) or plain text. That's
* enough for the shared blade partial to render the form, for
@@ -79,7 +79,7 @@ abstract class ConfigurableAdapter implements HostInventoryAdapter
*
* @return array<int, array{key: string, label: string, type?: string, options?: array<string, string>, secret?: bool, required?: bool, help?: string|null, placeholder?: string|null, default?: array<int, string>|string|null}>
*/
- abstract public function credentialSchema(): array;
+ abstract public function settingsSchema(): array;
/**
* Adapter-specific extra fields the vendor emits, keyed by the
@@ -108,6 +108,35 @@ abstract class ConfigurableAdapter implements HostInventoryAdapter
return [];
}
+ /**
+ * Section titles + help copy for the settings schema. Adapters
+ * that group their credential fields via a `section` key on
+ * schema entries override this to give each section a labeled
+ * <fieldset> in the settings UI. Default is empty, in which case
+ * the credentials partial renders the schema entries flat.
+ *
+ * Expected shape:
+ * ['section_key' => ['title' => string, 'help' => ?string], ...]
+ *
+ * @return array<string, array{title: string, help?: string}>
+ */
+ public function settingsSections(): array
+ {
+ return [];
+ }
+
+ /**
+ * Optional: name a settingsSections() key that should include
+ * the Base URL row. The shell opens the fieldset around Base URL
+ * and the credentials partial's schema loop continues rendering
+ * into the same fieldset for that section's entries. Returns null
+ * to keep Base URL rendered above the fieldsets (default).
+ */
+ public function baseUrlSection(): ?string
+ {
+ return null;
+ }
+
public function name(): string
{
return $this->instance->slug;
@@ -138,7 +167,7 @@ abstract class ConfigurableAdapter implements HostInventoryAdapter
return false;
}
- foreach ($this->credentialSchema() as $field) {
+ foreach ($this->settingsSchema() as $field) {
if (($field['required'] ?? true) && ! SyncAdapterConfig::has($this->instance->id, $field['key'])) {
return false;
}
@@ -180,11 +209,6 @@ abstract class ConfigurableAdapter implements HostInventoryAdapter
return $this->instance->active ? 'partial' : 'inactive';
}
- public function settingsView(): string
- {
- return 'settings.adapters.adapter_credentials';
- }
-
/**
* Rules the controller enforces before saveConfig() runs.
* ExternalUrl blocks loopback / RFC-1918 / cloud-metadata targets
@@ -198,7 +222,7 @@ abstract class ConfigurableAdapter implements HostInventoryAdapter
$slug = $this->instance->slug;
$rules = [
- $slug.'_asset_tag_pattern' => ['nullable', 'string', 'max:191'],
+ $slug.'_asset_tag_pattern' => ['nullable', 'string', 'max:191', new \App\Rules\AssetTagPatternRule],
$slug.'_default_category_id' => ['required', 'integer', 'exists:categories,id'],
$slug.'_default_status_id' => ['required', 'integer', 'exists:status_labels,id'],
$slug.'_user_match_strategy' => ['nullable', 'string', 'in:none,email,username,username_then_email'],
@@ -208,7 +232,7 @@ abstract class ConfigurableAdapter implements HostInventoryAdapter
$rules[$slug.'_url'] = ['required', new ExternalUrl];
}
- foreach ($this->credentialSchema() as $field) {
+ foreach ($this->settingsSchema() as $field) {
// Auth fields default to required so admins can't save a
// half-configured adapter that then silently refuses to
// sync because isEnabled() returns false. Secret fields
@@ -239,6 +263,17 @@ abstract class ConfigurableAdapter implements HostInventoryAdapter
continue;
}
+ // Field-map repeater posts as an associative array of
+ // {snipe_field: vendor_path}. Values are trimmed strings
+ // (dot-paths). Empty submissions produce an empty array,
+ // which persists as "{}" and reads back as no mappings.
+ if ($type === 'field_map') {
+ $rules[$fieldName] = [$required ? 'required' : 'nullable', 'array'];
+ $rules[$fieldName.'.*'] = ['nullable', 'string'];
+
+ continue;
+ }
+
$rules[$fieldName] = [
$required ? 'required' : 'nullable',
'string',
@@ -287,7 +322,7 @@ abstract class ConfigurableAdapter implements HostInventoryAdapter
*/
private function persistCredentialsFromSchema(Request $request, string $slug): void
{
- foreach ($this->credentialSchema() as $field) {
+ foreach ($this->settingsSchema() as $field) {
$fieldName = $slug.'_'.$field['key'];
$type = $field['type'] ?? 'text';
@@ -335,6 +370,27 @@ abstract class ConfigurableAdapter implements HostInventoryAdapter
continue;
}
+ // Field-map repeater: assoc array of {field_key: path}.
+ // Empty submissions overwrite as {} so a deliberate
+ // "clear everything" from the UI sticks. Blank path
+ // values within the array are dropped so a mistakenly
+ // added empty row doesn't roundtrip.
+ if ($type === 'field_map') {
+ $values = (array) $request->input($fieldName, []);
+ $values = array_filter(
+ $values,
+ fn ($v, $k) => is_string($k) && $k !== '' && is_string($v) && trim($v) !== '',
+ ARRAY_FILTER_USE_BOTH,
+ );
+ SyncAdapterConfig::put(
+ $this->instance->id,
+ $field['key'],
+ json_encode($values),
+ );
+
+ continue;
+ }
+
if (! $request->filled($fieldName)) {
continue;
}
@@ -1015,7 +1071,7 @@ abstract class ConfigurableAdapter implements HostInventoryAdapter
);
}
- foreach ($this->credentialSchema() as $field) {
+ foreach ($this->settingsSchema() as $field) {
if ($field['key'] !== $key) {
continue;
}
diff --git a/app/SyncAdapters/Unifi/UnifiAdapter.php b/app/SyncAdapters/Unifi/UnifiAdapter.php
index 33d25f358c..2154de4c64 100644
--- a/app/SyncAdapters/Unifi/UnifiAdapter.php
+++ b/app/SyncAdapters/Unifi/UnifiAdapter.php
@@ -35,18 +35,18 @@ class UnifiAdapter extends ConfigurableAdapter
return 'https://your-controller:8443';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'api_key',
- 'label' => 'API Key',
+ 'label' => trans('admin/settings/sync_adapters.label_api_key'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.unifi_api_key_help'),
],
[
'key' => 'site_id',
- 'label' => 'Site ID',
+ 'label' => trans('admin/settings/sync_adapters.label_site_id'),
'help' => trans('admin/settings/sync_adapters.unifi_site_id_help'),
],
];
diff --git a/app/SyncAdapters/WorkspaceOne/WorkspaceOneAdapter.php b/app/SyncAdapters/WorkspaceOne/WorkspaceOneAdapter.php
index a319b229fc..2014ed4dca 100644
--- a/app/SyncAdapters/WorkspaceOne/WorkspaceOneAdapter.php
+++ b/app/SyncAdapters/WorkspaceOne/WorkspaceOneAdapter.php
@@ -46,22 +46,22 @@ class WorkspaceOneAdapter extends ConfigurableAdapter implements PushableAdapter
return 'https://as###.awmdm.com';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'tenant_code',
- 'label' => 'Tenant Code',
+ 'label' => trans('admin/settings/sync_adapters.label_tenant_code'),
'help' => trans('admin/settings/sync_adapters.workspace_one_tenant_code_help'),
],
[
'key' => 'client_id',
- 'label' => 'Client ID',
+ 'label' => trans('admin/settings/sync_adapters.label_client_id'),
'help' => trans('admin/settings/sync_adapters.workspace_one_client_id_help'),
],
[
'key' => 'client_secret',
- 'label' => 'Client Secret',
+ 'label' => trans('admin/settings/sync_adapters.label_client_secret'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.workspace_one_client_secret_help'),
],
diff --git a/app/SyncAdapters/Zentral/ZentralAdapter.php b/app/SyncAdapters/Zentral/ZentralAdapter.php
index 1e100fc16b..ef6adaab20 100644
--- a/app/SyncAdapters/Zentral/ZentralAdapter.php
+++ b/app/SyncAdapters/Zentral/ZentralAdapter.php
@@ -19,12 +19,12 @@ class ZentralAdapter extends ConfigurableAdapter
return 'Zentral';
}
- public function credentialSchema(): array
+ public function settingsSchema(): array
{
return [
[
'key' => 'token',
- 'label' => 'API Token',
+ 'label' => trans('admin/settings/sync_adapters.label_api_token'),
'secret' => true,
'help' => trans('admin/settings/sync_adapters.zentral_token_help'),
],
diff --git a/tests/Feature/SyncAdapters/NewBuiltInAdaptersRenderTest.php b/tests/Feature/SyncAdapters/NewBuiltInAdaptersRenderTest.php
index 97466ef96d..2ca582f68e 100644
--- a/tests/Feature/SyncAdapters/NewBuiltInAdaptersRenderTest.php
+++ b/tests/Feature/SyncAdapters/NewBuiltInAdaptersRenderTest.php
@@ -25,7 +25,7 @@ class NewBuiltInAdaptersRenderTest extends TestCase
->getContent();
$this->assertStringContainsString('Mosyle', $html);
- // Schema field label from MosyleAdapter::credentialSchema()
+ // Schema field label from MosyleAdapter::settingsSchema()
$this->assertMatchesRegularExpression('/name="mosyle_token"/', $html);
}
diff --git a/tests/Feature/SyncAdapters/Osctrl/OsctrlAdapterTest.php b/tests/Feature/SyncAdapters/Osctrl/OsctrlAdapterTest.php
index 225a5d4b11..1f0935a6a6 100644
--- a/tests/Feature/SyncAdapters/Osctrl/OsctrlAdapterTest.php
+++ b/tests/Feature/SyncAdapters/Osctrl/OsctrlAdapterTest.php
@@ -75,7 +75,7 @@ class OsctrlAdapterTest extends TestCase
$adapter = new OsctrlAdapter($instance->fresh());
- // Environment field is required (default in credentialSchema),
+ // Environment field is required (default in settingsSchema),
// so isEnabled() must refuse until it's present. Prevents the
// Sync Now button from becoming clickable on a half-configured
// adapter.