Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: deprecate RemoveOrgUser in favor of RemoveOrgUsers #10951

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,39 @@ import PrimaryButton from '../../../../components/PrimaryButton'
import useAtmosphere from '../../../../hooks/useAtmosphere'
import useMutationProps from '../../../../hooks/useMutationProps'
import useRouter from '../../../../hooks/useRouter'
import RemoveOrgUserMutation from '../../../../mutations/RemoveOrgUserMutation'
import RemoveOrgUsersMutation from '../../../../mutations/RemoveOrgUsersMutation'

const StyledButton = styled(PrimaryButton)({
margin: '1.5rem auto 0'
})

interface Props {
orgId: string
closePortal: () => void
}

const StyledDialogContainer = styled(DialogContainer)({
width: 'auto'
})

const LeaveOrgModal = (props: Props) => {
const {orgId} = props
const {orgId, closePortal} = props
const atmosphere = useAtmosphere()
const {history} = useRouter()
const {onCompleted, onError, submitMutation, submitting} = useMutationProps()
const handleClick = () => {
if (submitting) return
submitMutation()
RemoveOrgUserMutation(
RemoveOrgUsersMutation(
atmosphere,
{orgId, userId: atmosphere.viewerId},
{orgId, userIds: [atmosphere.viewerId]},
{
history,
onError,
onCompleted
onCompleted: () => {
onCompleted()
closePortal()
}
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,16 @@ const BillingLeader = (props: Props) => {
isOrgAdmin: isViewerOrgAdmin,
isBillingLeader: isViewerBillingLeader
} = organization
const {togglePortal: toggleLeave, modalPortal: leaveModal} = useModal()
const {togglePortal: toggleRemove, modalPortal: removeModal} = useModal()
const {
togglePortal: toggleLeave,
modalPortal: leaveModal,
closePortal: closeLeaveModal
} = useModal()
const {
togglePortal: toggleRemove,
modalPortal: removeModal,
closePortal: closeRemoveModal
} = useModal()
const {user: billingLeaderUser, role} = billingLeader
const {id: userId, preferredName, picture} = billingLeaderUser
const canEdit = isViewerOrgAdmin || (isViewerBillingLeader && role === 'BILLING_LEADER')
Expand All @@ -100,9 +108,14 @@ const BillingLeader = (props: Props) => {
)}
</ActionsBlock>
</RowActions>
{leaveModal(<LeaveOrgModal orgId={orgId} />)}
{leaveModal(<LeaveOrgModal orgId={orgId} closePortal={closeLeaveModal} />)}
{removeModal(
<RemoveFromOrgModal orgId={orgId} userId={userId} preferredName={preferredName} />
<RemoveFromOrgModal
orgId={orgId}
userId={userId}
preferredName={preferredName}
closePortal={closeRemoveModal}
/>
)}
</StyledRow>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,16 @@ const UserActions: React.FC<UserActionsProps> = ({
const {
user: {id: userId}
} = organizationUser
const {togglePortal: toggleLeave, modalPortal: leaveModal} = useModal()
const {togglePortal: toggleRemove, modalPortal: removeModal} = useModal()
const {
togglePortal: toggleLeave,
modalPortal: leaveModal,
closePortal: closeLeaveModal
} = useModal()
const {
togglePortal: toggleRemove,
modalPortal: removeModal,
closePortal: closeRemoveModal
} = useModal()
return (
<RowActions>
<ActionsBlock>
Expand All @@ -119,9 +127,14 @@ const UserActions: React.FC<UserActionsProps> = ({
toggleLeave={toggleLeave}
toggleRemove={toggleRemove}
/>
{leaveModal(<LeaveOrgModal orgId={orgId} />)}
{leaveModal(<LeaveOrgModal orgId={orgId} closePortal={closeLeaveModal} />)}
{removeModal(
<RemoveFromOrgModal orgId={orgId} userId={userId} preferredName={preferredName} />
<RemoveFromOrgModal
orgId={orgId}
userId={userId}
preferredName={preferredName}
closePortal={closeRemoveModal}
/>
)}
</ActionsBlock>
</RowActions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PrimaryButton from '../../../../components/PrimaryButton'
import useAtmosphere from '../../../../hooks/useAtmosphere'
import useMutationProps from '../../../../hooks/useMutationProps'
import useRouter from '../../../../hooks/useRouter'
import RemoveOrgUserMutation from '../../../../mutations/RemoveOrgUserMutation'
import RemoveOrgUsersMutation from '../../../../mutations/RemoveOrgUsersMutation'

const StyledButton = styled(PrimaryButton)({
margin: '1.5rem auto 0'
Expand All @@ -17,20 +17,32 @@ interface Props {
orgId: string
userId: string
preferredName: string
closePortal: () => void
}

const StyledDialogContainer = styled(DialogContainer)({
width: '400'
})

const RemoveFromOrgModal = (props: Props) => {
const {orgId, preferredName, userId} = props
const {orgId, preferredName, userId, closePortal} = props
const atmosphere = useAtmosphere()
const {history} = useRouter()
const {onCompleted, onError, submitMutation, submitting} = useMutationProps()
const handleClick = () => {
submitMutation()
RemoveOrgUserMutation(atmosphere, {orgId, userId}, {history, onError, onCompleted})
RemoveOrgUsersMutation(
atmosphere,
{orgId, userIds: [userId]},
{
history,
onError,
onCompleted: () => {
onCompleted()
closePortal()
}
}
)
}
return (
<StyledDialogContainer>
Expand Down
Loading