From 01192aaeb706370d29c2d04d725d4f6c79cda493 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 11 Mar 2017 02:19:02 -0300 Subject: [PATCH] Ivan - Add all install steps [skip ci] --- client/gulp/config.js | 3 +- client/gulp/tasks/watch.js | 2 +- client/src/app-components/toggle-button.js | 4 +- client/src/app-components/toggle-button.scss | 7 ++ client/src/app/Routes.js | 12 +-- client/src/app/install/install-layout.js | 4 +- .../app/install/install-step-3-database.js | 78 +++++++++++++++++++ .../app/install/install-step-3-database.scss | 18 +++++ .../app/install/install-step-3-settings.js | 14 ---- .../app/install/install-step-3-settings.scss | 1 - .../install/install-step-4-administrator.js | 14 ---- .../install/install-step-4-administrator.scss | 1 - .../app/install/install-step-4-user-system.js | 68 ++++++++++++++++ .../install/install-step-4-user-system.scss | 14 ++++ .../src/app/install/install-step-5-admin.js | 77 ++++++++++++++++++ .../src/app/install/install-step-5-admin.scss | 18 +++++ .../src/app/install/install-step-5-install.js | 14 ---- .../app/install/install-step-5-install.scss | 1 - .../app/install/install-step-6-completed.js | 18 ++++- client/src/core-components/form-field.js | 11 ++- client/src/data/fixtures/system-fixtures.js | 35 ++++++++- client/src/data/languages/en.js | 23 ++++-- client/src/index.html | 1 + 23 files changed, 368 insertions(+), 70 deletions(-) create mode 100644 client/src/app/install/install-step-3-database.js create mode 100644 client/src/app/install/install-step-3-database.scss delete mode 100644 client/src/app/install/install-step-3-settings.js delete mode 100644 client/src/app/install/install-step-3-settings.scss delete mode 100644 client/src/app/install/install-step-4-administrator.js delete mode 100644 client/src/app/install/install-step-4-administrator.scss create mode 100644 client/src/app/install/install-step-4-user-system.js create mode 100644 client/src/app/install/install-step-4-user-system.scss create mode 100644 client/src/app/install/install-step-5-admin.js create mode 100644 client/src/app/install/install-step-5-admin.scss delete mode 100644 client/src/app/install/install-step-5-install.js delete mode 100644 client/src/app/install/install-step-5-install.scss diff --git a/client/gulp/config.js b/client/gulp/config.js index 23403c8d..86e35dc7 100644 --- a/client/gulp/config.js +++ b/client/gulp/config.js @@ -15,8 +15,7 @@ module.exports = { }, 'styles': { - 'src': './src/*.scss', - 'watch': './src/**/*.scss', + 'src': './src/**/*.scss', 'dest': './build/css/' }, diff --git a/client/gulp/tasks/watch.js b/client/gulp/tasks/watch.js index 975bc7f7..8c7207c2 100644 --- a/client/gulp/tasks/watch.js +++ b/client/gulp/tasks/watch.js @@ -6,7 +6,7 @@ var config = require('../config'); gulp.task('watch', ['browserSync', 'server'], function() { // Scripts are automatically watched by Watchify inside Browserify task - gulp.watch(config.styles.watch, ['sass']); + gulp.watch(config.styles.src, ['sass']); gulp.watch(config.images.src, ['imagemin']); gulp.watch(config.sourceDir + 'index.html', ['copyIndex']); diff --git a/client/src/app-components/toggle-button.js b/client/src/app-components/toggle-button.js index ee32845b..ebd3098e 100644 --- a/client/src/app-components/toggle-button.js +++ b/client/src/app-components/toggle-button.js @@ -4,7 +4,6 @@ import classNames from 'classnames'; import i18n from 'lib-app/i18n'; class ToggleButton extends React.Component { - static propTypes = { value: React.PropTypes.bool, @@ -22,6 +21,7 @@ class ToggleButton extends React.Component { getClass() { let classes = { 'toggle-button': true, + 'toggle-button_disabled': (this.props.disabled), [this.props.className]: (this.props.className) }; @@ -30,7 +30,7 @@ class ToggleButton extends React.Component { onClick() { - if (this.props.onChange) { + if (this.props.onChange && !this.props.disabled) { this.props.onChange({ target: { value: !this.props.value diff --git a/client/src/app-components/toggle-button.scss b/client/src/app-components/toggle-button.scss index 6006ae56..f0c3ce7f 100644 --- a/client/src/app-components/toggle-button.scss +++ b/client/src/app-components/toggle-button.scss @@ -7,4 +7,11 @@ border-radius: 4px; text-align: center; user-select: none; + cursor: pointer; + + &_disabled { + cursor: default; + background-color: transparent; + color: $dark-grey; + } } \ No newline at end of file diff --git a/client/src/app/Routes.js b/client/src/app/Routes.js index db90bd6b..f6d3c668 100644 --- a/client/src/app/Routes.js +++ b/client/src/app/Routes.js @@ -57,9 +57,9 @@ import AdminPanelEmailTemplates from 'app/admin/panel/settings/admin-panel-email import InstallLayout from 'app/install/install-layout'; import InstallStep1Language from 'app/install/install-step-1-language'; import InstallStep2Requirements from 'app/install/install-step-2-requirements'; -import InstallStep3Settings from 'app/install/install-step-3-settings'; -import InstallStep4Administrator from 'app/install/install-step-4-administrator'; -import InstallStep5Install from 'app/install/install-step-5-install'; +import InstallStep3Database from 'app/install/install-step-3-database'; +import InstallStep4UserSystem from 'app/install/install-step-4-user-system'; +import InstallStep5Admin from 'app/install/install-step-5-admin'; import InstallStep6Completed from 'app/install/install-step-6-completed'; const history = syncHistoryWithStore(browserHistory, store); @@ -95,9 +95,9 @@ export default ( - - - + + + diff --git a/client/src/app/install/install-layout.js b/client/src/app/install/install-layout.js index 61a5c1d7..b74b1cdd 100644 --- a/client/src/app/install/install-layout.js +++ b/client/src/app/install/install-layout.js @@ -10,9 +10,9 @@ import Icon from 'core-components/icon'; const steps = [ 'LANGUAGE', 'SERVER_REQUIREMENTS', - 'SETTINGS_SETUP', + 'DATABASE_CONFIGURATION', + 'USER_SYSTEM', 'ADMIN_SETUP', - 'INSTALL', 'COMPLETED' ]; diff --git a/client/src/app/install/install-step-3-database.js b/client/src/app/install/install-step-3-database.js new file mode 100644 index 00000000..08ed8ebb --- /dev/null +++ b/client/src/app/install/install-step-3-database.js @@ -0,0 +1,78 @@ +import React from 'react'; +import {browserHistory} from 'react-router'; + +import i18n from 'lib-app/i18n'; +import API from 'lib-app/api-call'; + +import Button from 'core-components/button'; +import Header from 'core-components/header'; +import Form from 'core-components/form'; +import FormField from 'core-components/form-field'; +import SubmitButton from 'core-components/submit-button'; +import Message from 'core-components/message'; + +class InstallStep3Database extends React.Component { + + state = { + loading: false, + error: false, + errorMessage: '' + }; + + render() { + return ( +
+
+ {this.renderMessage()} +
+ + + + +
+ {i18n('NEXT')} + +
+ +
+ ); + } + + renderMessage() { + let message = null; + + if(this.state.error) { + message = ( + + {i18n('ERROR_UPDATING_SETTINGS')}: {this.state.errorMessage} + + ); + } + + return message; + } + + onPreviousClick(event) { + event.preventDefault(); + browserHistory.push('/install/step-2'); + } + + onSubmit(form) { + this.setState({ + loading: true + }, () => { + API.call({ + path: '/system/init-database', + data: form + }) + .then(() => browserHistory.push('/install/step-4')) + .catch(({message}) => this.setState({ + loading: false, + error: true, + errorMessage: message + })); + }); + } +} + +export default InstallStep3Database; \ No newline at end of file diff --git a/client/src/app/install/install-step-3-database.scss b/client/src/app/install/install-step-3-database.scss new file mode 100644 index 00000000..6a4bac27 --- /dev/null +++ b/client/src/app/install/install-step-3-database.scss @@ -0,0 +1,18 @@ +@import "../../scss/vars"; + +.install-step-3 { + + &__message { + margin-bottom: 20px; + } + + &__previous { + float: left; + } + + &__next { + float: left; + position: absolute; + margin-left: 286px; + } +} \ No newline at end of file diff --git a/client/src/app/install/install-step-3-settings.js b/client/src/app/install/install-step-3-settings.js deleted file mode 100644 index 31048b3c..00000000 --- a/client/src/app/install/install-step-3-settings.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; - -class InstallStep3Settings extends React.Component { - - render() { - return ( -
- INSTALLATION -
- ); - } -} - -export default InstallStep3Settings; \ No newline at end of file diff --git a/client/src/app/install/install-step-3-settings.scss b/client/src/app/install/install-step-3-settings.scss deleted file mode 100644 index c990d9a8..00000000 --- a/client/src/app/install/install-step-3-settings.scss +++ /dev/null @@ -1 +0,0 @@ -@import "../../scss/vars"; diff --git a/client/src/app/install/install-step-4-administrator.js b/client/src/app/install/install-step-4-administrator.js deleted file mode 100644 index f3a63395..00000000 --- a/client/src/app/install/install-step-4-administrator.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; - -class InstallStep4Administrator extends React.Component { - - render() { - return ( -
- INSTALLATION -
- ); - } -} - -export default InstallStep4Administrator; \ No newline at end of file diff --git a/client/src/app/install/install-step-4-administrator.scss b/client/src/app/install/install-step-4-administrator.scss deleted file mode 100644 index c990d9a8..00000000 --- a/client/src/app/install/install-step-4-administrator.scss +++ /dev/null @@ -1 +0,0 @@ -@import "../../scss/vars"; diff --git a/client/src/app/install/install-step-4-user-system.js b/client/src/app/install/install-step-4-user-system.js new file mode 100644 index 00000000..b5f5af88 --- /dev/null +++ b/client/src/app/install/install-step-4-user-system.js @@ -0,0 +1,68 @@ +import React from 'react'; +import {browserHistory} from 'react-router'; + +import i18n from 'lib-app/i18n'; +import API from 'lib-app/api-call'; + +import ToggleButton from 'app-components/toggle-button'; +import Button from 'core-components/button'; +import Header from 'core-components/header'; +import Form from 'core-components/form'; +import FormField from 'core-components/form-field'; +import SubmitButton from 'core-components/submit-button'; + +class InstallStep4UserSystem extends React.Component { + + state = { + form: { + 'user-system-enabled': true, + 'registration': true + } + }; + + render() { + return ( +
+
+
+ + +
+ {i18n('NEXT')} + +
+ +
+ ); + } + + onChange(form) { + this.setState({ + form: { + 'user-system-enabled': form['user-system-enabled'], + 'registration': form['user-system-enabled'] && form['registration'] + } + }); + } + + onPreviousClick(event) { + event.preventDefault(); + browserHistory.push('/install/step-3'); + } + + onSubmit(form) { + API.call({ + path: '/system/init-settings', + data: { + 'user-system-enabled': form['user-system-enabled'], + 'registration': form['registration'] + } + }).then(() => browserHistory.push('/install/step-5')); + } + + isDisabled() { + return !this.state.form['user-system-enabled']; + } +} + +export default InstallStep4UserSystem; \ No newline at end of file diff --git a/client/src/app/install/install-step-4-user-system.scss b/client/src/app/install/install-step-4-user-system.scss new file mode 100644 index 00000000..92e326bb --- /dev/null +++ b/client/src/app/install/install-step-4-user-system.scss @@ -0,0 +1,14 @@ +@import "../../scss/vars"; + +.install-step-4 { + + &__previous { + margin-right: 20px; + } + + &__next { + float: left; + position: absolute; + margin-left: 286px; + } +} \ No newline at end of file diff --git a/client/src/app/install/install-step-5-admin.js b/client/src/app/install/install-step-5-admin.js new file mode 100644 index 00000000..0c5c1903 --- /dev/null +++ b/client/src/app/install/install-step-5-admin.js @@ -0,0 +1,77 @@ +import React from 'react'; +import {browserHistory} from 'react-router'; + +import i18n from 'lib-app/i18n'; +import API from 'lib-app/api-call'; + +import Button from 'core-components/button'; +import Header from 'core-components/header'; +import Form from 'core-components/form'; +import FormField from 'core-components/form-field'; +import SubmitButton from 'core-components/submit-button'; +import Message from 'core-components/message'; + +class InstallStep5Admin extends React.Component { + + state = { + loading: false, + error: false, + errorMessage: '' + }; + + render() { + return ( +
+
+ {this.renderMessage()} +
+ + + +
+ {i18n('NEXT')} + +
+ +
+ ); + } + + renderMessage() { + let message = null; + + if(this.state.error) { + message = ( + + {i18n('ERROR_UPDATING_SETTINGS')}: {this.state.errorMessage} + + ); + } + + return message; + } + + onPreviousClick(event) { + event.preventDefault(); + browserHistory.push('/install/step-4'); + } + + onSubmit(form) { + this.setState({ + loading: true + }, () => { + API.call({ + path: '/system/init-admin', + data: form + }) + .then(() => browserHistory.push('/install/step-6')) + .catch(({message}) => this.setState({ + loading: false, + error: true, + errorMessage: message + })); + }); + } +} + +export default InstallStep5Admin; \ No newline at end of file diff --git a/client/src/app/install/install-step-5-admin.scss b/client/src/app/install/install-step-5-admin.scss new file mode 100644 index 00000000..2b8eb92d --- /dev/null +++ b/client/src/app/install/install-step-5-admin.scss @@ -0,0 +1,18 @@ +@import "../../scss/vars"; + +.install-step-5 { + + &__message { + margin-bottom: 20px; + } + + &__previous { + margin-right: 20px; + } + + &__next { + float: left; + position: absolute; + margin-left: 286px; + } +} \ No newline at end of file diff --git a/client/src/app/install/install-step-5-install.js b/client/src/app/install/install-step-5-install.js deleted file mode 100644 index 61d60200..00000000 --- a/client/src/app/install/install-step-5-install.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; - -class InstallStep5Install extends React.Component { - - render() { - return ( -
- INSTALLATION -
- ); - } -} - -export default InstallStep5Install; \ No newline at end of file diff --git a/client/src/app/install/install-step-5-install.scss b/client/src/app/install/install-step-5-install.scss deleted file mode 100644 index c990d9a8..00000000 --- a/client/src/app/install/install-step-5-install.scss +++ /dev/null @@ -1 +0,0 @@ -@import "../../scss/vars"; diff --git a/client/src/app/install/install-step-6-completed.js b/client/src/app/install/install-step-6-completed.js index d2733f8f..e610a83d 100644 --- a/client/src/app/install/install-step-6-completed.js +++ b/client/src/app/install/install-step-6-completed.js @@ -1,11 +1,25 @@ import React from 'react'; +import {browserHistory} from 'react-router'; + +import i18n from 'lib-app/i18n'; +import API from 'lib-app/api-call'; + +import Header from 'core-components/header'; +import Message from 'core-components/message'; class InstallStep6Completed extends React.Component { + componentDidMount() { + setTimeout(() => browserHistory.push('/admin'), 5000); + } + render() { return ( -
- INSTALLATION +
+
+ + {i18n('INSTALLATION_COMPLETED_DESCRIPTION')} +
); } diff --git a/client/src/core-components/form-field.js b/client/src/core-components/form-field.js index 376c11db..ee5a1441 100644 --- a/client/src/core-components/form-field.js +++ b/client/src/core-components/form-field.js @@ -29,7 +29,8 @@ class FormField extends React.Component { }; static defaultProps = { - field: 'input' + field: 'input', + fieldProps: {} }; static getDefaultValue(field) { @@ -120,7 +121,7 @@ class FormField extends React.Component { getFieldProps() { let props = _.extend({}, this.props.fieldProps, { - disabled: this.context.loading, + disabled: this.isDisabled(), errored: !!this.props.error, name: this.props.name, placeholder: this.props.placeholder, @@ -171,6 +172,12 @@ class FormField extends React.Component { this.props.onChange(event) } } + + isDisabled() { + const fieldProps = this.props.fieldProps; + + return (fieldProps.disabled === undefined) ? this.context.loading : fieldProps.disabled; + } focus() { if (this.refs.nativeField) { diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index 9a7ebe26..d160a64a 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -56,6 +56,37 @@ module.exports = [ } } }, + { + path: '/system/init-settings', + time: 50, + response: function() { + return { + status: 'success', + data: {} + }; + } + }, + { + path: '/system/init-database', + time: 50, + response: function() { + return { + status: 'success', + message: 'ERROR_SERVER', + data: {} + }; + } + }, + { + path: '/system/init-admin', + time: 50, + response: function() { + return { + status: 'success', + data: {} + }; + } + }, { path: '/system/edit-settings', time: 50, @@ -90,8 +121,8 @@ module.exports = [ }, configFile: { name: 'File: /api/config.php', - value: 'No writable', - ok: false + value: 'Writable', + ok: true } } }; diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index 80d15eda..b6b8ee57 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -210,9 +210,8 @@ export default { 'ACTIVITY_UN_BAN_USER': 'banned user', 'SERVER_REQUIREMENTS': 'Server requirements', - 'SETTINGS_SETUP': 'Settings setup', + 'DATABASE_CONFIGURATION': 'Database configuration', 'ADMIN_SETUP': 'Admin setup', - 'INSTALL': 'Install', 'COMPLETED': 'Completed', 'INSTALL_HEADER_TITLE': 'OpenSupports Installation Wizard', 'INSTALL_HEADER_DESCRIPTION': 'This wizard will help you to configure and install OpenSupports on your website', @@ -220,14 +219,26 @@ export default { 'REQUIREMENT': 'Requirement', 'VALUE': 'Value', 'REFRESH': 'Refresh', + 'USER_SYSTEM': 'User System', + 'PREVIOUS': 'Previous', + 'DATABASE_HOST': 'MySQL server', + 'DATABASE_NAME': 'MySQL database name', + 'DATABASE_USER': 'MySQL user', + 'DATABASE_PASSWORD': 'MySQL password', + 'ADMIN_NAME': 'Admin account name', + 'ADMIN_EMAIL': 'Admin account email', + 'ADMIN_PASSWORD': 'Admin account password', + 'ADMIN_PASSWORD_DESCRIPTION': 'Please remember this password. It is needed for accessing the admin panel. You can change it later.', + 'INSTALLATION_COMPLETED': 'Installation completed.', + 'INSTALLATION_COMPLETED_DESCRIPTION': 'The installation of OpenSupports is completed. Redirecting to admin panel...', 'STEP_TITLE': 'Step {current} of {total} - {title}', 'STEP_1_DESCRIPTION': 'Select your preferred language for the installation wizard.', 'STEP_2_DESCRIPTION': 'Here are listed the requirements for running OpenSupports. Please make sure that all requirements are satisfied.', - 'STEP_3_DESCRIPTION': 'Select your preferred language for the installation wizard.', - 'STEP_4_DESCRIPTION': 'Select your preferred language for the installation wizard.', - 'STEP_5_DESCRIPTION': 'Select your preferred language for the installation wizard.', - 'STEP_6_DESCRIPTION': 'Select your preferred language for the installation wizard.', + 'STEP_3_DESCRIPTION': 'Please fill the MySQL database configuration.', + 'STEP_4_DESCRIPTION': 'Please select your user system preferences.', + 'STEP_5_DESCRIPTION': 'Please configure the administrator account.', + 'STEP_6_DESCRIPTION': 'Installation is completed.', //VIEW DESCRIPTIONS 'CREATE_TICKET_DESCRIPTION': 'This is a form for creating tickets. Fill the form and send us your issues/doubts/suggestions. Our support system will answer it as soon as possible.', diff --git a/client/src/index.html b/client/src/index.html index a398c80c..04d3e7f6 100644 --- a/client/src/index.html +++ b/client/src/index.html @@ -9,6 +9,7 @@ OS4 +