mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: filter event logic
This commit is contained in:
parent
f6fd579742
commit
967f9c9232
@ -16,9 +16,9 @@ type Props = {
|
||||
isOpen: boolean;
|
||||
projectId: string;
|
||||
handleClose: () => void;
|
||||
onResponse: (question: string, response: any) => void;
|
||||
onGenerateResponse?: (question: string, response: any) => void;
|
||||
onReGenerateResponse?: (question: string, response: any) => void;
|
||||
onResponse: (query: string, response: any) => void;
|
||||
onGenerateResponse?: (query: string, response: any) => void;
|
||||
onReGenerateResponse?: (query: string, response: any) => void;
|
||||
onError?: (error: any) => void;
|
||||
placement?: Placement;
|
||||
prompt?: string;
|
||||
|
@ -44,7 +44,7 @@ export const WidgetIssuesList: React.FC<WidgetIssuesListProps> = (props) => {
|
||||
element_id: tab,
|
||||
mode: "peek",
|
||||
filters: {
|
||||
due_date: issue.target_date,
|
||||
target_date: issue.target_date,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
@ -122,22 +122,19 @@ export const CycleIssuesHeader: React.FC = observer(() => {
|
||||
(key: keyof IIssueFilterOptions, value: string | string[]) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
const newValues = issueFilters?.filters?.[key] ?? [];
|
||||
let isFilterRemoved = false;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((val) => {
|
||||
if (!newValues.includes(val)) newValues.push(val);
|
||||
else isFilterRemoved = true;
|
||||
});
|
||||
} else {
|
||||
if (issueFilters?.filters?.[key]?.includes(value)) {
|
||||
newValues.splice(newValues.indexOf(value), 1);
|
||||
isFilterRemoved = true;
|
||||
} else newValues.push(value);
|
||||
if (issueFilters?.filters?.[key]?.includes(value)) newValues.splice(newValues.indexOf(value), 1);
|
||||
else newValues.push(value);
|
||||
}
|
||||
|
||||
updateFilters(workspaceSlug, projectId, EIssueFilterType.FILTERS, { [key]: newValues }, cycleId).then(() =>
|
||||
captureIssuesFilterEvent({
|
||||
eventName: isFilterRemoved ? FILTER_REMOVED : FILTER_APPLIED,
|
||||
eventName: (issueFilters?.filters?.[key] ?? []).length > newValues.length ? FILTER_REMOVED : FILTER_APPLIED,
|
||||
payload: {
|
||||
routePath: router.asPath,
|
||||
filters: issueFilters,
|
||||
@ -254,7 +251,9 @@ export const CycleIssuesHeader: React.FC = observer(() => {
|
||||
className="ml-1.5 flex-shrink-0"
|
||||
placement="bottom-start"
|
||||
>
|
||||
{currentProjectCycleIds?.map((cycleId) => <CycleDropdownOption key={cycleId} cycleId={cycleId} />)}
|
||||
{currentProjectCycleIds?.map((cycleId) => (
|
||||
<CycleDropdownOption key={cycleId} cycleId={cycleId} />
|
||||
))}
|
||||
</CustomMenu>
|
||||
}
|
||||
/>
|
||||
|
@ -62,18 +62,14 @@ export const GlobalIssuesHeader: React.FC<Props> = observer((props) => {
|
||||
(key: keyof IIssueFilterOptions, value: string | string[]) => {
|
||||
if (!workspaceSlug || !globalViewId) return;
|
||||
const newValues = issueFilters?.filters?.[key] ?? [];
|
||||
let isFilterRemoved = false;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((val) => {
|
||||
if (!newValues.includes(val)) newValues.push(val);
|
||||
else isFilterRemoved = true;
|
||||
});
|
||||
} else {
|
||||
if (issueFilters?.filters?.[key]?.includes(value)) {
|
||||
isFilterRemoved = true;
|
||||
newValues.splice(newValues.indexOf(value), 1);
|
||||
} else newValues.push(value);
|
||||
if (issueFilters?.filters?.[key]?.includes(value)) newValues.splice(newValues.indexOf(value), 1);
|
||||
else newValues.push(value);
|
||||
}
|
||||
|
||||
updateFilters(
|
||||
@ -84,7 +80,7 @@ export const GlobalIssuesHeader: React.FC<Props> = observer((props) => {
|
||||
globalViewId.toString()
|
||||
).then(() => {
|
||||
captureIssuesFilterEvent({
|
||||
eventName: isFilterRemoved ? FILTER_REMOVED : FILTER_APPLIED,
|
||||
eventName: (issueFilters?.filters?.[key] ?? []).length > newValues.length ? FILTER_REMOVED : FILTER_APPLIED,
|
||||
payload: {
|
||||
routePath: router.asPath,
|
||||
filters: issueFilters,
|
||||
|
@ -123,22 +123,19 @@ export const ModuleIssuesHeader: React.FC = observer(() => {
|
||||
(key: keyof IIssueFilterOptions, value: string | string[]) => {
|
||||
if (!projectId) return;
|
||||
const newValues = issueFilters?.filters?.[key] ?? [];
|
||||
let isFilterRemoved = false;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((val) => {
|
||||
if (!newValues.includes(val)) newValues.push(val);
|
||||
else isFilterRemoved = true;
|
||||
});
|
||||
} else {
|
||||
if (issueFilters?.filters?.[key]?.includes(value)) {
|
||||
isFilterRemoved = true;
|
||||
newValues.splice(newValues.indexOf(value), 1);
|
||||
} else newValues.push(value);
|
||||
if (issueFilters?.filters?.[key]?.includes(value)) newValues.splice(newValues.indexOf(value), 1);
|
||||
else newValues.push(value);
|
||||
}
|
||||
|
||||
updateFilters(projectId.toString(), EIssueFilterType.FILTERS, { [key]: newValues }).then(() => {
|
||||
captureIssuesFilterEvent({
|
||||
eventName: isFilterRemoved ? FILTER_REMOVED : FILTER_APPLIED,
|
||||
eventName: (issueFilters?.filters?.[key] ?? []).length > newValues.length ? FILTER_REMOVED : FILTER_APPLIED,
|
||||
payload: {
|
||||
routePath: router.asPath,
|
||||
filters: issueFilters,
|
||||
|
@ -70,22 +70,19 @@ export const ProjectIssuesHeader: React.FC = observer(() => {
|
||||
(key: keyof IIssueFilterOptions, value: string | string[]) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
const newValues = issueFilters?.filters?.[key] ?? [];
|
||||
let isFilterRemoved = false;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((val) => {
|
||||
if (!newValues.includes(val)) newValues.push(val);
|
||||
else isFilterRemoved = true;
|
||||
});
|
||||
} else {
|
||||
if (issueFilters?.filters?.[key]?.includes(value)) {
|
||||
newValues.splice(newValues.indexOf(value), 1);
|
||||
isFilterRemoved = true;
|
||||
} else newValues.push(value);
|
||||
if (issueFilters?.filters?.[key]?.includes(value)) newValues.splice(newValues.indexOf(value), 1);
|
||||
else newValues.push(value);
|
||||
}
|
||||
|
||||
updateFilters(workspaceSlug, projectId, EIssueFilterType.FILTERS, { [key]: newValues }).then(() =>
|
||||
captureIssuesFilterEvent({
|
||||
eventName: isFilterRemoved ? FILTER_REMOVED : FILTER_APPLIED,
|
||||
eventName: (issueFilters?.filters?.[key] ?? []).length > newValues.length ? FILTER_REMOVED : FILTER_APPLIED,
|
||||
payload: {
|
||||
routePath: router.asPath,
|
||||
filters: issueFilters,
|
||||
|
@ -90,17 +90,14 @@ export const ProjectViewIssuesHeader: React.FC = observer(() => {
|
||||
(key: keyof IIssueFilterOptions, value: string | string[]) => {
|
||||
if (!workspaceSlug || !projectId || !viewId) return;
|
||||
const newValues = issueFilters?.filters?.[key] ?? [];
|
||||
let isFilterRemoved = false;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((val) => {
|
||||
if (!newValues.includes(val)) newValues.push(val);
|
||||
else isFilterRemoved = true;
|
||||
});
|
||||
} else {
|
||||
if (issueFilters?.filters?.[key]?.includes(value)) {
|
||||
isFilterRemoved = true;
|
||||
newValues.splice(newValues.indexOf(value), 1);
|
||||
} else newValues.push(value);
|
||||
if (issueFilters?.filters?.[key]?.includes(value)) newValues.splice(newValues.indexOf(value), 1);
|
||||
else newValues.push(value);
|
||||
}
|
||||
|
||||
updateFilters(
|
||||
@ -111,7 +108,7 @@ export const ProjectViewIssuesHeader: React.FC = observer(() => {
|
||||
viewId.toString()
|
||||
).then(() => {
|
||||
captureIssuesFilterEvent({
|
||||
eventName: isFilterRemoved ? FILTER_REMOVED : FILTER_APPLIED,
|
||||
eventName: (issueFilters?.filters?.[key] ?? []).length > newValues.length ? FILTER_REMOVED : FILTER_APPLIED,
|
||||
payload: {
|
||||
routePath: router.asPath,
|
||||
filters: issueFilters,
|
||||
|
@ -249,7 +249,7 @@ export const CreateInboxIssueModal: React.FC<Props> = observer((props) => {
|
||||
// this is done so that the title do not reset after gpt popover closed
|
||||
reset(getValues());
|
||||
}}
|
||||
onResponse={(response) => {
|
||||
onResponse={(_,response) => {
|
||||
handleAiAssistance(response);
|
||||
}}
|
||||
button={
|
||||
|
@ -92,14 +92,14 @@ export const ProjectViewAppliedFiltersRoot: React.FC = observer(() => {
|
||||
filters: {
|
||||
...(appliedFilters ?? {}),
|
||||
},
|
||||
}).then((res) => {
|
||||
}).then((res) =>
|
||||
captureEvent(VIEW_UPDATED, {
|
||||
view_id: res.id,
|
||||
filters: res.filters,
|
||||
element: "View Navbar",
|
||||
state: "SUCCESS",
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -92,11 +92,12 @@ export const AllIssueLayoutRoot: React.FC = observer(() => {
|
||||
if (workspaceSlug && globalViewId) {
|
||||
await fetchAllGlobalViews(workspaceSlug.toString());
|
||||
await fetchFilters(workspaceSlug.toString(), globalViewId.toString());
|
||||
captureIssuesListOpenedEvent({
|
||||
routePath: router.asPath,
|
||||
});
|
||||
await fetchIssues(workspaceSlug.toString(), globalViewId.toString(), issueIds ? "mutation" : "init-loader");
|
||||
routerFilterParams();
|
||||
captureIssuesListOpenedEvent({
|
||||
filters: globalViewId ? filters?.[globalViewId.toString()] : undefined,
|
||||
routePath: router.asPath,
|
||||
});
|
||||
}
|
||||
},
|
||||
{ revalidateIfStale: false, revalidateOnFocus: false }
|
||||
|
@ -28,15 +28,15 @@ export const ArchivedIssueLayoutRoot: React.FC = observer(() => {
|
||||
async () => {
|
||||
if (workspaceSlug && projectId) {
|
||||
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString());
|
||||
captureIssuesListOpenedEvent({
|
||||
routePath: router.asPath,
|
||||
filters: issuesFilter?.issueFilters?.filters,
|
||||
});
|
||||
await issues?.fetchIssues(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
issues?.groupedIssueIds ? "mutation" : "init-loader"
|
||||
);
|
||||
captureIssuesListOpenedEvent({
|
||||
routePath: router.asPath,
|
||||
filters: issuesFilter?.issueFilters?.filters,
|
||||
});
|
||||
}
|
||||
},
|
||||
{ revalidateIfStale: false, revalidateOnFocus: false }
|
||||
|
@ -41,16 +41,16 @@ export const CycleLayoutRoot: React.FC = observer(() => {
|
||||
async () => {
|
||||
if (workspaceSlug && projectId && cycleId) {
|
||||
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), cycleId.toString());
|
||||
captureIssuesListOpenedEvent({
|
||||
routePath: router.asPath,
|
||||
filters: issuesFilter?.issueFilters?.filters,
|
||||
});
|
||||
await issues?.fetchIssues(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
issues?.groupedIssueIds ? "mutation" : "init-loader",
|
||||
cycleId.toString()
|
||||
);
|
||||
captureIssuesListOpenedEvent({
|
||||
routePath: router.asPath,
|
||||
filters: issuesFilter?.issueFilters?.filters,
|
||||
});
|
||||
}
|
||||
},
|
||||
{ revalidateIfStale: false, revalidateOnFocus: false }
|
||||
@ -131,7 +131,7 @@ export const CycleLayoutRoot: React.FC = observer(() => {
|
||||
) : null}
|
||||
</div>
|
||||
{/* peek overview */}
|
||||
<IssuePeekOverview issuesFilter={issuesFilter.issueFilters}/>
|
||||
<IssuePeekOverview issuesFilter={issuesFilter.issueFilters} />
|
||||
</Fragment>
|
||||
)}
|
||||
</div>
|
||||
|
@ -28,15 +28,15 @@ export const DraftIssueLayoutRoot: React.FC = observer(() => {
|
||||
async () => {
|
||||
if (workspaceSlug && projectId) {
|
||||
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString());
|
||||
captureIssuesListOpenedEvent({
|
||||
routePath: router.asPath,
|
||||
filters: issuesFilter?.issueFilters?.filters,
|
||||
});
|
||||
await issues?.fetchIssues(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
issues?.groupedIssueIds ? "mutation" : "init-loader"
|
||||
);
|
||||
captureIssuesListOpenedEvent({
|
||||
routePath: router.asPath,
|
||||
filters: issuesFilter?.issueFilters?.filters,
|
||||
});
|
||||
}
|
||||
},
|
||||
{ revalidateIfStale: false, revalidateOnFocus: false }
|
||||
|
@ -37,16 +37,16 @@ export const ModuleLayoutRoot: React.FC = observer(() => {
|
||||
async () => {
|
||||
if (workspaceSlug && projectId && moduleId) {
|
||||
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), moduleId.toString());
|
||||
captureIssuesListOpenedEvent({
|
||||
routePath: router.asPath,
|
||||
filters: issuesFilter?.issueFilters?.filters,
|
||||
})
|
||||
await issues?.fetchIssues(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
issues?.groupedIssueIds ? "mutation" : "init-loader",
|
||||
moduleId.toString()
|
||||
);
|
||||
captureIssuesListOpenedEvent({
|
||||
routePath: router.asPath,
|
||||
filters: issuesFilter?.issueFilters?.filters,
|
||||
});
|
||||
}
|
||||
},
|
||||
{ revalidateIfStale: false, revalidateOnFocus: false }
|
||||
@ -116,7 +116,7 @@ export const ModuleLayoutRoot: React.FC = observer(() => {
|
||||
) : null}
|
||||
</div>
|
||||
{/* peek overview */}
|
||||
<IssuePeekOverview issuesFilter={issuesFilter.issueFilters}/>
|
||||
<IssuePeekOverview issuesFilter={issuesFilter.issueFilters} />
|
||||
</Fragment>
|
||||
)}
|
||||
</div>
|
||||
|
@ -33,16 +33,16 @@ export const ProjectViewLayoutRoot: React.FC = observer(() => {
|
||||
async () => {
|
||||
if (workspaceSlug && projectId && viewId) {
|
||||
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), viewId.toString());
|
||||
captureIssuesListOpenedEvent({
|
||||
routePath: router.asPath,
|
||||
filters: issuesFilter?.issueFilters?.filters,
|
||||
});
|
||||
await issues?.fetchIssues(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
issues?.groupedIssueIds ? "mutation" : "init-loader",
|
||||
viewId.toString()
|
||||
);
|
||||
captureIssuesListOpenedEvent({
|
||||
routePath: router.asPath,
|
||||
filters: issuesFilter?.issueFilters?.filters,
|
||||
});
|
||||
}
|
||||
},
|
||||
{ revalidateIfStale: false, revalidateOnFocus: false }
|
||||
@ -81,7 +81,7 @@ export const ProjectViewLayoutRoot: React.FC = observer(() => {
|
||||
</div>
|
||||
|
||||
{/* peek overview */}
|
||||
<IssuePeekOverview issuesFilter={issuesFilter.issueFilters}/>
|
||||
<IssuePeekOverview issuesFilter={issuesFilter.issueFilters} />
|
||||
</Fragment>
|
||||
)}
|
||||
</div>
|
||||
|
@ -425,7 +425,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
|
||||
// this is done so that the title do not reset after gpt popover closed
|
||||
reset(getValues());
|
||||
}}
|
||||
onResponse={(response) => {
|
||||
onResponse={(_,response) => {
|
||||
handleAiAssistance(response);
|
||||
}}
|
||||
placement="top-end"
|
||||
|
@ -191,14 +191,14 @@ const PageDetailsPage: NextPageWithLayout = observer(() => {
|
||||
};
|
||||
|
||||
try {
|
||||
await createPage(formData).then(() => {
|
||||
await createPage(formData).then(() =>
|
||||
captureEvent(PAGE_DUPLICATED, {
|
||||
page_id: pageId,
|
||||
access: access == 1 ? "private" : "public",
|
||||
element: "Pages detail page",
|
||||
state: "SUCCESS",
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
} catch (error) {
|
||||
actionCompleteAlert({
|
||||
title: `Page could not be duplicated`,
|
||||
@ -211,14 +211,14 @@ const PageDetailsPage: NextPageWithLayout = observer(() => {
|
||||
const archivePage = async () => {
|
||||
if (!workspaceSlug || !projectId || !pageId) return;
|
||||
try {
|
||||
await archivePageAction(workspaceSlug as string, projectId as string, pageId as string).then(() => {
|
||||
await archivePageAction(workspaceSlug as string, projectId as string, pageId as string).then(() =>
|
||||
captureEvent(PAGE_ARCHIVED, {
|
||||
page_id: pageId,
|
||||
access: access == 1 ? "private" : "public",
|
||||
element: "Pages detail page",
|
||||
state: "SUCCESS",
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
} catch (error) {
|
||||
actionCompleteAlert({
|
||||
title: `Page could not be archived`,
|
||||
@ -231,14 +231,14 @@ const PageDetailsPage: NextPageWithLayout = observer(() => {
|
||||
const unArchivePage = async () => {
|
||||
if (!workspaceSlug || !projectId || !pageId) return;
|
||||
try {
|
||||
await restorePageAction(workspaceSlug as string, projectId as string, pageId as string).then(() => {
|
||||
await restorePageAction(workspaceSlug as string, projectId as string, pageId as string).then(() =>
|
||||
captureEvent(PAGE_RESTORED, {
|
||||
page_id: pageId,
|
||||
access: access == 1 ? "private" : "public",
|
||||
element: "Pages detail page",
|
||||
state: "SUCCESS",
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
} catch (error) {
|
||||
actionCompleteAlert({
|
||||
title: `Page could not be restored`,
|
||||
@ -251,14 +251,14 @@ const PageDetailsPage: NextPageWithLayout = observer(() => {
|
||||
const lockPage = async () => {
|
||||
if (!workspaceSlug || !projectId || !pageId) return;
|
||||
try {
|
||||
await lockPageAction().then(() => {
|
||||
await lockPageAction().then(() =>
|
||||
captureEvent(PAGE_LOCKED, {
|
||||
page_id: pageId,
|
||||
access: access == 1 ? "private" : "public",
|
||||
element: "Pages detail page",
|
||||
state: "SUCCESS",
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
} catch (error) {
|
||||
actionCompleteAlert({
|
||||
title: `Page could not be locked`,
|
||||
@ -271,14 +271,14 @@ const PageDetailsPage: NextPageWithLayout = observer(() => {
|
||||
const unlockPage = async () => {
|
||||
if (!workspaceSlug || !projectId || !pageId) return;
|
||||
try {
|
||||
await unlockPageAction().then(() => {
|
||||
await unlockPageAction().then(() =>
|
||||
captureEvent(PAGE_UNLOCKED, {
|
||||
page_id: pageId,
|
||||
access: access == 1 ? "private" : "public",
|
||||
element: "Pages detail page",
|
||||
state: "SUCCESS",
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
} catch (error) {
|
||||
actionCompleteAlert({
|
||||
title: `Page could not be unlocked`,
|
||||
@ -389,21 +389,21 @@ const PageDetailsPage: NextPageWithLayout = observer(() => {
|
||||
reset(getValues());
|
||||
}}
|
||||
onResponse={handleAiAssistance}
|
||||
onGenerateResponse={(question) => {
|
||||
onGenerateResponse={(question) =>
|
||||
captureEvent(AI_TRIGGERED, {
|
||||
page_id: pageId,
|
||||
element: "Pages detail page",
|
||||
question: question,
|
||||
});
|
||||
}}
|
||||
onReGenerateResponse={(question, response) => {
|
||||
})
|
||||
}
|
||||
onReGenerateResponse={(question, response) =>
|
||||
captureEvent(AI_RES_REGENERATED, {
|
||||
page_id: pageId,
|
||||
element: "Pages detail page",
|
||||
question: question,
|
||||
prev_answer: response,
|
||||
});
|
||||
}}
|
||||
})
|
||||
}
|
||||
placement="top-end"
|
||||
button={
|
||||
<button
|
||||
|
Loading…
Reference in New Issue
Block a user