-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
342 additions
and
32 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 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 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
57 changes: 57 additions & 0 deletions
57
rdmo/projects/assets/js/components/helper/ProjectsPopover.js
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,57 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { Overlay, Popover } from 'react-bootstrap' | ||
|
||
import { getOverlay } from '../../utils' | ||
|
||
const ProjectsPopover = ({ last, overlay, projectsActions, setCurrentOverlay, show = true, target }) => { | ||
if (show === false) { | ||
return null | ||
} | ||
|
||
const { content, id, order, placement, title } = getOverlay({ id: overlay }) | ||
|
||
const handleDismiss = () => { | ||
setCurrentOverlay({'overlay': '', 'last': false}) | ||
projectsActions.dismissOverlay() | ||
} | ||
|
||
const handleNext = () => { | ||
const nextOverlay = getOverlay({ order: order + 1}) | ||
setCurrentOverlay({'overlay': nextOverlay.id, 'last': nextOverlay.order === 4 ? true : false}) | ||
projectsActions.nextOverlay() | ||
} | ||
|
||
return ( | ||
<Overlay | ||
show={show} | ||
placement={placement} | ||
container={target} | ||
> | ||
<Popover | ||
id={id} | ||
placement={placement} | ||
title={title} | ||
> | ||
<div>{content}</div> | ||
<div className="popover-buttons"> | ||
<button type="button" className={`btn btn-sm popover-dismiss ${last ? 'btn-primary' : ''}`} onClick={handleDismiss} title="Dismiss all tips on this page">{gettext('Dismiss')}</button> | ||
{!last && | ||
<button type="button" className="btn btn-primary btn-sm popover-next" onClick={handleNext}>{gettext('Next tip')}</button> | ||
} | ||
</div> | ||
</Popover> | ||
</Overlay> | ||
) | ||
} | ||
|
||
ProjectsPopover.propTypes = { | ||
last: PropTypes.bool, | ||
overlay: PropTypes.string.isRequired, | ||
projectsActions: PropTypes.object, | ||
setCurrentOverlay: PropTypes.func, | ||
show: PropTypes.bool, | ||
target: PropTypes.instanceOf(Element), | ||
} | ||
|
||
export default ProjectsPopover |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { default as PendingInvitations } from './PendingInvitations' | ||
export { default as ProjectFilters } from './ProjectFilters' | ||
export { default as ProjectImport } from './ProjectImport' | ||
export { default as ProjectsPopover } from './ProjectsPopover' | ||
export { default as Table } from './Table' |
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 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 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 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,18 @@ | ||
import { language } from 'rdmo/core/assets/js/utils' | ||
import OVERLAYS from './overlays' | ||
|
||
const getOverlay = ({ order, id }) => { | ||
const overlay = OVERLAYS.find(config => (id ? config.id === id : config.order === order)) | ||
|
||
if (overlay) { | ||
return { | ||
...overlay, | ||
content: overlay.content[language], | ||
title: overlay.title[language] | ||
} | ||
} | ||
|
||
return null | ||
} | ||
|
||
export default getOverlay |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export * from './constants' | ||
export { default as getOverlay } from './getOverlay' | ||
export * from './getProjectTitlePath' | ||
export { default as getUserRoles } from './getUserRoles' | ||
export { default as userIsManager } from './userIsManager' | ||
export { default as OVERLAYS } from './overlays' | ||
export { default as TRANSLATIONS } from './translations' | ||
export { default as userIsManager } from './userIsManager' |
Oops, something went wrong.