From c979909da91134d3e152c75e816ac66ecd1f0a91 Mon Sep 17 00:00:00 2001 From: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com> Date: Thu, 21 May 2026 10:51:33 +0530 Subject: [PATCH] fix: show copy icon on legacy environmentId, reintroduce duplicate survey action (ENG-978, ENG-987) (#8061) Co-authored-by: Claude Opus 4.7 (1M context) --- .../list/components/survey-dropdown-menu.tsx | 47 ++++++++++++++++++- .../settings/(setup)/app-connection/page.tsx | 1 - apps/web/playwright/survey-overview.spec.ts | 4 +- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/apps/web/modules/survey/list/components/survey-dropdown-menu.tsx b/apps/web/modules/survey/list/components/survey-dropdown-menu.tsx index 4e75607178..f1faf6b875 100644 --- a/apps/web/modules/survey/list/components/survey-dropdown-menu.tsx +++ b/apps/web/modules/survey/list/components/survey-dropdown-menu.tsx @@ -1,6 +1,7 @@ "use client"; -import { EyeIcon, LinkIcon, MoreVertical, SquarePenIcon, TrashIcon } from "lucide-react"; +import { useQueryClient } from "@tanstack/react-query"; +import { CopyIcon, EyeIcon, LinkIcon, MoreVertical, SquarePenIcon, TrashIcon } from "lucide-react"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useMemo, useState } from "react"; @@ -9,9 +10,12 @@ import { useTranslation } from "react-i18next"; import { logger } from "@formbricks/logger"; import { useWorkspace } from "@/app/(app)/workspaces/[workspaceId]/context/workspace-context"; import { cn } from "@/lib/cn"; +import { getFormattedErrorMessage } from "@/lib/utils/helper"; import { getV3ApiErrorMessage } from "@/modules/api/lib/v3-client"; import { EditPublicSurveyAlertDialog } from "@/modules/survey/components/edit-public-survey-alert-dialog"; import { copySurveyLink } from "@/modules/survey/lib/client-utils"; +import { copySurveyToOtherWorkspaceAction } from "@/modules/survey/list/actions"; +import { surveyKeys } from "@/modules/survey/list/lib/query"; import { TSurveyListItem } from "@/modules/survey/list/types/survey-overview"; import { DeleteDialog } from "@/modules/ui/components/delete-dialog"; import { @@ -42,9 +46,11 @@ export const SurveyDropDownMenu = ({ const { t } = useTranslation(); const [isDeleteDialogOpen, setDeleteDialogOpen] = useState(false); const [loading, setLoading] = useState(false); + const [isDuplicating, setIsDuplicating] = useState(false); const [isDropDownOpen, setIsDropDownOpen] = useState(false); const [isCautionDialogOpen, setIsCautionDialogOpen] = useState(false); const router = useRouter(); + const queryClient = useQueryClient(); const editHref = `/workspaces/${workspace?.id}/surveys/${survey.id}/edit`; @@ -85,6 +91,29 @@ export const SurveyDropDownMenu = ({ setIsCautionDialogOpen(true); }; + const handleDuplicateSurvey = async () => { + if (!workspace?.id) return; + setIsDuplicating(true); + setIsDropDownOpen(false); + try { + const response = await copySurveyToOtherWorkspaceAction({ + surveyId: survey.id, + targetWorkspaceId: workspace.id, + }); + if (response?.data) { + toast.success(t("workspace.surveys.survey_duplicated_successfully")); + await queryClient.invalidateQueries({ queryKey: surveyKeys.lists() }); + return; + } + toast.error(getFormattedErrorMessage(response)); + } catch (error) { + logger.error(error); + toast.error(t("common.something_went_wrong_please_try_again")); + } finally { + setIsDuplicating(false); + } + }; + if (!hasVisibleActions) { return null; } @@ -120,6 +149,22 @@ export const SurveyDropDownMenu = ({ )} + {canManageSurvey && ( + + + + )} {canPreviewOrCopyLink && (