From d6091c55b4a4971139acda88a7052811f025a95c Mon Sep 17 00:00:00 2001 From: h-kanazawa Date: Fri, 6 Sep 2019 10:00:23 +0100 Subject: [PATCH] feat(Home): Allows site admins to quickly leave organisations no longer of interest from the home screen. (https://github.com/LearningLocker/learninglocker/pull/1444 - [LL-166](https://learningpool.atlassian.net/browse/LL-166)) --- ui/src/containers/Home/index.js | 21 ++++++++++++++++++--- ui/src/containers/OrgMemberButton/index.js | 4 ++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ui/src/containers/Home/index.js b/ui/src/containers/Home/index.js index f5b51ad54d..5de6d265f4 100644 --- a/ui/src/containers/Home/index.js +++ b/ui/src/containers/Home/index.js @@ -11,6 +11,7 @@ import { Map, List as ImmutList, fromJS } from 'immutable'; import { AutoSizer, List as VirtualList, InfiniteLoader } from 'react-virtualized'; import { withProps, compose, withState } from 'recompose'; import { actions as routerActions } from 'redux-router5'; +import moment from 'moment'; import { isSiteAdminSelector, authenticationSelector, logout, orgLoginStart, loggedInUserSelector } from 'ui/redux/modules/auth'; import { queryStringToQuery } from 'ui/redux/modules/search'; import { withSchema } from 'ui/utils/hocs'; @@ -19,7 +20,7 @@ import FullPageBackground from 'ui/components/FullPageBackground'; import AuthContainer from 'ui/containers/AuthContainer'; import smallLogo from 'ui/static/smallLogo.png'; import Register from 'ui/containers/Register'; -import moment from 'moment'; +import OrgMemberButton from 'ui/containers/OrgMemberButton'; import styles from './styles.css'; class Home extends Component { @@ -84,7 +85,7 @@ class Home extends Component { } renderOrg = ({ key, style, index }) => { - const { models } = this.props; + const { models, isSiteAdmin } = this.props; if (models.has(index)) { const organisation = models.get(index); @@ -92,7 +93,21 @@ class Home extends Component { const rightActions = []; if (organisation.get('expiration') && moment(organisation.get('expiration')).isBefore(moment())) { - rightActions.push(Expired); + rightActions.push( + + Expired + + ); + } + if (isSiteAdmin) { + rightActions.push( + + ); } return ( diff --git a/ui/src/containers/OrgMemberButton/index.js b/ui/src/containers/OrgMemberButton/index.js index 2b69bf4a60..1940c2cd3a 100644 --- a/ui/src/containers/OrgMemberButton/index.js +++ b/ui/src/containers/OrgMemberButton/index.js @@ -41,7 +41,7 @@ const enhance = compose( }) ); -const render = ({ handleJoin, handleLeave, model, userOrgs }) => { +const OrgMemberButton = ({ handleJoin, handleLeave, model, userOrgs }) => { const hasOrg = userOrgs.includes(model.get('_id')); return hasOrg ? ; }; -export default enhance(render); +export default enhance(OrgMemberButton);