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

Config.js modularized #14470

Merged

Conversation

Piyush3079
Copy link
Contributor

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:

  • 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

@devenbansod devenbansod changed the base branch from master to gsoc-js-refactoring August 1, 2018 11:18
@devenbansod
Copy link
Member

Please rebase and squash

@Piyush3079 Piyush3079 force-pushed the Mod_Js_Config_Js branch 10 times, most recently from 2da2163 to e251c8d Compare August 1, 2018 14:28
Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
Signed-off-by: Piyush Vijay <piyushvijay.1997@gmail.com>
@devenbansod devenbansod self-requested a review August 1, 2018 15:29
@devenbansod devenbansod self-assigned this Aug 1, 2018
@Piyush3079 Piyush3079 force-pushed the Mod_Js_Config_Js branch 3 times, most recently from e3a2240 to c1f42b0 Compare August 1, 2018 15:59
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.

Some minor comments and queries.

js/src/config.js Outdated
// default values for fields
// export var defaultValues = {};

// ------------------------------------------------------------------
Copy link
Member

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]";
Copy link
Member

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?

Copy link
Contributor Author

@Piyush3079 Piyush3079 Aug 2, 2018

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.

}
$.extend(PMA_messages, arguments[arguments.length - 2]);
$.extend(defaultValues, arguments[arguments.length - 1]);
// console.log(PMA_messages);
Copy link
Member

Choose a reason for hiding this comment

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

stray debug statement?

}

window.getConfigData = function () {
// debugger;
Copy link
Member

Choose a reason for hiding this comment

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

stray debug statement?

}

export function setupValidation () {
// debugger;
Copy link
Member

Choose a reason for hiding this comment

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

stray debug statements?

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>
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.

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",
Copy link
Contributor Author

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.

@@ -0,0 +1,39 @@
#!/bin/sh
Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Member

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';
Copy link
Contributor Author

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.

@codecov
Copy link

codecov bot commented Aug 2, 2018

Codecov Report

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

@@                  Coverage Diff                   @@
##             gsoc-js-refactoring   #14470   +/-   ##
======================================================
  Coverage                       ?   50.53%           
  Complexity                     ?    14434           
======================================================
  Files                          ?      501           
  Lines                          ?    68012           
  Branches                       ?        0           
======================================================
  Hits                           ?    34372           
  Misses                         ?    33640           
  Partials                       ?        0

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 overall. Some comments.

Tested locally. Works fine.

@@ -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;
Copy link
Member

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'
Copy link
Member

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?

Copy link
Contributor Author

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.


if [ -f package.json ] ; then
echo "Running Yarn Install"
yarn install
Copy link
Member

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?

Copy link
Contributor Author

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?


#Performing cleanup
#Removing yarn files
rm yarn.lock
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -0,0 +1,39 @@
#!/bin/sh
Copy link
Member

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?

#Removing babel files as they are not required in production
rm .babelrc
rm webpack.config.babel.js

Copy link
Member

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?

Copy link
Contributor Author

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.

@@ -0,0 +1,39 @@
#!/bin/sh
Copy link
Member

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?

@Piyush3079 Piyush3079 force-pushed the Mod_Js_Config_Js branch 4 times, most recently from bffc1aa to 733b029 Compare August 3, 2018 12:34
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.

@@ -5165,3 +5165,21 @@ function checkPasswordStrength (value, meter_obj, meter_object_label, username)
case 4: meter_object_label.html(PMA_messages.strStrong);
}
}

Copy link
Contributor Author

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';
Copy link
Contributor Author

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: */
Copy link
Contributor Author

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';
Copy link
Contributor Author

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';
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 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"
Copy link
Contributor Author

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"
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

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.

LGTM.

@devenbansod devenbansod merged commit 0e16cc5 into phpmyadmin:gsoc-js-refactoring Aug 7, 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.

None yet

2 participants