mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 13:10:20 -05:00
8da063d640
[web] Add prefix of token hash to link sharing URLs GitOrigin-RevId: 4b764c076a335768ab261dd1e181d90ce00fd1a2
157 lines
4.1 KiB
JavaScript
157 lines
4.1 KiB
JavaScript
import EditMember from './edit-member'
|
|
import LinkSharing from './link-sharing'
|
|
import Invite from './invite'
|
|
import SendInvites from './send-invites'
|
|
import ViewMember from './view-member'
|
|
import OwnerInfo from './owner-info'
|
|
import SendInvitesNotice from './send-invites-notice'
|
|
import { useEditorContext } from '../../../shared/context/editor-context'
|
|
import { useProjectContext } from '../../../shared/context/project-context'
|
|
import { useSplitTestContext } from '../../../shared/context/split-test-context'
|
|
import { useMemo } from 'react'
|
|
import { Row } from 'react-bootstrap'
|
|
import PropTypes from 'prop-types'
|
|
import RecaptchaConditions from '../../../shared/components/recaptcha-conditions'
|
|
|
|
export default function ShareModalBody() {
|
|
const { splitTestVariants } = useSplitTestContext({
|
|
splitTestVariants: PropTypes.object,
|
|
})
|
|
|
|
const { members, invites, features } = useProjectContext()
|
|
const { isProjectOwner } = useEditorContext()
|
|
|
|
// whether the project has not reached the collaborator limit
|
|
const canAddCollaborators = useMemo(() => {
|
|
if (!isProjectOwner || !features) {
|
|
return false
|
|
}
|
|
|
|
if (features.collaborators === -1) {
|
|
// infinite collaborators
|
|
return true
|
|
}
|
|
|
|
return members.length + invites.length < features.collaborators
|
|
}, [members, invites, features, isProjectOwner])
|
|
|
|
switch (splitTestVariants['project-share-modal-paywall']) {
|
|
case 'new-copy-top':
|
|
return (
|
|
<>
|
|
{isProjectOwner ? (
|
|
<>
|
|
<SendInvites canAddCollaborators={canAddCollaborators} />
|
|
<Row className="public-access-level" />
|
|
</>
|
|
) : (
|
|
<SendInvitesNotice />
|
|
)}
|
|
|
|
<OwnerInfo />
|
|
|
|
{members.map(member =>
|
|
isProjectOwner ? (
|
|
<EditMember key={member._id} member={member} />
|
|
) : (
|
|
<ViewMember key={member._id} member={member} />
|
|
)
|
|
)}
|
|
|
|
{invites.map(invite => (
|
|
<Invite
|
|
key={invite._id}
|
|
invite={invite}
|
|
isProjectOwner={isProjectOwner}
|
|
/>
|
|
))}
|
|
|
|
{isProjectOwner && (
|
|
<>
|
|
<br />
|
|
<LinkSharing />
|
|
</>
|
|
)}
|
|
|
|
{!window.ExposedSettings.recaptchaDisabled?.invite && (
|
|
<RecaptchaConditions />
|
|
)}
|
|
</>
|
|
)
|
|
case 'new-copy-middle':
|
|
return (
|
|
<>
|
|
<OwnerInfo />
|
|
|
|
{members.map(member =>
|
|
isProjectOwner ? (
|
|
<EditMember key={member._id} member={member} />
|
|
) : (
|
|
<ViewMember key={member._id} member={member} />
|
|
)
|
|
)}
|
|
|
|
{invites.map(invite => (
|
|
<Invite
|
|
key={invite._id}
|
|
invite={invite}
|
|
isProjectOwner={isProjectOwner}
|
|
/>
|
|
))}
|
|
|
|
{isProjectOwner ? (
|
|
<SendInvites canAddCollaborators={canAddCollaborators} />
|
|
) : (
|
|
<SendInvitesNotice />
|
|
)}
|
|
|
|
{isProjectOwner && (
|
|
<>
|
|
<br />
|
|
<LinkSharing />
|
|
</>
|
|
)}
|
|
|
|
{!window.ExposedSettings.recaptchaDisabled?.invite && (
|
|
<RecaptchaConditions />
|
|
)}
|
|
</>
|
|
)
|
|
case 'new-copy-bottom':
|
|
case 'default':
|
|
default:
|
|
return (
|
|
<>
|
|
{isProjectOwner && <LinkSharing />}
|
|
|
|
<OwnerInfo />
|
|
|
|
{members.map(member =>
|
|
isProjectOwner ? (
|
|
<EditMember key={member._id} member={member} />
|
|
) : (
|
|
<ViewMember key={member._id} member={member} />
|
|
)
|
|
)}
|
|
|
|
{invites.map(invite => (
|
|
<Invite
|
|
key={invite._id}
|
|
invite={invite}
|
|
isProjectOwner={isProjectOwner}
|
|
/>
|
|
))}
|
|
|
|
{isProjectOwner ? (
|
|
<SendInvites canAddCollaborators={canAddCollaborators} />
|
|
) : (
|
|
<SendInvitesNotice />
|
|
)}
|
|
|
|
{!window.ExposedSettings.recaptchaDisabled?.invite && (
|
|
<RecaptchaConditions />
|
|
)}
|
|
</>
|
|
)
|
|
}
|
|
}
|