refactor: favorites sidebar implementation (#6716)
* chore: code separation for favorites * chore: error handling
This commit is contained in:
parent
40c0bbcfb4
commit
cb344ea1f5
8 changed files with 121 additions and 50 deletions
|
|
@ -2,3 +2,4 @@ export * from "./ai";
|
|||
export * from "./estimates";
|
||||
export * from "./gantt-chart";
|
||||
export * from "./project";
|
||||
export * from "./sidebar-favorites";
|
||||
|
|
|
|||
41
web/ce/constants/sidebar-favorites.ts
Normal file
41
web/ce/constants/sidebar-favorites.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { Briefcase, ContrastIcon, FileText, Layers, LucideIcon } from "lucide-react";
|
||||
// plane imports
|
||||
import { IFavorite } from "@plane/types";
|
||||
import { DiceIcon, FavoriteFolderIcon, ISvgIcons } from "@plane/ui";
|
||||
|
||||
export const FAVORITE_ITEM_ICONS: Record<string, React.FC<ISvgIcons> | LucideIcon> = {
|
||||
page: FileText,
|
||||
project: Briefcase,
|
||||
view: Layers,
|
||||
module: DiceIcon,
|
||||
cycle: ContrastIcon,
|
||||
folder: FavoriteFolderIcon,
|
||||
};
|
||||
|
||||
export const FAVORITE_ITEM_LINKS: {
|
||||
[key: string]: {
|
||||
itemLevel: "project" | "workspace";
|
||||
getLink: (favorite: IFavorite) => string;
|
||||
};
|
||||
} = {
|
||||
project: {
|
||||
itemLevel: "project",
|
||||
getLink: () => `issues`,
|
||||
},
|
||||
cycle: {
|
||||
itemLevel: "project",
|
||||
getLink: (favorite) => `cycles/${favorite.entity_identifier}`,
|
||||
},
|
||||
module: {
|
||||
itemLevel: "project",
|
||||
getLink: (favorite) => `modules/${favorite.entity_identifier}`,
|
||||
},
|
||||
view: {
|
||||
itemLevel: "project",
|
||||
getLink: (favorite) => `views/${favorite.entity_identifier}`,
|
||||
},
|
||||
page: {
|
||||
itemLevel: "project",
|
||||
getLink: (favorite) => `pages/${favorite.entity_identifier}`,
|
||||
},
|
||||
};
|
||||
26
web/ce/hooks/use-additional-favorite-item-details.ts
Normal file
26
web/ce/hooks/use-additional-favorite-item-details.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// plane imports
|
||||
import { IFavorite } from "@plane/types";
|
||||
// components
|
||||
import { getFavoriteItemIcon } from "@/components/workspace/sidebar/favorites/favorite-items/common";
|
||||
|
||||
export const useAdditionalFavoriteItemDetails = () => {
|
||||
const getAdditionalFavoriteItemDetails = (_workspaceSlug: string, favorite: IFavorite) => {
|
||||
const { entity_type: favoriteItemEntityType } = favorite;
|
||||
const favoriteItemName = favorite?.entity_data?.name || favorite?.name;
|
||||
|
||||
let itemIcon;
|
||||
let itemTitle;
|
||||
|
||||
switch (favoriteItemEntityType) {
|
||||
default:
|
||||
itemTitle = favoriteItemName;
|
||||
itemIcon = getFavoriteItemIcon(favoriteItemEntityType);
|
||||
break;
|
||||
}
|
||||
return { itemIcon, itemTitle };
|
||||
};
|
||||
|
||||
return {
|
||||
getAdditionalFavoriteItemDetails,
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue