Skip to content

Commit

Permalink
feat(Home): Allows site admins to quickly leave organisations no long…
Browse files Browse the repository at this point in the history
…er of interest from the home screen. (#1444 - [LL-166](https://learningpool.atlassian.net/browse/LL-166))
  • Loading branch information
h-kanazawa authored and ryasmi committed Sep 6, 2019
1 parent 46213c6 commit d6091c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
21 changes: 18 additions & 3 deletions ui/src/containers/Home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand Down Expand Up @@ -84,15 +85,29 @@ 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);

const name = organisation.get('name');

const rightActions = [];
if (organisation.get('expiration') && moment(organisation.get('expiration')).isBefore(moment())) {
rightActions.push(<span style={{ color: 'red' }}>Expired</span>);
rightActions.push(
<span
key="expired"
style={{ color: 'red' }}>
Expired
</span>
);
}
if (isSiteAdmin) {
rightActions.push(
<OrgMemberButton
key="member"
schema="organisation"
id={organisation.get('_id')} />
);
}

return (
Expand Down
4 changes: 2 additions & 2 deletions ui/src/containers/OrgMemberButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
? <button
Expand All @@ -60,4 +60,4 @@ const render = ({ handleJoin, handleLeave, model, userOrgs }) => {
</button>;
};

export default enhance(render);
export default enhance(OrgMemberButton);

0 comments on commit d6091c5

Please sign in to comment.