Rename isAdmin to isProjectOwner in he ShareProjectContext to avoid confusion

GitOrigin-RevId: 0bfc7317b197960114f2a06fbbc20818bc4c5ffb
This commit is contained in:
M Fahru 2022-07-08 01:03:14 -04:00 committed by Copybot
parent b4402c41e8
commit e26c90f5fc
7 changed files with 46 additions and 34 deletions

View file

@ -2,7 +2,7 @@ div(ng-controller="ReactShareProjectModalController")
share-project-modal(
handle-hide="handleHide"
show="show"
is-admin="isAdmin"
is-project-owner="isProjectOwner"
)
div(ng-controller="EditorNavigationToolbarController")

View file

@ -9,7 +9,7 @@ import MemberPrivileges from './member-privileges'
import { resendInvite, revokeInvite } from '../utils/api'
import { useProjectContext } from '../../../shared/context/project-context'
export default function Invite({ invite, isAdmin }) {
export default function Invite({ invite, isProjectOwner }) {
return (
<Row className="project-invite">
<Col xs={7}>
@ -18,7 +18,7 @@ export default function Invite({ invite, isAdmin }) {
<div className="small">
<Trans i18nKey="invite_not_accepted" />
.&nbsp;
{isAdmin && <ResendInvite invite={invite} />}
{isProjectOwner && <ResendInvite invite={invite} />}
</div>
</Col>
@ -26,7 +26,7 @@ export default function Invite({ invite, isAdmin }) {
<MemberPrivileges privileges={invite.privileges} />
</Col>
{isAdmin && (
{isProjectOwner && (
<Col xs={2} className="text-center">
<RevokeInvite invite={invite} />
</Col>
@ -37,7 +37,7 @@ export default function Invite({ invite, isAdmin }) {
Invite.propTypes = {
invite: PropTypes.object.isRequired,
isAdmin: PropTypes.bool.isRequired,
isProjectOwner: PropTypes.bool.isRequired,
}
function ResendInvite({ invite }) {

View file

@ -13,7 +13,7 @@ import PropTypes from 'prop-types'
import RecaptchaConditions from '../../../shared/components/recaptcha-conditions'
export default function ShareModalBody() {
const { isAdmin } = useShareProjectContext()
const { isProjectOwner } = useShareProjectContext()
const { splitTestVariants } = useSplitTestContext({
splitTestVariants: PropTypes.object,
})
@ -24,7 +24,7 @@ export default function ShareModalBody() {
case 'new-copy-top':
return (
<>
{isAdmin ? (
{isProjectOwner ? (
<>
<SendInvites />
<Row className="public-access-level" />
@ -36,7 +36,7 @@ export default function ShareModalBody() {
<OwnerInfo />
{members.map(member =>
isAdmin ? (
isProjectOwner ? (
<EditMember key={member._id} member={member} />
) : (
<ViewMember key={member._id} member={member} />
@ -44,10 +44,14 @@ export default function ShareModalBody() {
)}
{invites.map(invite => (
<Invite key={invite._id} invite={invite} isAdmin={isAdmin} />
<Invite
key={invite._id}
invite={invite}
isProjectOwner={isProjectOwner}
/>
))}
{isAdmin && (
{isProjectOwner && (
<>
<br />
<LinkSharing />
@ -65,7 +69,7 @@ export default function ShareModalBody() {
<OwnerInfo />
{members.map(member =>
isAdmin ? (
isProjectOwner ? (
<EditMember key={member._id} member={member} />
) : (
<ViewMember key={member._id} member={member} />
@ -73,12 +77,16 @@ export default function ShareModalBody() {
)}
{invites.map(invite => (
<Invite key={invite._id} invite={invite} isAdmin={isAdmin} />
<Invite
key={invite._id}
invite={invite}
isProjectOwner={isProjectOwner}
/>
))}
{isAdmin ? <SendInvites /> : <SendInvitesNotice />}
{isProjectOwner ? <SendInvites /> : <SendInvitesNotice />}
{isAdmin && (
{isProjectOwner && (
<>
<br />
<LinkSharing />
@ -95,12 +103,12 @@ export default function ShareModalBody() {
default:
return (
<>
{isAdmin && <LinkSharing />}
{isProjectOwner && <LinkSharing />}
<OwnerInfo />
{members.map(member =>
isAdmin ? (
isProjectOwner ? (
<EditMember key={member._id} member={member} />
) : (
<ViewMember key={member._id} member={member} />
@ -108,10 +116,14 @@ export default function ShareModalBody() {
)}
{invites.map(invite => (
<Invite key={invite._id} invite={invite} isAdmin={isAdmin} />
<Invite
key={invite._id}
invite={invite}
isProjectOwner={isProjectOwner}
/>
))}
{isAdmin ? <SendInvites /> : <SendInvitesNotice />}
{isProjectOwner ? <SendInvites /> : <SendInvitesNotice />}
{!window.ExposedSettings.recaptchaDisabled?.invite && (
<RecaptchaConditions />

View file

@ -18,7 +18,7 @@ const ShareProjectContext = createContext()
ShareProjectContext.Provider.propTypes = {
value: PropTypes.shape({
isAdmin: PropTypes.bool.isRequired,
isProjectOwner: PropTypes.bool.isRequired,
updateProject: PropTypes.func.isRequired,
monitorRequest: PropTypes.func.isRequired,
inFlight: PropTypes.bool,
@ -44,7 +44,7 @@ const ShareProjectModal = React.memo(function ShareProjectModal({
handleHide,
show,
animation = true,
isAdmin,
isProjectOwner,
}) {
const [inFlight, setInFlight] = useState(false)
const [error, setError] = useState()
@ -113,7 +113,7 @@ const ShareProjectModal = React.memo(function ShareProjectModal({
return (
<ShareProjectContext.Provider
value={{
isAdmin,
isProjectOwner,
updateProject,
monitorRequest,
inFlight,
@ -135,7 +135,7 @@ const ShareProjectModal = React.memo(function ShareProjectModal({
ShareProjectModal.propTypes = {
animation: PropTypes.bool,
handleHide: PropTypes.func.isRequired,
isAdmin: PropTypes.bool.isRequired,
isProjectOwner: PropTypes.bool.isRequired,
show: PropTypes.bool.isRequired,
}

View file

@ -16,7 +16,7 @@ App.component(
export default App.controller(
'ReactShareProjectModalController',
function ($scope, eventTracking, ide) {
$scope.isAdmin = false
$scope.isProjectOwner = false
$scope.show = false
$scope.handleHide = () => {
@ -25,10 +25,10 @@ export default App.controller(
})
}
$scope.openShareProjectModal = isAdmin => {
$scope.openShareProjectModal = isProjectOwner => {
eventTracking.sendMBOnce('ide-open-share-modal-once')
$scope.$applyAsync(() => {
$scope.isAdmin = isAdmin
$scope.isProjectOwner = isProjectOwner
$scope.show = true
})
}

View file

@ -46,7 +46,7 @@ export const LinkSharingLoading = args => {
return <ShareProjectModal {...args} />
}
export const NonAdminLinkSharingOff = args => {
export const NonProjectOwnerLinkSharingOff = args => {
useScope({
project: {
...args.project,
@ -54,10 +54,10 @@ export const NonAdminLinkSharingOff = args => {
},
})
return <ShareProjectModal {...args} isAdmin={false} />
return <ShareProjectModal {...args} isProjectOwner={false} />
}
export const NonAdminLinkSharingOn = args => {
export const NonProjectOwnerLinkSharingOn = args => {
useScope({
project: {
...args.project,
@ -65,7 +65,7 @@ export const NonAdminLinkSharingOn = args => {
},
})
return <ShareProjectModal {...args} isAdmin={false} />
return <ShareProjectModal {...args} isProjectOwner={false} />
}
export const RestrictedTokenMember = args => {
@ -139,7 +139,7 @@ export default {
args: {
show: true,
animation: false,
isAdmin: true,
isProjectOwner: true,
user: {},
project,
},

View file

@ -77,7 +77,7 @@ describe('<ShareProjectModal/>', function () {
const modalProps = {
show: true,
isAdmin: true,
isProjectOwner: true,
handleHide: sinon.stub(),
}
@ -192,7 +192,7 @@ describe('<ShareProjectModal/>', function () {
},
}}
>
<ShareProjectModal {...modalProps} isAdmin />
<ShareProjectModal {...modalProps} isProjectOwner />
</EditorProviders>
)
@ -210,7 +210,7 @@ describe('<ShareProjectModal/>', function () {
},
}}
>
<ShareProjectModal {...modalProps} isAdmin={false} />
<ShareProjectModal {...modalProps} isProjectOwner={false} />
</EditorProviders>
)
@ -235,7 +235,7 @@ describe('<ShareProjectModal/>', function () {
},
}}
>
<ShareProjectModal {...modalProps} isAdmin={false} />
<ShareProjectModal {...modalProps} isProjectOwner={false} />
</EditorProviders>
)