diff --git a/.gitignore b/.gitignore index eff774450..3b59ff2f5 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist/coral-admin/bundle.js *.iml .env gaba.cfg +.idea/ diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index 5d21fc819..a0b43361d 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -8,7 +8,7 @@ import CommunityContainer from 'containers/Community/CommunityContainer'; import LayoutContainer from 'containers/LayoutContainer'; const routes = ( - + diff --git a/client/coral-admin/src/actions/auth.js b/client/coral-admin/src/actions/auth.js new file mode 100644 index 000000000..c5a03132f --- /dev/null +++ b/client/coral-admin/src/actions/auth.js @@ -0,0 +1,19 @@ +import * as actions from '../constants/auth'; +import {base, handleResp, getInit} from '../helpers/response'; + +// Check Login + +const checkLoginRequest = () => ({type: actions.CHECK_LOGIN_REQUEST}); +const checkLoginSuccess = (user, isAdmin) => ({type: actions.CHECK_LOGIN_SUCCESS, user, isAdmin}); +const checkLoginFailure = error => ({type: actions.CHECK_LOGIN_FAILURE, error}); + +export const checkLogin = () => dispatch => { + dispatch(checkLoginRequest()); + fetch(`${base}/auth`, getInit('GET')) + .then(handleResp) + .then(user => { + const isAdmin = !!user.roles.filter(i => i === 'admin').length; + dispatch(checkLoginSuccess(user, isAdmin)); + }) + .catch(error => dispatch(checkLoginFailure(error))); +}; diff --git a/client/coral-admin/src/components/Comment.js b/client/coral-admin/src/components/Comment.js index 154d68134..80c67aebd 100644 --- a/client/coral-admin/src/components/Comment.js +++ b/client/coral-admin/src/components/Comment.js @@ -1,11 +1,11 @@ import React from 'react'; -import {Button, Icon} from 'react-mdl'; import timeago from 'timeago.js'; import styles from './CommentList.css'; import I18n from 'coral-framework/modules/i18n/i18n'; import translations from '../translations.json'; import Linkify from 'react-linkify'; +import {FabButton} from 'coral-ui'; const linkify = new Linkify(); @@ -14,7 +14,7 @@ export default props => { const links = linkify.getMatches(props.comment.get('body')); return ( -
  • +
  • person @@ -26,12 +26,12 @@ export default props => { {links ? Contains Link : null}
    - {props.actions.map(action => canShowAction(action, props.comment) ? ( - + /> ) : null)}
    diff --git a/client/coral-admin/src/components/CommentList.js b/client/coral-admin/src/components/CommentList.js index 819de62b0..e4682252d 100644 --- a/client/coral-admin/src/components/CommentList.js +++ b/client/coral-admin/src/components/CommentList.js @@ -112,15 +112,15 @@ export default class CommentList extends React.Component { } render () { - const {singleView, commentIds, comments, hideActive} = this.props; + const {singleView, commentIds, comments, hideActive, key} = this.props; const {active} = this.state; return ( -