π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
fix: refactor related bugs (#3384)
rahulrameshafadda7cf040c
diff --git a/web/components/issues/issue-detail/subscription.tsx b/web/components/issues/issue-detail/subscription.tsxindex 7093f86274..d20bc53cf6 100644--- a/web/components/issues/issue-detail/subscription.tsx+++ b/web/components/issues/issue-detail/subscription.tsx@@ -51,7 +51,7 @@ export const IssueSubscription: FC<TIssueSubscription> = observer((props) => {}};- if (issue?.created_by === currentUserId || issue?.assignee_ids.includes(currentUserId)) return <></>;+ if (issue?.created_by === currentUserId || issue?.assignee_ids?.includes(currentUserId)) return <></>;return (<div>diff --git a/web/components/issues/issue-layouts/filters/applied-filters/roots/project-view-root.tsx b/web/components/issues/issue-layouts/filters/applied-filters/roots/project-view-root.tsxindex ffbae9ac84..6748676b50 100644--- a/web/components/issues/issue-layouts/filters/applied-filters/roots/project-view-root.tsx+++ b/web/components/issues/issue-layouts/filters/applied-filters/roots/project-view-root.tsx@@ -28,9 +28,9 @@ export const ProjectViewAppliedFiltersRoot: React.FC = observer(() => {project: { projectLabels },} = useLabel();const { projectStates } = useProjectState();- const { getViewById, updateView } = useProjectView();+ const { viewMap, updateView } = useProjectView();// derived values- const viewDetails = viewId ? getViewById(viewId.toString()) : null;+ const viewDetails = viewId ? viewMap[viewId.toString()] : null;const userFilters = issueFilters?.filters;// filters whose value not null or empty arrayconst appliedFilters: IIssueFilterOptions = {};@@ -43,18 +43,30 @@ export const ProjectViewAppliedFiltersRoot: React.FC = observer(() => {const handleRemoveFilter = (key: keyof IIssueFilterOptions, value: string | null) => {if (!workspaceSlug || !projectId) return;if (!value) {- updateFilters(workspaceSlug, projectId, EIssueFilterType.FILTERS, {- [key]: null,- });+ updateFilters(+ workspaceSlug,+ projectId,+ EIssueFilterType.FILTERS,+ {+ [key]: null,+ },+ viewId+ );return;}let newValues = issueFilters?.filters?.[key] ?? [];newValues = newValues.filter((val) => val !== value);- updateFilters(workspaceSlug, projectId, EIssueFilterType.FILTERS, {- [key]: newValues,- });+ updateFilters(+ workspaceSlug,+ projectId,+ EIssueFilterType.FILTERS,+ {+ [key]: newValues,+ },+ viewId+ );};const handleClearAllFilters = () => {@@ -67,14 +79,14 @@ export const ProjectViewAppliedFiltersRoot: React.FC = observer(() => {};// return if no filters are applied- if (Object.keys(appliedFilters).length === 0) return null;+ if (Object.keys(appliedFilters).length === 0 && !areFiltersDifferent(appliedFilters, viewDetails?.filters ?? {}))+ return null;const handleUpdateView = () => {if (!workspaceSlug || !projectId || !viewId || !viewDetails) return;updateView(workspaceSlug.toString(), projectId.toString(), viewId.toString(), {- query_data: {- ...viewDetails.query_data,+ filters: {...(appliedFilters ?? {}),},});@@ -90,15 +102,13 @@ export const ProjectViewAppliedFiltersRoot: React.FC = observer(() => {states={projectStates}/>- {appliedFilters &&- viewDetails?.query_data &&- areFiltersDifferent(appliedFilters, viewDetails?.query_data ?? {}) && (- <div className="flex flex-shrink-0 items-center justify-center">- <Button variant="primary" size="sm" onClick={handleUpdateView}>- Update view- </Button>- </div>- )}+ {viewDetails?.filters && areFiltersDifferent(appliedFilters, viewDetails?.filters ?? {}) && (+ <div className="flex flex-shrink-0 items-center justify-center">+ <Button variant="primary" size="sm" onClick={handleUpdateView}>+ Update view+ </Button>+ </div>+ )}</div>);});diff --git a/web/components/issues/issue-layouts/properties/labels.tsx b/web/components/issues/issue-layouts/properties/labels.tsxindex b22083c077..67295af0f0 100644--- a/web/components/issues/issue-layouts/properties/labels.tsx+++ b/web/components/issues/issue-layouts/properties/labels.tsx@@ -62,6 +62,18 @@ export const IssuePropertyLabels: React.FC<IIssuePropertyLabels> = observer((proif (workspaceSlug && projectId) fetchProjectLabels(workspaceSlug, projectId).then(() => setIsLoading(false));};+ const { styles, attributes } = usePopper(referenceElement, popperElement, {+ placement: placement ?? "bottom-start",+ modifiers: [+ {+ name: "preventOverflow",+ options: {+ padding: 12,+ },+ },+ ],+ });+if (!value) return null;let projectLabels: IIssueLabel[] = defaultOptions;@@ -86,18 +98,6 @@ export const IssuePropertyLabels: React.FC<IIssuePropertyLabels> = observer((proconst filteredOptions =query === "" ? options : options?.filter((option) => option.query.toLowerCase().includes(query.toLowerCase()));- const { styles, attributes } = usePopper(referenceElement, popperElement, {- placement: placement ?? "bottom-start",- modifiers: [- {- name: "preventOverflow",- options: {- padding: 12,- },- },- ],- });-const label = (<div className="flex h-5 w-full flex-wrap items-center gap-2 overflow-hidden text-custom-text-200">{value.length > 0 ? (diff --git a/web/components/issues/issue-layouts/save-filter-view.tsx b/web/components/issues/issue-layouts/save-filter-view.tsxindex 42fac26ef2..8bf2cb2115 100644--- a/web/components/issues/issue-layouts/save-filter-view.tsx+++ b/web/components/issues/issue-layouts/save-filter-view.tsx@@ -20,7 +20,7 @@ export const SaveFilterView: FC<ISaveFilterView> = (props) => {<CreateUpdateProjectViewModalworkspaceSlug={workspaceSlug}projectId={projectId}- preLoadedData={{ query_data: { ...filterParams } }}+ preLoadedData={{ filters: { ...filterParams } }}isOpen={viewModal}onClose={() => setViewModal(false)}/>diff --git a/web/components/issues/peek-overview/view.tsx b/web/components/issues/peek-overview/view.tsxindex fbe4d01a5d..d422d91e02 100644--- a/web/components/issues/peek-overview/view.tsx+++ b/web/components/issues/peek-overview/view.tsx@@ -84,6 +84,7 @@ export const IssueView: FC<IIssueView> = observer((props) => {router.push({pathname: `/${workspaceSlug}/projects/${projectId}/${is_archived ? "archived-issues" : "issues"}/${issueId}`,});+ removeRoutePeekId();};const handleCopyText = (e: React.MouseEvent<HTMLButtonElement>) => {diff --git a/web/components/issues/sub-issues/issue-list-item.tsx b/web/components/issues/sub-issues/issue-list-item.tsxindex cd25fc10ba..0e8fe76a2c 100644--- a/web/components/issues/sub-issues/issue-list-item.tsx+++ b/web/components/issues/sub-issues/issue-list-item.tsx@@ -80,8 +80,12 @@ export const IssueListItem: React.FC<ISubIssues> = observer((props) => {) : (<divclassName="flex h-full w-full cursor-pointer items-center justify-center rounded-sm transition-all hover:bg-custom-background-80"- onClick={() => {- setSubIssueHelpers(parentIssueId, "preview_loader", issue.id);+ onClick={async () => {+ if (!subIssueHelpers.issue_visibility.includes(issue.id)) {+ setSubIssueHelpers(parentIssueId, "preview_loader", issue.id);+ await subIssueOperations.fetchSubIssues(workspaceSlug, projectId, issue.id);+ setSubIssueHelpers(parentIssueId, "preview_loader", issue.id);+ }setSubIssueHelpers(parentIssueId, "issue_visibility", issue.id);}}>diff --git a/web/components/issues/sub-issues/issues-list.tsx b/web/components/issues/sub-issues/issues-list.tsxindex 1d9e1ed950..eaa3e098ef 100644--- a/web/components/issues/sub-issues/issues-list.tsx+++ b/web/components/issues/sub-issues/issues-list.tsx@@ -7,7 +7,6 @@ import { IssueListItem } from "./issue-list-item";// typesimport { TIssue } from "@plane/types";import { TSubIssueOperations } from "./root";-import useSWR from "swr";export interface IIssueList {workspaceSlug: string;@@ -38,24 +37,12 @@ export const IssueList: FC<IIssueList> = observer((props) => {subIssues: { subIssuesByIssueId, subIssueHelpersByIssueId },} = useIssueDetail();- useSWR(- workspaceSlug && projectId && parentIssueId- ? `ISSUE_DETAIL_SUB_ISSUES_${workspaceSlug}_${projectId}_${parentIssueId}`- : null,- async () => {- workspaceSlug &&- projectId &&- parentIssueId &&- (await subIssueOperations.fetchSubIssues(workspaceSlug, projectId, parentIssueId));- }- );-const subIssueIds = subIssuesByIssueId(parentIssueId);const subIssueHelpers = subIssueHelpersByIssueId(parentIssueId);return (<>- {subIssueHelpers.preview_loader.includes(parentIssueId) ? "Loading..." : "Hello"}+ {subIssueHelpers.preview_loader.includes(parentIssueId) ? "Loading..." : null}<div className="relative">{subIssueIds &&diff --git a/web/components/issues/sub-issues/root.tsx b/web/components/issues/sub-issues/root.tsxindex a39277e93a..967df8541a 100644--- a/web/components/issues/sub-issues/root.tsx+++ b/web/components/issues/sub-issues/root.tsx@@ -1,6 +1,7 @@import { FC, useMemo, useState } from "react";import { observer } from "mobx-react-lite";import { Plus, ChevronRight, ChevronDown, Loader } from "lucide-react";+import useSWR from "swr";// hooksimport { useIssueDetail } from "hooks/store";import useToast from "hooks/use-toast";@@ -33,9 +34,7 @@ export type TSubIssueOperations = {projectId: string,parentIssueId: string,issueId: string,- currentIssue: Partial<TIssue>,- oldIssue?: Partial<TIssue> | undefined,- fromModal?: boolean+ data: Partial<TIssue>) => Promise<void>;removeSubIssue: (workspaceSlug: string, projectId: string, parentIssueId: string, issueId: string) => Promise<void>;deleteSubIssue: (workspaceSlug: string, projectId: string, parentIssueId: string, issueId: string) => Promise<void>;@@ -85,6 +84,18 @@ export const SubIssuesRoot: FC<ISubIssuesRoot> = observer((props) => {},});+ useSWR(+ workspaceSlug && projectId && parentIssueId+ ? `ISSUE_DETAIL_SUB_ISSUES_${workspaceSlug}_${projectId}_${parentIssueId}`+ : null,+ async () => {+ workspaceSlug &&+ projectId &&+ parentIssueId &&+ (await subIssueOperations.fetchSubIssues(workspaceSlug, projectId, parentIssueId));+ }+ );+const handleIssueCrudState = (key: "create" | "existing" | "update" | "delete",_parentIssueId: string | null,@@ -144,13 +155,11 @@ export const SubIssuesRoot: FC<ISubIssuesRoot> = observer((props) => {projectId: string,parentIssueId: string,issueId: string,- currentIssue: Partial<TIssue>,- oldIssue: Partial<TIssue> | undefined = undefined,- fromModal: boolean = false+ data: Partial<TIssue>) => {try {setSubIssueHelpers(parentIssueId, "issue_loader", issueId);- await updateSubIssue(workspaceSlug, projectId, parentIssueId, issueId, currentIssue, oldIssue, fromModal);+ await updateSubIssue(workspaceSlug, projectId, parentIssueId, issueId, data);setToastAlert({type: "success",title: "Sub-issue updated successfully",@@ -386,15 +395,7 @@ export const SubIssuesRoot: FC<ISubIssuesRoot> = observer((props) => {}}data={issueCrudState?.update?.issue ?? undefined}onSubmit={async (_issue: TIssue) => {- await subIssueOperations.updateSubIssue(- workspaceSlug,- projectId,- parentIssueId,- _issue.id,- _issue,- issueCrudState?.update?.issue,- true- );+ await subIssueOperations.updateSubIssue(workspaceSlug, projectId, parentIssueId, _issue.id, _issue);}}/></>diff --git a/web/components/views/form.tsx b/web/components/views/form.tsxindex ad38a470c4..c20354b3da 100644--- a/web/components/views/form.tsx+++ b/web/components/views/form.tsx@@ -47,7 +47,7 @@ export const ProjectViewForm: React.FC<Props> = observer((props) => {});const selectedFilters: IIssueFilterOptions = {};- Object.entries(watch("query_data") ?? {}).forEach(([key, value]) => {+ Object.entries(watch("filters") ?? {}).forEach(([key, value]) => {if (!value) return;if (Array.isArray(value) && value.length === 0) return;@@ -59,7 +59,7 @@ export const ProjectViewForm: React.FC<Props> = observer((props) => {const handleRemoveFilter = (key: keyof IIssueFilterOptions, value: string | null) => {// If value is null then remove all the filters of that keyif (!value) {- setValue("query_data", {+ setValue("filters", {...selectedFilters,[key]: null,});@@ -76,14 +76,18 @@ export const ProjectViewForm: React.FC<Props> = observer((props) => {if (selectedFilters?.[key]?.includes(value)) newValues.splice(newValues.indexOf(value), 1);}- setValue("query_data", {+ setValue("filters", {...selectedFilters,[key]: newValues,});};const handleCreateUpdateView = async (formData: IProjectView) => {- await handleFormSubmit(formData);+ await handleFormSubmit({+ name: formData.name,+ description: formData.description,+ filters: formData.filters,+ } as IProjectView);reset({...defaultValues,@@ -93,7 +97,7 @@ export const ProjectViewForm: React.FC<Props> = observer((props) => {const clearAllFilters = () => {if (!selectedFilters) return;- setValue("query_data", {});+ setValue("filters", {});};useEffect(() => {@@ -156,7 +160,7 @@ export const ProjectViewForm: React.FC<Props> = observer((props) => {<div><Controllercontrol={control}- name="query_data"+ name="filters"render={({ field: { onChange, value: filters } }) => (<FiltersDropdown title="Filters" tabIndex={3}><FilterSelectiondiff --git a/web/components/views/view-list-item.tsx b/web/components/views/view-list-item.tsxindex 9796ac8f45..1b04dbff03 100644--- a/web/components/views/view-list-item.tsx+++ b/web/components/views/view-list-item.tsx@@ -62,7 +62,7 @@ export const ProjectViewListItem: React.FC<Props> = observer((props) => {});};- const totalFilters = calculateTotalFilters(view.query_data ?? {});+ const totalFilters = calculateTotalFilters(view.filters ?? {});const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;diff --git a/web/store/issue/issue-details/relation.store.ts b/web/store/issue/issue-details/relation.store.tsindex f9e0ac5f03..fa32798ded 100644--- a/web/store/issue/issue-details/relation.store.ts+++ b/web/store/issue/issue-details/relation.store.ts@@ -94,7 +94,6 @@ export class IssueRelationStore implements IIssueRelationStore {const relation_key = key as TIssueRelationTypes;const relation_issues = response[relation_key];const issues = relation_issues.flat().map((issue) => issue.issue_detail);- if (issues && issues.length > 0) this.rootIssueDetailStore.rootIssueStore.issues.addIssue(issues);set(this.relationMap,[issueId, relation_key],diff --git a/web/store/issue/issue-details/root.store.ts b/web/store/issue/issue-details/root.store.tsindex 2e8497e015..c03c921302 100644--- a/web/store/issue/issue-details/root.store.ts+++ b/web/store/issue/issue-details/root.store.ts@@ -208,11 +208,8 @@ export class IssueDetail implements IIssueDetail {projectId: string,parentIssueId: string,issueId: string,- oldIssue: Partial<TIssue>,- currentIssue?: Partial<TIssue>,- fromModal?: boolean- ) =>- this.subIssues.updateSubIssue(workspaceSlug, projectId, parentIssueId, issueId, oldIssue, currentIssue, fromModal);+ data: Partial<TIssue>+ ) => this.subIssues.updateSubIssue(workspaceSlug, projectId, parentIssueId, issueId, data);removeSubIssue = async (workspaceSlug: string, projectId: string, parentIssueId: string, issueId: string) =>this.subIssues.removeSubIssue(workspaceSlug, projectId, parentIssueId, issueId);deleteSubIssue = async (workspaceSlug: string, projectId: string, parentIssueId: string, issueId: string) =>diff --git a/web/store/issue/issue-details/sub_issues.store.ts b/web/store/issue/issue-details/sub_issues.store.tsindex 964c32742a..a1bd3f8183 100644--- a/web/store/issue/issue-details/sub_issues.store.ts+++ b/web/store/issue/issue-details/sub_issues.store.ts@@ -28,9 +28,7 @@ export interface IIssueSubIssuesStoreActions {projectId: string,parentIssueId: string,issueId: string,- currentIssue: Partial<TIssue>,- oldIssue?: Partial<TIssue> | undefined,- fromModal?: boolean+ data: Partial<TIssue>) => Promise<void>;removeSubIssue: (workspaceSlug: string, projectId: string, parentIssueId: string, issueId: string) => Promise<void>;deleteSubIssue: (workspaceSlug: string, projectId: string, parentIssueId: string, issueId: string) => Promise<void>;@@ -118,16 +116,15 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore {this.rootIssueDetailStore.rootIssueStore.issues.addIssue(subIssues);- if (subIssues.length > 0) {- runInAction(() => {- set(this.subIssuesStateDistribution, parentIssueId, subIssuesStateDistribution);- set(- this.subIssues,- parentIssueId,- subIssues.map((issue) => issue.id)- );- });- }+ runInAction(() => {+ set(this.subIssuesStateDistribution, parentIssueId, subIssuesStateDistribution);+ set(+ this.subIssues,+ parentIssueId,+ subIssues.map((issue) => issue.id)+ );+ });+return response;} catch (error) {throw error;@@ -172,39 +169,16 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore {projectId: string,parentIssueId: string,issueId: string,- currentIssue: Partial<TIssue>,- oldIssue: Partial<TIssue> | undefined = undefined,- fromModal: boolean = false+ data: Partial<TIssue>) => {try {- if (!fromModal)- await this.rootIssueDetailStore.rootIssueStore.projectIssues.updateIssue(- workspaceSlug,- projectId,- issueId,- currentIssue- );-- if (!oldIssue) return;-- if (currentIssue.state_id != oldIssue.state_id) {- }+ await this.rootIssueDetailStore.rootIssueStore.projectIssues.updateIssue(workspaceSlug, projectId, issueId, data);- if (currentIssue.parent_id != oldIssue.parent_id) {+ if (data.hasOwnProperty("parent_id") && data.parent_id !== parentIssueId) {+ runInAction(() => {+ pull(this.subIssues[parentIssueId], issueId);+ });}- // const updateResponse = await this.rootIssueDetailStore.rootIssueStore.projectIssues.updateIssue(- // workspaceSlug,- // projectId,- // issueId,- // oldIssue- // );-- // console.log("---");- // console.log("parentIssueId", parentIssueId);- // console.log("fromModal", fromModal);- // console.log("updateResponse", updateResponse);- // console.log("---");-return;} catch (error) {throw error;diff --git a/web/store/issue/project-views/filter.store.ts b/web/store/issue/project-views/filter.store.tsindex 83bc2e79e3..d01f274343 100644--- a/web/store/issue/project-views/filter.store.ts+++ b/web/store/issue/project-views/filter.store.ts@@ -139,7 +139,7 @@ export class ProjectViewIssuesFilter extends IssueFilterHelperStore implements Itry {if (!viewId) throw new Error("View id is required");- if (isEmpty(this.filters) || isEmpty(this.filters[projectId]) || isEmpty(filters)) return;+ if (isEmpty(this.filters) || isEmpty(this.filters[viewId]) || isEmpty(filters)) return;const _filters = {filters: this.filters[viewId].filters as IIssueFilterOptions,diff --git a/web/store/issue/project-views/issue.store.ts b/web/store/issue/project-views/issue.store.tsindex 263877849b..1908b8a10e 100644--- a/web/store/issue/project-views/issue.store.ts+++ b/web/store/issue/project-views/issue.store.ts@@ -130,11 +130,15 @@ export class ProjectViewIssues extends IssueHelperStore implements IProjectViewIconst response = await this.issueService.getIssues(workspaceSlug, projectId, params);runInAction(() => {- set(this.issues, [viewId], Object.keys(response));+ set(+ this.issues,+ [viewId],+ response.map((issue) => issue.id)+ );this.loader = undefined;});- this.rootIssueStore.issues.addIssue(Object.values(response));+ this.rootIssueStore.issues.addIssue(response);return response;} catch (error) {