diff --git a/src/components/Settings.js b/src/components/Settings.js
index 7cad2630..a789a49e 100644
--- a/src/components/Settings.js
+++ b/src/components/Settings.js
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import { withRouter } from 'react-router';
import { withStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
+import { connect } from 'react-redux';
import { FormGroup } from '@material-ui/core';
import { withTranslation } from 'react-i18next';
import Styles from '../Styles';
@@ -13,6 +14,7 @@ import Main from './common/Main';
import { SETTINGS_MAIN_ID } from '../config/selectors';
import SyncAdvancedSwitch from './space/sync/SyncAdvancedSwitch';
import StudentModeSwitch from './common/StudentModeSwitch';
+import { DEFAULT_STUDENT_MODE } from '../config/constants';
// eslint-disable-next-line react/prefer-stateless-function
export class Settings extends Component {
@@ -29,10 +31,15 @@ export class Settings extends Component {
i18n: PropTypes.shape({
changeLanguage: PropTypes.func.isRequired,
}).isRequired,
+ studentMode: PropTypes.bool,
+ };
+
+ static defaultProps = {
+ studentMode: DEFAULT_STUDENT_MODE,
};
render() {
- const { classes, t } = this.props;
+ const { classes, t, studentMode } = this.props;
return (
@@ -42,10 +49,10 @@ export class Settings extends Component {
-
+ {studentMode ? null : }
@@ -53,7 +60,15 @@ export class Settings extends Component {
}
}
-const StyledComponent = withStyles(Styles, { withTheme: true })(Settings);
+const mapStateToProps = ({ authentication }) => ({
+ studentMode: authentication.getIn(['user', 'settings', 'studentMode']),
+});
+
+const ConnectedComponent = connect(mapStateToProps, null)(Settings);
+
+const StyledComponent = withStyles(Styles, { withTheme: true })(
+ ConnectedComponent
+);
const TranslatedComponent = withTranslation()(StyledComponent);
diff --git a/src/components/__snapshots__/Settings.test.js.snap b/src/components/__snapshots__/Settings.test.js.snap
index e540ef40..4ce88813 100644
--- a/src/components/__snapshots__/Settings.test.js.snap
+++ b/src/components/__snapshots__/Settings.test.js.snap
@@ -15,10 +15,10 @@ exports[` renders correctly 1`] = `
-
+
diff --git a/src/components/common/MediaCard.js b/src/components/common/MediaCard.js
index 48b4e784..39a6ede4 100644
--- a/src/components/common/MediaCard.js
+++ b/src/components/common/MediaCard.js
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
+import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
import Card from '@material-ui/core/Card';
import CardActionArea from '@material-ui/core/CardActionArea';
@@ -16,7 +17,7 @@ import ClearButton from '../space/ClearButton';
import ExportButton from '../space/ExportButton';
import SyncButton from '../space/SyncButton';
import Text from './Text';
-import { MIN_CARD_WIDTH } from '../../config/constants';
+import { MIN_CARD_WIDTH, DEFAULT_STUDENT_MODE } from '../../config/constants';
import {
buildSpaceCardId,
SPACE_DESCRIPTION_EXPAND_BUTTON_CLASS,
@@ -56,13 +57,33 @@ const styles = theme => ({
});
export const MediaCard = props => {
- const { classes, image, text, viewLink, space, showActions } = props;
+ const {
+ classes,
+ image,
+ text,
+ viewLink,
+ space,
+ showActions,
+ studentMode,
+ } = props;
const { id, name } = space;
const [expanded, setExpanded] = React.useState(false);
const handleExpandClick = () => {
setExpanded(!expanded);
};
+ const renderTeacherActions = () => {
+ if (!studentMode) {
+ return (
+ <>
+
+
+ >
+ );
+ }
+ return null;
+ };
+
return (
@@ -88,9 +109,8 @@ export const MediaCard = props => {
{showActions && (
-
-
+ {renderTeacherActions()}
{text && (
({
+ studentMode: authentication.getIn(['user', 'settings', 'studentMode']),
+});
+
+const ConnectedComponent = connect(mapStateToProps, null)(MediaCard);
+
+export default withStyles(styles)(ConnectedComponent);
diff --git a/src/components/common/__snapshots__/MediaCard.test.js.snap b/src/components/common/__snapshots__/MediaCard.test.js.snap
index 29080fae..9bf9800f 100644
--- a/src/components/common/__snapshots__/MediaCard.test.js.snap
+++ b/src/components/common/__snapshots__/MediaCard.test.js.snap
@@ -89,9 +89,6 @@ exports[` with showActions = true with text defined r
-
with showActions = true with text defined r
}
}
/>
+
@@ -161,9 +161,6 @@ exports[` with showActions = true with text undefined
-
with showActions = true with text undefined
}
}
/>
+
diff --git a/src/components/space/SpaceHeader.js b/src/components/space/SpaceHeader.js
index ee0cffad..fe172ff4 100644
--- a/src/components/space/SpaceHeader.js
+++ b/src/components/space/SpaceHeader.js
@@ -25,6 +25,7 @@ import {
SPACE_PREVIEW_ICON_CLASS,
DRAWER_BUTTON_ID,
} from '../../config/selectors';
+import { DEFAULT_STUDENT_MODE } from '../../config/constants';
class SpaceHeader extends Component {
static propTypes = {
@@ -45,6 +46,11 @@ class SpaceHeader extends Component {
handleDrawerOpen: PropTypes.func.isRequired,
dispatchSaveSpace: PropTypes.func.isRequired,
t: PropTypes.func.isRequired,
+ studentMode: PropTypes.bool,
+ };
+
+ static defaultProps = {
+ studentMode: DEFAULT_STUDENT_MODE,
};
handleSave = () => {
@@ -138,6 +144,20 @@ class SpaceHeader extends Component {
return null;
}
+ renderTeacherButtons() {
+ const { studentMode } = this.props;
+ if (!studentMode) {
+ return (
+ <>
+ {this.renderDeleteButton()}
+ {this.renderSyncButton()}
+ {this.renderSaveButton()}
+ >
+ );
+ }
+ return null;
+ }
+
render() {
const {
openDrawer,
@@ -168,11 +188,9 @@ class SpaceHeader extends Component {
{name}
{this.renderClearButton()}
- {this.renderSyncButton()}
{this.renderPreviewIcon()}
- {this.renderDeleteButton()}
{this.renderExportButton()}
- {this.renderSaveButton()}
+ {this.renderTeacherButtons()}
@@ -180,10 +198,11 @@ class SpaceHeader extends Component {
}
}
-const mapStateToProps = ({ Space }) => ({
+const mapStateToProps = ({ Space, authentication }) => ({
space: Space.get('current')
.get('content')
.toJS(),
+ studentMode: authentication.getIn(['user', 'settings', 'studentMode']),
});
const mapDispatchToProps = {