fix: issue parent activity (#1629)

This commit is contained in:
Aaryan Khandelwal 2023-07-23 22:14:41 +05:30 committed by GitHub
parent a7b5ad55ab
commit 464c13fcd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 45 additions and 37 deletions

View File

@ -2,7 +2,7 @@ import { useRouter } from "next/router";
// components
import { CycleIssuesGanttChartView } from "components/cycles";
import { IssueGanttChartView } from "components/issues/gantt-chart";
import { IssueGanttChartView } from "components/issues";
import { ModuleIssuesGanttChartView } from "components/modules";
import { ViewIssuesGanttChartView } from "components/views";

View File

@ -54,8 +54,22 @@ const activityDetails: {
},
attachment: {
message: (activity) => {
if (activity.verb === "created") return "uploaded a new attachment.";
else return "removed the attachment.";
if (activity.verb === "created")
return (
<>
uploaded a new{" "}
<a
href={`${activity.new_value}`}
target="_blank"
rel="noopener noreferrer"
className="font-medium text-custom-text-100 inline-flex items-center gap-1 hover:underline"
>
attachment
<Icon iconName="launch" className="!text-xs" />
</a>
</>
);
else return "removed an attachment.";
},
icon: <Icon iconName="attach_file" className="!text-sm" aria-hidden="true" />,
},
@ -187,28 +201,15 @@ const activityDetails: {
href={`${activity.new_value}`}
target="_blank"
rel="noopener noreferrer"
className="text-custom-text-100"
className="font-medium text-custom-text-100 inline-flex items-center gap-1 hover:underline"
>
link
<Icon iconName="launch" className="!text-xs" />
</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.
</>
);
else return "removed a link.";
},
icon: <Icon iconName="link" className="!text-sm" aria-hidden="true" />,
},
@ -244,18 +245,18 @@ const activityDetails: {
},
parent: {
message: (activity) => {
if (!activity.old_value)
if (!activity.new_value)
return (
<>
set the parent to{" "}
<span className="font-medium text-custom-text-100">{activity.new_value}</span>.
removed the parent{" "}
<span className="font-medium text-custom-text-100">{activity.old_value}</span>.
</>
);
else
return (
<>
removed the parent{" "}
<span className="font-medium text-custom-text-100">{activity.old_value}</span>.
set the parent to{" "}
<span className="font-medium text-custom-text-100">{activity.new_value}</span>.
</>
);
},
@ -373,7 +374,7 @@ export const IssueActivitySection: React.FC<Props> = ({ issueId, user }) => {
{issueActivities.map((activityItem, index) => {
// determines what type of action is performed
const message = activityItem.field
? activityDetails[activityItem.field as keyof typeof activityDetails].message(
? activityDetails[activityItem.field as keyof typeof activityDetails]?.message(
activityItem
)
: "created the issue.";

View File

@ -6,14 +6,14 @@ import { mutate } from "swr";
// react-dropzone
import { useDropzone } from "react-dropzone";
// toast
import useToast from "hooks/use-toast";
// fetch key
import { ISSUE_ATTACHMENTS } from "constants/fetch-keys";
// services
import issuesService from "services/issues.service";
// type
// hooks
import useToast from "hooks/use-toast";
// types
import { IIssueAttachment } from "types";
// fetch-keys
import { ISSUE_ATTACHMENTS, PROJECT_ISSUES_ACTIVITY } from "constants/fetch-keys";
const maxFileSize = 5 * 1024 * 1024; // 5 MB
@ -56,6 +56,7 @@ export const IssueAttachmentUpload: React.FC<Props> = ({ disabled = false }) =>
(prevData) => [res, ...(prevData ?? [])],
false
);
mutate(PROJECT_ISSUES_ACTIVITY(issueId as string));
setToastAlert({
type: "success",
title: "Success!",

View File

@ -81,12 +81,12 @@ export const IssueAttachments = () => {
} uploaded on ${renderLongDateFormat(file.updated_at)}`}
>
<span>
<ExclamationIcon className="h-3 w-3 fill-current text-custom-text-100" />
<ExclamationIcon className="h-3 w-3 fill-current" />
</span>
</Tooltip>
</div>
<div className="flex items-center gap-3 text-xs text-gray-500">
<div className="flex items-center gap-3 text-xs text-custom-text-200">
<span>{getFileExtension(file.asset).toUpperCase()}</span>
<span>{convertBytesToSize(file.attributes.size)}</span>
</div>
@ -101,7 +101,7 @@ export const IssueAttachments = () => {
setAttachmentDeleteModal(true);
}}
>
<XMarkIcon className="h-4 w-4 text-gray-500 hover:text-gray-800" />
<XMarkIcon className="h-4 w-4 text-custom-text-200 hover:text-custom-text-100" />
</button>
</div>
))}

View File

@ -19,7 +19,7 @@ import { getFileName } from "helpers/attachment.helper";
// types
import type { IIssueAttachment } from "types";
// fetch-keys
import { ISSUE_ATTACHMENTS } from "constants/fetch-keys";
import { ISSUE_ATTACHMENTS, PROJECT_ISSUES_ACTIVITY } from "constants/fetch-keys";
type Props = {
isOpen: boolean;
@ -53,6 +53,7 @@ export const DeleteAttachmentModal: React.FC<Props> = ({ isOpen, setIsOpen, data
issueId as string,
assetId as string
)
.then(() => mutate(PROJECT_ISSUES_ACTIVITY(issueId as string)))
.catch(() => {
setToastAlert({
type: "error",

View File

@ -0,0 +1,3 @@
export * from "./attachment-upload";
export * from "./attachments";
export * from "./delete-attachment-modal";

View File

@ -1,3 +1,4 @@
export * from "./attachment";
export * from "./comment";
export * from "./sidebar-select";
export * from "./view-select";
@ -5,12 +6,10 @@ export * from "./activity";
export * from "./delete-issue-modal";
export * from "./description-form";
export * from "./form";
export * from "./gantt-chart";
export * from "./main-content";
export * from "./modal";
export * from "./my-issues-list-item";
export * from "./parent-issues-list-modal";
export * from "./sidebar";
export * from "./sub-issues-list";
export * from "./attachment-upload";
export * from "./attachments";
export * from "./delete-attachment-modal";

View File

@ -76,6 +76,9 @@ const IssueDetailsPage: NextPage = () => {
...formData,
};
delete payload.blocker_issues;
delete payload.blocked_issues;
await issuesService
.patchIssue(workspaceSlug as string, projectId as string, issueId as string, payload, user)
.then(() => {