Merge branch 'user-permissions' of https://github.com/strapi/strapi into user-permissions

This commit is contained in:
Jim Laurie 2017-12-04 16:51:32 +01:00
commit b54a2e087c
19 changed files with 107 additions and 63 deletions

View File

@ -1,6 +1,8 @@
# Don't check auto-generated stuff into git
coverage
node_modules
build
plugins.json
stats.json
package-lock.json

View File

@ -62,9 +62,9 @@ export class AdminPage extends React.Component { // eslint-disable-line react/pr
this.props.history.push(`/plugins/users-permissions/auth/${endPoint}`);
}
if (!this.isUrlProtected(props) && includes(props.location.pathname, 'login') && !this.hasAdminUser()) {
this.props.history.push('/plugins/users-permissions/auth/register');
}
// if (!this.isUrlProtected(props) && includes(props.location.pathname, 'login') && !this.hasAdminUser()) {
// this.props.history.push('/plugins/users-permissions/auth/register');
// }
if (!this.isUrlProtected(props) && includes(props.location.pathname, 'register') && this.hasAdminUser()) {
this.props.history.push('/plugins/users-permissions/auth/login');

View File

@ -14,7 +14,7 @@ import cn from 'classnames';
import { get, isUndefined, map } from 'lodash';
// Design
import Input from 'components/Input';
// import Input from 'components/Input';
import PluginCard from 'components/PluginCard';
import PluginHeader from 'components/PluginHeader';
@ -57,7 +57,7 @@ export class InstallPluginPage extends React.Component { // eslint-disable-line
description={{ id: 'app.components.InstallPluginPage.description' }}
actions={[]}
/>
<div className={cn('row', styles.inputContainer)}>
{/*}<div className={cn('row', styles.inputContainer)}>
<Input
customBootstrapClass="col-md-12"
label="app.components.InstallPluginPage.InputSearch.label"
@ -68,7 +68,7 @@ export class InstallPluginPage extends React.Component { // eslint-disable-line
validations={{}}
value={this.props.search}
/>
</div>
</div>*/}
<div className={cn('row', styles.wrapper)}>
{map(this.props.availablePlugins, (plugin) => (
<PluginCard
@ -95,8 +95,8 @@ InstallPluginPage.propTypes = {
didFetchPlugins: PropTypes.bool.isRequired,
getPlugins: PropTypes.func.isRequired,
history: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
search: PropTypes.string.isRequired,
// onChange: PropTypes.func.isRequired,
// search: PropTypes.string.isRequired,
};
const mapStateToProps = makeSelectInstallPluginPage();

View File

@ -11,7 +11,16 @@ import { connect } from 'react-redux';
import { bindActionCreators, compose } from 'redux';
import { createStructuredSelector } from 'reselect';
import PropTypes from 'prop-types';
import { map, get, isObject, isEmpty, replace, toNumber, toString } from 'lodash';
import {
get,
includes,
isObject,
isEmpty,
map,
replace,
toNumber,
toString,
} from 'lodash';
import { router } from 'app';
// Components.
@ -121,7 +130,7 @@ export class Edit extends React.Component {
componentWillReceiveProps(nextProps) {
if (this.props.editSuccess !== nextProps.editSuccess) {
if (!isEmpty(this.props.location.search)) {
if (!isEmpty(this.props.location.search) && includes(this.props.location.search, '?redirectUrl')) {
router.push(replace(this.props.location.search, '?redirectUrl=', ''));
} else {
router.push(replace(this.props.location.pathname, 'create', ''));
@ -169,7 +178,6 @@ export class Edit extends React.Component {
}
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;
const mainField = get(currentModel, 'info.mainField') || primaryKey;

View File

@ -71,8 +71,6 @@ export function* editRecord(action) {
params,
});
console.log(recordCleaned);
yield put(recordEdited());
strapi.notification.success('content-manager.success.record.save');
} catch (err) {

View File

@ -5,7 +5,8 @@
background-color: rgba(16, 22, 34, 0.02);
border: 1px solid #E3E9F3;
border-radius: 0.25rem;
border-bottom-left-radius: 0;
border-bottom-left-radius: 0!important;
border-bottom-right-radius: 0!important;
color: rgba(16, 22, 34, 0.5);
line-height: 3.2rem;
font-size: 1.3rem;
@ -14,6 +15,7 @@
text-transform: capitalize;
-moz-appearance: none;
-webkit-appearance: none;
box-shadow: 0px 2px 1px rgba(104, 118, 142, 0.05);
&:before {
content: '\F002';
display: inline-table;
@ -50,7 +52,7 @@
line-height: 3.4rem;
font-size: 1.3rem;
font-family: 'Lato' !important;
box-shadow: 0px 1px 1px rgba(104, 118, 142, 0.05);
box-shadow: 0px 2px 1px rgba(104, 118, 142, 0.05);
&:focus {
border-color: #78caff;
}
@ -61,8 +63,8 @@
height: 16.3rem;
overflow: scroll;
border: 1px solid #E3E9F3;
border-top-left-radius: 0;
border-top-right-radius: 0;
border-top-left-radius: 0!important;
border-top-right-radius: 0!important;
border-top: none;
border-radius: 0.25rem;
> ul {

View File

@ -6,18 +6,26 @@
import React from 'react';
import PropTypes from 'prop-types';
import { router } from 'app';
import styles from './styles.scss';
function InputSearchLi({ onClick, isAdding, item }) {
const icon = isAdding ? 'fa-plus' : 'fa-minus-circle';
const liStyle = isAdding ? { cursor: 'pointer' } : {};
const handleClick = isAdding ? () => onClick(item) : () => {};
const path = `/plugins/content-manager/user/${item.id}?redirectUrl=/plugins/content-manager/user/?page=1&limit=20&sort=id&source=users-permissions`;
const handleGoto = (e) => {
e.preventDefault();
e.stopPropagation();
router.push(path);
};
return (
<li className={styles.li} style={liStyle} onClick={handleClick}>
<div>
<div>
<div className={styles.container}>
{item.username}
<i className="fa fa-external-link" onClick={handleGoto} />
</div>
<div
onClick={(e) => {

View File

@ -28,3 +28,13 @@
}
}
}
.container {
>i {
margin-left: 10px;
color: #1C5DE7;
font-size: 10px;
cursor: pointer;
}
}

View File

@ -25,10 +25,13 @@ class ListRow extends React.Component { // eslint-disable-line react/prefer-stat
}
}
// Roles that can't be deleted
// Roles that can't be deleted && modified
// Don't delete this line
protectedRoleIDs = ['0'];
// Roles that can't be deleted;
undeletableIDs = ['1'];
generateContent = () => {
let icons = [
{
@ -47,6 +50,10 @@ class ListRow extends React.Component { // eslint-disable-line react/prefer-stat
icons = [];
}
if (includes(this.undeletableIDs, get(this.props.item, 'id').toString())) {
icons = [{ icoType: 'pencil', onClick: this.handleClick }];
}
return (
<div className={cn('row', styles.wrapper)}>
<div className="col-md-2">

View File

@ -7,7 +7,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Collapse } from 'reactstrap';
import { capitalize, get, map } from 'lodash';
import { capitalize, get, isEmpty, map } from 'lodash';
import { FormattedMessage } from 'react-intl';
import Controller from 'components/Controller';
@ -26,7 +26,10 @@ class Plugin extends React.Component { // eslint-disable-line react/prefer-state
handleClick = () => {
this.props.changePluginSelected(this.props.name);
this.setState({ collapse: !this.state.collapse });
if (!isEmpty(get(this.props.plugin, 'controllers'))) {
this.setState({ collapse: !this.state.collapse });
}
if (this.state.collapse) {
this.context.resetShouldDisplayPoliciesHint();
@ -46,9 +49,9 @@ class Plugin extends React.Component { // eslint-disable-line react/prefer-state
<i className={`fa fa-${icon}`} />
</div>
) : ''}
<span className={styles.name}>{this.props.name}</span>
<div className={styles.name} style={{ width:'30%'}}>{this.props.name}</div>
&nbsp;&nbsp;
<span className={styles.description}>
<div className={styles.description}>
{this.props.name === 'application' ? (
<FormattedMessage
id="users-permissions.Plugin.permissions.application.description"
@ -59,7 +62,7 @@ class Plugin extends React.Component { // eslint-disable-line react/prefer-state
values={{ name: capitalize(this.props.name) }}
/>
)}
</span>
</div>
</div>
<div className={this.state.collapse ? styles.chevronUp : styles.chevronDown}>
</div>

View File

@ -46,9 +46,17 @@
> div:not(:first-child) {
padding-top: 2.3rem;
}
> div:last-child {
padding-bottom: 1.8rem;
}
}
.description {
// width: 50%;
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: #8B91A0;
font-size: 12px;
font-weight: 400;

View File

@ -29,7 +29,7 @@ class Policies extends React.Component { // eslint-disable-line react/prefer-sta
return (
<div className={cn('col-md-5',styles.policies)}>
<div className="container-fluid">
<div className="row">
<div className={cn('row', styles.inputWrapper)}>
<div className={cn('col-md-12', styles.header)}>
<FormattedMessage id={`${baseTitle}.${title}`} />
</div>

View File

@ -7,6 +7,14 @@
margin-bottom: 1.1rem;
padding-top: 2.8rem;
font-size: 18px;
font-weight: 900;
font-weight: 800;
line-height: 3.6rem;
}
.inputWrapper {
> div:nth-child(2) {
> label {
font-weight: 800!important;
}
}
}

View File

@ -60,6 +60,9 @@ export class AuthPage extends React.Component { // eslint-disable-line react/pre
// NOTE: prepare for comfirm email;
// this.props.history.push(`/plugins/users-permissions/auth/register-success/${this.props.modifiedData.email}`);
break;
case 'forgot-password':
console.log('fuck');
break;
default:
}
@ -134,6 +137,9 @@ export class AuthPage extends React.Component { // eslint-disable-line react/pre
render() {
const inputs = get(form, ['form', this.props.match.params.authType]);
const divStyle = this.props.match.params.authType === 'register' ? { marginTop: '3.2rem' } : { marginTop: '.9rem' };
const withLogo = this.props.match.params.authType === 'register' ? (
<div className={styles.logoContainer}><img src={LogoStrapi} alt="logo" /></div>
) : '';
const headerDescription = this.props.match.params.authType === 'register' ?
<FormattedMessage id="users-permissions.Auth.header.register.description" />
: <span />;
@ -181,6 +187,7 @@ export class AuthPage extends React.Component { // eslint-disable-line react/pre
{this.renderLink()}
</div>
</div>
{withLogo}
</div>
);
}

View File

@ -77,3 +77,13 @@
}
}
}
.logoContainer {
position: absolute;
bottom: 20px;
left: 10px;
> img {
height: 20px;
}
}

View File

@ -17,12 +17,12 @@
"Auth.form.login.password.label": "Password",
"Auth.form.login.rememberMe.label": "Remember me",
"Auth.form.login.username.label": "Username",
"Auth.form.login.username.placeholder": "Soupette",
"Auth.form.login.username.placeholder": "John Doe",
"Auth.form.register.email.label": "Email",
"Auth.form.register.email.placeholder": "johndoe@gmail.com",
"Auth.form.register.username.label": "Username",
"Auth.form.register.username.placeholder": "Soupette",
"Auth.form.register.username.placeholder": "John Doe",
"Auth.form.register.password.label": "Password",
"Auth.form.register.confirmPassword.label": "Confirmation Password",
@ -114,7 +114,7 @@
"Policies.InputSelect.empty": "None",
"Policies.InputSelect.label": "Allow to perform this action for:",
"Policies.header.hint": "Select the application's actions or the plugin's actions and put your mouse over to display the bounded route",
"Policies.header.hint": "Select the application's actions or the plugin's actions and click on the cog icon to display the bounded route",
"Policies.header.title": "Advanced settings",
"PopUpForm.button.cancel": "Cancel",

View File

@ -17,12 +17,12 @@
"Auth.form.login.password.label": "Mot de Passe",
"Auth.form.login.rememberMe.label": "Se souvenir de moi",
"Auth.form.login.username.label": "Username",
"Auth.form.login.username.placeholder": "Soupette",
"Auth.form.login.username.placeholder": "John Doe",
"Auth.form.register.email.label": "Email",
"Auth.form.register.email.placeholder": "johndoe@gmail.com",
"Auth.form.register.username.label": "Username",
"Auth.form.register.username.placeholder": "Soupette",
"Auth.form.register.username.placeholder": "John Doe",
"Auth.form.register.password.label": "Mot de Passe",
"Auth.form.register.confirmPassword.label": "Confirmez le Mot de Passe",
@ -115,8 +115,8 @@
"Policies.InputSelect.empty": "Aucune",
"Policies.InputSelect.label": "Autorisez cette action pour :",
"Policies.header.hint": "Sélectionnez ...",
"Policies.header.tile": "Paramètres avancés",
"Policies.header.hint": "Sélectionnez les actions de l'application ou d'un plugin et cliquer sur l'icon de paramètres pour voir les routes associées à cette action",
"Policies.header.title": "Paramètres avancés",
"popUpForm.button.cancel": "Annuler",
"popUpForm.button.save": "Sauvegarder",

View File

@ -256,35 +256,8 @@
}
},
"application": {
"controllers": {
"product": {
"find": {
"enabled": true,
"policy": ""
},
"findOne": {
"enabled": true,
"policy": ""
},
"create": {
"enabled": true,
"policy": ""
},
"update": {
"enabled": true,
"policy": ""
},
"destroy": {
"enabled": true,
"policy": ""
},
"identity": {
"enabled": true,
"policy": ""
}
}
}
"controllers": {}
}
}
}
}
}

View File

@ -47,7 +47,7 @@ module.exports = {
return ctx.badRequest(null, [{ messages: [{ id: 'Bad request' }] }]);
}
if (role === '0') {
if (role === '0' || role === '1') {
return ctx.badRequest(null, [{ messages: [{ id: 'Unauthorized' }] }]);
}