<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <tab id="shenobis" translate="label" sortOrder="900">
            <label>Shenobis</label>
        </tab>
        <section id="shenobis_product_push" translate="label" sortOrder="900" showInDefault="1" showInWebsite="1"
                 showInStore="1">
            <label>Product Push Notifications</label>
            <tab>shenobis</tab>
            <resource>Magento_Config::config</resource>
            <group id="general" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1"
                   showInStore="1">
                <label>General</label>
                <field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Enabled</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
                <field id="endpoint_url" translate="label comment" type="text" sortOrder="20" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Frontend Push Endpoint URL</label>
                    <comment>Magento POSTs each product notification to this React Router endpoint as JSON. Leave empty to only store notifications for polling.</comment>
                    <validate>validate-url</validate>
                </field>
                <field id="shared_secret" translate="label comment" type="obscure" sortOrder="30" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Shared Secret</label>
                    <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
                    <comment>Sent as X-Notification-Secret and required by the JSON feed when configured.</comment>
                </field>
                <field id="feed_limit" translate="label" type="text" sortOrder="40" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Default Feed Limit</label>
                    <validate>validate-digits</validate>
                </field>
                <field id="test_connection" translate="label comment" type="button" sortOrder="50" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Test Connection</label>
                    <frontend_model>Shenobis\ProductPushNotification\Block\Adminhtml\System\Config\TestConnection</frontend_model>
                    <comment>Sends a test notification to the configured frontend endpoint and validates the JSON response schema.</comment>
                </field>
            </group>
        </section>
    </system>
</config>
