-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Group tree views refactored and improved.
- Loading branch information
1 parent
6e7302c
commit 10ad73b
Showing
26 changed files
with
575 additions
and
596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { FormattedMessage, injectIntl } from 'react-intl'; | ||
import { Link } from 'react-router-dom'; | ||
import { OverlayTrigger, Tooltip } from 'react-bootstrap'; | ||
|
||
import GroupsTreeNode from './GroupsTreeNode'; | ||
import Button, { TheButtonGroup } from '../../widgets/TheButton'; | ||
|
||
import { GroupIcon, AssignmentsIcon, EditIcon } from '../../icons'; | ||
import withLinks from '../../../helpers/withLinks'; | ||
import { hasPermissions } from '../../../helpers/common'; | ||
|
||
import './styles.css'; | ||
|
||
const defaultButtonsCreator = ( | ||
group, | ||
selectedGroupId, | ||
{ GROUP_EDIT_URI_FACTORY, GROUP_INFO_URI_FACTORY, GROUP_DETAIL_URI_FACTORY } | ||
) => | ||
group.id !== selectedGroupId ? ( | ||
<TheButtonGroup> | ||
{hasPermissions(group, 'update') && ( | ||
<OverlayTrigger | ||
placement="bottom" | ||
overlay={ | ||
<Tooltip id={`info-${group.id}`}> | ||
<FormattedMessage id="app.editGroup.titleShort" defaultMessage="Edit Group" /> | ||
</Tooltip> | ||
}> | ||
<Link to={GROUP_EDIT_URI_FACTORY(group.id)}> | ||
<Button variant="warning" size="xs"> | ||
<EditIcon smallGapLeft smallGapRight /> | ||
</Button> | ||
</Link> | ||
</OverlayTrigger> | ||
)} | ||
|
||
<OverlayTrigger | ||
placement="bottom" | ||
overlay={ | ||
<Tooltip id={`info-${group.id}`}> | ||
<FormattedMessage id="app.group.info" defaultMessage="Group Info" /> | ||
</Tooltip> | ||
}> | ||
<Link to={GROUP_INFO_URI_FACTORY(group.id)}> | ||
<Button variant="primary" size="xs"> | ||
<GroupIcon /> | ||
</Button> | ||
</Link> | ||
</OverlayTrigger> | ||
|
||
{hasPermissions(group, 'viewDetail') && ( | ||
<OverlayTrigger | ||
placement="bottom" | ||
overlay={ | ||
<Tooltip id={`info-${group.id}`}> | ||
<FormattedMessage id="app.group.assignments" defaultMessage="Assignments" /> | ||
</Tooltip> | ||
}> | ||
<Link to={GROUP_DETAIL_URI_FACTORY(group.id)}> | ||
<Button variant="primary" size="xs"> | ||
<AssignmentsIcon smallGapLeft smallGapRight /> | ||
</Button> | ||
</Link> | ||
</OverlayTrigger> | ||
)} | ||
</TheButtonGroup> | ||
) : null; | ||
|
||
const GroupsTree = React.memo( | ||
({ | ||
groups, | ||
selectedGroupId = null, | ||
autoloadAuthors = false, | ||
isExpanded = false, | ||
buttonsCreator = defaultButtonsCreator, | ||
}) => ( | ||
<ul className="groupTree nav flex-column"> | ||
{groups.map(group => ( | ||
<GroupsTreeNode | ||
key={group.id} | ||
group={group} | ||
selectedGroupId={selectedGroupId} | ||
autoloadAuthors={autoloadAuthors} | ||
isExpanded={isExpanded} | ||
buttonsCreator={buttonsCreator} | ||
/> | ||
))} | ||
</ul> | ||
) | ||
); | ||
|
||
GroupsTree.propTypes = { | ||
groups: PropTypes.array.isRequired, | ||
selectedGroupId: PropTypes.string, | ||
autoloadAuthors: PropTypes.bool, | ||
isExpanded: PropTypes.bool, | ||
buttonsCreator: PropTypes.func, | ||
links: PropTypes.object, | ||
intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired, | ||
}; | ||
|
||
export default withLinks(injectIntl(GroupsTree)); |
Oops, something went wrong.