added project states events

This commit is contained in:
Lakhan 2024-06-04 14:37:57 +05:30
parent 97eea75cb7
commit ffc987bcc8
3 changed files with 15 additions and 10 deletions

View File

@ -8,7 +8,7 @@ import type { IState } from "@plane/types";
// ui // ui
import { Button, CustomSelect, Input, Tooltip, TOAST_TYPE, setToast } from "@plane/ui"; import { Button, CustomSelect, Input, Tooltip, TOAST_TYPE, setToast } from "@plane/ui";
// constants // constants
import { STATE_CREATED, STATE_UPDATED } from "@/constants/event-tracker"; import { E_STATES, STATE_CREATED, STATE_UPDATED } from "@/constants/event-tracker";
import { GROUP_CHOICES } from "@/constants/project"; import { GROUP_CHOICES } from "@/constants/project";
// hooks // hooks
import { useEventTracker, useProjectState } from "@/hooks/store"; import { useEventTracker, useProjectState } from "@/hooks/store";
@ -43,7 +43,7 @@ export const CreateUpdateStateInline: React.FC<Props> = observer((props) => {
// form info // form info
const { const {
handleSubmit, handleSubmit,
formState: { errors, isSubmitting }, formState: { errors, isSubmitting, dirtyFields },
watch, watch,
reset, reset,
control, control,
@ -91,7 +91,7 @@ export const CreateUpdateStateInline: React.FC<Props> = observer((props) => {
payload: { payload: {
...res, ...res,
state: "SUCCESS", state: "SUCCESS",
element: "Project settings states page", element: E_STATES,
}, },
}); });
}) })
@ -114,7 +114,7 @@ export const CreateUpdateStateInline: React.FC<Props> = observer((props) => {
payload: { payload: {
...formData, ...formData,
state: "FAILED", state: "FAILED",
element: "Project settings states page", element: E_STATES,
}, },
}); });
}); });
@ -130,8 +130,9 @@ export const CreateUpdateStateInline: React.FC<Props> = observer((props) => {
eventName: STATE_UPDATED, eventName: STATE_UPDATED,
payload: { payload: {
...res, ...res,
change_details: Object.keys(dirtyFields),
state: "SUCCESS", state: "SUCCESS",
element: "Project settings states page", element: E_STATES,
}, },
}); });
setToast({ setToast({
@ -158,7 +159,7 @@ export const CreateUpdateStateInline: React.FC<Props> = observer((props) => {
payload: { payload: {
...formData, ...formData,
state: "FAILED", state: "FAILED",
element: "Project settings states page", element: E_STATES,
}, },
}); });
}); });
@ -292,9 +293,7 @@ export const CreateUpdateStateInline: React.FC<Props> = observer((props) => {
variant="primary" variant="primary"
type="submit" type="submit"
loading={isSubmitting} loading={isSubmitting}
onClick={() => { onClick={() => setTrackElement(E_STATES)}
setTrackElement("PROJECT_SETTINGS_STATE_PAGE");
}}
size="sm" size="sm"
> >
{data ? (isSubmitting ? "Updating" : "Update") : isSubmitting ? "Creating" : "Create"} {data ? (isSubmitting ? "Updating" : "Update") : isSubmitting ? "Creating" : "Create"}

View File

@ -7,6 +7,8 @@ import { Pencil, X, ArrowDown, ArrowUp } from "lucide-react";
import { IState } from "@plane/types"; import { IState } from "@plane/types";
// ui // ui
import { Tooltip, StateGroupIcon } from "@plane/ui"; import { Tooltip, StateGroupIcon } from "@plane/ui";
// constants
import { E_STATES } from "@/constants/event-tracker";
// hooks // hooks
import { useEventTracker, useProjectState } from "@/hooks/store"; import { useEventTracker, useProjectState } from "@/hooks/store";
import { usePlatformOS } from "@/hooks/use-platform-os"; import { usePlatformOS } from "@/hooks/use-platform-os";
@ -103,7 +105,7 @@ export const StatesListItem: React.FC<Props> = observer((props) => {
state.default || groupLength === 1 ? "cursor-not-allowed" : "" state.default || groupLength === 1 ? "cursor-not-allowed" : ""
} grid place-items-center`} } grid place-items-center`}
onClick={() => { onClick={() => {
setTrackElement("PROJECT_SETTINGS_STATE_PAGE"); setTrackElement(E_STATES);
handleDeleteState(); handleDeleteState();
}} }}
disabled={state.default || groupLength === 1} disabled={state.default || groupLength === 1}

View File

@ -138,6 +138,7 @@ export const getProjectStateEventPayload = (payload: any) => ({
default: payload.default, default: payload.default,
state: payload.state, state: payload.state,
element: payload.element, element: payload.element,
change_details: payload.change_details,
}); });
// Workspace crud Events // Workspace crud Events
@ -222,3 +223,6 @@ export const SNOOZED_NOTIFICATIONS = "Snoozed notifications viewed";
export const ARCHIVED_NOTIFICATIONS = "Archived notifications viewed"; export const ARCHIVED_NOTIFICATIONS = "Archived notifications viewed";
// Groups // Groups
export const GROUP_WORKSPACE = "Workspace_metrics"; export const GROUP_WORKSPACE = "Workspace_metrics";
// Elements
export const E_STATES = "Project states page";