Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

feat(plg): Tweak invite co-workers flow#63374

Merged
vdavid merged 4 commits into
mainfrom
dv/invite-coworkers-flow
Jun 20, 2024
Merged

feat(plg): Tweak invite co-workers flow#63374
vdavid merged 4 commits into
mainfrom
dv/invite-coworkers-flow

Conversation

@vdavid

@vdavid vdavid commented Jun 20, 2024

Copy link
Copy Markdown
Contributor

The "Invite co-workers" flow was not up to spec.

This PR fixes it to match this spec:

  • If you are a team of size seats = 1, then "Invite coworkers" should take you to the add seats page because you won't be able to invite anyone until you add seats
  • If you are a team of size seats = N, and have M invited/accepted users where M < N, then you should see this
  • If you are a team of size seats = N and have N invited/accepted users, then you should see this

Test plan

Here is a 1-min Loom where I went through all cases.

@vdavid vdavid requested review from a team, chenkc805 and rrhyne June 20, 2024 08:55
@cla-bot cla-bot Bot added the cla-signed label Jun 20, 2024
Comment on lines +91 to +104
const getTeamInviteButton = useCallback(() => {
const isSoloUser = subscriptionSummaryQueryResult?.data?.teamMaxMembers === 1
const hasFreeSeats = subscriptionSummaryQueryResult?.data ? subscriptionSummaryQueryResult.data.teamMaxMembers > subscriptionSummaryQueryResult.data.teamCurrentMembers : false
const targetUrl= hasFreeSeats ? '/cody/team/manage' : '/cody/manage/subscription/new?addSeats=1'
const label = (isSoloUser || hasFreeSeats) ? 'Invite co-workers' : 'Add seats'
return <Button
as={Link}
to={targetUrl}
variant="success"
className="text-nowrap"
>
<Icon aria-hidden={true} svgPath={mdiPlusThick} /> {label}
</Button>
}, [subscriptionSummaryQueryResult?.data])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may have a wrong button label for a while:

  • when subscriptionSummaryQueryResult.isLoading isSoloUser and hasFreeSeats will be false, and 'Add seats' label will be shown
  • subscriptionSummaryQueryResult gets to error or success state in a while and one of the mentioned variables may have true value and label will be 'Invite co-workers'.

I suggest we return null until we get subscriptionSummaryQueryResult fetched.

I also think we don't need useCallback here. It doesn't seem to add any performance gains: the <Button component will be recreated anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vdavid vdavid enabled auto-merge (squash) June 20, 2024 09:15
@vdavid vdavid merged commit 03179a7 into main Jun 20, 2024
@vdavid vdavid deleted the dv/invite-coworkers-flow branch June 20, 2024 10:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants