diff --git a/packages/strapi-plugin-setings-manager/admin/src/components/InputNumber/index.js b/packages/strapi-plugin-setings-manager/admin/src/components/InputNumber/index.js
new file mode 100644
index 0000000000..01c1f53963
--- /dev/null
+++ b/packages/strapi-plugin-setings-manager/admin/src/components/InputNumber/index.js
@@ -0,0 +1,125 @@
+/**
+*
+* InputNumber
+* Customization
+* - deactivateErrorHighlight: bool
+* allow the user to remove bootstrap class 'has-danger' on the inputText
+* - customBootstrapClass : string
+* overrides the default 'col-md-6' on the inputText
+* - handleBlur: function
+* overrides the default input validations
+* - errors : array
+* custom errors if set to false it deactivate error display
+*
+* Required
+* - name : string
+* - handleChange : function
+* - value : string
+* - validations : object
+*
+* Optionnal
+* - description : input description
+* - handleFocus : function
+* - placeholder : string if set to "" nothing will display
+*
+*/
+
+import React from 'react';
+import styles from './styles.scss';
+
+class InputNumber extends React.Component { // eslint-disable-line react/prefer-stateless-function
+ constructor(props) {
+ super(props);
+ this.state = {
+ errors: false,
+ hasInitialValue: false,
+ };
+ }
+
+ componentDidMount() {
+ if (this.props.value && this.props.value.length !== '') {
+ this.setState({ hasInitialValue: true });
+ }
+ }
+
+ componentWillReceiveProps(nextProps) {
+ if (this.props.errors !== nextProps.errors) {
+ let errors = false;
+ if (_.isEmpty(nextProps.errors)) {
+ errors = nextProps.errors === true ? [] : false;
+ } else {
+ errors = nextProps.errors;
+ }
+ this.setState({ errors });
+ }
+ }
+
+ handleBlur = ({ target }) => {
+ // prevent error display if input is initially empty
+ if (target.value.length > 0 || this.state.hasInitialValue) {
+ // validates basic string validations
+ // add custom logic here such as alerts...
+ const errors = this.validate(target.value);
+ this.setState({ errors, hasInitialValue: true });
+ }
+ }
+
+ validate = (value) => {
+ const errors = !_.isEmpty(_.pick(this.props.validations, 'required')) && value.length > 0 ?
+ false : ['This field is required'];
+ return errors;
+ }
+
+ render() {
+ const inputValue = this.props.value || '';
+ // override default onBlur
+ const handleBlur = this.props.handleBlur || this.handleBlur;
+ // override bootStrapClass
+ const bootStrapClass = this.props.customBootstrapClass ? this.props.customBootstrapClass : 'col-md-4';
+ // set error class with override possibility
+ const bootStrapClassDanger = !this.props.deactivateErrorHighlight && this.state.errors ? 'has-danger' : '';
+ const placeholder = this.props.placeholder || `Change ${this.props.name} field`;
+ return (
+
+
+
+
{React.Children.toArray(content)}
);
@@ -32,17 +60,22 @@ App.contextTypes = {
};
App.propTypes = {
- children: React.PropTypes.node.isRequired,
+ children: React.PropTypes.node,
exposedComponents: React.PropTypes.object.isRequired,
};
export function mapDispatchToProps(dispatch) {
- return {
- dispatch,
- };
+ return bindActionCreators(
+ {
+ menuFetch,
+ },
+ dispatch
+ );
}
-const mapStateToProps = createStructuredSelector({});
+const mapStateToProps = createStructuredSelector({
+ app: selectGlobalDomain(),
+});
// Wrap the component to inject dispatch and state into it
export default connect(mapStateToProps, mapDispatchToProps)(App);
diff --git a/packages/strapi-plugin-setings-manager/admin/src/containers/App/reducer.js b/packages/strapi-plugin-setings-manager/admin/src/containers/App/reducer.js
index 38026c39cd..c302cf9b88 100644
--- a/packages/strapi-plugin-setings-manager/admin/src/containers/App/reducer.js
+++ b/packages/strapi-plugin-setings-manager/admin/src/containers/App/reducer.js
@@ -4,12 +4,19 @@
*
*/
-import { fromJS } from 'immutable';
+import { fromJS, List } from 'immutable';
+import {
+ MENU_FETCH_SUCCEEDED,
+} from './constants';
-const initialState = fromJS({});
+const initialState = fromJS({
+ sections: List(),
+});
function appReducer(state = initialState, action) {
switch (action.type) {
+ case MENU_FETCH_SUCCEEDED:
+ return state.set('menuSections', action.menu.sections);
default:
return state;
}
diff --git a/packages/strapi-plugin-setings-manager/admin/src/containers/App/sagas.js b/packages/strapi-plugin-setings-manager/admin/src/containers/App/sagas.js
new file mode 100644
index 0000000000..45e3ca5c5c
--- /dev/null
+++ b/packages/strapi-plugin-setings-manager/admin/src/containers/App/sagas.js
@@ -0,0 +1,30 @@
+import { takeLatest } from 'redux-saga';
+import { LOCATION_CHANGE } from 'react-router-redux';
+import { put, fork } from 'redux-saga/effects';
+
+import { fetchMenuSucceeded } from './actions';
+import { MENU_FETCH } from './constants';
+
+export function* fetchMenu() {
+ try {
+ const opts = {
+ method: 'GET',
+ };
+ const response = yield fetch('/settings-manager/menu', opts);
+ const data = yield response.json();
+
+ yield put(fetchMenuSucceeded(data));
+
+ } catch(err) {
+ window.Strapi.notification.error(
+ 'An error occurred.'
+ );
+ }
+}
+
+
+function* defaultSaga() {
+ yield fork(takeLatest, MENU_FETCH, fetchMenu);
+}
+
+export default [defaultSaga];
diff --git a/packages/strapi-plugin-setings-manager/admin/src/containers/App/selectors.js b/packages/strapi-plugin-setings-manager/admin/src/containers/App/selectors.js
index b3654897ca..d65351b535 100644
--- a/packages/strapi-plugin-setings-manager/admin/src/containers/App/selectors.js
+++ b/packages/strapi-plugin-setings-manager/admin/src/containers/App/selectors.js
@@ -1,10 +1,10 @@
-// import { createSelector } from 'reselect';
+import { createSelector } from 'reselect';
/**
* Direct selector to the list state domain
*/
-// const selectGlobalDomain = () => state => state.get('global');
+const selectGlobalDomain = () => state => state.get('global');
const selectLocationState = () => {
let prevRoutingState;
@@ -23,3 +23,4 @@ const selectLocationState = () => {
};
export { selectLocationState };
+export default selectGlobalDomain;
diff --git a/packages/strapi-plugin-setings-manager/admin/src/containers/App/styles.scss b/packages/strapi-plugin-setings-manager/admin/src/containers/App/styles.scss
new file mode 100644
index 0000000000..ea67d5f306
--- /dev/null
+++ b/packages/strapi-plugin-setings-manager/admin/src/containers/App/styles.scss
@@ -0,0 +1,17 @@
+.app { /* stylelint-disable */
+ min-height: calc(100vh - 6rem); // TODO should be variable
+ background: rgba(14,22,34,0.02);
+}
+.baseline {
+ // display: none;
+ z-index: 100001;
+ opacity: .2;
+ position: absolute;
+ top:0; left:0;
+ width: 100%;
+ height: 500%;
+ min-height: 100%;
+ background: url('../../assets/images/baseline-18.png');
+ // background: url('../../assets/images/baseline-20.png');
+ pointer-events: none;
+}
diff --git a/packages/strapi-plugin-setings-manager/admin/src/containers/Home/index.js b/packages/strapi-plugin-setings-manager/admin/src/containers/Home/index.js
index d09d296790..9a55f954dd 100644
--- a/packages/strapi-plugin-setings-manager/admin/src/containers/Home/index.js
+++ b/packages/strapi-plugin-setings-manager/admin/src/containers/Home/index.js
@@ -8,24 +8,40 @@ import React from 'react';
import { connect } from 'react-redux';
import Helmet from 'react-helmet';
import PluginLeftMenu from 'components/PluginLeftMenu';
+import InputToggle from 'components/InputToggle';
import selectHome from './selectors';
import styles from './styles.scss';
export class Home extends React.Component { // eslint-disable-line react/prefer-stateless-function
- // constructor(props) {
- // super(props);
- // // this.leftMenuItems = [
- // // {
- // // header: 'global settings',
- // // items: [
- // // general, 'languages', 'advanced'],
- // // }
- // // ]
- // }
+ constructor(props) {
+ super(props);
+ this.state = {
+ value: false,
+ value1: null,
+ }
+ }
+ handleChange = ({ target }) => {
+ console.log('ok');
+ console.log(target);
+ this.setState({ value: !this.state.value});
+ }
render() {
-
+
+ const test = {
+ "name": "bame",
+ "slug": "name",
+ "target": "general.name",
+ "type": "text",
+ "value": "ExperienceApp",
+ "validations" : {
+ "maxLength": 12,
+ "required": true,
+ "regex": /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
+ }
+ };
+
return (
@@ -39,7 +55,20 @@ export class Home extends React.Component { // eslint-disable-line react/prefer-
diff --git a/packages/strapi-plugin-setings-manager/admin/src/routes.json b/packages/strapi-plugin-setings-manager/admin/src/routes.json
index 43d0316f07..ecdedccf41 100644
--- a/packages/strapi-plugin-setings-manager/admin/src/routes.json
+++ b/packages/strapi-plugin-setings-manager/admin/src/routes.json
@@ -1,6 +1,6 @@
{
"/": {
- "name": "home",
- "container": "Home"
+ "name": "app",
+ "container": "App"
}
}