diff --git a/docs/3.x.x/en/guides/models.md b/docs/3.x.x/en/guides/models.md index a5b56d8605..a68d8978df 100644 --- a/docs/3.x.x/en/guides/models.md +++ b/docs/3.x.x/en/guides/models.md @@ -21,6 +21,7 @@ The following types are currently available: - `biginteger` - `float` - `decimal` + - `password` - `date` - `time` - `datetime` @@ -30,6 +31,7 @@ The following types are currently available: - `uuid` - `enumeration` - `json` + - `email` #### Example @@ -48,6 +50,9 @@ The following types are currently available: "lastname": { "type": "string" }, + "password": { + "type": "password" + }, "about": { "type": "description" }, @@ -392,7 +397,7 @@ Additional settings can be set on models: "collectionName": "Users_v1", "globalId": "Users", "attributes": { - + } } ``` diff --git a/packages/strapi-helper-plugin/lib/src/app.js b/packages/strapi-helper-plugin/lib/src/app.js index 93c85d792c..66aaa11cfc 100755 --- a/packages/strapi-helper-plugin/lib/src/app.js +++ b/packages/strapi-helper-plugin/lib/src/app.js @@ -14,25 +14,33 @@ import App from 'containers/App'; // eslint-disable-line import configureStore from './store'; import { translationMessages } from './i18n'; -const tryRequire = (bootstrap = false) => { +const tryRequireRoot = (source) => { try { - const config = bootstrap ? require('../../../../admin/src/bootstrap.js').default : require('../../../../admin/src/requirements.js').default; - return config; + return require('../../../../admin/src/' + source + '.js').default; } catch(err) { return null; } }; -const bootstrap = tryRequire(true); -const pluginRequirements = tryRequire(); +const tryRequireConfig = (source) => { + try { + return require('../../../../config/' + source + '.js').default; + } catch(err) { + return null; + } +}; -let injectedComponents; +const bootstrap = tryRequireRoot('bootstrap'); +const pluginRequirements = tryRequireRoot('requirements'); +const layout = tryRequireConfig('layout'); -try { - injectedComponents = require('injectedComponents').default; -} catch(err) { - injectedComponents = []; -} +const injectedComponents = (() => { + try { + return require('injectedComponents').default; + } catch(err) { + return []; + } +}); // Plugin identifier based on the package.json `name` value const pluginPkg = require('../../../../package.json'); @@ -84,6 +92,7 @@ strapi.registerPlugin({ translationMessages, bootstrap, pluginRequirements, + layout, preventComponentRendering: false, blockerComponent: null, injectedComponents, diff --git a/packages/strapi-helper-plugin/lib/src/components/Input/index.js b/packages/strapi-helper-plugin/lib/src/components/Input/index.js index 2334b72a12..cddcd651fa 100644 --- a/packages/strapi-helper-plugin/lib/src/components/Input/index.js +++ b/packages/strapi-helper-plugin/lib/src/components/Input/index.js @@ -250,7 +250,7 @@ class Input extends React.Component { // eslint-disable-line react/prefer-statel { convertType: mongooseType => { switch (mongooseType.toLowerCase()) { case 'string': + case 'password': case 'text': + case 'email': return 'String'; case 'integer': case 'biginteger': diff --git a/packages/strapi-plugin-content-manager/admin/src/bootstrap.js b/packages/strapi-plugin-content-manager/admin/src/bootstrap.js index acc622fcb2..01a7aa5312 100644 --- a/packages/strapi-plugin-content-manager/admin/src/bootstrap.js +++ b/packages/strapi-plugin-content-manager/admin/src/bootstrap.js @@ -5,7 +5,7 @@ const bootstrap = (plugin) => new Promise((resolve, reject) => { generateMenu() .then(menu => { plugin.leftMenuSections = menu; - + console.log(plugin.leftMenuSections); resolve(plugin); }) .catch(e => reject(e)); diff --git a/packages/strapi-plugin-content-manager/admin/src/components/EditForm/index.js b/packages/strapi-plugin-content-manager/admin/src/components/EditForm/index.js index 5e393b300d..ba074d9482 100755 --- a/packages/strapi-plugin-content-manager/admin/src/components/EditForm/index.js +++ b/packages/strapi-plugin-content-manager/admin/src/components/EditForm/index.js @@ -25,10 +25,14 @@ class EditForm extends React.Component { getInputType = (type = '') => { switch (type.toLowerCase()) { + case 'password': + return 'password'; case 'boolean': return 'checkbox'; case 'text': return 'textarea'; + case 'email': + return 'email'; case 'string': return 'text'; case 'date': @@ -47,7 +51,7 @@ class EditForm extends React.Component { render() { const source = getQueryParameters(this.props.location.search, 'source'); const currentSchema = get(this.props.schema, [this.props.currentModelName]) || get(this.props.schema, ['plugins', source, this.props.currentModelName]); - const currentLayout = source === undefined || source === 'content-manager' ? get(this.props.layout, [this.props.currentModelName]) : get(this.props.layout, ['plugins', source, this.props.currentModelName]); + const currentLayout = get(this.props.layout, [this.props.currentModelName]); // Remove `id` field const displayedFields = merge(currentLayout, omit(currentSchema.fields, 'id')); @@ -71,7 +75,7 @@ class EditForm extends React.Component { return ( { - const source = getQueryParameters(this.props.location.search, 'source'); - const currentSchema = get(this.props.schema, [this.props.currentModelName]) || get(this.props.schema, ['plugins', source, this.props.currentModelName]); + const currentSchema = get(this.props.schema, [this.props.currentModelName]) || get(this.props.schema, ['plugins', this.source, this.props.currentModelName]); let formattedValue = e.target.value; @@ -154,10 +157,8 @@ export class Edit extends React.Component { map(this.props.record.toJS(), (value, key) => form[key] = value); const formErrors = checkFormValidity(form, this.props.formValidations.toJS()); - const source = getQueryParameters(this.props.location.search, 'source'); - if (isEmpty(formErrors)) { - this.props.editRecord(source); + this.props.editRecord(this.source); } else { this.props.setFormErrors(formErrors); } @@ -168,8 +169,7 @@ export class Edit extends React.Component { return
Loading...
; } - const source = getQueryParameters(this.props.location.search, 'source'); - const currentModel = get(this.props.models, ['models', this.props.currentModelName]) || get(this.props.models, ['plugins', source, 'models', this.props.currentModelName]); + const currentModel = get(this.props.models, ['models', this.props.currentModelName]) || get(this.props.models, ['plugins', this.source, 'models', this.props.currentModelName]); // Plugin header config const primaryKey = currentModel.primaryKey; diff --git a/packages/strapi-plugin-content-manager/config/layout.js b/packages/strapi-plugin-content-manager/config/layout.js index f053ebf797..94cb0494bf 100644 --- a/packages/strapi-plugin-content-manager/config/layout.js +++ b/packages/strapi-plugin-content-manager/config/layout.js @@ -1 +1 @@ -module.exports = {}; +export default ({}); diff --git a/packages/strapi-plugin-users-permissions/models/User.settings.json b/packages/strapi-plugin-users-permissions/models/User.settings.json index 862c801845..deef6b9210 100644 --- a/packages/strapi-plugin-users-permissions/models/User.settings.json +++ b/packages/strapi-plugin-users-permissions/models/User.settings.json @@ -11,7 +11,7 @@ "unique": true }, "email": { - "type": "string", + "type": "email", "minLength": 6, "unique": true }, @@ -19,14 +19,14 @@ "type": "string" }, "password": { - "type": "string", + "type": "password", "minLength": 6 }, "resetPasswordToken": { "type": "string" }, "role": { - "type": "string" + "type": "integer" } } }