mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: views events updated
This commit is contained in:
parent
9f9b31245d
commit
2f67ca7a5f
@ -8,12 +8,13 @@ import { ContextMenu, CustomMenu, TContextMenuItem, TOAST_TYPE, setToast } from
|
||||
// components
|
||||
import { CreateUpdateProjectViewModal, DeleteProjectViewModal } from "@/components/views";
|
||||
// constants
|
||||
import { E_VIEWS } from "@/constants/event-tracker";
|
||||
import { EUserProjectRoles } from "@/constants/project";
|
||||
// helpers
|
||||
import { cn } from "@/helpers/common.helper";
|
||||
import { copyUrlToClipboard } from "@/helpers/string.helper";
|
||||
// hooks
|
||||
import { useUser } from "@/hooks/store";
|
||||
import { useEventTracker, useUser } from "@/hooks/store";
|
||||
|
||||
type Props = {
|
||||
parentRef: React.RefObject<HTMLElement>;
|
||||
@ -31,6 +32,7 @@ export const ViewQuickActions: React.FC<Props> = observer((props) => {
|
||||
const {
|
||||
membership: { currentProjectRole },
|
||||
} = useUser();
|
||||
const { setTrackElement } = useEventTracker();
|
||||
// auth
|
||||
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
|
||||
|
||||
@ -48,7 +50,10 @@ export const ViewQuickActions: React.FC<Props> = observer((props) => {
|
||||
const MENU_ITEMS: TContextMenuItem[] = [
|
||||
{
|
||||
key: "edit",
|
||||
action: () => setCreateUpdateViewModal(true),
|
||||
action: () => {
|
||||
setTrackElement(E_VIEWS);
|
||||
setCreateUpdateViewModal(true);
|
||||
},
|
||||
title: "Edit",
|
||||
icon: Pencil,
|
||||
shouldRender: isEditingAllowed,
|
||||
@ -67,7 +72,10 @@ export const ViewQuickActions: React.FC<Props> = observer((props) => {
|
||||
},
|
||||
{
|
||||
key: "delete",
|
||||
action: () => setDeleteViewModal(true),
|
||||
action: () => {
|
||||
setTrackElement(E_VIEWS);
|
||||
setDeleteViewModal(true);
|
||||
},
|
||||
title: "Delete",
|
||||
icon: Trash2,
|
||||
shouldRender: isEditingAllowed,
|
||||
|
@ -7,11 +7,12 @@ import { IProjectView } from "@plane/types";
|
||||
import { FavoriteStar } from "@/components/core";
|
||||
import { DeleteProjectViewModal, CreateUpdateProjectViewModal, ViewQuickActions } from "@/components/views";
|
||||
// constants
|
||||
import { E_VIEWS, VIEW_FAVORITED, VIEW_UNFAVORITED } from "@/constants/event-tracker";
|
||||
import { EUserProjectRoles } from "@/constants/project";
|
||||
// helpers
|
||||
import { calculateTotalFilters } from "@/helpers/filter.helper";
|
||||
// hooks
|
||||
import { useProjectView, useUser } from "@/hooks/store";
|
||||
import { useEventTracker, useProjectView, useUser } from "@/hooks/store";
|
||||
|
||||
type Props = {
|
||||
parentRef: React.RefObject<HTMLElement>;
|
||||
@ -31,6 +32,7 @@ export const ViewListItemAction: FC<Props> = observer((props) => {
|
||||
membership: { currentProjectRole },
|
||||
} = useUser();
|
||||
const { addViewToFavorites, removeViewFromFavorites } = useProjectView();
|
||||
const { captureEvent } = useEventTracker();
|
||||
|
||||
// derived values
|
||||
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
|
||||
@ -42,12 +44,20 @@ export const ViewListItemAction: FC<Props> = observer((props) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
|
||||
addViewToFavorites(workspaceSlug.toString(), projectId.toString(), view.id);
|
||||
captureEvent(VIEW_FAVORITED, {
|
||||
view_id: view.id,
|
||||
element: E_VIEWS,
|
||||
});
|
||||
};
|
||||
|
||||
const handleRemoveFromFavorites = () => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
|
||||
removeViewFromFavorites(workspaceSlug.toString(), projectId.toString(), view.id);
|
||||
captureEvent(VIEW_UNFAVORITED, {
|
||||
view_id: view.id,
|
||||
element: E_VIEWS,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user