Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

✨ Update dashboard page (#1915)

Luke Vella20776023562c
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json
index 5cd94d31d..544fa9af1 100644
--- a/apps/web/public/locales/en/app.json
+++ b/apps/web/public/locales/en/app.json
@@ -497,5 +497,6 @@
"noSeatsAvailableAlertBillingDescription": "Increase the number of seats in this space from the <a>billing page</a>.",
"noSeatsAvailableAlertSelfHostedDescription": "You will need to <a>upgrade</a> to increase the number of seats in this space.",
"seatsUpdatedAlertTitle": "Seats Updated",
- "seatsUpdatedAlertDescription": "Your seat allocation has been successfully updated. The changes will be reflected in your next billing cycle."
+ "seatsUpdatedAlertDescription": "Your seat allocation has been successfully updated. The changes will be reflected in your next billing cycle.",
+ "memberCount": "{count, plural, =0 {No members} one {1 member} other {# members}}"
}
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/page.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/page.tsx
index 4e9149bdc..769dfbf72 100644
--- a/apps/web/src/app/[locale]/(space)/(dashboard)/page.tsx
+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/page.tsx
@@ -6,9 +6,9 @@ import {
BillingPageIcon,
CreatePageIcon,
EventPageIcon,
+ MembersPageIcon,
PollPageIcon,
- PreferencesPageIcon,
- ProfilePageIcon,
+ SettingsPageIcon,
} from "@/app/components/page-icons";
import {
PageContainer,
@@ -16,35 +16,53 @@ import {
PageHeader,
PageTitle,
} from "@/app/components/page-layout";
-import { requireSpace } from "@/auth/data";
+import { requireSpace, requireUser } from "@/auth/data";
import { Trans } from "@/components/trans";
import { IfCloudHosted } from "@/contexts/environment";
import { getUpcomingEventsCount } from "@/features/scheduled-event/data";
+import { getSpaceSeatCount, loadMembers } from "@/features/space/data";
+import { defineAbilityForMember } from "@/features/space/member/ability";
import { getTranslation } from "@/i18n/server";
+import { IfFeatureEnabled } from "@/lib/feature-flags/client";
import { FeedbackAlert } from "./feedback-alert";
async function loadData() {
- const space = await requireSpace();
+ const [space, user] = await Promise.all([requireSpace(), requireUser()]);
- const [livePollCount, upcomingEventCount] = await Promise.all([
- prisma.poll.count({
- where: {
- spaceId: space.id,
- status: "live",
- deleted: false,
- },
- }),
- getUpcomingEventsCount(),
- ]);
+ const [livePollCount, upcomingEventCount, memberCount, seatCount] =
+ await Promise.all([
+ prisma.poll.count({
+ where: {
+ spaceId: space.id,
+ status: "live",
+ deleted: false,
+ },
+ }),
+ getUpcomingEventsCount(),
+ loadMembers().then((members) => members.total),
+ getSpaceSeatCount(space.id),
+ ]);
+
+ const ability = defineAbilityForMember({ space, user });
+ const canManageBilling = ability.can("manage", "Billing");
return {
livePollCount,
upcomingEventCount,
+ memberCount,
+ seatCount,
+ canManageBilling,
};
}
export default async function Page() {
- const { livePollCount, upcomingEventCount } = await loadData();
+ const {
+ livePollCount,
+ upcomingEventCount,
+ memberCount,
+ seatCount,
+ canManageBilling,
+ } = await loadData();
return (
<PageContainer>
@@ -112,36 +130,53 @@ export default async function Page() {
</div>
<div className="space-y-4">
<h2 className="text-muted-foreground text-sm">
- <Trans i18nKey="account" defaults="Account" />
+ <Trans i18nKey="settings" defaults="Settings" />
</h2>
<TileGrid>
<Tile asChild>
- <Link href="/account/profile">
- <ProfilePageIcon />
+ <Link href="/settings/general">
+ <SettingsPageIcon />
<TileTitle>
- <Trans i18nKey="profile" defaults="Profile" />
+ <Trans i18nKey="general" defaults="General" />
</TileTitle>
</Link>
</Tile>
<Tile asChild>
- <Link href="/account/preferences">
- <PreferencesPageIcon />
+ <Link href="/settings/members">
+ <MembersPageIcon />
<TileTitle>
- <Trans i18nKey="preferences" defaults="Preferences" />
+ <Trans i18nKey="members" defaults="Members" />
</TileTitle>
+ <TileDescription>
+ <Trans
+ i18nKey="memberCount"
+ defaults="{count, plural, =0 {No members} one {1 member} other {# members}}"
+ values={{ count: memberCount }}
+ />
+ </TileDescription>
</Link>
</Tile>
- <IfCloudHosted>
- <Tile asChild>
- <Link href="/settings/billing">
- <BillingPageIcon />
- <TileTitle>
- <Trans i18nKey="billing" defaults="Billing" />
- </TileTitle>
- </Link>
- </Tile>
- </IfCloudHosted>
+
+ <IfFeatureEnabled feature="billing">
+ {canManageBilling && (
+ <Tile asChild>
+ <Link href="/settings/billing">
+ <BillingPageIcon />
+ <TileTitle>
+ <Trans i18nKey="billing" defaults="Billing" />
+ </TileTitle>
+ <TileDescription>
+ <Trans
+ i18nKey="seatCount"
+ defaults="{count, plural, =0 {No seats} one {1 seat} other {# seats}}"
+ values={{ count: seatCount }}
+ />
+ </TileDescription>
+ </Link>
+ </Tile>
+ )}
+ </IfFeatureEnabled>
</TileGrid>
</div>
</PageContent>
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/settings/billing/page.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/settings/billing/page.tsx
index 266971bff..eb1596f1f 100644
--- a/apps/web/src/app/[locale]/(space)/(dashboard)/settings/billing/page.tsx
+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/settings/billing/page.tsx
@@ -12,6 +12,7 @@ import {
import { Trans } from "@/components/trans";
import { getSpaceSubscription } from "@/features/billing/data";
import { loadMembers } from "@/features/space/data";
+import { defineAbilityForMember } from "@/features/space/member/ability";
import { getTotalSeatsForSpace } from "@/features/space/utils";
import { getTranslation } from "@/i18n/server";
import { isFeatureEnabled } from "@/lib/feature-flags/server";
@@ -22,10 +23,10 @@ export default async function BillingSettingsPage() {
}
const [space, user] = await Promise.all([requireSpace(), requireUser()]);
- // Check if user is owner - only owners can access billing
- const isOwner = space.ownerId === user.id;
+ const ability = defineAbilityForMember({ space, user });
+ const canManageBilling = ability.can("manage", "Billing");
- if (!isOwner) {
+ if (!canManageBilling) {
return (
<EmptyState>
<EmptyStateIcon>
diff --git a/apps/web/src/app/components/page-icons.tsx b/apps/web/src/app/components/page-icons.tsx
index 520318edc..7a5f1cc6c 100644
--- a/apps/web/src/app/components/page-icons.tsx
+++ b/apps/web/src/app/components/page-icons.tsx
@@ -83,7 +83,7 @@ export function SpacesPageIcon() {
export function MembersPageIcon() {
return (
- <PageIcon color="indigo" size="md">
+ <PageIcon color="gray" size="md">
<UsersIcon />
</PageIcon>
);
diff --git a/apps/web/src/features/space/member/ability.ts b/apps/web/src/features/space/member/ability.ts
index 5bcf1b057..6c8a44af1 100644
--- a/apps/web/src/features/space/member/ability.ts
+++ b/apps/web/src/features/space/member/ability.ts
@@ -10,7 +10,7 @@ export type MemberAbilityContext = {
space: { id: string; ownerId: string; role: MemberRole };
};
-type Action = "cancel" | "create" | "read" | "update" | "delete";
+type Action = "cancel" | "create" | "read" | "update" | "delete" | "manage";
type Subject = Subjects<{
ScheduledEvent: {
spaceId: string;
@@ -27,6 +27,7 @@ type Subject = Subjects<{
id: string;
ownerId: string;
};
+ Billing: Record<string, never>;
}>;
export type MemberAbility = PureAbility<[Action, Subject], PrismaQuery>;
@@ -53,6 +54,7 @@ export function defineAbilityForMember(ctx?: MemberAbilityContext) {
builder.can("delete", "Space", {
ownerId: ctx.user.id,
});
+ builder.can("manage", "Billing");
}
return builder.build();