mirror of
https://github.com/makeplane/plane.git
synced 2026-07-12 05:21:14 +02:00
fix: types
This commit is contained in:
44
packages/types/src/dashboard.d.ts
vendored
44
packages/types/src/dashboard.d.ts
vendored
@@ -4,11 +4,6 @@ import { TIssue } from "./issues/issue";
|
||||
import { TStateGroups } from "./state";
|
||||
import { TIssueRelationTypes } from "@/plane-web/types";
|
||||
|
||||
export type WidgetProps = {
|
||||
dashboardId: string;
|
||||
workspaceSlug: string;
|
||||
};
|
||||
|
||||
export type TWidgetKeys =
|
||||
| "overview_stats"
|
||||
| "assigned_issues"
|
||||
@@ -22,7 +17,6 @@ export type TWidgetKeys =
|
||||
export type TIssuesListTypes = "pending" | "upcoming" | "overdue" | "completed";
|
||||
|
||||
// widget filters
|
||||
export type TRecentActivityWidgetFilters = "all" | "projects" | "pages" | "issues";
|
||||
|
||||
export type TAssignedIssuesWidgetFilters = {
|
||||
custom_dates?: string[];
|
||||
@@ -186,41 +180,3 @@ export type THomeDashboardResponse = {
|
||||
dashboard: TDashboard;
|
||||
widgets: TWidget[];
|
||||
};
|
||||
|
||||
// home
|
||||
type TPageEntityData = {
|
||||
id: string;
|
||||
name: string;
|
||||
logo_props: TLogoProps;
|
||||
project_id: string;
|
||||
owned_by: string;
|
||||
project_identifier: string;
|
||||
};
|
||||
|
||||
type TProjectEntityData = {
|
||||
id: string;
|
||||
name: string;
|
||||
logo_props: TLogoProps;
|
||||
project_members: ProjectMember[];
|
||||
identifier: string;
|
||||
};
|
||||
|
||||
type TIssueEntityData = {
|
||||
id: string;
|
||||
name: string;
|
||||
state: string;
|
||||
priority: TIssuePriorities;
|
||||
assignees: string[];
|
||||
type: string | null;
|
||||
sequence_id: number;
|
||||
project_id: string;
|
||||
project_identifier: string;
|
||||
};
|
||||
|
||||
type TActivityEntityData = {
|
||||
id: string;
|
||||
entity_name: "page" | "project" | "issue";
|
||||
entity_identifier: string;
|
||||
visited_at: string;
|
||||
entity_data: TPageEntityData | TProjectEntityData | TIssueEntityData;
|
||||
};
|
||||
|
||||
46
packages/types/src/home.d.ts
vendored
Normal file
46
packages/types/src/home.d.ts
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import { TLogoProps } from "./common";
|
||||
import { TIssuePriorities } from "./issues";
|
||||
|
||||
export type TRecentActivityFilterKeys = "all item" | "issue" | "page" | "project";
|
||||
export type THomeWidgetKeys = "quick_links" | "recent_activity" | "stickies";
|
||||
|
||||
export type THomeWidgetProps = {
|
||||
workspaceSlug: string;
|
||||
};
|
||||
|
||||
export type TPageEntityData = {
|
||||
id: string;
|
||||
name: string;
|
||||
logo_props: TLogoProps;
|
||||
project_id: string;
|
||||
owned_by: string;
|
||||
project_identifier: string;
|
||||
};
|
||||
|
||||
export type TProjectEntityData = {
|
||||
id: string;
|
||||
name: string;
|
||||
logo_props: TLogoProps;
|
||||
project_members: string[];
|
||||
identifier: string;
|
||||
};
|
||||
|
||||
export type TIssueEntityData = {
|
||||
id: string;
|
||||
name: string;
|
||||
state: string;
|
||||
priority: TIssuePriorities;
|
||||
assignees: string[];
|
||||
type: string | null;
|
||||
sequence_id: number;
|
||||
project_id: string;
|
||||
project_identifier: string;
|
||||
};
|
||||
|
||||
export type TActivityEntityData = {
|
||||
id: string;
|
||||
entity_name: "page" | "project" | "issue";
|
||||
entity_identifier: string;
|
||||
visited_at: string;
|
||||
entity_data: TPageEntityData | TProjectEntityData | TIssueEntityData;
|
||||
};
|
||||
1
packages/types/src/index.d.ts
vendored
1
packages/types/src/index.d.ts
vendored
@@ -40,3 +40,4 @@ export * from "./timezone";
|
||||
export * from "./activity";
|
||||
export * from "./epics";
|
||||
export * from "./charts";
|
||||
export * from "./home";
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { observer } from "mobx-react";
|
||||
import { useParams } from "next/navigation";
|
||||
// types
|
||||
import { TWidgetKeys, WidgetProps } from "@plane/types";
|
||||
// components
|
||||
import { THomeWidgetKeys, THomeWidgetProps, TWidgetKeys } from "@plane/types";
|
||||
// hooks
|
||||
import { useDashboard, useProject } from "@/hooks/store";
|
||||
import { useHome } from "@/hooks/store/use-home";
|
||||
// components
|
||||
import { HomePageHeader } from "@/plane-web/components/home/header";
|
||||
import { RecentActivityWidget } from "./widgets";
|
||||
import { DashboardQuickLinks } from "./widgets/links";
|
||||
@@ -13,8 +12,9 @@ import { ManageWidgetsModal } from "./widgets/manage";
|
||||
import { StickiesWidget } from "@/plane-web/components/stickies";
|
||||
|
||||
const WIDGETS_LIST: {
|
||||
[key: string]: { component: React.FC<WidgetProps>; fullWidth: boolean };
|
||||
[key in THomeWidgetKeys]: { component: React.FC<THomeWidgetProps>; fullWidth: boolean };
|
||||
} = {
|
||||
quick_links: { component: DashboardQuickLinks, fullWidth: false },
|
||||
recent_activity: { component: RecentActivityWidget, fullWidth: false },
|
||||
stickies: { component: StickiesWidget, fullWidth: false },
|
||||
};
|
||||
@@ -22,15 +22,10 @@ const WIDGETS_LIST: {
|
||||
export const DashboardWidgets = observer(() => {
|
||||
// router
|
||||
const { workspaceSlug } = useParams();
|
||||
const { totalProjectIds } = useProject();
|
||||
// store hooks
|
||||
const { toggleWidgetSettings, showWidgetSettings } = useHome();
|
||||
const { homeDashboardId, homeDashboardWidgets } = useDashboard();
|
||||
|
||||
const doesWidgetExist = (widgetKey: TWidgetKeys) =>
|
||||
Boolean(homeDashboardWidgets?.find((widget) => widget.key === widgetKey));
|
||||
|
||||
if (!workspaceSlug || !homeDashboardId) return null;
|
||||
if (!workspaceSlug) return null;
|
||||
|
||||
return (
|
||||
<div className="relative flex flex-col gap-7">
|
||||
@@ -40,21 +35,16 @@ export const DashboardWidgets = observer(() => {
|
||||
isModalOpen={showWidgetSettings}
|
||||
handleOnClose={() => toggleWidgetSettings(false)}
|
||||
/>
|
||||
<DashboardQuickLinks workspaceSlug={workspaceSlug.toString()} />
|
||||
|
||||
{Object.entries(WIDGETS_LIST).map(([key, widget]) => {
|
||||
const WidgetComponent = widget.component;
|
||||
// if the widget doesn't exist, return null
|
||||
// if (!doesWidgetExist(key as TWidgetKeys)) return null;
|
||||
// if the widget is full width, return it in a 2 column grid
|
||||
if (widget.fullWidth)
|
||||
return (
|
||||
<div key={key} className="lg:col-span-2">
|
||||
<WidgetComponent dashboardId={homeDashboardId} workspaceSlug={workspaceSlug.toString()} />
|
||||
<WidgetComponent workspaceSlug={workspaceSlug.toString()} />
|
||||
</div>
|
||||
);
|
||||
else
|
||||
return <WidgetComponent key={key} dashboardId={homeDashboardId} workspaceSlug={workspaceSlug.toString()} />;
|
||||
else return <WidgetComponent key={key} workspaceSlug={workspaceSlug.toString()} />;
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -4,11 +4,9 @@ import { useHome } from "@/hooks/store/use-home";
|
||||
import { LinkCreateUpdateModal } from "./create-update-link-modal";
|
||||
import { ProjectLinkList } from "./links";
|
||||
import { useLinks } from "./use-links";
|
||||
import { THomeWidgetProps } from "@plane/types";
|
||||
|
||||
type TProps = {
|
||||
workspaceSlug: string;
|
||||
};
|
||||
export const DashboardQuickLinks = observer((props: TProps) => {
|
||||
export const DashboardQuickLinks = observer((props: THomeWidgetProps) => {
|
||||
const { workspaceSlug } = props;
|
||||
const { linkOperations } = useLinks(workspaceSlug);
|
||||
const {
|
||||
|
||||
@@ -122,7 +122,7 @@ export const WidgetItem: FC<Props> = observer((props) => {
|
||||
<WidgetItemDragHandle sort_order={widget.sort_order} isDragging={isDragging} />
|
||||
<div>{widget.title}</div>
|
||||
</div>
|
||||
<ToggleSwitch />
|
||||
{/* <ToggleSwitch /> */}
|
||||
</div>
|
||||
{isLastChild && <DropIndicator isVisible={instruction === "reorder-below"} />}
|
||||
</div>
|
||||
|
||||
@@ -5,12 +5,13 @@ import { observer } from "mobx-react";
|
||||
import { ChevronDown } from "lucide-react";
|
||||
import { CustomMenu } from "@plane/ui";
|
||||
import { cn } from "@plane/utils";
|
||||
import { TRecentActivityFilterKeys } from "@plane/types";
|
||||
|
||||
export type TFiltersDropdown = {
|
||||
className?: string;
|
||||
activeFilter: string;
|
||||
setActiveFilter: (filter: string) => void;
|
||||
filters: { name: string; icon?: React.ReactNode }[];
|
||||
activeFilter: TRecentActivityFilterKeys;
|
||||
setActiveFilter: (filter: TRecentActivityFilterKeys) => void;
|
||||
filters: { name: TRecentActivityFilterKeys; icon?: React.ReactNode }[];
|
||||
};
|
||||
|
||||
export const FiltersDropdown: FC<TFiltersDropdown> = observer((props) => {
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
import { useRef, useState } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { WidgetProps } from "@/components/dashboard/widgets";
|
||||
// types
|
||||
import { TActivityEntityData } from "@plane/types";
|
||||
import { TActivityEntityData, THomeWidgetProps, TRecentActivityFilterKeys } from "@plane/types";
|
||||
// components
|
||||
import { FiltersDropdown } from "./filters";
|
||||
import { RecentIssue } from "./issue";
|
||||
@@ -19,17 +18,19 @@ import { EmptyWorkspace } from "../empty-states";
|
||||
|
||||
const WIDGET_KEY = EWidgetKeys.RECENT_ACTIVITY;
|
||||
const workspaceService = new WorkspaceService();
|
||||
const filters = [
|
||||
const filters: { name: TRecentActivityFilterKeys; icon?: React.ReactNode }[] = [
|
||||
{ name: "all item" },
|
||||
{ name: "issue", icon: <LayersIcon className="w-4 h-4" /> },
|
||||
{ name: "page", icon: <FileText size={16} /> },
|
||||
{ name: "project", icon: <Briefcase size={16} /> },
|
||||
];
|
||||
|
||||
export const RecentActivityWidget: React.FC<WidgetProps> = observer((props) => {
|
||||
export const RecentActivityWidget: React.FC<THomeWidgetProps> = observer((props) => {
|
||||
const { workspaceSlug } = props;
|
||||
// state
|
||||
const [filter, setFilter] = useState<TRecentActivityFilterKeys>(filters[0].name);
|
||||
// ref
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const [filter, setFilter] = useState(filters[0].name);
|
||||
|
||||
const { data: recents, isLoading } = useSWR(
|
||||
workspaceSlug ? `WORKSPACE_RECENT_ACTIVITY_${workspaceSlug}_${filter}` : null,
|
||||
|
||||
Reference in New Issue
Block a user