Skip to content

Commit 82d3777

Browse files
authored
Merge pull request #2070 from HarshMN2345/fix-SER-31-disabled-invite-tooltip
2 parents c61b5c8 + 359359e commit 82d3777

File tree

2 files changed

+56
-18
lines changed

2 files changed

+56
-18
lines changed

src/routes/(console)/organization-[organization]/header.svelte

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
import { toLocaleDate } from '$lib/helpers/date';
88
import { isTabSelected } from '$lib/helpers/load';
99
import { Cover } from '$lib/layout';
10-
import { daysLeftInTrial, getServiceLimit, plansInfo, readOnly } from '$lib/stores/billing';
10+
import {
11+
daysLeftInTrial,
12+
getServiceLimit,
13+
plansInfo,
14+
readOnly,
15+
tierToPlan
16+
} from '$lib/stores/billing';
1117
import { members, newMemberModal, type Organization } from '$lib/stores/organization';
1218
import {
1319
canSeeBilling,
@@ -114,14 +120,25 @@
114120
{/if}
115121

116122
{#if $isOwner}
117-
<Button
118-
secondary
119-
size="s"
120-
on:click={() => newMemberModal.set(true)}
121-
disabled={areMembersLimited}>
122-
<Icon icon={IconPlus} size="s" slot="start" />
123-
Invite
124-
</Button>
123+
<Tooltip disabled={!areMembersLimited} placement="bottom-end">
124+
<div>
125+
<Button
126+
secondary
127+
size="s"
128+
on:click={() => newMemberModal.set(true)}
129+
disabled={areMembersLimited}>
130+
<Icon icon={IconPlus} size="s" slot="start" />
131+
Invite
132+
</Button>
133+
</div>
134+
<div slot="tooltip">
135+
{organization?.billingPlan === BillingPlan.FREE
136+
? 'Upgrade to add more members'
137+
: `You've reached the members limit for the ${
138+
tierToPlan(organization?.billingPlan)?.name
139+
} plan`}
140+
</div>
141+
</Tooltip>
125142
{/if}
126143
</Layout.Stack>
127144
</div>

src/routes/(console)/organization-[organization]/members/+page.svelte

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@
3131
Icon,
3232
Typography,
3333
Popover,
34-
ActionMenu
34+
ActionMenu,
35+
Tooltip
3536
} from '@appwrite.io/pink-svelte';
37+
import { BillingPlan } from '$lib/constants';
38+
import { tierToPlan } from '$lib/stores/billing';
3639
3740
export let data;
3841
@@ -41,6 +44,13 @@
4144
let showEdit = false;
4245
let showDropdown = [];
4346
47+
// Calculate if button should be disabled and tooltip should show
48+
$: memberCount = data.organizationMembers?.total ?? 0;
49+
$: isFreeWithMembers = $organization?.billingPlan === BillingPlan.FREE && memberCount >= 1;
50+
$: isButtonDisabled = isCloud
51+
? isFreeWithMembers || !$currentPlan?.addons?.seats?.supported
52+
: false;
53+
4454
const resend = async (member: Models.Membership) => {
4555
try {
4656
await sdk.forConsole.teams.createMembership(
@@ -70,14 +80,25 @@
7080
<Container>
7181
<Layout.Stack direction="row" justifyContent="space-between">
7282
<Typography.Title>Members</Typography.Title>
73-
<ConsoleButton
74-
size="s"
75-
event="create_user"
76-
on:click={() => newMemberModal.set(true)}
77-
disabled={isCloud ? !$currentPlan?.addons?.seats?.supported : false}>
78-
<Icon size="s" icon={IconPlus} slot="start" />
79-
<span class="text">Invite</span>
80-
</ConsoleButton>
83+
<Tooltip disabled={!isButtonDisabled} placement="bottom-end">
84+
<div>
85+
<ConsoleButton
86+
size="s"
87+
event="create_user"
88+
on:click={() => newMemberModal.set(true)}
89+
disabled={isButtonDisabled}>
90+
<Icon size="s" icon={IconPlus} slot="start" />
91+
<span class="text">Invite</span>
92+
</ConsoleButton>
93+
</div>
94+
<div slot="tooltip">
95+
{$organization?.billingPlan === BillingPlan.FREE
96+
? 'Upgrade to add more members'
97+
: `You've reached the members limit for the ${
98+
tierToPlan($organization?.billingPlan)?.name
99+
} plan`}
100+
</div>
101+
</Tooltip>
81102
</Layout.Stack>
82103

83104
<Table.Root

0 commit comments

Comments
 (0)