Legacy polls notice (#141)

* Add notice for legacy polls

* Update badges
This commit is contained in:
Luke Vella 2022-04-27 17:15:56 +01:00 committed by GitHub
parent 671f5b16fd
commit a91013ab16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 79 additions and 53 deletions

View file

@ -29,6 +29,20 @@ const ManagePoll: React.VoidFunctionComponent<{
const modalContext = useModalContext(); const modalContext = useModalContext();
const handleChangeOptions = () => {
if (poll.legacy) {
modalContext.render({
overlayClosable: true,
title: "Sorry!",
description:
"This poll was created with an older version of Rallly and does not support this feature.",
cancelText: "Close",
});
} else {
openChangeOptionsModal();
}
};
const { mutate: updatePollMutation, isLoading: isUpdating } = const { mutate: updatePollMutation, isLoading: isUpdating } =
useUpdatePollMutation(); useUpdatePollMutation();
const [ const [
@ -61,11 +75,7 @@ const ManagePoll: React.VoidFunctionComponent<{
} }
: { : {
type: "date", type: "date",
date: date: start,
start.indexOf("T") === -1
? start
: // legacy polls
new Date(start).toISOString().substring(0, 10),
}; };
}), }),
timeZone: poll.timeZone ?? "", timeZone: poll.timeZone ?? "",
@ -166,13 +176,11 @@ const ManagePoll: React.VoidFunctionComponent<{
label="Edit details" label="Edit details"
onClick={openChangePollDetailsModa} onClick={openChangePollDetailsModa}
/> />
{!poll.legacy ? (
<DropdownItem <DropdownItem
icon={Table} icon={Table}
label="Edit options" label="Edit options"
onClick={openChangeOptionsModal} onClick={handleChangeOptions}
/> />
) : null}
<DropdownItem <DropdownItem
icon={Save} icon={Save}
label="Export to CSV" label="Export to CSV"

View file

@ -8,6 +8,7 @@ import Button from "../button";
import { usePoll } from "../poll-context"; import { usePoll } from "../poll-context";
import Popover from "../popover"; import Popover from "../popover";
import { usePreferences } from "../preferences/use-preferences"; import { usePreferences } from "../preferences/use-preferences";
import Tooltip from "../tooltip";
export interface PollSubheaderProps {} export interface PollSubheaderProps {}
@ -36,15 +37,16 @@ const PollSubheader: React.VoidFunctionComponent<PollSubheaderProps> = () => {
}} }}
/> />
&nbsp; &nbsp;
<span className="inline-flex space-x-1">
{poll.role === "admin" ? ( {poll.role === "admin" ? (
poll.verified ? ( poll.verified ? (
<span className="inline-block cursor-default rounded-lg border border-green-400 bg-green-50 px-1 text-sm text-green-500"> <span className="inline-flex h-5 cursor-default items-center rounded-md bg-green-100/50 px-1 text-xs text-green-500 transition-colors">
Verified Verified
</span> </span>
) : ( ) : (
<Popover <Popover
trigger={ trigger={
<button className="inline-block rounded-lg border px-2 text-sm text-slate-400 transition-colors hover:bg-white hover:text-slate-700 hover:shadow-sm active:bg-gray-100"> <button className="inline-flex h-5 items-center rounded-md bg-slate-200 px-1 text-xs text-slate-500 transition-colors hover:bg-slate-300 hover:shadow-sm active:bg-slate-200">
Unverified Unverified
</button> </button>
} }
@ -63,7 +65,9 @@ const PollSubheader: React.VoidFunctionComponent<PollSubheaderProps> = () => {
/> />
</div> </div>
{didSendVerificationEmail ? ( {didSendVerificationEmail ? (
<div className="text-green-500">Verification email sent.</div> <div className="text-green-500">
Verification email sent.
</div>
) : ( ) : (
<Button <Button
onClick={() => { onClick={() => {
@ -78,6 +82,17 @@ const PollSubheader: React.VoidFunctionComponent<PollSubheaderProps> = () => {
</Popover> </Popover>
) )
) : null} ) : null}
{poll.legacy && poll.role === "admin" ? (
<Tooltip
width={400}
content="This poll was created with an older version of Rallly. Some features might not work."
>
<span className="inline-flex h-5 cursor-default items-center rounded-md bg-amber-100 px-1 text-xs text-amber-500">
Legacy
</span>
</Tooltip>
) : null}
</span>
</div> </div>
<span className="hidden md:inline">&nbsp;&bull;&nbsp;</span> <span className="hidden md:inline">&nbsp;&bull;&nbsp;</span>
<span className="whitespace-nowrap"> <span className="whitespace-nowrap">

View file

@ -21,6 +21,7 @@ export interface TooltipProps {
content?: React.ReactNode; content?: React.ReactNode;
disabled?: boolean; disabled?: boolean;
className?: string; className?: string;
width?: number;
} }
const Tooltip: React.VoidFunctionComponent<TooltipProps> = ({ const Tooltip: React.VoidFunctionComponent<TooltipProps> = ({
@ -29,6 +30,7 @@ const Tooltip: React.VoidFunctionComponent<TooltipProps> = ({
children, children,
disabled, disabled,
content, content,
width,
}) => { }) => {
const arrowRef = React.useRef<HTMLDivElement | null>(null); const arrowRef = React.useRef<HTMLDivElement | null>(null);
const [open, setOpen] = React.useState(false); const [open, setOpen] = React.useState(false);
@ -109,6 +111,7 @@ const Tooltip: React.VoidFunctionComponent<TooltipProps> = ({
position: strategy, position: strategy,
top: y ?? "", top: y ?? "",
left: x ?? "", left: x ?? "",
maxWidth: width,
}, },
})} })}
> >