Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue parent activity, refactor: attachment, link issue activity #1629

Merged
merged 1 commit into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/app/components/core/gantt-chart-view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
49 changes: 25 additions & 24 deletions apps/app/components/issues/activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" />,
},
Expand Down Expand Up @@ -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" />,
},
Expand Down Expand Up @@ -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>.
</>
);
},
Expand Down Expand Up @@ -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.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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!",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions apps/app/components/issues/attachment/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./attachment-upload";
export * from "./attachments";
export * from "./delete-attachment-modal";
5 changes: 2 additions & 3 deletions apps/app/components/issues/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
export * from "./attachment";
export * from "./comment";
export * from "./sidebar-select";
export * from "./view-select";
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";
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down