mirror of
https://github.com/makeplane/plane.git
synced 2026-07-13 05:49:40 +02:00
[WEB-1843] chore: minor file restructuring for bulk ops and issue embeds. (#577)
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
// types
|
||||
import { TEmbedItem } from "@/types";
|
||||
|
||||
export type TEmbedConfig = {
|
||||
issue?: TIssueEmbedConfig;
|
||||
};
|
||||
@@ -18,12 +21,3 @@ export type TIssueEmbedConfig = {
|
||||
workspaceSlug: string | undefined;
|
||||
}) => React.ReactNode;
|
||||
};
|
||||
|
||||
export type TEmbedItem = {
|
||||
id: string;
|
||||
title: string;
|
||||
subTitle: string;
|
||||
icon: React.ReactNode;
|
||||
projectId: string;
|
||||
workspaceSlug: string;
|
||||
};
|
||||
|
||||
@@ -1,24 +1,2 @@
|
||||
// editor
|
||||
import { TEmbedConfig, TReadOnlyEmbedConfig } from "@plane/editor";
|
||||
// types
|
||||
import { TPageEmbedType } from "@plane/types";
|
||||
// plane web components
|
||||
import { IssueEmbedUpgradeCard } from "@/plane-web/components/pages";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export const useIssueEmbed = (workspaceSlug: string, projectId: string, queryType: TPageEmbedType = "issue") => {
|
||||
const widgetCallback = () => <IssueEmbedUpgradeCard />;
|
||||
|
||||
const issueEmbedProps: TEmbedConfig["issue"] = {
|
||||
widgetCallback,
|
||||
};
|
||||
|
||||
const issueEmbedReadOnlyProps: TReadOnlyEmbedConfig["issue"] = {
|
||||
widgetCallback,
|
||||
};
|
||||
|
||||
return {
|
||||
issueEmbedProps,
|
||||
issueEmbedReadOnlyProps,
|
||||
};
|
||||
};
|
||||
// Removed the implementation for the CE hook as it was using an overridden type causing the build to fail.
|
||||
export * from "ee/hooks/use-issue-embed";
|
||||
|
||||
@@ -17,7 +17,6 @@ import { PageContentBrowser, PageEditorTitle, PageContentLoader } from "@/compon
|
||||
import { cn } from "@/helpers/common.helper";
|
||||
// hooks
|
||||
import { useMember, useMention, useUser, useWorkspace } from "@/hooks/store";
|
||||
import { useIssueEmbed } from "@/hooks/use-issue-embed";
|
||||
import { usePageFilters } from "@/hooks/use-page-filters";
|
||||
// plane web hooks
|
||||
import { useIssueEmbed } from "@/plane-web/hooks/use-issue-embed";
|
||||
@@ -97,13 +96,6 @@ export const PageEditorBody: React.FC<Props> = observer((props) => {
|
||||
if (pageId === undefined || pageDescription === undefined || !pageDescriptionYJS || !isDescriptionReady)
|
||||
return <PageContentLoader />;
|
||||
|
||||
const handleIssueSearch = async (searchQuery: string) => {
|
||||
const response = await fetchIssues(searchQuery);
|
||||
return response;
|
||||
};
|
||||
|
||||
if (pageDescription === undefined) return <PageContentLoader />;
|
||||
|
||||
return (
|
||||
<div className="flex items-center h-full w-full overflow-y-auto">
|
||||
<div
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// editor
|
||||
import { TEmbedItem } from "@plane/editor";
|
||||
// types
|
||||
import { TPageEmbedResponse, TPageEmbedType } from "@plane/types";
|
||||
// ui
|
||||
import { PriorityIcon } from "@plane/ui";
|
||||
// services
|
||||
import { ProjectPageService } from "@/services/page";
|
||||
|
||||
const pageService = new ProjectPageService();
|
||||
|
||||
export const useIssueEmbed = (workspaceSlug: string, projectId: string, queryType: TPageEmbedType = "issue") => {
|
||||
const fetchIssues = async (searchQuery: string): Promise<TEmbedItem[]> => {
|
||||
const response = await pageService.searchEmbed<TPageEmbedResponse[]>(workspaceSlug, projectId, {
|
||||
query_type: queryType,
|
||||
query: searchQuery,
|
||||
count: 10,
|
||||
});
|
||||
const structuredIssues: TEmbedItem[] = (response ?? []).map((issue) => ({
|
||||
id: issue.id,
|
||||
subTitle: `${issue.project__identifier}-${issue.sequence_id}`,
|
||||
title: issue.name,
|
||||
icon: <PriorityIcon priority={issue.priority} />,
|
||||
projectId: projectId,
|
||||
workspaceSlug: workspaceSlug,
|
||||
}));
|
||||
return structuredIssues;
|
||||
};
|
||||
|
||||
return {
|
||||
fetchIssues,
|
||||
};
|
||||
};
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./issue-embed";
|
||||
export * from "./issue-embed-upgrade-card";
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export * from "ce/components/pages/editor/embed/issue-embed-upgrade-card";
|
||||
1
web/ee/hooks/use-bulk-operation-status.ts
Normal file
1
web/ee/hooks/use-bulk-operation-status.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const useBulkOperationStatus = () => true;
|
||||
@@ -1 +1,68 @@
|
||||
export * from "ce/hooks/use-issue-embed";
|
||||
// editor
|
||||
import { TEmbedConfig, TEmbedItem, TIssueEmbedConfig, TReadOnlyEmbedConfig } from "@plane/editor";
|
||||
// types
|
||||
import { TPageEmbedResponse, TPageEmbedType } from "@plane/types";
|
||||
// ui
|
||||
import { PriorityIcon } from "@plane/ui";
|
||||
// plane web components
|
||||
import { IssueEmbedCard } from "@/plane-web/components/pages";
|
||||
// services
|
||||
import { ProjectPageService } from "@/services/page";
|
||||
|
||||
const pageService = new ProjectPageService();
|
||||
|
||||
export const useIssueEmbed = (workspaceSlug: string, projectId: string, queryType: TPageEmbedType = "issue") => {
|
||||
const fetchIssues = async (searchQuery: string): Promise<TEmbedItem[]> => {
|
||||
const response = await pageService.searchEmbed<TPageEmbedResponse[]>(workspaceSlug, projectId, {
|
||||
query_type: queryType,
|
||||
query: searchQuery,
|
||||
count: 10,
|
||||
});
|
||||
const structuredIssues: TEmbedItem[] = (response ?? []).map((issue) => ({
|
||||
id: issue.id,
|
||||
subTitle: `${issue.project__identifier}-${issue.sequence_id}`,
|
||||
title: issue.name,
|
||||
icon: <PriorityIcon priority={issue.priority} />,
|
||||
projectId: projectId,
|
||||
workspaceSlug: workspaceSlug,
|
||||
}));
|
||||
return structuredIssues;
|
||||
};
|
||||
|
||||
const searchCallback: TIssueEmbedConfig["searchCallback"] = async (query: string): Promise<TEmbedItem[]> =>
|
||||
new Promise((resolve) => {
|
||||
setTimeout(async () => {
|
||||
const response = await fetchIssues(query);
|
||||
const issueItemsWithIdentifiers = response?.map((issue) => ({
|
||||
...issue,
|
||||
projectId: projectId.toString(),
|
||||
workspaceSlug: workspaceSlug.toString(),
|
||||
}));
|
||||
resolve(issueItemsWithIdentifiers);
|
||||
}, 300);
|
||||
});
|
||||
|
||||
const widgetCallback: TIssueEmbedConfig["widgetCallback"] = ({
|
||||
issueId,
|
||||
projectId: projectIdFromEmbed,
|
||||
workspaceSlug: workspaceSlugFromEmbed,
|
||||
}) => {
|
||||
const resolvedProjectId = projectIdFromEmbed ?? projectId?.toString() ?? "";
|
||||
const resolvedWorkspaceSlug = workspaceSlugFromEmbed ?? workspaceSlug?.toString() ?? "";
|
||||
return <IssueEmbedCard issueId={issueId} projectId={resolvedProjectId} workspaceSlug={resolvedWorkspaceSlug} />;
|
||||
};
|
||||
|
||||
const issueEmbedProps: TEmbedConfig["issue"] = {
|
||||
searchCallback,
|
||||
widgetCallback,
|
||||
};
|
||||
|
||||
const issueEmbedReadOnlyProps: TReadOnlyEmbedConfig["issue"] = {
|
||||
widgetCallback,
|
||||
};
|
||||
|
||||
return {
|
||||
issueEmbedProps,
|
||||
issueEmbedReadOnlyProps,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user