forked from github/plane
refactor: issue activity message logic (#1614)
This commit is contained in:
parent
6c2600efa7
commit
f9c3f02d15
@ -6,8 +6,6 @@ import useSWR from "swr";
|
|||||||
|
|
||||||
// services
|
// services
|
||||||
import issuesService from "services/issues.service";
|
import issuesService from "services/issues.service";
|
||||||
// hooks
|
|
||||||
import useEstimateOption from "hooks/use-estimate-option";
|
|
||||||
// components
|
// components
|
||||||
import { CommentCard } from "components/issues/comment";
|
import { CommentCard } from "components/issues/comment";
|
||||||
// ui
|
// ui
|
||||||
@ -17,88 +15,288 @@ import { Squares2X2Icon } from "@heroicons/react/24/outline";
|
|||||||
import { BlockedIcon, BlockerIcon } from "components/icons";
|
import { BlockedIcon, BlockerIcon } from "components/icons";
|
||||||
// helpers
|
// helpers
|
||||||
import { renderShortDateWithYearFormat, timeAgo } from "helpers/date-time.helper";
|
import { renderShortDateWithYearFormat, timeAgo } from "helpers/date-time.helper";
|
||||||
import { addSpaceIfCamelCase } from "helpers/string.helper";
|
import { capitalizeFirstLetter } from "helpers/string.helper";
|
||||||
// types
|
// types
|
||||||
import { ICurrentUserResponse, IIssueComment, IIssueLabels } from "types";
|
import { ICurrentUserResponse, IIssueActivity, IIssueComment } from "types";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import { PROJECT_ISSUES_ACTIVITY, PROJECT_ISSUE_LABELS } from "constants/fetch-keys";
|
import { PROJECT_ISSUES_ACTIVITY } from "constants/fetch-keys";
|
||||||
|
|
||||||
const activityDetails: {
|
const activityDetails: {
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
message?: string;
|
message: (activity: IIssueActivity) => React.ReactNode;
|
||||||
icon: JSX.Element;
|
icon: React.ReactNode;
|
||||||
};
|
};
|
||||||
} = {
|
} = {
|
||||||
assignee: {
|
assignee: {
|
||||||
message: "removed the assignee",
|
message: (activity) => (
|
||||||
|
<>
|
||||||
|
removed the assignee{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.old_value}</span>.
|
||||||
|
</>
|
||||||
|
),
|
||||||
icon: <Icon iconName="group" className="!text-sm" aria-hidden="true" />,
|
icon: <Icon iconName="group" className="!text-sm" aria-hidden="true" />,
|
||||||
},
|
},
|
||||||
assignees: {
|
assignees: {
|
||||||
message: "added a new assignee",
|
message: (activity) => (
|
||||||
|
<>
|
||||||
|
added a new assignee{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.new_value}</span>.
|
||||||
|
</>
|
||||||
|
),
|
||||||
icon: <Icon iconName="group" className="!text-sm" aria-hidden="true" />,
|
icon: <Icon iconName="group" className="!text-sm" aria-hidden="true" />,
|
||||||
},
|
},
|
||||||
blocks: {
|
archived_at: {
|
||||||
message: "marked this issue being blocked by",
|
message: (activity) => {
|
||||||
icon: <BlockedIcon height="12" width="12" color="#6b7280" />,
|
if (activity.new_value === "restore") return "restored the issue.";
|
||||||
|
else return "archived the issue.";
|
||||||
|
},
|
||||||
|
icon: <Icon iconName="archive" className="!text-sm" aria-hidden="true" />,
|
||||||
|
},
|
||||||
|
attachment: {
|
||||||
|
message: (activity) => {
|
||||||
|
if (activity.verb === "created") return "uploaded a new attachment.";
|
||||||
|
else return "removed the attachment.";
|
||||||
|
},
|
||||||
|
icon: <Icon iconName="attach_file" className="!text-sm" aria-hidden="true" />,
|
||||||
},
|
},
|
||||||
blocking: {
|
blocking: {
|
||||||
message: "marked this issue is blocking",
|
message: (activity) => {
|
||||||
|
if (activity.old_value === "")
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
marked this issue is blocking issue{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.new_value}</span>.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
else
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
removed the blocking issue{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.old_value}</span>.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
icon: <BlockerIcon height="12" width="12" color="#6b7280" />,
|
icon: <BlockerIcon height="12" width="12" color="#6b7280" />,
|
||||||
},
|
},
|
||||||
|
blocks: {
|
||||||
|
message: (activity) => {
|
||||||
|
if (activity.old_value === "")
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
marked this issue is being blocked by{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.new_value}</span>.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
else
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
removed this issue being blocked by issue{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.old_value}</span>.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
icon: <BlockedIcon height="12" width="12" color="#6b7280" />,
|
||||||
|
},
|
||||||
cycles: {
|
cycles: {
|
||||||
message: "set the cycle to",
|
message: (activity) => {
|
||||||
|
if (activity.verb === "created")
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
added this issue to the cycle{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.new_value}</span>.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
else if (activity.verb === "updated")
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
set the cycle to{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.new_value}</span>.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
else
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
removed the issue from the cycle{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.old_value}</span>.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
icon: <Icon iconName="contrast" className="!text-sm" aria-hidden="true" />,
|
icon: <Icon iconName="contrast" className="!text-sm" aria-hidden="true" />,
|
||||||
},
|
},
|
||||||
|
description: {
|
||||||
|
message: (activity) => "updated the description.",
|
||||||
|
icon: <Icon iconName="chat" className="!text-sm" aria-hidden="true" />,
|
||||||
|
},
|
||||||
estimate_point: {
|
estimate_point: {
|
||||||
message: "set the estimate point to",
|
message: (activity) => {
|
||||||
|
if (!activity.new_value) return "removed the estimate point.";
|
||||||
|
else
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
set the estimate point to{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.new_value}</span>.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
icon: <Icon iconName="change_history" className="!text-sm" aria-hidden="true" />,
|
icon: <Icon iconName="change_history" className="!text-sm" aria-hidden="true" />,
|
||||||
},
|
},
|
||||||
labels: {
|
labels: {
|
||||||
|
message: (activity) => {
|
||||||
|
if (activity.old_value === "")
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
added a new label{" "}
|
||||||
|
<span className="inline-flex items-center gap-3 rounded-full border border-custom-border-300 px-2 py-0.5 text-xs">
|
||||||
|
<span
|
||||||
|
className="h-1.5 w-1.5 rounded-full"
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#000000",
|
||||||
|
}}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.new_value}</span>
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
else
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
removed the label{" "}
|
||||||
|
<span className="inline-flex items-center gap-3 rounded-full border border-custom-border-300 px-2 py-0.5 text-xs">
|
||||||
|
<span
|
||||||
|
className="h-1.5 w-1.5 rounded-full"
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#000000",
|
||||||
|
}}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.old_value}</span>
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
icon: <Icon iconName="sell" className="!text-sm" aria-hidden="true" />,
|
icon: <Icon iconName="sell" className="!text-sm" aria-hidden="true" />,
|
||||||
},
|
},
|
||||||
modules: {
|
|
||||||
message: "set the module to",
|
|
||||||
icon: <Icon iconName="dataset" className="!text-sm" aria-hidden="true" />,
|
|
||||||
},
|
|
||||||
state: {
|
|
||||||
message: "set the state to",
|
|
||||||
icon: <Squares2X2Icon className="h-3 w-3" aria-hidden="true" />,
|
|
||||||
},
|
|
||||||
priority: {
|
|
||||||
message: "set the priority to",
|
|
||||||
icon: <Icon iconName="signal_cellular_alt" className="!text-sm" aria-hidden="true" />,
|
|
||||||
},
|
|
||||||
name: {
|
|
||||||
message: "set the name to",
|
|
||||||
icon: <Icon iconName="chat" className="!text-sm" aria-hidden="true" />,
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
message: "updated the description.",
|
|
||||||
icon: <Icon iconName="chat" className="!text-sm" aria-hidden="true" />,
|
|
||||||
},
|
|
||||||
target_date: {
|
|
||||||
message: "set the due date to",
|
|
||||||
icon: <Icon iconName="calendar_today" className="!text-sm" aria-hidden="true" />,
|
|
||||||
},
|
|
||||||
parent: {
|
|
||||||
message: "set the parent to",
|
|
||||||
icon: <Icon iconName="supervised_user_circle" className="!text-sm" aria-hidden="true" />,
|
|
||||||
},
|
|
||||||
estimate: {
|
|
||||||
message: "updated the estimate",
|
|
||||||
icon: <Icon iconName="change_history" className="!text-sm" aria-hidden="true" />,
|
|
||||||
},
|
|
||||||
link: {
|
link: {
|
||||||
message: "updated the link",
|
message: (activity) => {
|
||||||
|
if (activity.verb === "created")
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
added this{" "}
|
||||||
|
<a
|
||||||
|
href={`${activity.new_value}`}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="text-custom-text-100"
|
||||||
|
>
|
||||||
|
link
|
||||||
|
</a>{" "}
|
||||||
|
to the issue.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
else
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
removed this{" "}
|
||||||
|
<a
|
||||||
|
href={`${activity.old_value}`}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="text-custom-text-100"
|
||||||
|
>
|
||||||
|
link
|
||||||
|
</a>{" "}
|
||||||
|
from the issue.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
icon: <Icon iconName="link" className="!text-sm" aria-hidden="true" />,
|
icon: <Icon iconName="link" className="!text-sm" aria-hidden="true" />,
|
||||||
},
|
},
|
||||||
attachment: {
|
modules: {
|
||||||
message: "updated the attachment",
|
message: (activity) => {
|
||||||
icon: <Icon iconName="attach_file" className="!text-sm" aria-hidden="true" />,
|
if (activity.verb === "created")
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
added this issue to the module{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.new_value}</span>.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
else if (activity.verb === "updated")
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
set the module to{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.new_value}</span>.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
else
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
removed the issue from the module{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.old_value}</span>.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
icon: <Icon iconName="dataset" className="!text-sm" aria-hidden="true" />,
|
||||||
},
|
},
|
||||||
archived_at: {
|
name: {
|
||||||
message: "archived",
|
message: (activity) => `set the name to ${activity.new_value}.`,
|
||||||
icon: <Icon iconName="archive" className="!text-sm" aria-hidden="true" />,
|
icon: <Icon iconName="chat" className="!text-sm" aria-hidden="true" />,
|
||||||
|
},
|
||||||
|
parent: {
|
||||||
|
message: (activity) => {
|
||||||
|
if (!activity.old_value)
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
set the parent to{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.new_value}</span>.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
else
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
removed the parent{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.old_value}</span>.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
icon: <Icon iconName="supervised_user_circle" className="!text-sm" aria-hidden="true" />,
|
||||||
|
},
|
||||||
|
priority: {
|
||||||
|
message: (activity) => (
|
||||||
|
<>
|
||||||
|
set the priority to{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">
|
||||||
|
{activity.new_value ? capitalizeFirstLetter(activity.new_value) : "None"}
|
||||||
|
</span>
|
||||||
|
.
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
icon: <Icon iconName="signal_cellular_alt" className="!text-sm" aria-hidden="true" />,
|
||||||
|
},
|
||||||
|
state: {
|
||||||
|
message: (activity) => (
|
||||||
|
<>
|
||||||
|
set the state to{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">{activity.new_value}</span>.
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
icon: <Squares2X2Icon className="h-3 w-3" aria-hidden="true" />,
|
||||||
|
},
|
||||||
|
target_date: {
|
||||||
|
message: (activity) => {
|
||||||
|
if (!activity.new_value) return "removed the due date.";
|
||||||
|
else
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
set the due date to{" "}
|
||||||
|
<span className="font-medium text-custom-text-100">
|
||||||
|
{renderShortDateWithYearFormat(activity.new_value)}
|
||||||
|
</span>
|
||||||
|
.
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
icon: <Icon iconName="calendar_today" className="!text-sm" aria-hidden="true" />,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -111,29 +309,17 @@ export const IssueActivitySection: React.FC<Props> = ({ issueId, user }) => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug, projectId } = router.query;
|
const { workspaceSlug, projectId } = router.query;
|
||||||
|
|
||||||
const { isEstimateActive, estimatePoints } = useEstimateOption();
|
|
||||||
|
|
||||||
const { data: issueActivities, mutate: mutateIssueActivities } = useSWR(
|
const { data: issueActivities, mutate: mutateIssueActivities } = useSWR(
|
||||||
workspaceSlug && projectId && issueId ? PROJECT_ISSUES_ACTIVITY(issueId as string) : null,
|
workspaceSlug && projectId ? PROJECT_ISSUES_ACTIVITY(issueId) : null,
|
||||||
workspaceSlug && projectId && issueId
|
|
||||||
? () =>
|
|
||||||
issuesService.getIssueActivities(
|
|
||||||
workspaceSlug as string,
|
|
||||||
projectId as string,
|
|
||||||
issueId as string
|
|
||||||
)
|
|
||||||
: null
|
|
||||||
);
|
|
||||||
|
|
||||||
const { data: issueLabels } = useSWR<IIssueLabels[]>(
|
|
||||||
projectId ? PROJECT_ISSUE_LABELS(projectId as string) : null,
|
|
||||||
workspaceSlug && projectId
|
workspaceSlug && projectId
|
||||||
? () => issuesService.getIssueLabels(workspaceSlug as string, projectId as string)
|
? () =>
|
||||||
|
issuesService.getIssueActivities(workspaceSlug as string, projectId as string, issueId)
|
||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleCommentUpdate = async (comment: IIssueComment) => {
|
const handleCommentUpdate = async (comment: IIssueComment) => {
|
||||||
if (!workspaceSlug || !projectId || !issueId) return;
|
if (!workspaceSlug || !projectId || !issueId) return;
|
||||||
|
|
||||||
await issuesService
|
await issuesService
|
||||||
.patchIssueComment(
|
.patchIssueComment(
|
||||||
workspaceSlug as string,
|
workspaceSlug as string,
|
||||||
@ -143,9 +329,7 @@ export const IssueActivitySection: React.FC<Props> = ({ issueId, user }) => {
|
|||||||
comment,
|
comment,
|
||||||
user
|
user
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => mutateIssueActivities());
|
||||||
mutateIssueActivities();
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCommentDelete = async (commentId: string) => {
|
const handleCommentDelete = async (commentId: string) => {
|
||||||
@ -164,15 +348,6 @@ export const IssueActivitySection: React.FC<Props> = ({ issueId, user }) => {
|
|||||||
.then(() => mutateIssueActivities());
|
.then(() => mutateIssueActivities());
|
||||||
};
|
};
|
||||||
|
|
||||||
const getLabelColor = (labelId: string) => {
|
|
||||||
if (!issueLabels) return;
|
|
||||||
const label = issueLabels.find((label) => label.id === labelId);
|
|
||||||
if (typeof label !== "undefined") {
|
|
||||||
return label.color !== "" ? label.color : "#000000";
|
|
||||||
}
|
|
||||||
return "#000000";
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!issueActivities) {
|
if (!issueActivities) {
|
||||||
return (
|
return (
|
||||||
<Loader className="space-y-4">
|
<Loader className="space-y-4">
|
||||||
@ -195,207 +370,75 @@ export const IssueActivitySection: React.FC<Props> = ({ issueId, user }) => {
|
|||||||
return (
|
return (
|
||||||
<div className="flow-root">
|
<div className="flow-root">
|
||||||
<ul role="list" className="-mb-4">
|
<ul role="list" className="-mb-4">
|
||||||
{issueActivities.map((activityItem, activityItemIdx) => {
|
{issueActivities.map((activityItem, index) => {
|
||||||
// determines what type of action is performed
|
// determines what type of action is performed
|
||||||
let action = activityDetails[activityItem.field as keyof typeof activityDetails]?.message;
|
const message = activityItem.field
|
||||||
if (activityItem.field === "labels") {
|
? activityDetails[activityItem.field as keyof typeof activityDetails].message(
|
||||||
action = activityItem.new_value !== "" ? "added a new label" : "removed the label";
|
activityItem
|
||||||
} else if (activityItem.field === "blocking") {
|
)
|
||||||
action =
|
: "created the issue.";
|
||||||
activityItem.new_value !== ""
|
|
||||||
? "marked this issue is blocking"
|
|
||||||
: "removed the issue from blocking";
|
|
||||||
} else if (activityItem.field === "blocks") {
|
|
||||||
action =
|
|
||||||
activityItem.new_value !== ""
|
|
||||||
? "marked this issue being blocked by"
|
|
||||||
: "removed blocker";
|
|
||||||
} else if (activityItem.field === "target_date") {
|
|
||||||
action =
|
|
||||||
activityItem.new_value && activityItem.new_value !== ""
|
|
||||||
? "set the due date to"
|
|
||||||
: "removed the due date";
|
|
||||||
} else if (activityItem.field === "parent") {
|
|
||||||
action =
|
|
||||||
activityItem.new_value && activityItem.new_value !== ""
|
|
||||||
? "set the parent to"
|
|
||||||
: "removed the parent";
|
|
||||||
} else if (activityItem.field === "priority") {
|
|
||||||
action =
|
|
||||||
activityItem.new_value && activityItem.new_value !== ""
|
|
||||||
? "set the priority to"
|
|
||||||
: "removed the priority";
|
|
||||||
} else if (activityItem.field === "description") {
|
|
||||||
action = "updated the";
|
|
||||||
} else if (activityItem.field === "attachment") {
|
|
||||||
action = `${activityItem.verb} the`;
|
|
||||||
} else if (activityItem.field === "link") {
|
|
||||||
action = `${activityItem.verb} the`;
|
|
||||||
} else if (activityItem.field === "estimate") {
|
|
||||||
action = "updated the";
|
|
||||||
} else if (activityItem.field === "cycles") {
|
|
||||||
action =
|
|
||||||
activityItem.new_value && activityItem.new_value !== ""
|
|
||||||
? "set the cycle to"
|
|
||||||
: "removed the cycle";
|
|
||||||
} else if (activityItem.field === "modules") {
|
|
||||||
action =
|
|
||||||
activityItem.new_value && activityItem.new_value !== ""
|
|
||||||
? "set the module to"
|
|
||||||
: "removed the module";
|
|
||||||
} else if (activityItem.field === "archived_at") {
|
|
||||||
action =
|
|
||||||
activityItem.new_value && activityItem.new_value === "restore"
|
|
||||||
? "restored the issue"
|
|
||||||
: "archived the issue";
|
|
||||||
}
|
|
||||||
// for values that are after the action clause
|
|
||||||
let value: any = activityItem.new_value ? activityItem.new_value : activityItem.old_value;
|
|
||||||
if (
|
|
||||||
activityItem.verb === "created" &&
|
|
||||||
activityItem.field !== "cycles" &&
|
|
||||||
activityItem.field !== "modules" &&
|
|
||||||
activityItem.field !== "attachment" &&
|
|
||||||
activityItem.field !== "link" &&
|
|
||||||
activityItem.field !== "estimate"
|
|
||||||
) {
|
|
||||||
value = <span className="text-custom-text-200">created this issue.</span>;
|
|
||||||
} else if (activityItem.field === "state") {
|
|
||||||
value = activityItem.new_value ? addSpaceIfCamelCase(activityItem.new_value) : "None";
|
|
||||||
} else if (activityItem.field === "labels") {
|
|
||||||
let name;
|
|
||||||
let id = "#000000";
|
|
||||||
if (activityItem.new_value !== "") {
|
|
||||||
name = activityItem.new_value;
|
|
||||||
id = activityItem.new_identifier ? activityItem.new_identifier : id;
|
|
||||||
} else {
|
|
||||||
name = activityItem.old_value;
|
|
||||||
id = activityItem.old_identifier ? activityItem.old_identifier : id;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = (
|
|
||||||
<span className="relative inline-flex items-center rounded-full border border-custom-border-200 px-2 py-0.5 text-xs">
|
|
||||||
<span className="absolute flex flex-shrink-0 items-center justify-center">
|
|
||||||
<span
|
|
||||||
className="h-1.5 w-1.5 rounded-full"
|
|
||||||
style={{
|
|
||||||
backgroundColor: getLabelColor(id),
|
|
||||||
}}
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
<span className="ml-3 font-medium text-custom-text-100">{name}</span>
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
} else if (activityItem.field === "assignees") {
|
|
||||||
value = activityItem.new_value;
|
|
||||||
} else if (activityItem.field === "target_date") {
|
|
||||||
const date =
|
|
||||||
activityItem.new_value && activityItem.new_value !== ""
|
|
||||||
? activityItem.new_value
|
|
||||||
: activityItem.old_value;
|
|
||||||
value = renderShortDateWithYearFormat(date as string);
|
|
||||||
} else if (activityItem.field === "description") {
|
|
||||||
value = "description";
|
|
||||||
} else if (activityItem.field === "attachment") {
|
|
||||||
value = "attachment";
|
|
||||||
} else if (activityItem.field === "cycles") {
|
|
||||||
const cycles =
|
|
||||||
activityItem.new_value && activityItem.new_value !== ""
|
|
||||||
? activityItem.new_value
|
|
||||||
: activityItem.old_value;
|
|
||||||
value = cycles ? addSpaceIfCamelCase(cycles) : "None";
|
|
||||||
} else if (activityItem.field === "modules") {
|
|
||||||
const modules =
|
|
||||||
activityItem.new_value && activityItem.new_value !== ""
|
|
||||||
? activityItem.new_value
|
|
||||||
: activityItem.old_value;
|
|
||||||
value = modules ? addSpaceIfCamelCase(modules) : "None";
|
|
||||||
} else if (activityItem.field === "link") {
|
|
||||||
value = "link";
|
|
||||||
} else if (activityItem.field === "estimate_point") {
|
|
||||||
value = activityItem.new_value
|
|
||||||
? isEstimateActive
|
|
||||||
? estimatePoints.find((e) => e.key === parseInt(activityItem.new_value ?? "", 10))
|
|
||||||
?.value
|
|
||||||
: activityItem.new_value +
|
|
||||||
` Point${parseInt(activityItem.new_value ?? "", 10) > 1 ? "s" : ""}`
|
|
||||||
: "None";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("field" in activityItem && activityItem.field !== "updated_by") {
|
if ("field" in activityItem && activityItem.field !== "updated_by") {
|
||||||
return (
|
return (
|
||||||
<li key={activityItem.id}>
|
<li key={activityItem.id}>
|
||||||
<div className="relative pb-1">
|
<div className="relative pb-1">
|
||||||
{issueActivities.length > 1 && activityItemIdx !== issueActivities.length - 1 ? (
|
{issueActivities.length > 1 && index !== issueActivities.length - 1 ? (
|
||||||
<span
|
<span
|
||||||
className="absolute top-5 left-5 -ml-px h-full w-0.5 bg-custom-background-80"
|
className="absolute top-5 left-5 -ml-px h-full w-0.5 bg-custom-background-80"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="relative flex items-start space-x-2">
|
<div className="relative flex items-start space-x-2">
|
||||||
<>
|
<div>
|
||||||
<div>
|
<div className="relative px-1.5">
|
||||||
<div className="relative px-1.5">
|
<div className="mt-1.5">
|
||||||
<div className="mt-1.5">
|
<div className="ring-6 flex h-7 w-7 items-center justify-center rounded-full bg-custom-background-80 text-custom-text-200 ring-white">
|
||||||
<div className="ring-6 flex h-7 w-7 items-center justify-center rounded-full bg-custom-background-80 text-custom-text-200 ring-white">
|
{activityItem.field ? (
|
||||||
{activityItem.field ? (
|
activityItem.new_value === "restore" ? (
|
||||||
activityItem.new_value === "restore" ? (
|
<Icon iconName="history" className="text-sm text-custom-text-200" />
|
||||||
<Icon
|
|
||||||
iconName="history"
|
|
||||||
className="text-sm text-custom-text-200"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
activityDetails[
|
|
||||||
activityItem.field as keyof typeof activityDetails
|
|
||||||
]?.icon
|
|
||||||
)
|
|
||||||
) : activityItem.actor_detail.avatar &&
|
|
||||||
activityItem.actor_detail.avatar !== "" ? (
|
|
||||||
<img
|
|
||||||
src={activityItem.actor_detail.avatar}
|
|
||||||
alt={activityItem.actor_detail.first_name}
|
|
||||||
height={24}
|
|
||||||
width={24}
|
|
||||||
className="rounded-full"
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<div
|
activityDetails[activityItem.field as keyof typeof activityDetails]
|
||||||
className={`grid h-7 w-7 place-items-center rounded-full border-2 border-white bg-gray-700 text-xs text-white`}
|
?.icon
|
||||||
>
|
)
|
||||||
{activityItem.actor_detail.first_name.charAt(0)}
|
) : activityItem.actor_detail.avatar &&
|
||||||
</div>
|
activityItem.actor_detail.avatar !== "" ? (
|
||||||
)}
|
<img
|
||||||
</div>
|
src={activityItem.actor_detail.avatar}
|
||||||
|
alt={activityItem.actor_detail.first_name}
|
||||||
|
height={24}
|
||||||
|
width={24}
|
||||||
|
className="rounded-full"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
className={`grid h-7 w-7 place-items-center rounded-full border-2 border-white bg-gray-700 text-xs text-white`}
|
||||||
|
>
|
||||||
|
{activityItem.actor_detail.first_name.charAt(0)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="min-w-0 flex-1 py-3">
|
</div>
|
||||||
<div className="text-xs text-custom-text-200">
|
<div className="min-w-0 flex-1 py-3">
|
||||||
{activityItem.field === "archived_at" &&
|
<div className="text-xs text-custom-text-200 break-words">
|
||||||
activityItem.new_value !== "restore" ? (
|
{activityItem.field === "archived_at" &&
|
||||||
<span className="text-gray font-medium">Plane</span>
|
activityItem.new_value !== "restore" ? (
|
||||||
) : (
|
<span className="text-gray font-medium">Plane</span>
|
||||||
<span className="text-gray font-medium">
|
) : (
|
||||||
{activityItem.actor_detail.first_name}
|
<span className="text-gray font-medium">
|
||||||
{activityItem.actor_detail.is_bot
|
{activityItem.actor_detail.first_name}
|
||||||
? " Bot"
|
{activityItem.actor_detail.is_bot
|
||||||
: " " + activityItem.actor_detail.last_name}
|
? " Bot"
|
||||||
</span>
|
: " " + activityItem.actor_detail.last_name}
|
||||||
)}
|
|
||||||
<span> {action} </span>
|
|
||||||
{activityItem.field !== "archived_at" && (
|
|
||||||
<span className="text-xs font-medium text-custom-text-100">
|
|
||||||
{" "}
|
|
||||||
{value}{" "}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
<span className="whitespace-nowrap">
|
|
||||||
{timeAgo(activityItem.created_at)}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
)}{" "}
|
||||||
|
{message}{" "}
|
||||||
|
<span className="whitespace-nowrap">
|
||||||
|
{timeAgo(activityItem.created_at)}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@ -404,7 +447,7 @@ export const IssueActivitySection: React.FC<Props> = ({ issueId, user }) => {
|
|||||||
return (
|
return (
|
||||||
<div key={activityItem.id} className="mt-4">
|
<div key={activityItem.id} className="mt-4">
|
||||||
<CommentCard
|
<CommentCard
|
||||||
comment={activityItem as any}
|
comment={activityItem as IIssueComment}
|
||||||
onSubmit={handleCommentUpdate}
|
onSubmit={handleCommentUpdate}
|
||||||
handleCommentDeletion={handleCommentDelete}
|
handleCommentDeletion={handleCommentDelete}
|
||||||
/>
|
/>
|
||||||
|
@ -52,8 +52,8 @@ export const CommentCard: React.FC<Props> = ({ comment, onSubmit, handleCommentD
|
|||||||
const onEnter = (formData: IIssueComment) => {
|
const onEnter = (formData: IIssueComment) => {
|
||||||
if (isSubmitting) return;
|
if (isSubmitting) return;
|
||||||
setIsEditing(false);
|
setIsEditing(false);
|
||||||
|
|
||||||
onSubmit(formData);
|
onSubmit(formData);
|
||||||
console.log(formData);
|
|
||||||
|
|
||||||
editorRef.current?.setEditorValue(formData.comment_json);
|
editorRef.current?.setEditorValue(formData.comment_json);
|
||||||
showEditorRef.current?.setEditorValue(formData.comment_json);
|
showEditorRef.current?.setEditorValue(formData.comment_json);
|
||||||
|
54
apps/app/types/issues.d.ts
vendored
54
apps/app/types/issues.d.ts
vendored
@ -147,25 +147,6 @@ export interface BlockeIssueDetail {
|
|||||||
project_detail: IProjectLite;
|
project_detail: IProjectLite;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IIssueComment {
|
|
||||||
id: string;
|
|
||||||
actor: string;
|
|
||||||
actor_detail: IUserLite;
|
|
||||||
created_at: Date;
|
|
||||||
updated_at: Date;
|
|
||||||
comment: string;
|
|
||||||
comment_html: string;
|
|
||||||
comment_json: any;
|
|
||||||
attachments: any[];
|
|
||||||
created_by: string;
|
|
||||||
updated_by: string;
|
|
||||||
project: string;
|
|
||||||
project_detail: IProjectLite;
|
|
||||||
workspace: string;
|
|
||||||
workspace_detail: IWorkspaceLite;
|
|
||||||
issue: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type IssuePriorities = {
|
export type IssuePriorities = {
|
||||||
id: string;
|
id: string;
|
||||||
created_at: Date;
|
created_at: Date;
|
||||||
@ -209,25 +190,32 @@ export interface IIssueLabels {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IIssueActivity {
|
export interface IIssueActivity {
|
||||||
id: string;
|
actor: string;
|
||||||
actor_detail: IUserLite;
|
actor_detail: IUserLite;
|
||||||
created_at: Date;
|
|
||||||
updated_at: Date;
|
|
||||||
verb: string;
|
|
||||||
field: string | null;
|
|
||||||
old_value: string | null;
|
|
||||||
new_value: string | null;
|
|
||||||
comment: string;
|
|
||||||
attachments: any[];
|
attachments: any[];
|
||||||
old_identifier: string | null;
|
comment: string;
|
||||||
new_identifier: string | null;
|
created_at: Date;
|
||||||
created_by: string;
|
created_by: string;
|
||||||
updated_by: string;
|
field: string | null;
|
||||||
project: string;
|
id: string;
|
||||||
workspace: string;
|
|
||||||
issue: string;
|
issue: string;
|
||||||
issue_comment: string | null;
|
issue_comment: string | null;
|
||||||
actor: string;
|
new_identifier: string | null;
|
||||||
|
new_value: string | null;
|
||||||
|
old_identifier: string | null;
|
||||||
|
old_value: string | null;
|
||||||
|
project: string;
|
||||||
|
updated_at: Date;
|
||||||
|
updated_by: string;
|
||||||
|
verb: string;
|
||||||
|
workspace: string;
|
||||||
|
workspace_detail: IWorkspaceLite;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IIssueComment extends IIssueActivity {
|
||||||
|
comment_html: string;
|
||||||
|
comment_json: any;
|
||||||
|
comment_stripped: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IIssueLite {
|
export interface IIssueLite {
|
||||||
|
8
apps/app/types/users.d.ts
vendored
8
apps/app/types/users.d.ts
vendored
@ -53,13 +53,13 @@ export interface ICurrentUserResponse extends IUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IUserLite {
|
export interface IUserLite {
|
||||||
readonly id: string;
|
|
||||||
first_name: string;
|
|
||||||
last_name: string;
|
|
||||||
email: string;
|
|
||||||
avatar: string;
|
avatar: string;
|
||||||
created_at: Date;
|
created_at: Date;
|
||||||
|
email: string;
|
||||||
|
first_name: string;
|
||||||
|
readonly id: string;
|
||||||
is_bot: boolean;
|
is_bot: boolean;
|
||||||
|
last_name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IUserActivity {
|
export interface IUserActivity {
|
||||||
|
Loading…
Reference in New Issue
Block a user