commit 42c980a00955b4fbcf79edf759520dd48061f74d Author: Dean Reilly Date: Wed Dec 12 22:05:30 2012 +0000 1821548-new_changes diff --git a/core/modules/config/config.admin.inc b/core/modules/config/config.admin.inc index 8f88ae4..2a24190 100644 --- a/core/modules/config/config.admin.inc +++ b/core/modules/config/config.admin.inc @@ -41,9 +41,6 @@ function config_admin_sync_form(array &$form, array &$form_state, StorageInterfa continue; } - // Add the CSS for the inline diff. - $form['#attached']['css'][] = drupal_get_path('module', 'system') . '/system.diff.css'; - // @todo A table caption would be more appropriate, but does not have the // visual importance of a heading. $form[$config_change_type]['heading'] = array( @@ -65,38 +62,20 @@ function config_admin_sync_form(array &$form, array &$form_state, StorageInterfa } $form[$config_change_type]['list'] = array( '#theme' => 'table', - '#header' => array('Name'), + '#header' => array('Name', 'Operations'), ); foreach ($config_files as $config_file) { - $form[$config_change_type]['list']['#rows'][] = array($config_file); - - switch ($config_change_type) { - case 'change': - $fieldset_title = t('View changes of @config_file', array('@config_file' => $config_file)); - break; - - case 'create': - $fieldset_title = t('View added file @config_file', array('@config_file' => $config_file)); - break; - - case 'delete': - $fieldset_title = t('View removed file @config_file', array('@config_file' => $config_file)); - break; - } - - // Show the additions/changes/deletions in a nice collapsible fieldset. - $fieldset = array( - '#type' => 'fieldset', - '#title' => $fieldset_title, - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $fieldset['diff'] = array( - '#markup' => config_diff($target_storage, $source_storage, $config_file), - ); $form[$config_change_type]['list']['#rows'][] = array( - array('data' => $fieldset), + 'name' => $config_file, + 'operations' => array( + 'data' => array( + '#type' => 'link', + '#title' => t('Diff'), + '#href' => 'admin/config/development/sync/diff/' . $config_file, + '#ajax' => array('dialog' => array('modal' =>TRUE)), + ), + ), ); } } @@ -147,3 +126,39 @@ function config_admin_import_form_submit($form, &$form_state) { drupal_set_message(t('The import failed due to an error. Any errors have been logged.'), 'error'); } } + +/** + * Page callback: Shows diff of specificed configuration file. + * + * @param string $config_file + * The name of the configuration file. + * + * @return string + * Table showing a two-way diff between the active and staged configuration. + */ +function config_admin_diff_page($config_file) { + // Retrieve a list of differences between last known state and active store. + $source_storage = drupal_container()->get('config.storage.staging'); + $target_storage = drupal_container()->get('config.storage'); + + // Add the CSS for the inline diff. + $output['#attached']['css'][] = drupal_get_path('module', 'system') . '/system.diff.css'; + + $output['title'] = array( + '#theme' => 'html_tag__h3', + '#tag' => 'h3', + '#value' => t('View changes of @config_file', array('@config_file' => $config_file)), + ); + + $output['diff'] = array( + '#markup' => config_diff($target_storage, $source_storage, $config_file), + ); + + $output['back'] = array( + '#type' => 'link', + '#title' => "Back to 'Synchornize configuration' page.", + '#href' => 'admin/config/development/sync', + ); + + return $output; +} diff --git a/core/modules/config/config.module b/core/modules/config/config.module index a41fc09..7482171 100644 --- a/core/modules/config/config.module +++ b/core/modules/config/config.module @@ -48,6 +48,14 @@ function config_menu() { 'access arguments' => array('synchronize configuration'), 'file' => 'config.admin.inc', ); + $items['admin/config/development/sync/diff/%'] = array( + 'title' => 'Configuration file diff', + 'description' => 'Diff between active and staged configuraiton.', + 'page callback' => 'config_admin_diff_page', + 'page arguments' => array(5), + 'access arguments' => array('synchronize configuration'), + 'file' => 'config.admin.inc', + ); $items['admin/config/development/sync/import'] = array( 'title' => 'Import', 'type' => MENU_DEFAULT_LOCAL_TASK,