Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

refactor: issue list modal refactor (#6702)

Vamsi Krishnaa40e44c6d5a1
diff --git a/web/core/components/core/modals/existing-issues-list-modal.tsx b/web/core/components/core/modals/existing-issues-list-modal.tsx
index bd6db1f196..f0af7ef47c 100644
--- a/web/core/components/core/modals/existing-issues-list-modal.tsx
+++ b/web/core/components/core/modals/existing-issues-list-modal.tsx
@@ -24,13 +24,15 @@ import { IssueSearchModalEmptyState } from "./issue-search-modal-empty-state";
type Props = {
workspaceSlug: string | undefined;
- projectId: string | undefined;
+ projectId?: string;
isOpen: boolean;
handleClose: () => void;
searchParams: Partial<TProjectIssuesSearchParams>;
handleOnSubmit: (data: ISearchIssueResponse[]) => Promise<void>;
workspaceLevelToggle?: boolean;
shouldHideIssue?: (issue: ISearchIssueResponse) => boolean;
+ selectedWorkItems?: ISearchIssueResponse[];
+ workItemSearchServiceCallback?: (params: TProjectIssuesSearchParams) => Promise<ISearchIssueResponse[]>;
};
const projectService = new ProjectService();
@@ -47,6 +49,8 @@ export const ExistingIssuesListModal: React.FC<Props> = (props) => {
handleOnSubmit,
workspaceLevelToggle = false,
shouldHideIssue,
+ selectedWorkItems,
+ workItemSearchServiceCallback,
} = props;
// states
const [isLoading, setIsLoading] = useState(false);
@@ -85,20 +89,35 @@ export const ExistingIssuesListModal: React.FC<Props> = (props) => {
handleClose();
};
- useEffect(() => {
- if (!isOpen || !workspaceSlug || !projectId) return;
+ const handleSearch = () => {
+ if (!isOpen || !workspaceSlug) return;
setIsLoading(true);
- projectService
- .projectIssuesSearch(workspaceSlug as string, projectId as string, {
- search: debouncedSearchTerm,
- ...searchParams,
- workspace_search: isWorkspaceLevel,
- })
+ const searchService =
+ workItemSearchServiceCallback ??
+ (projectId
+ ? projectService.projectIssuesSearch.bind(projectService, workspaceSlug?.toString(), projectId?.toString())
+ : undefined);
+ if (!searchService) return;
+ searchService({
+ search: debouncedSearchTerm,
+ ...searchParams,
+ workspace_search: isWorkspaceLevel,
+ })
.then((res) => setIssues(res))
.finally(() => {
setIsSearching(false);
setIsLoading(false);
});
+ };
+
+ useEffect(() => {
+ if (selectedWorkItems) {
+ setSelectedIssues(selectedWorkItems);
+ }
+ }, [isOpen, selectedWorkItems]);
+
+ useEffect(() => {
+ handleSearch();
}, [debouncedSearchTerm, isOpen, isWorkspaceLevel, projectId, workspaceSlug]);
const filteredIssues = issues.filter((issue) => !shouldHideIssue?.(issue));