From 8403bd6c7e67bcdfd5c8cc824d5473eaa3ac5b18 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 9 Feb 2015 12:07:43 +0530 Subject: [PATCH 1/2] rfe #1235 Relation view: move to main "Structure" page Signed-off-by: Madhura Jayaratne --- ChangeLog | 1 + js/indexes.js | 2 +- js/tbl_structure.js | 3 +- libraries/structure.lib.php | 63 +++++++++++++++++++++++++++------- libraries/tbl_indexes.lib.php | 6 ++-- libraries/tbl_relation.lib.php | 8 ++--- tbl_addfield.php | 4 +-- tbl_relation.php | 10 +++++- tbl_structure.php | 49 +++++++++++++++----------- 9 files changed, 97 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index b85659db36..24fbcff9ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,7 @@ phpMyAdmin - ChangeLog + rfe #1600 Clarify the "Inline" link + rfe #1179 Speed up slow triggers by using EVENT_OBJECT_SCHEMA + rfe #1192 ON DUPLICATE KEY UPDATE for loading CSV ++ rfe #1235 Relation view: move to main "Structure" page 4.3.10.0 (not yet released) diff --git a/js/indexes.js b/js/indexes.js index 6a7e8e7d85..009b940d13 100644 --- a/js/indexes.js +++ b/js/indexes.js @@ -575,7 +575,7 @@ AJAX.registerOnload('indexes.js', function () { if (data.sql_query) { $('
') .html(data.sql_query) - .prependTo('#page_content'); + .prependTo('#structure_content'); PMA_highlightSQL($('#page_content')); } PMA_commonActions.refreshMain(false, function () { diff --git a/js/tbl_structure.js b/js/tbl_structure.js index 7b4c1dd49d..73ba55e7b1 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -129,7 +129,6 @@ AJAX.registerOnload('tbl_structure.js', function () { $("#page_content") .empty() .append(data.message) - .append(data.sql_query) .show(); PMA_highlightSQL($('#page_content')); $(".result_query .notice").remove(); @@ -183,7 +182,7 @@ AJAX.registerOnload('tbl_structure.js', function () { if (data.sql_query) { $('
') .html(data.sql_query) - .prependTo('#page_content'); + .prependTo('#structure_content'); PMA_highlightSQL($('#page_content')); } toggleRowColors($curr_row.next()); diff --git a/libraries/structure.lib.php b/libraries/structure.lib.php index d6666d457f..adf8b3569e 100644 --- a/libraries/structure.lib.php +++ b/libraries/structure.lib.php @@ -1625,18 +1625,6 @@ function PMA_getHtmlForOptionalActionLinks($url_query, $tbl_is_view, . ''; if (! $tbl_is_view && ! $db_is_system_schema) { - // if internal relations are available, or foreign keys are supported - // ($tbl_storage_engine comes from libraries/tbl_info.inc.php - - if ($cfgRelation['relwork'] - || PMA_Util::isForeignKeySupported($tbl_storage_engine) - ) { - $html_output .= '' - . PMA_Util::getIcon( - 'b_relations.png', __('Relation view'), true - ) - . ''; - } if (!PMA_DRIZZLE) { $html_output .= ''; + foreach (PMA_getStructureSubTabs() as $tab) { + $html_output .= PMA_Util::getHtmlTab($tab, $url_params); + } + $html_output .= ''; + $html_output .= '
'; + } + return $html_output; +} + +/** + * Returns an array with necessary configurations to create + * sub-tabs in the Structure page at table level + * + * @return array Array containing configuration (icon, text, link, id) + * of sub-tabs + */ +function PMA_getStructureSubTabs() +{ + $subtabs = array(); + + $subtabs['structure']['icon'] = 'b_props'; + $subtabs['structure']['link'] = 'tbl_structure.php'; + $subtabs['structure']['text'] = __('Table Structure'); + $subtabs['structure']['id'] = 'table_strucuture_id'; + + $subtabs['relation']['icon'] = 'b_relations'; + $subtabs['relation']['link'] = 'tbl_relation.php'; + $subtabs['relation']['text'] = __('Relation View'); + $subtabs['relation']['id'] = 'table_relation_id'; + + return $subtabs; +} ?> diff --git a/libraries/tbl_indexes.lib.php b/libraries/tbl_indexes.lib.php index b7db2d99af..5724b10617 100644 --- a/libraries/tbl_indexes.lib.php +++ b/libraries/tbl_indexes.lib.php @@ -64,12 +64,10 @@ function PMA_handleCreateOrEditIndex($db, $table, $index) if ($GLOBALS['is_ajax_request'] == true) { $response = PMA_Response::getInstance(); - $response->addJSON('message', $message); - $response->addJSON('index_table', PMA_Index::getView($table, $db)); $response->addJSON( - 'sql_query', - PMA_Util::getMessage(null, $sql_query) + 'message', PMA_Util::getMessage($message, $sql_query, 'success') ); + $response->addJSON('index_table', PMA_Index::getView($table, $db)); } else { include 'tbl_structure.php'; } diff --git a/libraries/tbl_relation.lib.php b/libraries/tbl_relation.lib.php index a4dd46b6c1..a666b72f92 100644 --- a/libraries/tbl_relation.lib.php +++ b/libraries/tbl_relation.lib.php @@ -182,8 +182,6 @@ function PMA_getHtmlForCommonForm($db, $table, $columns, $cfgRelation, $tbl_storage_engine, $existrel, $existrel_foreign, $options_array ) { $html_output = PMA_getHtmlForCommonFormHeader($db, $table); - $html_output .= '
' - . '' . __('Relations') . ''; if ($cfgRelation['relwork']) { $html_output .= PMA_getHtmlForInternalRelationForm( @@ -198,8 +196,6 @@ function PMA_getHtmlForCommonForm($db, $table, $columns, $cfgRelation, ); } // end if (InnoDB) - $html_output .= '
'; - if ($cfgRelation['displaywork']) { $html_output .= PMA_getHtmlForDisplayFieldInfos( $db, $table, @@ -823,7 +819,7 @@ function PMA_handleUpdateForDisplayField($disp, $display_field, $db, $table, PMA_queryAsControlUser($upd_query); $html_output = PMA_Util::getMessage( __('Display column was successfully updated.'), - null, 'success' + '', 'success' ); } return $html_output; @@ -907,7 +903,7 @@ function PMA_handleUpdatesForInternalRelations($destination_db, if ($updated) { $html_output = PMA_Util::getMessage( __('Internal relations were successfully updated.'), - null, 'success' + '', 'success' ); } return $html_output; diff --git a/tbl_addfield.php b/tbl_addfield.php index 209f07bf2e..0c7aa1da2f 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -92,10 +92,8 @@ if (isset($_REQUEST['do_save_data'])) { __('Table %1$s has been altered successfully.') ); $message->addParam($table); - $response->addJSON('message', $message); $response->addJSON( - 'sql_query', - PMA_Util::getMessage(null, $sql_query) + 'message', PMA_Util::getMessage($message, $sql_query, 'success') ); exit; } else { diff --git a/tbl_relation.php b/tbl_relation.php index 44fa1b68e5..974105d153 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -20,6 +20,7 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/index.lib.php'; require_once 'libraries/tbl_relation.lib.php'; +require_once 'libraries/structure.lib.php'; $response = PMA_Response::getInstance(); @@ -124,6 +125,11 @@ if ($cfgRelation['displaywork']) { } +// display secondary level tabs if necessary +$engine = PMA_Table::sGetStatusInfo($db, $table, 'ENGINE'); +$response->addHTML(PMA_getStructureSecondaryTabs($engine)); +$response->addHTML('
'); + /** * Dialog */ @@ -144,5 +150,7 @@ if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) { $html_output .= PMA_getHtmlForDisplayIndexes(); } // Render HTML output -PMA_Response::getInstance()->addHTML($html_output); +$response->addHTML($html_output); + +$response->addHTML('
'); ?> diff --git a/tbl_structure.php b/tbl_structure.php index 1cea292eec..d1f0092337 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -76,26 +76,6 @@ if (isset($_REQUEST['change_column'])) { PMA_displayHtmlForColumnChange($db, $table, null, 'tbl_structure.php'); exit; } -/** - * Modifications have been submitted -> updates the table - */ -if (isset($_REQUEST['do_save_data'])) { - $regenerate = PMA_updateColumns($db, $table); - if ($regenerate) { - // This happens when updating failed - // @todo: do something appropriate - } else { - // continue to show the table's structure - unset($_REQUEST['selected']); - } -} -/** - * Adding indexes - */ -if (isset($_REQUEST['add_key'])) { - include 'sql.php'; - $GLOBALS['reload'] = true; -} /** * handle multiple field commands if required @@ -132,6 +112,33 @@ if (! empty($submit_mult)) { } } +// display secondary level tabs if necessary +$engine = PMA_Table::sGetStatusInfo($db, $table, 'ENGINE'); +$response->addHTML(PMA_getStructureSecondaryTabs($engine)); +$response->addHTML('
'); + +/** + * Modifications have been submitted -> updates the table + */ +if (isset($_REQUEST['do_save_data'])) { + $regenerate = PMA_updateColumns($db, $table); + if ($regenerate) { + // This happens when updating failed + // @todo: do something appropriate + } else { + // continue to show the table's structure + unset($_REQUEST['selected']); + } +} + +/** + * Adding indexes + */ +if (isset($_REQUEST['add_key'])) { + include 'sql.php'; + $GLOBALS['reload'] = true; +} + /** * Gets the relation settings */ @@ -195,4 +202,6 @@ $hidden_titles = PMA_getHiddenTitlesArray(); //display table structure require_once 'libraries/display_structure.inc.php'; + +$response->addHTML('
'); ?> From 8222af3cac575467f81b5666bde375a15a56876c Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 9 Feb 2015 13:03:43 +0530 Subject: [PATCH 2/2] Update tests Signed-off-by: Madhura Jayaratne --- test/libraries/PMA_tbl_relation_test.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/libraries/PMA_tbl_relation_test.php b/test/libraries/PMA_tbl_relation_test.php index 2ba4aeff05..80a94fede6 100644 --- a/test/libraries/PMA_tbl_relation_test.php +++ b/test/libraries/PMA_tbl_relation_test.php @@ -260,11 +260,6 @@ class PMA_TblRelationTest extends PHPUnit_Framework_TestCase $html ); - $this->assertContains( - __('Relations'), - $html - ); - $this->assertContains( __('Column'), $html