mirror of
https://github.com/strapi/strapi.git
synced 2025-08-04 14:56:22 +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`
|
||||
- `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": {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -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,
|
||||
|
@ -250,7 +250,7 @@ class Input extends React.Component { // eslint-disable-line react/prefer-statel
|
||||
<input
|
||||
className={`form-control ${!this.props.deactivateErrorHighlight && !isEmpty(this.state.errors) ? 'is-invalid': ''}`}
|
||||
onChange={this.props.onChange}
|
||||
value={this.props.value}
|
||||
value={type === 'password' ? '********' : this.props.value}
|
||||
name={this.props.name}
|
||||
id={this.props.label}
|
||||
onBlur={handleBlur}
|
||||
|
@ -14,7 +14,9 @@ module.exports = mongoose => {
|
||||
convertType: mongooseType => {
|
||||
switch (mongooseType.toLowerCase()) {
|
||||
case 'string':
|
||||
case 'password':
|
||||
case 'text':
|
||||
case 'email':
|
||||
return 'String';
|
||||
case 'integer':
|
||||
case 'biginteger':
|
||||
|
@ -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));
|
||||
|
@ -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 (
|
||||
<Input
|
||||
key={attr}
|
||||
type={this.getInputType(details.type)}
|
||||
type={get(layout, 'type', this.getInputType(details.type))}
|
||||
label={get(layout, 'label') || details.label || ''}
|
||||
name={attr}
|
||||
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);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const source = getQueryParameters(this.props.location.search, 'source');
|
||||
const 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.setCurrentModelName(this.props.match.params.slug.toLowerCase());
|
||||
@ -111,7 +115,7 @@ export class Edit extends React.Component {
|
||||
if (this.props.match.params.id === 'create') {
|
||||
this.props.setIsCreating();
|
||||
} 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) => {
|
||||
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 <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', 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;
|
||||
|
@ -1 +1 @@
|
||||
module.exports = {};
|
||||
export default ({});
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user