mirror of
https://github.com/makeplane/plane
synced 2025-08-07 19:59:33 +00:00
[WEB-3175]fix: favorites menu (#6773)
* fix: favrotites menu open * fix: open fav menu on starring projec * chore: added constant for hardcoded text
This commit is contained in:
@@ -3,13 +3,13 @@ import { observer } from "mobx-react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { Earth, Lock } from "lucide-react";
|
||||
// types
|
||||
import { EViewAccess, EUserPermissions, EUserPermissionsLevel } from "@plane/constants";
|
||||
import { EViewAccess, EUserPermissions, EUserPermissionsLevel, IS_FAVORITE_MENU_OPEN } from "@plane/constants";
|
||||
import { useLocalStorage } from "@plane/hooks";
|
||||
import { IProjectView } from "@plane/types";
|
||||
// ui
|
||||
import { Tooltip, FavoriteStar } from "@plane/ui";
|
||||
// components
|
||||
import { DeleteProjectViewModal, CreateUpdateProjectViewModal, ViewQuickActions } from "@/components/views";
|
||||
// constants
|
||||
// helpers
|
||||
import { calculateTotalFilters } from "@/helpers/filter.helper";
|
||||
import { getPublishViewLink } from "@/helpers/project-views.helpers";
|
||||
@@ -37,6 +37,12 @@ export const ViewListItemAction: FC<Props> = observer((props) => {
|
||||
const { addViewToFavorites, removeViewFromFavorites } = useProjectView();
|
||||
const { getUserDetails } = useMember();
|
||||
|
||||
// local storage
|
||||
const { setValue: toggleFavoriteMenu, storedValue: isFavoriteOpen } = useLocalStorage<boolean>(
|
||||
IS_FAVORITE_MENU_OPEN,
|
||||
false
|
||||
);
|
||||
|
||||
// derived values
|
||||
const isEditingAllowed = allowPermissions(
|
||||
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
|
||||
@@ -50,10 +56,11 @@ export const ViewListItemAction: FC<Props> = observer((props) => {
|
||||
const publishLink = getPublishViewLink(view?.anchor);
|
||||
|
||||
// handlers
|
||||
const handleAddToFavorites = () => {
|
||||
const handleAddToFavorites = async () => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
|
||||
addViewToFavorites(workspaceSlug.toString(), projectId.toString(), view.id);
|
||||
await addViewToFavorites(workspaceSlug.toString(), projectId.toString(), view.id);
|
||||
if (!isFavoriteOpen) toggleFavoriteMenu(true);
|
||||
};
|
||||
|
||||
const handleRemoveFromFavorites = () => {
|
||||
|
||||
Reference in New Issue
Block a user