diff --git a/core/modules/config/config.admin.inc b/core/modules/config/config.admin.inc index 718c773..284fbb1 100644 --- a/core/modules/config/config.admin.inc +++ b/core/modules/config/config.admin.inc @@ -6,6 +6,8 @@ */ use Drupal\Core\Config\StorageInterface; +use Drupal\Core\Ajax\AjaxResponse; +use Drupal\Core\Ajax\OpenModalDialogCommand; /** * Helper function to construct the storage changes in a configuration synchronization form. @@ -37,6 +39,9 @@ function config_admin_sync_form(array &$form, array &$form_state, StorageInterfa return $form; } + // Add the AJAX library to the form. + $form['#attached']['library'][] = array('system', 'drupal.ajax'); + foreach ($config_changes as $config_change_type => $config_files) { if (empty($config_files)) { continue; @@ -70,7 +75,9 @@ function config_admin_sync_form(array &$form, array &$form_state, StorageInterfa $links['view_diff'] = array( 'title' => t('View differences'), 'href' => 'admin/config/development/sync/diff/' . $config_file, - 'ajax' => array('dialog' => array('modal' =>TRUE, 'width' => '700px')), + 'attributes' => array( + 'class' => array('use-ajax'), + ), ); $form[$config_change_type]['list']['#rows'][] = array( 'name' => $config_file, @@ -149,12 +156,6 @@ function config_admin_diff_page($config_file) { // Add the CSS for the inline diff. $output['#attached']['css'][] = drupal_get_path('module', 'system') . '/system.diff.css'; - $output['title'] = array( - '#theme' => 'html_tag', - '#tag' => 'h3', - '#value' => t('View changes of @config_file', array('@config_file' => $config_file)), - ); - $diff = config_diff($target_storage, $source_storage, $config_file); $formatter = new DrupalDiffFormatter(); $formatter->show_header = FALSE; @@ -175,10 +176,29 @@ function config_admin_diff_page($config_file) { '#type' => 'link', '#title' => "Back to 'Synchronize configuration' page.", '#href' => 'admin/config/development/sync', - '#attributes' => array( - 'class' => array('dialog-cancel'), - ), ); + $title = t('View changes of @config_file', array('@config_file' => $config_file)); + + // Return AJAX requests as a dialog. + if (Drupal::service('request')->isXmlHttpRequest()) { + // Add class to the close link. + $output['back']['#attributes']['class'][] = 'dialog-cancel'; + + $dialog_content = drupal_render($output); + $response = new AjaxResponse(); + $response->addCommand(new OpenModalDialogCommand($title, $dialog_content, array('width' => '700'))); + return $response; + } + // Otherwise show the page title as an element. + else { + $output['title'] = array( + '#theme' => 'html_tag', + '#tag' => 'h3', + '#value' => $title, + '#weight' => -10, + ); + } + return $output; }