Skip to content

Commit

Permalink
enhance(view): add Commit Type Message Property closed [#70]
Browse files Browse the repository at this point in the history
enhance(view): CommitNode Type add taskId Property

feat(view): Detail Component
  • Loading branch information
jin-Pro committed Sep 3, 2022
1 parent ac57011 commit e7f5bec
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
30 changes: 28 additions & 2 deletions packages/view/src/components/Detail/Detail.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
/* eslint-disable react/no-array-index-key */
import type { GlobalProps } from "types/global";

import { getTargetCommit, getTime } from "./Detail.util";

const TARGET_ID = "2a7a93cde9c9f74d5f05c1d0fb1da8e96da7057b";

const Detail = ({ data }: GlobalProps) => {
console.log(data);
return <>Detail</>;
const commit = getTargetCommit({ data, id: TARGET_ID });
if (!commit) return null;
const { authorDate, message, committer } = commit;
const time = getTime(authorDate);
return (
<>
<div>작성 날짜</div>
<p>{time}</p>

<div>메세지</div>
<p>{message}</p>

<div>Committer Name</div>
{committer.names.map((name: string, i: number) => (
<p key={i}>{name}</p>
))}

<div>Committer Email</div>
{committer.emails.map((email: string, i: number) => (
<p key={i}>{email}</p>
))}
</>
);
};

export default Detail;
34 changes: 34 additions & 0 deletions packages/view/src/components/Detail/Detail.util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { GlobalProps } from "types/global";

import type { CommitNode } from "types/NodeTypes.temp";

type GetTargetCommit = GlobalProps & { id: string };

export const getTargetCommit = ({ data, id }: GetTargetCommit) => {
if (data?.length === 0) return undefined;
const flatCommitNode: CommitNode[] = data
.map((clusterNode) => clusterNode.commitNodeList)
.flat();
const [target] = flatCommitNode.filter(
(commitNode) => commitNode.commit.id === id
);

// parent Commit 추출하기
// const parentCommitId = target.commit.parentIds;
// console.log(parentCommitId);
// const parentCommits = parentCommitId.map((parentId) =>
// flatCommitNode.filter(commitNode => commitNode.commit.id === parentId)
// );
// console.log(parentCommits);

// 동일한 Cluster Commit 추출하기
// const { taskId: ClusterId } = target;
// const clusterCommits = flatCommitNode.filter(
// (commitNode) => commitNode.taskId === ClusterId
// );
// console.log(clusterCommits);
return target?.commit;
};

export const getTime = (date: Date) =>
String(date).split(".")[0].replace("T", " ");
4 changes: 2 additions & 2 deletions packages/view/src/types/NodeTypes.temp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type Commit = {
authorDate: Date;
commitDate: Date;
diffStatistics: DiffStatistics;

message: string;
// fill necessary properties...
};

Expand All @@ -63,7 +63,7 @@ export type CommitNode = NodeBase & {
nodeTypeName: "COMMIT";
commit: Commit;
seq: number;

taskId: number; // 동일한 Cluster 내부 commit 참조 id
hasMajorTag: boolean;
hasMinorTag: boolean;
isMergeCommit: boolean;
Expand Down

0 comments on commit e7f5bec

Please sign in to comment.