feat: add existing issue option added in spreadsheet view (#1397)

This commit is contained in:
Anmol Singh Bhatia 2023-06-26 18:01:28 +05:30 committed by GitHub
parent ae051b28af
commit ad3411284b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 12 deletions

View File

@ -572,8 +572,11 @@ export const IssuesView: React.FC<Props> = ({
/> />
) : issueView === "spreadsheet" ? ( ) : issueView === "spreadsheet" ? (
<SpreadsheetView <SpreadsheetView
type={type}
handleEditIssue={handleEditIssue} handleEditIssue={handleEditIssue}
handleDeleteIssue={handleDeleteIssue} handleDeleteIssue={handleDeleteIssue}
openIssuesListModal={type !== "issue" ? openIssuesListModal : null}
isCompleted={isCompleted}
user={user} user={user}
userAuth={memberRole} userAuth={memberRole}
/> />

View File

@ -5,7 +5,7 @@ import { useRouter } from "next/router";
// components // components
import { SpreadsheetColumns, SpreadsheetIssues } from "components/core"; import { SpreadsheetColumns, SpreadsheetIssues } from "components/core";
import { Icon, Spinner } from "components/ui"; import { CustomMenu, Icon, Spinner } from "components/ui";
// hooks // hooks
import useIssuesProperties from "hooks/use-issue-properties"; import useIssuesProperties from "hooks/use-issue-properties";
import useSpreadsheetIssuesView from "hooks/use-spreadsheet-issues-view"; import useSpreadsheetIssuesView from "hooks/use-spreadsheet-issues-view";
@ -17,15 +17,21 @@ import { SPREADSHEET_COLUMN } from "constants/spreadsheet";
import { PlusIcon } from "@heroicons/react/24/outline"; import { PlusIcon } from "@heroicons/react/24/outline";
type Props = { type Props = {
type: "issue" | "cycle" | "module";
handleEditIssue: (issue: IIssue) => void; handleEditIssue: (issue: IIssue) => void;
handleDeleteIssue: (issue: IIssue) => void; handleDeleteIssue: (issue: IIssue) => void;
openIssuesListModal?: (() => void) | null;
isCompleted?: boolean;
user: ICurrentUserResponse | undefined; user: ICurrentUserResponse | undefined;
userAuth: UserAuth; userAuth: UserAuth;
}; };
export const SpreadsheetView: React.FC<Props> = ({ export const SpreadsheetView: React.FC<Props> = ({
type,
handleEditIssue, handleEditIssue,
handleDeleteIssue, handleDeleteIssue,
openIssuesListModal,
isCompleted = false,
user, user,
userAuth, userAuth,
}) => { }) => {
@ -79,6 +85,7 @@ export const SpreadsheetView: React.FC<Props> = ({
className="relative group grid auto-rows-[minmax(44px,1fr)] hover:rounded-sm hover:bg-brand-surface-2 border-b border-brand-base w-full min-w-max" className="relative group grid auto-rows-[minmax(44px,1fr)] hover:rounded-sm hover:bg-brand-surface-2 border-b border-brand-base w-full min-w-max"
style={{ gridTemplateColumns }} style={{ gridTemplateColumns }}
> >
{type === "issue" ? (
<button <button
className="flex gap-1.5 items-center pl-7 py-2.5 text-sm sticky left-0 z-[1] text-brand-secondary bg-brand-base group-hover:text-brand-base group-hover:bg-brand-surface-2 border-brand-base w-full" className="flex gap-1.5 items-center pl-7 py-2.5 text-sm sticky left-0 z-[1] text-brand-secondary bg-brand-base group-hover:text-brand-base group-hover:bg-brand-surface-2 border-brand-base w-full"
onClick={() => { onClick={() => {
@ -89,6 +96,39 @@ export const SpreadsheetView: React.FC<Props> = ({
<PlusIcon className="h-4 w-4" /> <PlusIcon className="h-4 w-4" />
Add Issue Add Issue
</button> </button>
) : (
!isCompleted && (
<CustomMenu
className="sticky left-0 z-[1]"
customButton={
<button
className="flex gap-1.5 items-center pl-7 py-2.5 text-sm sticky left-0 z-[1] text-brand-secondary bg-brand-base group-hover:text-brand-base group-hover:bg-brand-surface-2 border-brand-base w-full"
type="button"
>
<PlusIcon className="h-4 w-4" />
Add Issue
</button>
}
position="left"
menuItemsClassName="left-5 !w-36"
noBorder
>
<CustomMenu.MenuItem
onClick={() => {
const e = new KeyboardEvent("keydown", { key: "c" });
document.dispatchEvent(e);
}}
>
Create new
</CustomMenu.MenuItem>
{openIssuesListModal && (
<CustomMenu.MenuItem onClick={openIssuesListModal}>
Add an existing issue
</CustomMenu.MenuItem>
)}
</CustomMenu>
)
)}
</div> </div>
</div> </div>
) : ( ) : (

View File

@ -19,6 +19,7 @@ type Props = {
noChevron?: boolean; noChevron?: boolean;
position?: "left" | "right"; position?: "left" | "right";
verticalPosition?: "top" | "bottom"; verticalPosition?: "top" | "bottom";
menuItemsClassName?: string;
customButton?: JSX.Element; customButton?: JSX.Element;
menuItemsWhiteBg?: boolean; menuItemsWhiteBg?: boolean;
}; };
@ -44,6 +45,7 @@ const CustomMenu = ({
noChevron = false, noChevron = false,
position = "right", position = "right",
verticalPosition = "bottom", verticalPosition = "bottom",
menuItemsClassName = "",
customButton, customButton,
menuItemsWhiteBg = false, menuItemsWhiteBg = false,
}: Props) => ( }: Props) => (
@ -133,7 +135,7 @@ const CustomMenu = ({
menuItemsWhiteBg menuItemsWhiteBg
? "border-brand-surface-1 bg-brand-base" ? "border-brand-surface-1 bg-brand-base"
: "border-brand-base bg-brand-surface-1" : "border-brand-base bg-brand-surface-1"
}`} } ${menuItemsClassName}`}
> >
<div className="py-1">{children}</div> <div className="py-1">{children}</div>
</Menu.Items> </Menu.Items>