-
-
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
Config.js modularized #14470
Config.js modularized #14470
Conversation
Please rebase and squash |
2da2163
to
e251c8d
Compare
Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
e251c8d
to
cae2c2b
Compare
Signed-off-by: Piyush Vijay <piyushvijay.1997@gmail.com>
e3a2240
to
c1f42b0
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.
Some minor comments and queries.
js/src/config.js
Outdated
// default values for fields | ||
// export var defaultValues = {}; | ||
|
||
// ------------------------------------------------------------------ |
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.
Is this code needed?
@@ -483,7 +483,7 @@ public function addJsValidate($fieldId, $validators, array &$jsArray): void | |||
$vArgs[] = Sanitize::escapeJsString($arg); | |||
} | |||
$vArgs = $vArgs ? ", ['" . implode("', '", $vArgs) . "']" : ''; | |||
$jsArray[] = "validateField('$fieldId', '$vName', true$vArgs)"; | |||
$jsArray[] = "['$fieldId', '$vName', true$vArgs]"; |
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.
Any reason why this is required?
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 function is not available in global scope so it is giving reference error. There fore it is removed and an array is returrned from the function instead of a function call.
js/src/variables/get_config.js
Outdated
} | ||
$.extend(PMA_messages, arguments[arguments.length - 2]); | ||
$.extend(defaultValues, arguments[arguments.length - 1]); | ||
// console.log(PMA_messages); |
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.
stray debug statement?
js/src/variables/get_config.js
Outdated
} | ||
|
||
window.getConfigData = function () { | ||
// debugger; |
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.
stray debug statement?
js/src/functions/config.js
Outdated
} | ||
|
||
export function setupValidation () { | ||
// debugger; |
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.
stray debug statements?
c1f42b0
to
61e9780
Compare
Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
…onfig.js in file loading object. Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
Build script for js files. Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
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.
Requesting review from @devenbansod
@@ -7,7 +7,7 @@ | |||
"license": "GPL-2.0", | |||
"scripts": { | |||
"dev:wds": "webpack-dev-server --progress", | |||
"prod:build": "del js/lib js/dist && babel js/src/ -d js/lib --ignore .test.js && cross-env NODE_ENV=production webpack -p --progress", | |||
"prod:build": "del js/lib js/dist && babel js/src/ -d js/lib --ignore .test.js && cross-env NODE_ENV=production webpack -p --env.production --progress", |
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.
Adding production environment variable in webpack.config file.
scripts/build-js-files
Outdated
@@ -0,0 +1,39 @@ | |||
#!/bin/sh |
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.
@devenbansod can you please review this file. This is the script for creating production build for js files.
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.
Consider renaming this as a build-js.sh
script?
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.
Also, try to put the invocation for this script in its proper place inside scripts/create-release.sh
?
@@ -2,84 +2,95 @@ import path from 'path'; | |||
import webpack from 'webpack'; |
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.
Update webpack.config file for creating production build using command line.
cfc9ff8
to
79577f8
Compare
Codecov Report
@@ Coverage Diff @@
## gsoc-js-refactoring #14470 +/- ##
======================================================
Coverage ? 50.53%
Complexity ? 14434
======================================================
Files ? 501
Lines ? 68012
Branches ? 0
======================================================
Hits ? 34372
Misses ? 33640
Partials ? 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.
Looks good overall. Some comments.
Tested locally. Works fine.
webpack.config.babel.js
Outdated
@@ -2,84 +2,95 @@ import path from 'path'; | |||
import webpack from 'webpack'; | |||
import BundleAnalyzerPlugin from 'webpack-bundle-analyzer'; | |||
|
|||
let BindleAnalyzer = BundleAnalyzerPlugin.BundleAnalyzerPlugin; | |||
function WebpackConfig (env) { | |||
let BindleAnalyzer = 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.
Typo? BundleAnalyzer
?
return { | ||
mode: MODE, | ||
entry: { | ||
index_new: './js/src/index.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.
Still needs to be called as index_new
?
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.
Yeah as some of the files are still remaining.
scripts/build-js-files
Outdated
|
||
if [ -f package.json ] ; then | ||
echo "Running Yarn Install" | ||
yarn install |
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.
Does this assume that yarn is pre-installed, might be good to check it if possible?
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.
Yeah, as I have gone through the script create-release
, there isn't any check specified for composer so I guess there also we don't need to specify any check. Although, I tried adding the check but, didn't found anything about how to do that.
If you have any idea about how we can implement the check?
scripts/build-js-files
Outdated
|
||
#Performing cleanup | ||
#Removing yarn files | ||
rm yarn.lock |
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.
similar check as below would be good to have? -f yarn.lock
?
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.
Done
scripts/build-js-files
Outdated
@@ -0,0 +1,39 @@ | |||
#!/bin/sh |
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.
Consider renaming this as a build-js.sh
script?
scripts/build-js-files
Outdated
#Removing babel files as they are not required in production | ||
rm .babelrc | ||
rm webpack.config.babel.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.
Unrelated to this file: Once the modularization is complete, we aim to delete the files in js/*.js
right?
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.
Yup but we need to rebase master over this branch first to take change from master to this branch which can also be added in the modular code.
scripts/build-js-files
Outdated
@@ -0,0 +1,39 @@ | |||
#!/bin/sh |
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.
Also, try to put the invocation for this script in its proper place inside scripts/create-release.sh
?
79577f8
to
03b8a7e
Compare
bffc1aa
to
733b029
Compare
Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
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.
@@ -5165,3 +5165,21 @@ function checkPasswordStrength (value, meter_obj, meter_object_label, username) | |||
case 4: meter_object_label.html(PMA_messages.strStrong); | |||
} | |||
} | |||
|
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.
Created a copy of function to make it globally available.
@@ -0,0 +1,80 @@ | |||
import { PMA_Messages as PMA_messages } from '../variables/export_variables'; |
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.
Validation class to validate input for settings tab
@@ -0,0 +1,176 @@ | |||
/* 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.
Modular code for config.js
@@ -0,0 +1,589 @@ | |||
import { PMA_ajaxShowMessage } from '../utils/show_ajax_messages'; |
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 functions required to be imported in config.js for proper functionality.
@@ -0,0 +1,33 @@ | |||
import { validators } from '../classes/Config'; |
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 functions for importing validation parameters in Modular code which are to be used in modular code.
@@ -355,12 +355,12 @@ public function getDisplay( | |||
foreach ($this->_jsLangStrings as $strName => $strValue) { | |||
$jsLang[] = "'$strName': '" . Sanitize::jsFormat($strValue, false) . '\''; | |||
} | |||
$js[] = "$.extend(PMA_messages, {\n\t" | |||
. implode(",\n\t", $jsLang) . '})'; | |||
$js[] = "{\n\t" |
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.
Minor change as PMA_messages will not be available in global scope.
} | ||
|
||
$js[] = "$.extend(defaultValues, {\n\t" | ||
. implode(",\n\t", $jsDefault) . '})'; | ||
$js[] = "{\n\t" |
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.
Minor change as defaultValues will not be available in global scope
@@ -0,0 +1,42 @@ | |||
#!/bin/sh |
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.
Build script for creating production build of javascript files.
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.
LGTM.
This pr contains the modular code for Config.js file. This file is used for settings on various pages.
This pr is in continuation of Mod_Jd_Import_Export. Before reviewing this pr, review Mod_Js_Import_Export and merge and then compare with this pr.
Before submitting pull request, please check that every commit: