2023-09-13 14:03:58 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
|
|
|
|
//hook
|
|
|
|
import useMyIssues from "hooks/my-issues/use-my-issues";
|
|
|
|
import useIssuesView from "hooks/use-issues-view";
|
|
|
|
import useProfileIssues from "hooks/use-profile-issues";
|
2023-02-04 14:38:13 +00:00
|
|
|
// components
|
2023-07-26 12:21:26 +00:00
|
|
|
import { SingleBoard } from "components/core/views/board-view/single-board";
|
2023-09-13 14:03:58 +00:00
|
|
|
import { IssuePeekOverview } from "components/issues";
|
2023-06-23 05:38:53 +00:00
|
|
|
// icons
|
2023-09-11 06:15:28 +00:00
|
|
|
import { StateGroupIcon } from "components/icons";
|
2023-03-22 20:43:52 +00:00
|
|
|
// helpers
|
|
|
|
import { addSpaceIfCamelCase } from "helpers/string.helper";
|
2023-02-04 14:38:13 +00:00
|
|
|
// types
|
2023-07-26 12:21:26 +00:00
|
|
|
import { ICurrentUserResponse, IIssue, IIssueViewProps, IState, UserAuth } from "types";
|
2023-02-04 14:38:13 +00:00
|
|
|
|
|
|
|
type Props = {
|
2023-07-26 12:21:26 +00:00
|
|
|
addIssueToGroup: (groupTitle: string) => void;
|
|
|
|
disableUserActions: boolean;
|
2023-09-04 13:12:31 +00:00
|
|
|
disableAddIssueOption?: boolean;
|
2023-07-26 12:21:26 +00:00
|
|
|
dragDisabled: boolean;
|
|
|
|
handleIssueAction: (issue: IIssue, action: "copy" | "delete" | "edit") => void;
|
2023-02-13 05:02:02 +00:00
|
|
|
handleTrashBox: (isDragging: boolean) => void;
|
2023-07-26 12:21:26 +00:00
|
|
|
openIssuesListModal?: (() => void) | null;
|
2023-04-28 12:19:16 +00:00
|
|
|
removeIssue: ((bridgeId: string, issueId: string) => void) | null;
|
2023-09-13 14:03:58 +00:00
|
|
|
myIssueProjectId?: string | null;
|
|
|
|
handleMyIssueOpen?: (issue: IIssue) => void;
|
2023-07-26 12:21:26 +00:00
|
|
|
states: IState[] | undefined;
|
2023-06-06 16:06:00 +00:00
|
|
|
user: ICurrentUserResponse | undefined;
|
2023-02-04 14:38:13 +00:00
|
|
|
userAuth: UserAuth;
|
2023-07-26 12:21:26 +00:00
|
|
|
viewProps: IIssueViewProps;
|
2023-02-04 14:38:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const AllBoards: React.FC<Props> = ({
|
2023-07-26 12:21:26 +00:00
|
|
|
addIssueToGroup,
|
|
|
|
disableUserActions,
|
2023-09-04 13:12:31 +00:00
|
|
|
disableAddIssueOption = false,
|
2023-07-26 12:21:26 +00:00
|
|
|
dragDisabled,
|
|
|
|
handleIssueAction,
|
2023-02-13 05:02:02 +00:00
|
|
|
handleTrashBox,
|
2023-07-26 12:21:26 +00:00
|
|
|
openIssuesListModal,
|
2023-09-13 14:03:58 +00:00
|
|
|
myIssueProjectId,
|
|
|
|
handleMyIssueOpen,
|
2023-02-14 14:35:32 +00:00
|
|
|
removeIssue,
|
2023-07-26 12:21:26 +00:00
|
|
|
states,
|
2023-06-06 16:06:00 +00:00
|
|
|
user,
|
2023-02-04 14:38:13 +00:00
|
|
|
userAuth,
|
2023-07-26 12:21:26 +00:00
|
|
|
viewProps,
|
2023-02-04 14:38:13 +00:00
|
|
|
}) => {
|
2023-09-13 14:03:58 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, projectId, userId } = router.query;
|
|
|
|
|
|
|
|
const isProfileIssue =
|
|
|
|
router.pathname.includes("assigned") ||
|
|
|
|
router.pathname.includes("created") ||
|
|
|
|
router.pathname.includes("subscribed");
|
|
|
|
|
|
|
|
const isMyIssue = router.pathname.includes("my-issues");
|
|
|
|
|
|
|
|
const { mutateIssues } = useIssuesView();
|
|
|
|
const { mutateMyIssues } = useMyIssues(workspaceSlug?.toString());
|
|
|
|
const { mutateProfileIssues } = useProfileIssues(workspaceSlug?.toString(), userId?.toString());
|
|
|
|
|
2023-09-12 16:57:15 +00:00
|
|
|
const { displayFilters, groupedIssues } = viewProps;
|
2023-02-04 14:38:13 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2023-09-13 14:03:58 +00:00
|
|
|
<IssuePeekOverview
|
|
|
|
handleMutation={() =>
|
|
|
|
isMyIssue ? mutateMyIssues() : isProfileIssue ? mutateProfileIssues() : mutateIssues()
|
|
|
|
}
|
|
|
|
projectId={myIssueProjectId ? myIssueProjectId : projectId?.toString() ?? ""}
|
|
|
|
workspaceSlug={workspaceSlug?.toString() ?? ""}
|
|
|
|
readOnly={disableUserActions}
|
|
|
|
/>
|
2023-07-26 12:21:26 +00:00
|
|
|
{groupedIssues ? (
|
2023-05-05 11:37:29 +00:00
|
|
|
<div className="horizontal-scroll-enable flex h-full gap-x-4 p-8">
|
2023-07-26 12:21:26 +00:00
|
|
|
{Object.keys(groupedIssues).map((singleGroup, index) => {
|
2023-03-15 06:14:44 +00:00
|
|
|
const currentState =
|
2023-09-12 16:57:15 +00:00
|
|
|
displayFilters?.group_by === "state"
|
|
|
|
? states?.find((s) => s.id === singleGroup)
|
|
|
|
: null;
|
2023-02-28 09:12:46 +00:00
|
|
|
|
2023-09-12 16:57:15 +00:00
|
|
|
if (!displayFilters?.show_empty_groups && groupedIssues[singleGroup].length === 0)
|
|
|
|
return null;
|
2023-03-22 20:43:52 +00:00
|
|
|
|
2023-03-15 06:14:44 +00:00
|
|
|
return (
|
|
|
|
<SingleBoard
|
|
|
|
key={index}
|
2023-07-26 12:21:26 +00:00
|
|
|
addIssueToGroup={() => addIssueToGroup(singleGroup)}
|
2023-03-15 06:14:44 +00:00
|
|
|
currentState={currentState}
|
2023-07-26 12:21:26 +00:00
|
|
|
disableUserActions={disableUserActions}
|
2023-09-04 13:12:31 +00:00
|
|
|
disableAddIssueOption={disableAddIssueOption}
|
2023-07-26 12:21:26 +00:00
|
|
|
dragDisabled={dragDisabled}
|
2023-03-15 06:14:44 +00:00
|
|
|
groupTitle={singleGroup}
|
2023-07-26 12:21:26 +00:00
|
|
|
handleIssueAction={handleIssueAction}
|
2023-03-15 06:14:44 +00:00
|
|
|
handleTrashBox={handleTrashBox}
|
2023-07-26 12:21:26 +00:00
|
|
|
openIssuesListModal={openIssuesListModal ?? null}
|
2023-09-13 14:03:58 +00:00
|
|
|
handleMyIssueOpen={handleMyIssueOpen}
|
2023-03-15 06:14:44 +00:00
|
|
|
removeIssue={removeIssue}
|
2023-06-06 16:06:00 +00:00
|
|
|
user={user}
|
2023-03-15 06:14:44 +00:00
|
|
|
userAuth={userAuth}
|
2023-07-26 12:21:26 +00:00
|
|
|
viewProps={viewProps}
|
2023-03-15 06:14:44 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
})}
|
2023-09-12 16:57:15 +00:00
|
|
|
{!displayFilters?.show_empty_groups && (
|
2023-07-17 07:30:44 +00:00
|
|
|
<div className="h-full w-96 flex-shrink-0 space-y-2 p-1">
|
2023-03-22 20:43:52 +00:00
|
|
|
<h2 className="text-lg font-semibold">Hidden groups</h2>
|
|
|
|
<div className="space-y-3">
|
2023-07-26 12:21:26 +00:00
|
|
|
{Object.keys(groupedIssues).map((singleGroup, index) => {
|
2023-03-22 20:43:52 +00:00
|
|
|
const currentState =
|
2023-09-12 16:57:15 +00:00
|
|
|
displayFilters?.group_by === "state"
|
|
|
|
? states?.find((s) => s.id === singleGroup)
|
|
|
|
: null;
|
2023-03-22 20:43:52 +00:00
|
|
|
|
2023-07-26 12:21:26 +00:00
|
|
|
if (groupedIssues[singleGroup].length === 0)
|
2023-03-22 20:43:52 +00:00
|
|
|
return (
|
2023-03-23 12:40:28 +00:00
|
|
|
<div
|
|
|
|
key={index}
|
2023-07-10 07:17:00 +00:00
|
|
|
className="flex items-center justify-between gap-2 rounded bg-custom-background-90 p-2 shadow"
|
2023-03-23 12:40:28 +00:00
|
|
|
>
|
2023-03-22 20:43:52 +00:00
|
|
|
<div className="flex items-center gap-2">
|
2023-09-11 06:15:28 +00:00
|
|
|
{currentState && (
|
|
|
|
<StateGroupIcon
|
|
|
|
stateGroup={currentState.group}
|
|
|
|
color={currentState.color}
|
|
|
|
height="16px"
|
|
|
|
width="16px"
|
|
|
|
/>
|
|
|
|
)}
|
2023-03-22 20:43:52 +00:00
|
|
|
<h4 className="text-sm capitalize">
|
2023-09-12 16:57:15 +00:00
|
|
|
{displayFilters?.group_by === "state"
|
2023-03-22 20:43:52 +00:00
|
|
|
? addSpaceIfCamelCase(currentState?.name ?? "")
|
|
|
|
: addSpaceIfCamelCase(singleGroup)}
|
|
|
|
</h4>
|
|
|
|
</div>
|
2023-07-10 07:17:00 +00:00
|
|
|
<span className="text-xs text-custom-text-200">0</span>
|
2023-03-22 20:43:52 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
2023-02-04 14:38:13 +00:00
|
|
|
</div>
|
2023-03-15 06:14:44 +00:00
|
|
|
) : null}
|
2023-02-04 14:38:13 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|