Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
💄 Split Add location into location and video call buttons (#3439)
Luke Vella6d879f3d70a5
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.jsonindex 2a6700aef..1355e0231 100644--- a/apps/web/public/locales/en/app.json+++ b/apps/web/public/locales/en/app.json@@ -41,6 +41,7 @@"addSeats": "{count, plural, one {Add # seat} other {Add # seats}}","addTimeOption": "Add time option","addToCalendar": "Add to calendar",+ "addVideoCall": "Add video call","addWebhook": "Add webhook","admin": "Admin","adminAccessRequired": "Administrator access required",@@ -186,6 +187,8 @@"conferencingDescription": "Connect the tools you use for video calls so we can add meeting links to your events.","conferencingDisconnected": "Account disconnected","conferencingDisconnecting": "Disconnecting account…",+ "conferencingMenuAvailable": "Available",+ "conferencingMenuConnected": "Connected","conferencingNotConnected": "{provider} is not connected. Visit the <a>Conferencing settings</a> page to connect your account.","conferencingTeamsAdminConsentHint": "If your organization requires admin approval, send this link to your IT administrator.","conferencingTeamsCannotHost": "This Microsoft account can't create Teams meetings",@@ -454,7 +457,6 @@"industryReligiousOrganisation": "Religious organisation","industrySportsAndRecreation": "Sports and recreation","industryTechnology": "Technology",- "inPerson": "In-person","instanceSettingsDescription": "Configure your instance settings","invalidEmailAddress": "Please enter a valid email address","invalidFileType": "Invalid file type",diff --git a/apps/web/src/features/conferencing/components/conferencing-field.tsx b/apps/web/src/features/conferencing/components/conferencing-field.tsxindex 5a8b7bd71..98c936561 100644--- a/apps/web/src/features/conferencing/components/conferencing-field.tsx+++ b/apps/web/src/features/conferencing/components/conferencing-field.tsx@@ -5,6 +5,7 @@ import {DropdownMenuGroup,DropdownMenuItem,DropdownMenuLabel,+ DropdownMenuSeparator,} from "@rallly/ui/dropdown-menu";import { FormItem, FormLabel } from "@rallly/ui/form";import { Input } from "@rallly/ui/input";@@ -68,15 +69,17 @@ export const toConferencingFormValues = (conferencing?.provider === "custom" ? conferencing.label : "",});-// Menu entries for the shared "Add location" menu. Renders nothing once a-// choice is made: an event carries one meeting link. A caller on a free-// plan passes `upsell` to mark the Pro providers and take the click, so a-// choice that can never be cashed in is not made. Google Meet and a pasted+// Menu entries for the "Add video call" menu: linked providers first,+// then the rest this instance offers, then a pasted link. Renders nothing+// once a choice is made: an event carries one meeting link. A caller on a+// free plan passes `upsell` to mark the Pro providers and take the click, so+// a choice that can never be cashed in is not made. Google Meet and a pasted// link are never gated.export function ConferencingProviderMenuItems({available,+ connected,upsell,-}: Pick<ConferencingOptions, "available"> & {+}: ConferencingOptions & {upsell?: {badge: React.ReactNode;onSelect: (provider: ConferencingProvider) => void;@@ -89,32 +92,51 @@ export function ConferencingProviderMenuItems({return null;}+ const unconnected = available.filter(+ (provider) => !connected.includes(provider),+ );++ const renderItem = (provider: ConferencingProvider) => {+ const gate = isProConferencingProvider(provider) ? upsell : undefined;+ return (+ <DropdownMenuItem+ key={provider}+ onClick={() => {+ if (gate) {+ gate.onSelect(provider);+ return;+ }+ form.setValue("conferencingProvider", provider, {+ shouldDirty: true,+ });+ }}+ >+ <ConferencingProviderIcon provider={provider} size={16} />+ {conferencingProviderLabels[provider]}+ {gate?.badge}+ </DropdownMenuItem>+ );+ };+return (- <DropdownMenuGroup>- <DropdownMenuLabel>- <Trans i18nKey="videoCall" defaults="Video call" />- </DropdownMenuLabel>- {available.map((provider) => {- const gate = isProConferencingProvider(provider) ? upsell : undefined;- return (- <DropdownMenuItem- key={provider}- onClick={() => {- if (gate) {- gate.onSelect(provider);- return;- }- form.setValue("conferencingProvider", provider, {- shouldDirty: true,- });- }}- >- <ConferencingProviderIcon provider={provider} size={16} />- {conferencingProviderLabels[provider]}- {gate?.badge}- </DropdownMenuItem>- );- })}+ <>+ {connected.length > 0 ? (+ <DropdownMenuGroup>+ <DropdownMenuLabel>+ <Trans i18nKey="conferencingMenuConnected" defaults="Connected" />+ </DropdownMenuLabel>+ {connected.map(renderItem)}+ </DropdownMenuGroup>+ ) : null}+ {unconnected.length > 0 ? (+ <DropdownMenuGroup>+ <DropdownMenuLabel>+ <Trans i18nKey="conferencingMenuAvailable" defaults="Available" />+ </DropdownMenuLabel>+ {unconnected.map(renderItem)}+ </DropdownMenuGroup>+ ) : null}+ {available.length > 0 ? <DropdownMenuSeparator /> : null}<DropdownMenuItemonClick={() => {form.setValue("conferencingProvider", "custom", {@@ -125,7 +147,7 @@ export function ConferencingProviderMenuItems({<VideoIcon /><Trans i18nKey="customVideoCall" defaults="Custom" /></DropdownMenuItem>- </DropdownMenuGroup>+ </>);}diff --git a/apps/web/src/features/poll/components/forms/poll-details-form.tsx b/apps/web/src/features/poll/components/forms/poll-details-form.tsxindex fe263bceb..2b91a8a7c 100644--- a/apps/web/src/features/poll/components/forms/poll-details-form.tsx+++ b/apps/web/src/features/poll/components/forms/poll-details-form.tsx@@ -2,14 +2,11 @@ import { Button } from "@rallly/ui/button";import {DropdownMenu,DropdownMenuContent,- DropdownMenuGroup,- DropdownMenuItem,- DropdownMenuLabel,DropdownMenuTrigger,} from "@rallly/ui/dropdown-menu";import { FormField, FormItem, FormLabel, FormMessage } from "@rallly/ui/form";import { Input } from "@rallly/ui/input";-import { BuildingIcon, PlusIcon } from "lucide-react";+import { PlusIcon } from "lucide-react";import * as React from "react";import { Controller, useFormContext } from "react-hook-form";import { showPayWall, useIsFree } from "@/features/billing/client";@@ -26,7 +23,7 @@ import { useFormValidation } from "@/lib/utils/form-validation";import { LazyRichTextEditor } from "./lazy-rich-text-editor";import type { NewEventData } from "./types";-// Without `conferencing`, "Add location" opens the address field directly.+// Without `conferencing`, only "Add location" is offered.export const PollDetailsForm = ({conferencing,}: {@@ -117,28 +114,28 @@ export const PollDetailsForm = ({) : null}{canAddAddress || canAddVideoCall || !descriptionExpanded ? (<div className="flex flex-wrap gap-2">+ {canAddAddress ? (+ <Button+ type="button"+ className="rounded-full"+ onClick={() => setLocationOpened(true)}+ >+ <PlusIcon data-icon="inline-start" />+ <Trans i18nKey="addLocation" defaults="Add location" />+ </Button>+ ) : null}{canAddVideoCall ? (<DropdownMenu><DropdownMenuTriggerrender={<Button type="button" className="rounded-full" />}><PlusIcon data-icon="inline-start" />- <Trans i18nKey="addLocation" defaults="Add location" />+ <Trans i18nKey="addVideoCall" defaults="Add video call" /></DropdownMenuTrigger><DropdownMenuContent align="start">- {canAddAddress ? (- <DropdownMenuGroup>- <DropdownMenuLabel>- <Trans i18nKey="inPerson" defaults="In-person" />- </DropdownMenuLabel>- <DropdownMenuItem onClick={() => setLocationOpened(true)}>- <BuildingIcon />- <Trans i18nKey="address" defaults="Address" />- </DropdownMenuItem>- </DropdownMenuGroup>- ) : null}<ConferencingProviderMenuItemsavailable={conferencing.available}+ connected={conferencing.connected}upsell={isFree? {@@ -156,15 +153,6 @@ export const PollDetailsForm = ({/></DropdownMenuContent></DropdownMenu>- ) : canAddAddress ? (- <Button- type="button"- className="rounded-full"- onClick={() => setLocationOpened(true)}- >- <PlusIcon data-icon="inline-start" />- <Trans i18nKey="addLocation" defaults="Add location" />- </Button>) : null}{!descriptionExpanded ? (<Buttondiff --git a/apps/web/tests/conferencing.spec.ts b/apps/web/tests/conferencing.spec.tsindex 582869d31..1a85fcb48 100644--- a/apps/web/tests/conferencing.spec.ts+++ b/apps/web/tests/conferencing.spec.ts@@ -93,7 +93,7 @@ test.describeconst newPollPage = new NewPollPage(page);await newPollPage.goto();- await page.getByRole("button", { name: "Add location" }).click();+ await page.getByRole("button", { name: "Add video call" }).click();const zoom = page.getByRole("menuitem", { name: "Zoom" });await expect(zoom.getByText("Pro")).toBeVisible();await zoom.click();@@ -119,7 +119,7 @@ test.describeconst newPollPage = new NewPollPage(page);await newPollPage.goto();- await page.getByRole("button", { name: "Add location" }).click();+ await page.getByRole("button", { name: "Add video call" }).click();await page.getByRole("menuitem", { name: "Zoom" }).click();const error = page.locator("#create-poll").getByRole("alert");@@ -129,7 +129,7 @@ test.describe).toHaveAttribute("href", "/settings/conferencing");await page.getByRole("button", { name: "Remove" }).click();- await page.getByRole("button", { name: "Add location" }).click();+ await page.getByRole("button", { name: "Add video call" }).click();await expect(page.getByRole("menuitem", { name: "Zoom" })).toBeVisible();await page.keyboard.press("Escape");});@@ -149,7 +149,7 @@ test.describeconst newPollPage = new NewPollPage(page);await newPollPage.goto();- await page.getByRole("button", { name: "Add location" }).click();+ await page.getByRole("button", { name: "Add video call" }).click();await page.getByRole("menuitem", { name: "Zoom" }).click();await expect(page.locator("#create-poll").getByRole("alert")).toHaveCount(0,@@ -170,7 +170,7 @@ test.describeconst newPollPage = new NewPollPage(page);await newPollPage.goto();- await page.getByRole("button", { name: "Add location" }).click();+ await page.getByRole("button", { name: "Add video call" }).click();await page.getByRole("menuitem", { name: "Custom" }).click();await page.getByLabel("Video call").fill("Jitsi");await page@@ -195,7 +195,7 @@ test.describeconst newPollPage = new NewPollPage(page);await newPollPage.goto();- await page.getByRole("button", { name: "Add location" }).click();+ await page.getByRole("button", { name: "Add video call" }).click();await page.getByRole("menuitem", { name: "Custom" }).click();await page.getByLabel("Video call").fill("Microsoft Teams");@@ -218,7 +218,7 @@ test.describeconst newPollPage = new NewPollPage(page);await newPollPage.goto();- await page.getByRole("button", { name: "Add location" }).click();+ await page.getByRole("button", { name: "Add video call" }).click();await page.getByRole("menuitem", { name: "Custom" }).click();await page.getByLabel("Video call").fill("Jitsi");await page.getByLabel("Link (optional)").fill("not a link");diff --git a/apps/web/tests/new-poll-page.ts b/apps/web/tests/new-poll-page.tsindex 7ef743aec..b941a96b6 100644--- a/apps/web/tests/new-poll-page.ts+++ b/apps/web/tests/new-poll-page.ts@@ -23,20 +23,13 @@ export class NewPollPage {await page.getByLabel(/title|event/i).fill(name);- // "Add location" is a menu when the organizer can add a video call and a- // plain button otherwise; either way the address field appears after.- // Exact label: the open menu is also named "Add location". A click that- // lands before React hydrates is dropped, so retry until the field shows.+ // A click that lands before React hydrates is dropped, so retry until the+ // field shows.const locationField = page.getByLabel("Location", { exact: true });await expect(async () => {await page.getByRole("button", { name: "Add location" }).click({ timeout: 2000 });- const addressItem = page.getByRole("menuitem", { name: "Address" });- await addressItem.or(locationField).first().waitFor({ timeout: 2000 });- if (await addressItem.isVisible()) {- await addressItem.click();- }await expect(locationField).toBeVisible({ timeout: 2000 });}).toPass();await locationField.fill("Online");