-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Modularize PMA Navigation JS files #14468
Conversation
Codecov Report
@@ Coverage Diff @@
## gsoc-js-refactoring #14468 +/- ##
======================================================
Coverage ? 49.93%
Complexity ? 14435
======================================================
Files ? 504
Lines ? 68972
Branches ? 0
======================================================
Hits ? 34441
Misses ? 34531
Partials ? 0 |
Please rebase and squash |
57f5b34
to
c17c254
Compare
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>
c17c254
to
383b9c9
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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; | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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: */ |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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.
webpack.config.babel.js
Outdated
}; | ||
var plugins = [ | ||
new webpack.optimize.OccurrenceOrderPlugin(), | ||
new webpack.HotModuleReplacementPlugin(), | ||
new webpack.NamedModulesPlugin(), | ||
new webpack.NoEmitOnErrorsPlugin() | ||
new webpack.NoEmitOnErrorsPlugin(), | ||
new plugin() |
There was a problem hiding this comment.
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: { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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; | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
webpack.config.babel.js
Outdated
@@ -1,5 +1,8 @@ | |||
import path from 'path'; | |||
import webpack from 'webpack'; | |||
import BundleAnalyzerPlugin from 'webpack-bundle-analyzer'; | |||
|
|||
let plugin = BundleAnalyzerPlugin.BundleAnalyzerPlugin; |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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>
383b9c9
to
9727a94
Compare
There was a problem hiding this 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.
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: