fix: add tooltip on disabled button

This commit is contained in:
Harsh Mahajan
2025-07-02 13:42:48 +05:30
parent 79b58da45b
commit 359359e95c
2 changed files with 56 additions and 18 deletions
@@ -7,7 +7,13 @@
import { toLocaleDate } from '$lib/helpers/date';
import { isTabSelected } from '$lib/helpers/load';
import { Cover } from '$lib/layout';
import { daysLeftInTrial, getServiceLimit, plansInfo, readOnly } from '$lib/stores/billing';
import {
daysLeftInTrial,
getServiceLimit,
plansInfo,
readOnly,
tierToPlan
} from '$lib/stores/billing';
import { members, newMemberModal, type Organization } from '$lib/stores/organization';
import {
canSeeBilling,
@@ -114,14 +120,25 @@
{/if}
{#if $isOwner}
<Button
secondary
size="s"
on:click={() => newMemberModal.set(true)}
disabled={areMembersLimited}>
<Icon icon={IconPlus} size="s" slot="start" />
Invite
</Button>
<Tooltip disabled={!areMembersLimited} placement="bottom-end">
<div>
<Button
secondary
size="s"
on:click={() => newMemberModal.set(true)}
disabled={areMembersLimited}>
<Icon icon={IconPlus} size="s" slot="start" />
Invite
</Button>
</div>
<div slot="tooltip">
{organization?.billingPlan === BillingPlan.FREE
? 'Upgrade to add more members'
: `You've reached the members limit for the ${
tierToPlan(organization?.billingPlan)?.name
} plan`}
</div>
</Tooltip>
{/if}
</Layout.Stack>
</div>
@@ -31,8 +31,11 @@
Icon,
Typography,
Popover,
ActionMenu
ActionMenu,
Tooltip
} from '@appwrite.io/pink-svelte';
import { BillingPlan } from '$lib/constants';
import { tierToPlan } from '$lib/stores/billing';
export let data;
@@ -41,6 +44,13 @@
let showEdit = false;
let showDropdown = [];
// Calculate if button should be disabled and tooltip should show
$: memberCount = data.organizationMembers?.total ?? 0;
$: isFreeWithMembers = $organization?.billingPlan === BillingPlan.FREE && memberCount >= 1;
$: isButtonDisabled = isCloud
? isFreeWithMembers || !$currentPlan?.addons?.seats?.supported
: false;
const resend = async (member: Models.Membership) => {
try {
await sdk.forConsole.teams.createMembership(
@@ -70,14 +80,25 @@
<Container>
<Layout.Stack direction="row" justifyContent="space-between">
<Typography.Title>Members</Typography.Title>
<ConsoleButton
size="s"
event="create_user"
on:click={() => newMemberModal.set(true)}
disabled={isCloud ? !$currentPlan?.addons?.seats?.supported : false}>
<Icon size="s" icon={IconPlus} slot="start" />
<span class="text">Invite</span>
</ConsoleButton>
<Tooltip disabled={!isButtonDisabled} placement="bottom-end">
<div>
<ConsoleButton
size="s"
event="create_user"
on:click={() => newMemberModal.set(true)}
disabled={isButtonDisabled}>
<Icon size="s" icon={IconPlus} slot="start" />
<span class="text">Invite</span>
</ConsoleButton>
</div>
<div slot="tooltip">
{$organization?.billingPlan === BillingPlan.FREE
? 'Upgrade to add more members'
: `You've reached the members limit for the ${
tierToPlan($organization?.billingPlan)?.name
} plan`}
</div>
</Tooltip>
</Layout.Stack>
<Table.Root