chore: implemented multiple modules select in the issues (#3484)
* fix: add multiple module in an issue * feat: implemented multiple modules select in the issue detail and issue peekoverview and resolved build errors. * feat: handled module parameters type error in the issue create and draft modal * feat: handled UI for modules select dropdown * fix: delete module activity updated * ui: module issue activity * fix: module search endpoint and issue fetch in the modules * fix: module ids optimized * fix: replaced module_id from boolean to array of module Id's in module search modal params --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
This commit is contained in:
parent
c6d6b9a0e9
commit
804dd8300d
43 changed files with 1016 additions and 488 deletions
|
|
@ -1,9 +1,10 @@
|
|||
import React, { useState } from "react";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import xor from "lodash/xor";
|
||||
// hooks
|
||||
import { useIssueDetail } from "hooks/store";
|
||||
// components
|
||||
import { ModuleDropdown } from "components/dropdowns";
|
||||
import { ModuleSelectDropdown } from "components/dropdowns";
|
||||
// ui
|
||||
import { Spinner } from "@plane/ui";
|
||||
// helpers
|
||||
|
|
@ -32,58 +33,56 @@ export const IssueModuleSelect: React.FC<TIssueModuleSelect> = observer((props)
|
|||
const issue = getIssueById(issueId);
|
||||
const disableSelect = disabled || isUpdating;
|
||||
|
||||
const handleIssueModuleChange = async (moduleId: string | null) => {
|
||||
if (!issue || issue.module_id === moduleId) return;
|
||||
const handleIssueModuleChange = async (moduleIds: undefined | string | (string | undefined)[]) => {
|
||||
if (!issue) return;
|
||||
|
||||
setIsUpdating(true);
|
||||
if (moduleId) await issueOperations.addIssueToModule?.(workspaceSlug, projectId, moduleId, [issueId]);
|
||||
else await issueOperations.removeIssueFromModule?.(workspaceSlug, projectId, issue.module_id ?? "", issueId);
|
||||
if (moduleIds === undefined && issue?.module_ids && issue?.module_ids.length > 0)
|
||||
await issueOperations.removeModulesFromIssue?.(workspaceSlug, projectId, issueId, issue?.module_ids);
|
||||
|
||||
if (typeof moduleIds === "string" && moduleIds)
|
||||
await issueOperations.removeModulesFromIssue?.(workspaceSlug, projectId, issueId, [moduleIds]);
|
||||
|
||||
if (Array.isArray(moduleIds)) {
|
||||
if (moduleIds.includes(undefined)) {
|
||||
await issueOperations.removeModulesFromIssue?.(
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
issueId,
|
||||
moduleIds.filter((x) => x != undefined) as string[]
|
||||
);
|
||||
} else {
|
||||
const _moduleIds = xor(issue?.module_ids, moduleIds)[0];
|
||||
if (_moduleIds) {
|
||||
if (issue?.module_ids?.includes(_moduleIds))
|
||||
await issueOperations.removeModulesFromIssue?.(workspaceSlug, projectId, issueId, [_moduleIds]);
|
||||
else await issueOperations.addModulesToIssue?.(workspaceSlug, projectId, issueId, [_moduleIds]);
|
||||
}
|
||||
}
|
||||
}
|
||||
setIsUpdating(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={cn("flex items-center gap-1 h-full", className)}>
|
||||
<ModuleDropdown
|
||||
value={issue?.module_id ?? null}
|
||||
onChange={handleIssueModuleChange}
|
||||
buttonVariant="transparent-with-text"
|
||||
<div className={cn(`flex items-center gap-1 h-full`, className)}>
|
||||
<ModuleSelectDropdown
|
||||
workspaceSlug={workspaceSlug}
|
||||
projectId={projectId}
|
||||
disabled={disableSelect}
|
||||
className="w-full group"
|
||||
buttonContainerClassName="w-full text-left"
|
||||
buttonClassName={`text-sm ${issue?.module_id ? "" : "text-custom-text-400"}`}
|
||||
value={issue?.module_ids?.length ? issue?.module_ids : undefined}
|
||||
onChange={handleIssueModuleChange}
|
||||
multiple={true}
|
||||
placeholder="No module"
|
||||
hideIcon
|
||||
dropdownArrow
|
||||
dropdownArrowClassName="h-3.5 w-3.5 hidden group-hover:inline"
|
||||
/>
|
||||
{/* <CustomSearchSelect
|
||||
value={issue?.module_id}
|
||||
onChange={(value: any) => handleIssueModuleChange(value)}
|
||||
options={options}
|
||||
customButton={
|
||||
<div>
|
||||
<Tooltip position="left" tooltipContent={`${issueModule?.name ?? "No module"}`}>
|
||||
<button
|
||||
type="button"
|
||||
className={`flex w-full items-center rounded bg-custom-background-80 px-2.5 py-0.5 text-xs ${
|
||||
disableSelect ? "cursor-not-allowed" : ""
|
||||
} max-w-[10rem]`}
|
||||
>
|
||||
<span
|
||||
className={`flex items-center gap-1.5 truncate ${
|
||||
issueModule ? "text-custom-text-100" : "text-custom-text-200"
|
||||
}`}
|
||||
>
|
||||
<span className="flex-shrink-0">{issueModule && <DiceIcon className="h-3.5 w-3.5" />}</span>
|
||||
<span className="truncate">{issueModule?.name ?? "No module"}</span>
|
||||
</span>
|
||||
</button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
}
|
||||
noChevron
|
||||
disabled={disableSelect}
|
||||
/> */}
|
||||
className={`w-full h-full group`}
|
||||
buttonContainerClassName="w-full"
|
||||
buttonClassName={`min-h-8 ${issue?.module_ids?.length ? `` : `text-custom-text-400`}`}
|
||||
buttonVariant="transparent-with-text"
|
||||
hideIcon={false}
|
||||
dropdownArrow={true}
|
||||
dropdownArrowClassName="h-3.5 w-3.5 hidden group-hover:inline"
|
||||
showTooltip={true}
|
||||
/>
|
||||
|
||||
{isUpdating && <Spinner className="h-4 w-4" />}
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue