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-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-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-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-07-26 12:21:26 +00:00
|
|
|
const { groupByProperty: selectedGroup, groupedIssues, showEmptyGroups } = viewProps;
|
2023-02-04 14:38:13 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
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 =
|
|
|
|
selectedGroup === "state" ? states?.find((s) => s.id === singleGroup) : null;
|
2023-02-28 09:12:46 +00:00
|
|
|
|
2023-07-26 12:21:26 +00:00
|
|
|
if (!showEmptyGroups && 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-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-03-22 20:43:52 +00:00
|
|
|
{!showEmptyGroups && (
|
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 =
|
|
|
|
selectedGroup === "state" ? states?.find((s) => s.id === singleGroup) : null;
|
|
|
|
|
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">
|
|
|
|
{selectedGroup === "state"
|
|
|
|
? 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
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|