Skip to content

Commit

Permalink
Add Exercise button (on the global exercise page) is now visible only…
Browse files Browse the repository at this point in the history
… to superadmin.
  • Loading branch information
Martin Krulis committed Oct 24, 2017
1 parent 170fcab commit 8f72a30
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pages/Exercises/Exercises.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import PageContent from '../../components/layout/PageContent';
import Box from '../../components/widgets/Box';
import { AddIcon, EditIcon } from '../../components/icons';
import { fetchManyStatus } from '../../redux/selectors/exercises';
import { canEditExercise } from '../../redux/selectors/users';
import { canEditExercise, isSuperAdmin } from '../../redux/selectors/users';
import { loggedInUserIdSelector } from '../../redux/selectors/auth';
import {
fetchExercises,
Expand Down Expand Up @@ -45,6 +45,7 @@ class Exercises extends Component {

render() {
const {
isSuperAdmin,
isAuthorOfExercise,
fetchStatus,
search,
Expand Down Expand Up @@ -121,6 +122,7 @@ class Exercises extends Component {
/>
}
footer={
isSuperAdmin &&
<p className="text-center">
<Button
bsStyle="success"
Expand Down Expand Up @@ -185,6 +187,7 @@ class Exercises extends Component {
Exercises.propTypes = {
loadAsync: PropTypes.func.isRequired,
createExercise: PropTypes.func.isRequired,
isSuperAdmin: PropTypes.bool.isRequired,
isAuthorOfExercise: PropTypes.func.isRequired,
push: PropTypes.func.isRequired,
links: PropTypes.object.isRequired,
Expand All @@ -198,6 +201,7 @@ export default withLinks(
const userId = loggedInUserIdSelector(state);
return {
fetchStatus: fetchManyStatus(state),
isSuperAdmin: isSuperAdmin(userId)(state),
isAuthorOfExercise: exerciseId =>
canEditExercise(userId, exerciseId)(state)
};
Expand Down

0 comments on commit 8f72a30

Please sign in to comment.