{% import "_includes/forms" as forms %} {% if yamlExists %}
{% if invert %}

{{ 'Update YAML Files'|t('app') }}

{{ 'Update your project config YAML files to reflect the latest changes in the loaded project config.'|t('app') }}

{% else %}

{{ 'Apply YAML Changes'|t('app') }}

{{ 'Apply changes in your project config YAML files to the loaded project config.'|t('app') }}

{% endif %} {{ csrfInput() }} {% if areChangesPending %}

{{ invert ? 'Make sure you’re not overwriting changes in the YAML files that were made on another environment.'|t('app') : 'Make sure you’ve followed the Environment Setup instructions before applying project config YAML changes.'|t('app', { url: 'https://craftcms.com/docs/3.x/project-config.html#environment-setup', })|raw }}

{% if invert %} {{ tag('button', { type: 'button', class: ['btn', 'formsubmit', 'secondary'], text: 'Update YAML files'|t('app'), data: { action: 'project-config/discard', confirm: 'Are you sure you want to discard the pending project config YAML changes?'|t('app'), }, }) }} {{ tag('button', { type: 'button', class: ['btn', 'formsubmit'], text: 'Apply YAML changes'|t('app'), data: { action: 'config-sync', params: { return: 'utilities/project-config', }, }, }) }} {% else %} {{ tag('button', { type: 'button', class: ['btn', 'formsubmit', 'secondary'], text: 'Apply changes only'|t('app'), data: { action: 'config-sync', params: { return: 'utilities/project-config', }, }, }) }} {{ tag('button', { type: 'button', class: ['btn', 'formsubmit'], text: 'Reapply everything'|t('app'), data: { action: 'config-sync', params: { return: 'utilities/project-config', force: 1, }, }, }) }} {% if not readOnly %} {{ tag('button', { type: 'button', class: ['btn', 'formsubmit'], text: 'Discard changes'|t('app'), data: { action: 'project-config/discard', confirm: 'Are you sure you want to discard the pending project config YAML changes?'|t('app'), }, }) }} {% endif %} {% endif %}
{% else %}

{{ 'There aren’t any pending project config changes to apply.'|t('app') }}

{{ tag('button', { type: 'button', class: ['btn', 'formsubmit'], text: 'Reapply everything'|t('app'), data: { action: 'config-sync', params: { return: 'utilities/project-config', force: 1, }, }, }) }}
{% endif %}
{% else %}

{{ 'Generate YAML Files'|t('app') }}

{{ 'Save the loaded project config data to YAML files in your {folder} folder.'|t('app', { folder: 'config/project/', })|raw }}

{{ actionInput('project-config/discard') }} {{ csrfInput() }}
{% endif %} {% if not readOnly %}

{{ 'Rebuild the Config'|t('app') }}

{{ 'Rebuild the project config based on the data stored throughout the database.'|t('app') }}

{{ actionInput('project-config/rebuild') }} {{ csrfInput() }}
{% endif %}

{{ 'Loaded Project Config Data'|t('app') }}

{{ entireConfig }}
{% css %} .pane { max-height: 500px; overflow: auto; } .pane pre { margin: 0; padding: 0; background-color: transparent; } {% endcss %} {% if areChangesPending %} {% js %} let cancelToken = axios.CancelToken.source(); Craft.sendActionRequest('GET', Craft.getActionUrl('project-config/diff', { invert: {{ invert|json_encode }}, }), { cancelToken: cancelToken.token, }).then(response => { cancelToken = null; let maxLines = 20; let lines = response.data.split(/\n/); let $diffPane = $('#diff') .removeClass('loading') .addClass('highlight'); let $pre = $('
', {
                class: 'language-diff',
            }).appendTo($diffPane);
            let $code = $('', {
                class: 'language-diff diff-highlight',
                html: Prism.highlight(lines.slice(0, maxLines).join("\n"), Prism.languages.diff, 'diff'),
            }).appendTo($pre);

            if (lines.length > maxLines) {
                let $p = $('

', { class: 'centeralign', }).appendTo($diffPane); let $a = $('', { class: 'largetext', text: Craft.t('app', 'Show all changes'), }).appendTo($p); $a.on('click', () => { $code.html(Prism.highlight(response.data, Prism.languages.diff, 'diff')); $p.remove(); }); } }); Garnish.$win.on('beforeunload', () => { if (cancelToken) { cancelToken.cancel(); } }); {% endjs %} {% css %} #diff.loading { height: 200px; } {% endcss %} {% endif %} {% js %} $('#download').on('click', () => { $('#download-spinner').removeClass('hidden'); let params = {}; if (Craft.csrfTokenName) { params[Craft.csrfTokenName] = Craft.csrfTokenValue; } Craft.downloadFromUrl("GET", "{{ actionUrl('project-config/download') }}", params) .then(() => { $('#download-spinner').addClass('hidden'); }) .catch(e => { $('#download-spinner').addClass('hidden'); throw e; }); }); {% endjs %}