Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
Offer option to reset poll for legacy events
Luke Vellacd2b0e2cb8a7
diff --git a/components/icons/refresh.svg b/components/icons/refresh.svgnew file mode 100644index 000000000..d776bb933--- /dev/null+++ b/components/icons/refresh.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">+ <path stroke-linecap="round" stroke-linejoin="round" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />+</svg>\ No newline at end of filediff --git a/components/poll/manage-poll.tsx b/components/poll/manage-poll.tsxindex 2b425460f..8f303cafe 100644--- a/components/poll/manage-poll.tsx+++ b/components/poll/manage-poll.tsx@@ -3,6 +3,7 @@ import Dropdown, { DropdownItem } from "../dropdown";import { usePoll } from "../use-poll";import Pencil from "@/components/icons/pencil-alt.svg";import Table from "@/components/icons/table.svg";+import Refresh from "@/components/icons/refresh.svg";import Save from "@/components/icons/save.svg";import Cog from "@/components/icons/cog.svg";import LockOpen from "@/components/icons/lock-open.svg";@@ -15,6 +16,8 @@ import { useUpdatePollMutation } from "./mutations";import { PollDetailsForm } from "../forms";import Button from "@/components/button";import { Placement } from "@popperjs/core";+import { useMutation, useQueryClient } from "react-query";+import axios from "axios";const PollOptionsForm = React.lazy(() => import("../forms/poll-options-form"));@@ -24,6 +27,40 @@ const ManagePoll: React.VoidFunctionComponent<{}> = ({ targetTimeZone, placement }) => {const { t } = useTranslation("app");const poll = usePoll();+ const queryClient = useQueryClient();+ const { mutate: resetPoll } = useMutation(+ async () => {+ await axios.get(`/api/legacy/${poll.urlId}?reset=true`);+ },+ {+ onSettled: () => {+ queryClient.invalidateQueries(["getPoll", poll.urlId]);+ },+ },+ );++ const [resetModalContext, openResetModal] = useModal({+ overlayClosable: true,+ title: "Are you sure?",+ description: (+ <>+ This will reset the poll to how it was before it was transferred to the+ new version.+ <em className="block mt-2">+ Any changes (including votes or comments) that were done in the new+ version will be lost.+ </em>+ </>+ ),+ okText: "Reset",+ okButtonProps: {+ type: "danger",+ },+ onOk: () => {+ resetPoll();+ },+ cancelText: "Cancel",+ });const { mutate: updatePollMutation, isLoading: isUpdating } =useUpdatePollMutation();@@ -122,9 +159,10 @@ const ManagePoll: React.VoidFunctionComponent<{),});return (- <>+ <div>{changeOptionsModalContextHolder}{changePollDetailsModalContextHolder}+ {resetModalContext}<Dropdownplacement={placement}trigger={<Button icon={<Cog />}>Manage</Button>}@@ -206,8 +244,17 @@ const ManagePoll: React.VoidFunctionComponent<{onClick={() => updatePollMutation({ closed: true })}/>)}+ {poll.legacy ? (+ <DropdownItem+ icon={Refresh}+ label="Reset poll"+ onClick={() => {+ openResetModal();+ }}+ />+ ) : null}</Dropdown>- </>+ </div>);};diff --git a/components/support.tsx b/components/support.tsxindex 183a298c6..a5c9852ab 100644--- a/components/support.tsx+++ b/components/support.tsx@@ -16,6 +16,18 @@ const Support: React.VoidFunctionComponent = () => {<div className="lg:flex py-16"><div className="grow mb-8"><h2 className="text-3xl mb-4">General</h2>+ <Disclosure as="div" className="bg-slate-50 p-2 rounded-lg mb-4">+ <Disclosure.Button className="font-medium text-lg py-2 px-3 rounded-lg active:bg-slate-200 block w-full text-left font-slate hover:text-indigo-500 hover:bg-slate-100 cursor-pointer">+ <Trans t={t} i18nKey="wrongDaysShownQuestion" />+ </Disclosure.Button>+ <Disclosure.Panel className="text py-2 px-3">+ <Trans+ t={t}+ i18nKey="wrongDaysShownAnswer"+ components={{ b: <strong /> }}+ />+ </Disclosure.Panel>+ </Disclosure><Disclosure as="div" className="bg-slate-50 p-2 rounded-lg mb-4"><Disclosure.Button className="font-medium text-lg py-2 px-3 rounded-lg active:bg-slate-200 block w-full text-left font-slate hover:text-indigo-500 hover:bg-slate-100 cursor-pointer"><Trans t={t} i18nKey="howDoIShareQuestion" />diff --git a/pages/poll.tsx b/pages/poll.tsxindex b23cdaf99..642ad6ba6 100644--- a/pages/poll.tsx+++ b/pages/poll.tsx@@ -240,16 +240,18 @@ const PollPage: NextPage = () => {}targetTimeZone={targetTimeZone}/>- <Popover- trigger={- <Button type="primary" icon={<Share />}>- Share- </Button>- }- placement={isWideScreen ? "bottom-end" : undefined}- >- <Sharing links={poll.links} />- </Popover>+ <div>+ <Popover+ trigger={+ <Button type="primary" icon={<Share />}>+ Share+ </Button>+ }+ placement={isWideScreen ? "bottom-end" : undefined}+ >+ <Sharing links={poll.links} />+ </Popover>+ </div></div>) : null}</div>diff --git a/public/locales/en/support.json b/public/locales/en/support.jsonindex 1c759064b..06894170b 100644--- a/public/locales/en/support.json+++ b/public/locales/en/support.json@@ -14,6 +14,8 @@"legacyPollsAnswer": "Legacy polls are stored in a different database but you can still access the poll with the same URL. The polls will be transferred over in to the new database when you first try to access it. If a poll has not been accessed for at least two months then it might no longer be available but you can contact <a>[email protected]</a> to attempt to recover it.","howDoIShareQuestion": "How do I share my poll with my participants?","howDoIShareAnswer": "To share your poll, click on the <b>Share</b> button next to the title of your poll and copy the participant link. You can share this link with your participants through your own channels such as email, whatsapp, facebook etc…",+ "wrongDaysShownQuestion": "My poll is now showing the wrong dates. What can I do?",+ "wrongDaysShownAnswer": "A number of users have been affected by this bug which is caused by the previous version storing the incorrect dates in the database. However when the dates are adjusted for the user's time zone they appear to be correct. If you notice that your days have shifted you can reset your poll by clicking <b>Manage</b> > <b>Reset Poll</b>. This will refetch the data from the legacy database and revert it to how it was before the transfer. <b>Any changes (including votes or comments) made after the poll was transferred will be lost</b>.","contributeQuestion": "How can I contribute?","contributeAnswer": "Rallly is 100% self-funded so the best way to contribute is to become a <a>sponsor</a>. This money will go towards paying for hosting and will support future development of this website."}