mirror of
https://github.com/strapi/strapi.git
synced 2025-08-04 23:03:00 +00:00
Update branch
Merge branch 'user-permissions' of github.com:strapi/strapi into user-permissions
This commit is contained in:
commit
272f2689a5
@ -21,6 +21,7 @@ The following types are currently available:
|
|||||||
- `biginteger`
|
- `biginteger`
|
||||||
- `float`
|
- `float`
|
||||||
- `decimal`
|
- `decimal`
|
||||||
|
- `password`
|
||||||
- `date`
|
- `date`
|
||||||
- `time`
|
- `time`
|
||||||
- `datetime`
|
- `datetime`
|
||||||
@ -30,6 +31,7 @@ The following types are currently available:
|
|||||||
- `uuid`
|
- `uuid`
|
||||||
- `enumeration`
|
- `enumeration`
|
||||||
- `json`
|
- `json`
|
||||||
|
- `email`
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
@ -48,6 +50,9 @@ The following types are currently available:
|
|||||||
"lastname": {
|
"lastname": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"password": {
|
||||||
|
"type": "password"
|
||||||
|
},
|
||||||
"about": {
|
"about": {
|
||||||
"type": "description"
|
"type": "description"
|
||||||
},
|
},
|
||||||
|
@ -14,25 +14,33 @@ import App from 'containers/App'; // eslint-disable-line
|
|||||||
import configureStore from './store';
|
import configureStore from './store';
|
||||||
import { translationMessages } from './i18n';
|
import { translationMessages } from './i18n';
|
||||||
|
|
||||||
const tryRequire = (bootstrap = false) => {
|
const tryRequireRoot = (source) => {
|
||||||
try {
|
try {
|
||||||
const config = bootstrap ? require('../../../../admin/src/bootstrap.js').default : require('../../../../admin/src/requirements.js').default;
|
return require('../../../../admin/src/' + source + '.js').default;
|
||||||
return config;
|
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const bootstrap = tryRequire(true);
|
const tryRequireConfig = (source) => {
|
||||||
const pluginRequirements = tryRequire();
|
|
||||||
|
|
||||||
let injectedComponents;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
injectedComponents = require('injectedComponents').default;
|
return require('../../../../config/' + source + '.js').default;
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
injectedComponents = [];
|
return null;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const bootstrap = tryRequireRoot('bootstrap');
|
||||||
|
const pluginRequirements = tryRequireRoot('requirements');
|
||||||
|
const layout = tryRequireConfig('layout');
|
||||||
|
|
||||||
|
const injectedComponents = (() => {
|
||||||
|
try {
|
||||||
|
return require('injectedComponents').default;
|
||||||
|
} catch(err) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Plugin identifier based on the package.json `name` value
|
// Plugin identifier based on the package.json `name` value
|
||||||
const pluginPkg = require('../../../../package.json');
|
const pluginPkg = require('../../../../package.json');
|
||||||
@ -84,6 +92,7 @@ strapi.registerPlugin({
|
|||||||
translationMessages,
|
translationMessages,
|
||||||
bootstrap,
|
bootstrap,
|
||||||
pluginRequirements,
|
pluginRequirements,
|
||||||
|
layout,
|
||||||
preventComponentRendering: false,
|
preventComponentRendering: false,
|
||||||
blockerComponent: null,
|
blockerComponent: null,
|
||||||
injectedComponents,
|
injectedComponents,
|
||||||
|
@ -250,7 +250,7 @@ class Input extends React.Component { // eslint-disable-line react/prefer-statel
|
|||||||
<input
|
<input
|
||||||
className={`form-control ${!this.props.deactivateErrorHighlight && !isEmpty(this.state.errors) ? 'is-invalid': ''}`}
|
className={`form-control ${!this.props.deactivateErrorHighlight && !isEmpty(this.state.errors) ? 'is-invalid': ''}`}
|
||||||
onChange={this.props.onChange}
|
onChange={this.props.onChange}
|
||||||
value={this.props.value}
|
value={type === 'password' ? '********' : this.props.value}
|
||||||
name={this.props.name}
|
name={this.props.name}
|
||||||
id={this.props.label}
|
id={this.props.label}
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
|
@ -14,7 +14,9 @@ module.exports = mongoose => {
|
|||||||
convertType: mongooseType => {
|
convertType: mongooseType => {
|
||||||
switch (mongooseType.toLowerCase()) {
|
switch (mongooseType.toLowerCase()) {
|
||||||
case 'string':
|
case 'string':
|
||||||
|
case 'password':
|
||||||
case 'text':
|
case 'text':
|
||||||
|
case 'email':
|
||||||
return 'String';
|
return 'String';
|
||||||
case 'integer':
|
case 'integer':
|
||||||
case 'biginteger':
|
case 'biginteger':
|
||||||
|
@ -5,7 +5,7 @@ const bootstrap = (plugin) => new Promise((resolve, reject) => {
|
|||||||
generateMenu()
|
generateMenu()
|
||||||
.then(menu => {
|
.then(menu => {
|
||||||
plugin.leftMenuSections = menu;
|
plugin.leftMenuSections = menu;
|
||||||
|
console.log(plugin.leftMenuSections);
|
||||||
resolve(plugin);
|
resolve(plugin);
|
||||||
})
|
})
|
||||||
.catch(e => reject(e));
|
.catch(e => reject(e));
|
||||||
|
@ -25,10 +25,14 @@ class EditForm extends React.Component {
|
|||||||
|
|
||||||
getInputType = (type = '') => {
|
getInputType = (type = '') => {
|
||||||
switch (type.toLowerCase()) {
|
switch (type.toLowerCase()) {
|
||||||
|
case 'password':
|
||||||
|
return 'password';
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
return 'checkbox';
|
return 'checkbox';
|
||||||
case 'text':
|
case 'text':
|
||||||
return 'textarea';
|
return 'textarea';
|
||||||
|
case 'email':
|
||||||
|
return 'email';
|
||||||
case 'string':
|
case 'string':
|
||||||
return 'text';
|
return 'text';
|
||||||
case 'date':
|
case 'date':
|
||||||
@ -47,7 +51,7 @@ class EditForm extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
const source = getQueryParameters(this.props.location.search, 'source');
|
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', 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
|
// Remove `id` field
|
||||||
const displayedFields = merge(currentLayout, omit(currentSchema.fields, 'id'));
|
const displayedFields = merge(currentLayout, omit(currentSchema.fields, 'id'));
|
||||||
@ -71,7 +75,7 @@ class EditForm extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<Input
|
<Input
|
||||||
key={attr}
|
key={attr}
|
||||||
type={this.getInputType(details.type)}
|
type={get(layout, 'type', this.getInputType(details.type))}
|
||||||
label={get(layout, 'label') || details.label || ''}
|
label={get(layout, 'label') || details.label || ''}
|
||||||
name={attr}
|
name={attr}
|
||||||
customBootstrapClass={get(layout, 'className') || ''}
|
customBootstrapClass={get(layout, 'className') || ''}
|
||||||
|
@ -94,14 +94,18 @@ export class Edit extends React.Component {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
this.source = getQueryParameters(this.props.location.search, 'source');
|
||||||
this.layout = bindLayout.call(this, layout);
|
this.layout = bindLayout.call(this, layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const source = getQueryParameters(this.props.location.search, 'source');
|
|
||||||
const attributes =
|
const attributes =
|
||||||
get(this.props.models, ['models', this.props.match.params.slug.toLowerCase(), 'attributes']) ||
|
get(this.props.models, ['models', this.props.match.params.slug.toLowerCase(), 'attributes']) ||
|
||||||
get(this.props.models, ['plugins', source, 'models', this.props.match.params.slug.toLowerCase(), 'attributes']);
|
get(this.props.models, ['plugins', this.source, 'models', this.props.match.params.slug.toLowerCase(), 'attributes']);
|
||||||
|
|
||||||
|
if (this.source) {
|
||||||
|
this.layout = bindLayout.call(this, get(this.context.plugins.toJS(), `${this.source}.layout`, layout));
|
||||||
|
}
|
||||||
|
|
||||||
this.props.setInitialState();
|
this.props.setInitialState();
|
||||||
this.props.setCurrentModelName(this.props.match.params.slug.toLowerCase());
|
this.props.setCurrentModelName(this.props.match.params.slug.toLowerCase());
|
||||||
@ -111,7 +115,7 @@ export class Edit extends React.Component {
|
|||||||
if (this.props.match.params.id === 'create') {
|
if (this.props.match.params.id === 'create') {
|
||||||
this.props.setIsCreating();
|
this.props.setIsCreating();
|
||||||
} else {
|
} else {
|
||||||
this.props.loadRecord(this.props.match.params.id, source);
|
this.props.loadRecord(this.props.match.params.id, this.source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,8 +137,7 @@ export class Edit extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleChange = (e) => {
|
handleChange = (e) => {
|
||||||
const source = getQueryParameters(this.props.location.search, 'source');
|
const currentSchema = get(this.props.schema, [this.props.currentModelName]) || get(this.props.schema, ['plugins', this.source, this.props.currentModelName]);
|
||||||
const currentSchema = get(this.props.schema, [this.props.currentModelName]) || get(this.props.schema, ['plugins', source, this.props.currentModelName]);
|
|
||||||
|
|
||||||
let formattedValue = e.target.value;
|
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);
|
map(this.props.record.toJS(), (value, key) => form[key] = value);
|
||||||
const formErrors = checkFormValidity(form, this.props.formValidations.toJS());
|
const formErrors = checkFormValidity(form, this.props.formValidations.toJS());
|
||||||
|
|
||||||
const source = getQueryParameters(this.props.location.search, 'source');
|
|
||||||
|
|
||||||
if (isEmpty(formErrors)) {
|
if (isEmpty(formErrors)) {
|
||||||
this.props.editRecord(source);
|
this.props.editRecord(this.source);
|
||||||
} else {
|
} else {
|
||||||
this.props.setFormErrors(formErrors);
|
this.props.setFormErrors(formErrors);
|
||||||
}
|
}
|
||||||
@ -168,8 +169,7 @@ export class Edit extends React.Component {
|
|||||||
return <p>Loading...</p>;
|
return <p>Loading...</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const source = getQueryParameters(this.props.location.search, 'source');
|
const currentModel = get(this.props.models, ['models', this.props.currentModelName]) || get(this.props.models, ['plugins', this.source, 'models', this.props.currentModelName]);
|
||||||
const currentModel = get(this.props.models, ['models', this.props.currentModelName]) || get(this.props.models, ['plugins', source, 'models', this.props.currentModelName]);
|
|
||||||
|
|
||||||
// Plugin header config
|
// Plugin header config
|
||||||
const primaryKey = currentModel.primaryKey;
|
const primaryKey = currentModel.primaryKey;
|
||||||
|
@ -1 +1 @@
|
|||||||
module.exports = {};
|
export default ({});
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
"unique": true
|
"unique": true
|
||||||
},
|
},
|
||||||
"email": {
|
"email": {
|
||||||
"type": "string",
|
"type": "email",
|
||||||
"minLength": 6,
|
"minLength": 6,
|
||||||
"unique": true
|
"unique": true
|
||||||
},
|
},
|
||||||
@ -19,14 +19,14 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"type": "string",
|
"type": "password",
|
||||||
"minLength": 6
|
"minLength": 6
|
||||||
},
|
},
|
||||||
"resetPasswordToken": {
|
"resetPasswordToken": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"role": {
|
"role": {
|
||||||
"type": "string"
|
"type": "integer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user