Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modularize PMA Navigation JS files #14468

Merged

Conversation

Piyush3079
Copy link
Contributor

This pr contains the modular code for PMA Navigation and the file names were changed in php files so that new modular code can be loaded rather than old code files.

This pr is in continuation of Mod_Js_Server_Status. Before reviewing this pr, review Mod_Js_Server_Status and merge and then compare with this pr.

Before submitting pull request, please check that every commit:

  • Has proper Signed-Off-By
  • Has commit message which describes it
  • Is needed on it's own, if you have just minor fixes to previous commits, you can squash them
  • Any new functionality is covered by tests

@codecov
Copy link

codecov bot commented Jul 8, 2018

Codecov Report

❗ No coverage uploaded for pull request base (gsoc-js-refactoring@ed6f106). Click here to learn what that means.
The diff coverage is 15.2%.

@@                  Coverage Diff                   @@
##             gsoc-js-refactoring   #14468   +/-   ##
======================================================
  Coverage                       ?   49.93%           
  Complexity                     ?    14435           
======================================================
  Files                          ?      504           
  Lines                          ?    68972           
  Branches                       ?        0           
======================================================
  Hits                           ?    34441           
  Misses                         ?    34531           
  Partials                       ?        0

@devenbansod devenbansod changed the base branch from master to gsoc-js-refactoring July 28, 2018 12:49
@devenbansod devenbansod changed the title PMA Navigation modularized Modularize PMA Navigation JS files Jul 28, 2018
@devenbansod devenbansod self-assigned this Jul 28, 2018
@devenbansod devenbansod self-requested a review July 28, 2018 12:50
@devenbansod
Copy link
Member

Please rebase and squash

@Piyush3079 Piyush3079 force-pushed the Mod_Js_Navigation branch 12 times, most recently from 57f5b34 to c17c254 Compare July 29, 2018 11:33
Signed-off-by: Piyush Vijay <piyushvijay.1997@gmail.com>
…ore file names added in ajax and index.

Signed-off-by: Piyush Vijay <piyushvijay.1997@gmail.com>
Copy link
Contributor Author

@Piyush3079 Piyush3079 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General comments to increase the understandability of the pr

@@ -13,6 +13,11 @@
// Send correct type:
header('Content-Type: text/javascript; charset=UTF-8');

// Preventing caching of this file
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove caching of this file to prevent storing of parameters in cache

@@ -271,388 +271,6 @@ function traverseNavigationForPaths () {
return params;
}

/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove events from js/navigation.js to avoid duplicate events and triggering of events twice

@@ -586,8 +589,8 @@ export let AJAX = {
* @todo This condition is to be removed once all the files are modularised
*/
if (checkNewCode(file)) {
var fileImports = ['server_privileges', 'server_databases', 'server_status_advisor',
'server_status_processes', 'server_status_variables',];
var fileImports = ['server_privileges', 'server_databases', 'error_report', 'navigation', 'server_status_advisor',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Navigations and error report files whitelisted for ajax loading

@@ -4,6 +4,97 @@
* @returns void
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File containing the functions related to navigation which can be imported in files.

/**
* Adding common files for every page
*/
for (let i in files.global) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For loading common files required on every page.

@@ -0,0 +1,513 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main navigation file containing the events related to navigation which are copied from js/navigations.js and modified accordingly for use with modular code.

@@ -183,13 +183,13 @@ private function _addDefaultScripts(): void

$this->_scripts->addFile('messages.php', array('l' => $GLOBALS['lang']));
$this->_scripts->addFile('common_params.php', array('l' => $GLOBALS['lang']));
$this->_scripts->addFile('vendors~index_new.js');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vendor files are added in webpack to create a common bundle for vendor files required on every page like jquery, sprintf etc.

};
var plugins = [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.NoEmitOnErrorsPlugin()
new webpack.NoEmitOnErrorsPlugin(),
new plugin()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundle analyzer plugin to run bundle analyzer in development mode.

@@ -47,6 +52,28 @@ export default [{
path: path.resolve(__dirname, 'js/dist'),
publicPath: PUBLIC_PATH
},
optimization: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default configuration for chunks generated by dynamic imports.

Copy link
Member

@devenbansod devenbansod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Tested locally, works fine.

Some minor comments added.

@@ -271,388 +271,6 @@ function traverseNavigationForPaths () {
return params;
}

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this complete file get deleted ultimately?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once all the files get revamped then only we will be able to delete this complete files because functions defined in this file are going to be used in many other files which are not revamped yet.

@@ -1,5 +1,8 @@
import path from 'path';
import webpack from 'webpack';
import BundleAnalyzerPlugin from 'webpack-bundle-analyzer';

let plugin = BundleAnalyzerPlugin.BundleAnalyzerPlugin;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This naming could/should be improved.

@@ -183,13 +183,13 @@ private function _addDefaultScripts(): void

$this->_scripts->addFile('messages.php', array('l' => $GLOBALS['lang']));
$this->_scripts->addFile('common_params.php', array('l' => $GLOBALS['lang']));
$this->_scripts->addFile('vendors~index_new.js');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was it not needed previously? and is only needed for this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not file specific. There is slight change in webpack configuration which is generating a combined bundle of vendor files needed on every page. So this files is the bundled vendor file.

@@ -37,6 +37,7 @@
"del-cli": "^1.1.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the following warning when I run yarn install:
warning " > babel-loader@7.1.5" has unmet peer dependency "babel-core@6".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to not including babel-core package but this will not have effect as we have installed babel-cli instead of babel-core.

Signed-off-by: Piyush Vijay <piyushvijay.1997@gmail.com>
…d in Header.php

Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
… login and logout again.

Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
Copy link
Member

@devenbansod devenbansod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Tested locally, works fine.

Moving ahead to unblock next PR.

TODO: @Piyush3079 to revisit renaming of files, folders, functions, classes once all files are revamped.

@devenbansod devenbansod merged commit 00e9049 into phpmyadmin:gsoc-js-refactoring Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants