Skip to content

fix: add tooltip on disabled button #2070

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

Merged
Merged
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
35 changes: 26 additions & 9 deletions src/routes/(console)/organization-[organization]/header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down