2021-03-12 05:23:46 -05:00
|
|
|
import { Button, Modal, Grid } from 'react-bootstrap'
|
2021-04-22 05:50:41 -04:00
|
|
|
import { Trans } from 'react-i18next'
|
2021-03-12 05:23:46 -05:00
|
|
|
import ShareModalBody from './share-modal-body'
|
|
|
|
import Icon from '../../../shared/components/icon'
|
|
|
|
import AccessibleModal from '../../../shared/components/accessible-modal'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import { ReadOnlyTokenLink } from './link-sharing'
|
2021-06-03 09:44:23 -04:00
|
|
|
import { useEditorContext } from '../../../shared/context/editor-context'
|
2021-03-12 05:23:46 -05:00
|
|
|
|
|
|
|
export default function ShareProjectModalContent({
|
|
|
|
show,
|
|
|
|
cancel,
|
|
|
|
animation,
|
|
|
|
inFlight,
|
2021-04-27 03:52:58 -04:00
|
|
|
error,
|
2021-03-12 05:23:46 -05:00
|
|
|
}) {
|
2021-06-03 09:44:23 -04:00
|
|
|
const { isRestrictedTokenMember } = useEditorContext({
|
|
|
|
isRestrictedTokenMember: PropTypes.bool,
|
|
|
|
})
|
|
|
|
|
2021-03-12 05:23:46 -05:00
|
|
|
return (
|
|
|
|
<AccessibleModal show={show} onHide={cancel} animation={animation}>
|
|
|
|
<Modal.Header closeButton>
|
|
|
|
<Modal.Title>
|
|
|
|
<Trans i18nKey="share_project" />
|
|
|
|
</Modal.Title>
|
|
|
|
</Modal.Header>
|
|
|
|
|
|
|
|
<Modal.Body className="modal-body-share">
|
|
|
|
<Grid fluid>
|
2021-06-03 09:44:23 -04:00
|
|
|
{isRestrictedTokenMember ? <ReadOnlyTokenLink /> : <ShareModalBody />}
|
2021-03-12 05:23:46 -05:00
|
|
|
</Grid>
|
|
|
|
</Modal.Body>
|
|
|
|
|
|
|
|
<Modal.Footer className="modal-footer-share">
|
|
|
|
<div className="modal-footer-left">
|
|
|
|
{inFlight && <Icon type="refresh" spin />}
|
|
|
|
{error && (
|
|
|
|
<span className="text-danger error">
|
|
|
|
<ErrorMessage error={error} />
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="modal-footer-right">
|
|
|
|
<Button
|
|
|
|
type="button"
|
|
|
|
onClick={cancel}
|
|
|
|
bsStyle="default"
|
|
|
|
disabled={inFlight}
|
|
|
|
>
|
|
|
|
<Trans i18nKey="close" />
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</Modal.Footer>
|
|
|
|
</AccessibleModal>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
ShareProjectModalContent.propTypes = {
|
|
|
|
cancel: PropTypes.func.isRequired,
|
|
|
|
show: PropTypes.bool,
|
|
|
|
animation: PropTypes.bool,
|
|
|
|
inFlight: PropTypes.bool,
|
2021-04-27 03:52:58 -04:00
|
|
|
error: PropTypes.string,
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function ErrorMessage({ error }) {
|
|
|
|
switch (error) {
|
|
|
|
case 'cannot_invite_non_user':
|
2021-03-25 06:11:31 -04:00
|
|
|
return <Trans i18nKey="cannot_invite_non_user" />
|
2021-03-12 05:23:46 -05:00
|
|
|
|
|
|
|
case 'cannot_verify_user_not_robot':
|
|
|
|
return <Trans i18nKey="cannot_verify_user_not_robot" />
|
|
|
|
|
|
|
|
case 'cannot_invite_self':
|
|
|
|
return <Trans i18nKey="cannot_invite_self" />
|
|
|
|
|
|
|
|
case 'invalid_email':
|
|
|
|
return <Trans i18nKey="invalid_email" />
|
|
|
|
|
|
|
|
case 'too_many_requests':
|
|
|
|
return <Trans i18nKey="too_many_requests" />
|
|
|
|
|
|
|
|
default:
|
|
|
|
return <Trans i18nKey="generic_something_went_wrong" />
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ErrorMessage.propTypes = {
|
2021-04-27 03:52:58 -04:00
|
|
|
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]).isRequired,
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|