Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
Redesign the members page to match the polls page (#2929)
Luke Vella380707d9aaeb
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.jsonindex 47cc4f30c..430a32572 100644--- a/apps/web/public/locales/en/app.json+++ b/apps/web/public/locales/en/app.json@@ -557,7 +557,7 @@"pending": "Pending","pendingDeletionNotice": "Your account and data will be permanently deleted on {deletionDate}.","pendingInvites": "Pending invites",- "pendingInvitesDescription": "Invite other users to share your space.",+ "pendingInvitesAlertDescription": "{count, plural, one {There is # pending invite} other {There are # pending invites}}","perSeatMonth": "/seat/mo","planFree": "Free","planHobbyDescription": "For casual users",@@ -673,9 +673,9 @@"searchPollsPlaceholder": "Search polls by title...","searchUsers": "Search users...","seatCount": "{count, plural, one {# seat} other {# seats}}",+ "seatsAvailable": "{count, plural, =0 {No seats available} one {# seat available} other {# seats available}}","seatsUpdatedAlertDescription": "Your seat allocation has been successfully updated. The changes will be reflected in your next billing cycle.","seatsUpdatedAlertTitle": "Seats updated",- "seatUsage": "{usedSeats} of {totalSeats} seats used","security": "Security","securityAuthentication": "Authentication","securityAuthenticationDescription": "Manage how you sign in to your account",@@ -809,6 +809,7 @@"verifyEmailDescription": "Enter the 6-digit code we sent to <b>{email}</b>","verifyEmailTitle": "Verify your email","viewClosedPolls": "View closed polls",+ "viewInvites": "View invites","viewPoll": "View poll","viewResults": "View results","voteSummaryAvailable": "{availableCount} of {total} available",diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/members/components/invite-dropdown-menu.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/members/components/cancel-invite-button.tsxsimilarity index 68%rename from apps/web/src/app/[locale]/(space)/(dashboard)/members/components/invite-dropdown-menu.tsxrename to apps/web/src/app/[locale]/(space)/(dashboard)/members/components/cancel-invite-button.tsxindex 37bc00070..c1e0448dd 100644--- a/apps/web/src/app/[locale]/(space)/(dashboard)/members/components/invite-dropdown-menu.tsx+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/members/components/cancel-invite-button.tsx@@ -12,15 +12,7 @@ import {DialogTitle,useDialog,} from "@rallly/ui/dialog";-import {- DropdownMenu,- DropdownMenuContent,- DropdownMenuItem,- DropdownMenuTrigger,-} from "@rallly/ui/dropdown-menu";-import { Icon } from "@rallly/ui/icon";import { toast } from "@rallly/ui/sonner";-import { MoreVerticalIcon, XIcon } from "lucide-react";import { useSpace } from "@/features/space/client";import { cancelInviteAction } from "@/features/space/member/actions";import { Trans, useTranslation } from "@/i18n/client";@@ -32,7 +24,7 @@ type SpaceMemberInvite = {spaceId: string;};-export function InviteDropdownMenu({ invite }: { invite: SpaceMemberInvite }) {+export function CancelInviteButton({ invite }: { invite: SpaceMemberInvite }) {const space = useSpace();const cancelInviteDialog = useDialog();const { t } = useTranslation();@@ -55,33 +47,15 @@ export function InviteDropdownMenu({ invite }: { invite: SpaceMemberInvite }) {return (<>- <DropdownMenu>- <DropdownMenuTrigger- render={- <Button- aria-label={t("moreOptions", { defaultValue: "More options" })}- variant="ghost"- size="icon"- />- }- >- <Icon>- <MoreVerticalIcon />- </Icon>- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- <DropdownMenuItem- onClick={() => {- cancelInviteDialog.trigger();- }}- disabled={!canCancelInvite}- variant="destructive"- >- <XIcon />- <Trans i18nKey="cancelInvite" defaults="Cancel invite" />- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>+ <Button+ size="sm"+ disabled={!canCancelInvite}+ onClick={() => {+ cancelInviteDialog.trigger();+ }}+ >+ <Trans i18nKey="cancel" defaults="Cancel" />+ </Button><Dialog {...cancelInviteDialog.dialogProps}><DialogContent size="sm"><DialogHeader>diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/members/components/invite-member-button.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/members/components/invite-member-button.tsxindex cbd2fbf78..e08f0d93a 100644--- a/apps/web/src/app/[locale]/(space)/(dashboard)/members/components/invite-member-button.tsx+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/members/components/invite-member-button.tsx@@ -24,6 +24,7 @@ export function InviteMemberButton({return (<><Button+ variant="primary"disabled={availableSeats <= 0}onClick={() => {if (space.getMemberAbility().cannot("create", "SpaceMemberInvite")) {diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/members/components/pending-invites-dialog.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/members/components/pending-invites-dialog.tsxnew file mode 100644index 000000000..5f734b600--- /dev/null+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/members/components/pending-invites-dialog.tsx@@ -0,0 +1,59 @@+"use client";++import type { DialogProps } from "@rallly/ui/dialog";+import {+ Dialog,+ DialogContent,+ DialogHeader,+ DialogTitle,+} from "@rallly/ui/dialog";+import { StackedList, StackedListItem } from "@/components/stacked-list";+import { SpaceRole } from "@/features/space/components/space-role";+import type { MemberRole } from "@/features/space/schema";+import { Trans } from "@/i18n/client";+import { CancelInviteButton } from "./cancel-invite-button";++export function PendingInvitesDialog({+ invites,+ ...dialogProps+}: {+ invites: {+ id: string;+ email: string;+ spaceId: string;+ role: MemberRole;+ invitedBy: { name: string };+ }[];+} & DialogProps) {+ return (+ <Dialog {...dialogProps}>+ <DialogContent size="md">+ <DialogHeader>+ <DialogTitle>+ <Trans i18nKey="pendingInvites" defaults="Pending invites" />+ </DialogTitle>+ </DialogHeader>+ <StackedList>+ {invites.map((invite) => (+ <StackedListItem key={invite.id}>+ <div className="flex-1">+ <div className="font-semibold text-sm">{invite.email}</div>+ <div className="text-muted-foreground text-sm">+ <Trans+ i18nKey="memberInvitedBy"+ defaults="Invited by {inviterName}"+ values={{ inviterName: invite.invitedBy.name }}+ />+ </div>+ </div>+ <div className="text-sm">+ <SpaceRole role={invite.role} />+ </div>+ <CancelInviteButton invite={invite} />+ </StackedListItem>+ ))}+ </StackedList>+ </DialogContent>+ </Dialog>+ );+}diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/members/members-page.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/members/members-page.tsxindex a00a03a14..9d6632f26 100644--- a/apps/web/src/app/[locale]/(space)/(dashboard)/members/members-page.tsx+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/members/members-page.tsx@@ -8,21 +8,18 @@ import {} from "@rallly/ui/alert";import { Badge } from "@rallly/ui/badge";import { Button } from "@rallly/ui/button";-import { InfoIcon, SparklesIcon } from "lucide-react";+import { useDialog } from "@rallly/ui/dialog";+import { InfoIcon, MailIcon, SparklesIcon } from "lucide-react";import Link from "next/link";+import React from "react";import { IfCloudHosted, IfSelfHosted } from "@/components/environment";import { OptimizedAvatarImage } from "@/components/optimized-avatar-image";import {PageContainer,PageContent,PageHeader,- PageSection,- PageSectionContent,- PageSectionDescription,- PageSectionDivider,- PageSectionGroup,- PageSectionHeader,- PageSectionTitle,+ PageHeaderActions,+ PageHeaderContent,PageTitle,} from "@/components/page-layout";import { StackedList, StackedListItem } from "@/components/stacked-list";@@ -32,9 +29,9 @@ import { SpaceRole } from "@/features/space/components/space-role";import { Trans } from "@/i18n/client";import { IfFeatureEnabled } from "@/lib/feature-flags/client";import { trpc } from "@/trpc/client";-import { InviteDropdownMenu } from "./components/invite-dropdown-menu";import { InviteMemberButton } from "./components/invite-member-button";import { MemberDropdownMenu } from "./components/member-dropdown-menu";+import { PendingInvitesDialog } from "./components/pending-invites-dialog";export function MembersPage({totalSeats,@@ -48,115 +45,124 @@ export function MembersPage({const [invites] = trpc.spaces.listInvites.useSuspenseQuery();const canInviteMembers = space.getAbility().can("invite", "Member");const hasInactiveMembers = space.data.tier === "hobby" && members.total > 1;+ const availableSeats = Math.max(totalSeats - usedSeats, 0);+ const pendingInvitesDialog = useDialog();+ const { dismiss: dismissPendingInvitesDialog } = pendingInvitesDialog;++ React.useEffect(() => {+ if (invites.length === 0) {+ dismissPendingInvitesDialog();+ }+ }, [invites.length, dismissPendingInvitesDialog]);return (<PageContainer><PageHeader>- <PageTitle>- <Trans i18nKey="members" defaults="Members" />- </PageTitle>+ <PageHeaderContent>+ <PageTitle>+ <Trans i18nKey="members" defaults="Members" />+ </PageTitle>+ </PageHeaderContent>+ {canInviteMembers ? (+ <PageHeaderActions>+ <p className="mr-2 text-muted-foreground text-sm">+ <Trans+ i18nKey="seatsAvailable"+ defaults="{count, plural, =0 {No seats available} one {# seat available} other {# seats available}}"+ values={{ count: availableSeats }}+ />+ </p>+ <InviteMemberButton usedSeats={usedSeats} totalSeats={totalSeats} />+ </PageHeaderActions>+ ) : null}</PageHeader>- <PageContent>- <PageSectionGroup>- <PageSection>- <PageSectionContent>- <IfFeatureEnabled feature="billing">- {hasInactiveMembers ? (- <Alert>- <InfoIcon />- <AlertTitle>- <Trans- i18nKey="membersInactiveAlertTitle"- defaults="Members are inactive"- />- </AlertTitle>- <AlertDescription>- <Trans- i18nKey="membersInactiveAlertDescription"- defaults="These members lost access when this space's Pro subscription ended. Their seats are kept and access is restored when the space is upgraded again."- />- </AlertDescription>- <AlertAction>- <Button- size="sm"- onClick={() => {- showPayWall({- from: "space-members",- action: "reactivate",- });- }}- >- <Trans- i18nKey="upgradeToPro"- defaults="Upgrade to Pro"+ <PageContent className="space-y-4">+ {canInviteMembers && invites.length > 0 ? (+ <Alert variant="primary">+ <MailIcon />+ <AlertDescription>+ <Trans+ i18nKey="pendingInvitesAlertDescription"+ defaults="{count, plural, one {There is # pending invite} other {There are # pending invites}}"+ values={{ count: invites.length }}+ />+ </AlertDescription>+ <AlertAction>+ <Button+ size="sm"+ onClick={() => {+ pendingInvitesDialog.trigger();+ }}+ >+ <Trans i18nKey="viewInvites" defaults="View invites" />+ </Button>+ </AlertAction>+ </Alert>+ ) : null}+ {canInviteMembers && availableSeats <= 0 ? (+ <Alert variant="info">+ <InfoIcon />+ <AlertDescription>+ <IfCloudHosted>+ <p>+ <Trans+ i18nKey="noSeatsAvailableAlertBillingDescription"+ defaults="Increase the number of seats in this space from the <a>billing page</a>."+ components={{+ a: (+ <Link+ className="underline hover:text-foreground"+ href="/settings/billing"/>- </Button>- </AlertAction>- </Alert>- ) : null}- </IfFeatureEnabled>- <StackedList>- {members.data.map((member) => (- <StackedListItem key={member.id}>- <div className="flex flex-1 items-center gap-4">- <OptimizedAvatarImage- src={member.image ?? undefined}- name={member.name}- size="xl"- />- <div>- <div className="flex items-center gap-x-2">- <div className="font-semibold text-sm">- {member.name}- </div>- <div>- {member.isOwner ? (- <Badge>- <Trans i18nKey="owner" defaults="Owner" />- </Badge>- ) : null}- <IfFeatureEnabled feature="billing">- {space.data.tier === "hobby" &&- !member.isOwner ? (- <Badge>- <Trans- i18nKey="memberInactive"- defaults="Inactive"- />- </Badge>- ) : null}- </IfFeatureEnabled>- </div>- </div>- <div className="text-muted-foreground text-sm">- {member.email}- </div>- </div>- </div>- <div className="text-sm">- <SpaceRole role={member.role} />- </div>- <MemberDropdownMenu member={member} />- </StackedListItem>- ))}- </StackedList>- </PageSectionContent>- </PageSection>- {!canInviteMembers && !hasInactiveMembers ? (- <Alert variant="primary">- <SparklesIcon />+ ),+ }}+ />+ </p>+ </IfCloudHosted>+ <IfSelfHosted>+ <p>+ <Trans+ i18nKey="noSeatsAvailableAlertSelfHostedDescription"+ defaults="You will need to <a>upgrade</a> to increase the number of seats in this space."+ components={{+ a: (+ <Link+ className="underline hover:text-foreground"+ prefetch={false}+ href="https://support.rallly.co/self-hosting/licensing"+ />+ ),+ }}+ />+ </p>+ </IfSelfHosted>+ </AlertDescription>+ </Alert>+ ) : null}+ <IfFeatureEnabled feature="billing">+ {hasInactiveMembers ? (+ <Alert>+ <InfoIcon />+ <AlertTitle>+ <Trans+ i18nKey="membersInactiveAlertTitle"+ defaults="Members are inactive"+ />+ </AlertTitle><AlertDescription><Trans- i18nKey="inviteMembersUpsellDescription"- defaults="Invite members to manage polls and events together in this space."+ i18nKey="membersInactiveAlertDescription"+ defaults="These members lost access when this space's Pro subscription ended. Their seats are kept and access is restored when the space is upgraded again."/></AlertDescription><AlertAction><Buttonsize="sm"- variant="link"onClick={() => {- showPayWall({ from: "space-members", action: "invite" });+ showPayWall({+ from: "space-members",+ action: "reactivate",+ });}}><Trans i18nKey="upgradeToPro" defaults="Upgrade to Pro" />@@ -164,121 +170,76 @@ export function MembersPage({</AlertAction></Alert>) : null}- {canInviteMembers ? (- <>- <PageSectionDivider />- <PageSection>- <PageSectionHeader>- <PageSectionTitle>- <Trans- i18nKey="pendingInvites"- defaults="Pending invites"- />- </PageSectionTitle>- <PageSectionDescription>- <Trans- i18nKey="pendingInvitesDescription"- defaults="Invite other users to share your space."- />- </PageSectionDescription>- </PageSectionHeader>- <PageSectionContent>- {invites.length > 0 ? (- <StackedList>- {invites.map((invite) => (- <StackedListItem key={invite.id}>- <div className="flex flex-1 items-center gap-4">- <OptimizedAvatarImage- name={invite.email}- size="xl"- />- <div>- <div className="flex items-center gap-x-2">- <div className="font-semibold text-sm">- {invite.email}- </div>- </div>- <div className="text-muted-foreground text-sm">- <Trans- i18nKey="memberInvitedBy"- defaults="Invited by {inviterName}"- values={{- inviterName: invite.invitedBy.name,- }}- />- </div>- </div>- </div>- <div className="text-sm">- <SpaceRole role={invite.role} />- </div>- <InviteDropdownMenu invite={invite} />- </StackedListItem>- ))}- </StackedList>- ) : null}- <div className="flex items-center gap-4">- <InviteMemberButton- usedSeats={usedSeats}- totalSeats={totalSeats}- />- <p className="font-medium text-sm">- <Trans- i18nKey="seatUsage"- defaults="{usedSeats} of {totalSeats} seats used"- values={{- usedSeats,- totalSeats,- }}- />- </p>- </div>- {totalSeats - usedSeats <= 0 ? (- <Alert variant="info">- <InfoIcon />- <AlertDescription>- <IfCloudHosted>- <p>- <Trans- i18nKey="noSeatsAvailableAlertBillingDescription"- defaults="Increase the number of seats in this space from the <a>billing page</a>."- components={{- a: (- <Link- className="underline hover:text-foreground"- href="/settings/billing"- />- ),- }}- />- </p>- </IfCloudHosted>- <IfSelfHosted>- <p>+ </IfFeatureEnabled>+ {!canInviteMembers && !hasInactiveMembers ? (+ <Alert variant="primary">+ <SparklesIcon />+ <AlertDescription>+ <Trans+ i18nKey="inviteMembersUpsellDescription"+ defaults="Invite members to manage polls and events together in this space."+ />+ </AlertDescription>+ <AlertAction>+ <Button+ size="sm"+ variant="link"+ onClick={() => {+ showPayWall({ from: "space-members", action: "invite" });+ }}+ >+ <Trans i18nKey="upgradeToPro" defaults="Upgrade to Pro" />+ </Button>+ </AlertAction>+ </Alert>+ ) : null}+ <StackedList>+ {members.data.map((member) => (+ <StackedListItem key={member.id}>+ <div className="flex flex-1 items-center gap-4">+ <OptimizedAvatarImage+ src={member.image ?? undefined}+ name={member.name}+ size="xl"+ />+ <div>+ <div className="flex items-center gap-x-2">+ <div className="font-semibold text-sm">{member.name}</div>+ <div>+ {member.isOwner ? (+ <Badge>+ <Trans i18nKey="owner" defaults="Owner" />+ </Badge>+ ) : null}+ <IfFeatureEnabled feature="billing">+ {space.data.tier === "hobby" && !member.isOwner ? (+ <Badge><Trans- i18nKey="noSeatsAvailableAlertSelfHostedDescription"- defaults="You will need to <a>upgrade</a> to increase the number of seats in this space."- components={{- a: (- <Link- className="underline hover:text-foreground"- prefetch={false}- href="https://support.rallly.co/self-hosting/licensing"- />- ),- }}+ i18nKey="memberInactive"+ defaults="Inactive"/>- </p>- </IfSelfHosted>- </AlertDescription>- </Alert>- ) : null}- </PageSectionContent>- </PageSection>- </>- ) : null}- </PageSectionGroup>+ </Badge>+ ) : null}+ </IfFeatureEnabled>+ </div>+ </div>+ <div className="text-muted-foreground text-sm">+ {member.email}+ </div>+ </div>+ </div>+ <div className="text-sm">+ <SpaceRole role={member.role} />+ </div>+ <MemberDropdownMenu member={member} />+ </StackedListItem>+ ))}+ </StackedList></PageContent>+ <PendingInvitesDialog+ invites={invites}+ {...pendingInvitesDialog.dialogProps}+ /></PageContainer>);}diff --git a/apps/web/tests/space-members.spec.ts b/apps/web/tests/space-members.spec.tsindex 49709ffb4..139974e74 100644--- a/apps/web/tests/space-members.spec.ts+++ b/apps/web/tests/space-members.spec.ts@@ -97,7 +97,7 @@ test.describe("Space members", () => {await gotoMembersPage(page, owner.email);await expect(- mainContent(page).getByText("1 of 3 seats used"),+ mainContent(page).getByText("2 seats available"),).toBeVisible();await page.getByRole("button", { name: "Invite member" }).click();@@ -106,10 +106,18 @@ test.describe("Space members", () => {await dialog.getByRole("button", { name: "Send invite" }).click();await expect(page.getByText("Invitation sent")).toBeVisible();+ await expect(+ mainContent(page).getByText("There is 1 pending invite"),+ ).toBeVisible();+ await page.getByRole("button", { name: "View invites" }).click();await expect(memberRow(page, inviteeEmail)).toBeVisible();await expect(memberRow(page, inviteeEmail).getByText(`Invited by ${owner.user.name}`),).toBeVisible();+ await page+ .getByRole("dialog")+ .getByRole("button", { name: "Close" })+ .click();// Capture the invite email before triggering the invitee's login so// the OTP capture doesn't pick it up instead.@@ -134,11 +142,9 @@ test.describe("Space members", () => {await page.reload();await expect(memberRow(page, "Invited Member")).toBeVisible();await expect(- memberRow(page, inviteeEmail).getByText(`Invited by ${owner.user.name}`),+ mainContent(page).getByText("There is 1 pending invite"),).toBeHidden();- await expect(- mainContent(page).getByText("2 of 3 seats used"),- ).toBeVisible();+ await expect(mainContent(page).getByText("1 seat available")).toBeVisible();});test("admin can cancel a pending invite", async ({ page }) => {@@ -156,14 +162,21 @@ test.describe("Space members", () => {await gotoMembersPage(page, owner.email);+ await expect(+ mainContent(page).getByText("There is 1 pending invite"),+ ).toBeVisible();+ await page.getByRole("button", { name: "View invites" }).click();+const inviteRow = memberRow(page, inviteeEmail);await expect(inviteRow).toBeVisible();- await inviteRow.getByRole("button", { name: "More options" }).click();- await page.getByRole("menuitem", { name: "Cancel invite" }).click();+ await inviteRow.getByRole("button", { name: "Cancel" }).click();await page.getByRole("button", { name: "Confirm" }).click();await expect(page.getByText("Invite canceled successfully")).toBeVisible();await expect(inviteRow).toBeHidden();+ await expect(+ mainContent(page).getByText("There is 1 pending invite"),+ ).toBeHidden();});test("admin can change a member's role", async ({ page }) => {@@ -192,9 +205,7 @@ test.describe("Space members", () => {});await gotoMembersPage(page, owner.email);- await expect(- mainContent(page).getByText("2 of 3 seats used"),- ).toBeVisible();+ await expect(mainContent(page).getByText("1 seat available")).toBeVisible();const row = memberRow(page, member.email);await row.getByRole("button", { name: "More options" }).click();@@ -205,7 +216,7 @@ test.describe("Space members", () => {await expect(row).toBeHidden();await expect(- mainContent(page).getByText("1 of 3 seats used"),+ mainContent(page).getByText("2 seats available"),).toBeVisible();});@@ -217,7 +228,7 @@ test.describe("Space members", () => {await gotoMembersPage(page, owner.email);await expect(- mainContent(page).getByText("1 of 1 seats used"),+ mainContent(page).getByText("No seats available"),).toBeVisible();await expect(page.getByRole("button", { name: "Invite member" }),