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
|
// components
|
||||||
import { CreateUpdateProjectViewModal, DeleteProjectViewModal } from "@/components/views";
|
import { CreateUpdateProjectViewModal, DeleteProjectViewModal } from "@/components/views";
|
||||||
// constants
|
// constants
|
||||||
|
import { E_VIEWS } from "@/constants/event-tracker";
|
||||||
import { EUserProjectRoles } from "@/constants/project";
|
import { EUserProjectRoles } from "@/constants/project";
|
||||||
// helpers
|
// helpers
|
||||||
import { cn } from "@/helpers/common.helper";
|
import { cn } from "@/helpers/common.helper";
|
||||||
import { copyUrlToClipboard } from "@/helpers/string.helper";
|
import { copyUrlToClipboard } from "@/helpers/string.helper";
|
||||||
// hooks
|
// hooks
|
||||||
import { useUser } from "@/hooks/store";
|
import { useEventTracker, useUser } from "@/hooks/store";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
parentRef: React.RefObject<HTMLElement>;
|
parentRef: React.RefObject<HTMLElement>;
|
||||||
@ -31,6 +32,7 @@ export const ViewQuickActions: React.FC<Props> = observer((props) => {
|
|||||||
const {
|
const {
|
||||||
membership: { currentProjectRole },
|
membership: { currentProjectRole },
|
||||||
} = useUser();
|
} = useUser();
|
||||||
|
const { setTrackElement } = useEventTracker();
|
||||||
// auth
|
// auth
|
||||||
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
|
||||||
|
|
||||||
@ -48,7 +50,10 @@ export const ViewQuickActions: React.FC<Props> = observer((props) => {
|
|||||||
const MENU_ITEMS: TContextMenuItem[] = [
|
const MENU_ITEMS: TContextMenuItem[] = [
|
||||||
{
|
{
|
||||||
key: "edit",
|
key: "edit",
|
||||||
action: () => setCreateUpdateViewModal(true),
|
action: () => {
|
||||||
|
setTrackElement(E_VIEWS);
|
||||||
|
setCreateUpdateViewModal(true);
|
||||||
|
},
|
||||||
title: "Edit",
|
title: "Edit",
|
||||||
icon: Pencil,
|
icon: Pencil,
|
||||||
shouldRender: isEditingAllowed,
|
shouldRender: isEditingAllowed,
|
||||||
@ -67,7 +72,10 @@ export const ViewQuickActions: React.FC<Props> = observer((props) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "delete",
|
key: "delete",
|
||||||
action: () => setDeleteViewModal(true),
|
action: () => {
|
||||||
|
setTrackElement(E_VIEWS);
|
||||||
|
setDeleteViewModal(true);
|
||||||
|
},
|
||||||
title: "Delete",
|
title: "Delete",
|
||||||
icon: Trash2,
|
icon: Trash2,
|
||||||
shouldRender: isEditingAllowed,
|
shouldRender: isEditingAllowed,
|
||||||
|
@ -7,11 +7,12 @@ import { IProjectView } from "@plane/types";
|
|||||||
import { FavoriteStar } from "@/components/core";
|
import { FavoriteStar } from "@/components/core";
|
||||||
import { DeleteProjectViewModal, CreateUpdateProjectViewModal, ViewQuickActions } from "@/components/views";
|
import { DeleteProjectViewModal, CreateUpdateProjectViewModal, ViewQuickActions } from "@/components/views";
|
||||||
// constants
|
// constants
|
||||||
|
import { E_VIEWS, VIEW_FAVORITED, VIEW_UNFAVORITED } from "@/constants/event-tracker";
|
||||||
import { EUserProjectRoles } from "@/constants/project";
|
import { EUserProjectRoles } from "@/constants/project";
|
||||||
// helpers
|
// helpers
|
||||||
import { calculateTotalFilters } from "@/helpers/filter.helper";
|
import { calculateTotalFilters } from "@/helpers/filter.helper";
|
||||||
// hooks
|
// hooks
|
||||||
import { useProjectView, useUser } from "@/hooks/store";
|
import { useEventTracker, useProjectView, useUser } from "@/hooks/store";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
parentRef: React.RefObject<HTMLElement>;
|
parentRef: React.RefObject<HTMLElement>;
|
||||||
@ -31,6 +32,7 @@ export const ViewListItemAction: FC<Props> = observer((props) => {
|
|||||||
membership: { currentProjectRole },
|
membership: { currentProjectRole },
|
||||||
} = useUser();
|
} = useUser();
|
||||||
const { addViewToFavorites, removeViewFromFavorites } = useProjectView();
|
const { addViewToFavorites, removeViewFromFavorites } = useProjectView();
|
||||||
|
const { captureEvent } = useEventTracker();
|
||||||
|
|
||||||
// derived values
|
// derived values
|
||||||
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
|
||||||
@ -42,12 +44,20 @@ export const ViewListItemAction: FC<Props> = observer((props) => {
|
|||||||
if (!workspaceSlug || !projectId) return;
|
if (!workspaceSlug || !projectId) return;
|
||||||
|
|
||||||
addViewToFavorites(workspaceSlug.toString(), projectId.toString(), view.id);
|
addViewToFavorites(workspaceSlug.toString(), projectId.toString(), view.id);
|
||||||
|
captureEvent(VIEW_FAVORITED, {
|
||||||
|
view_id: view.id,
|
||||||
|
element: E_VIEWS,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRemoveFromFavorites = () => {
|
const handleRemoveFromFavorites = () => {
|
||||||
if (!workspaceSlug || !projectId) return;
|
if (!workspaceSlug || !projectId) return;
|
||||||
|
|
||||||
removeViewFromFavorites(workspaceSlug.toString(), projectId.toString(), view.id);
|
removeViewFromFavorites(workspaceSlug.toString(), projectId.toString(), view.id);
|
||||||
|
captureEvent(VIEW_UNFAVORITED, {
|
||||||
|
view_id: view.id,
|
||||||
|
element: E_VIEWS,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user