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

feat(view): FakeIDEAdapter.ts 임의 수정 #490

Merged
merged 15 commits into from
Sep 30, 2023
Merged
File renamed without changes.
13 changes: 8 additions & 5 deletions packages/view/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "reflect-metadata";
import { container } from "tsyringe";
import { useEffect, useRef } from "react";
import BounceLoader from "react-spinners/BounceLoader";
import classNames from "classnames/bind";

import {
BranchSelector,
Expand All @@ -11,13 +12,15 @@ import {
VerticalClusterList,
FilteredAuthors,
} from "components";
import "./App.scss";
import type IDEPort from "ide/IDEPort";
import { useGlobalData } from "hooks";
import { RefreshButton } from "components/RefreshButton";
import type { IDESentEvents } from "types/IDESentEvents";

import styles from "./App.module.scss";

const App = () => {
const cx = classNames.bind(styles);
const initRef = useRef<boolean>(false);

const { filteredData, handleChangeAnalyzedData, handleChangeBranchList, loading, setLoading } = useGlobalData();
Expand Down Expand Up @@ -56,18 +59,18 @@ const App = () => {

return (
<>
<div className="header-container">
<div className={cx("header-container")}>
<BranchSelector />
<div className="header-buttons">
<div className={cx("header-buttons")}>
<ThemeSelector />
<RefreshButton />
</div>
</div>
<div className="top-container">
<div className={cx("top-container")}>
<TemporalFilter />
<FilteredAuthors />
</div>
<div className="middle-container">
<div className={cx("middle-container")}>
{filteredData.length !== 0 ? (
<>
<VerticalClusterList />
Expand Down
8 changes: 6 additions & 2 deletions packages/view/src/components/@common/Author/Author.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import classNames from "classnames/bind";

import type { AuthorInfo } from "types";
import "./Author.scss";

import styles from "./Author.module.scss";

const Author = ({ name, src }: AuthorInfo) => {
const cx = classNames.bind(styles);
return (
<div
className="author"
className={cx("author")}
data-tooltip-text={name}
>
<img
Expand Down
10 changes: 6 additions & 4 deletions packages/view/src/components/BranchSelector/BranchSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import { type ChangeEventHandler } from "react";
import "./BranchSelector.scss";
import classNames from "classnames/bind";

import { useGlobalData } from "hooks";
import { sendFetchAnalyzedDataCommand } from "services";

import styles from "./BranchSelector.module.scss";

const BranchSelector = () => {
const { branchList, selectedBranch, setSelectedBranch, setLoading } = useGlobalData();

const cx = classNames.bind(styles);
const handleChangeSelect: ChangeEventHandler<HTMLSelectElement> = (e) => {
setSelectedBranch(e.target.value);
setLoading(true);
sendFetchAnalyzedDataCommand(e.target.value);
};

return (
<section className="branch-selector">
<section className={cx("branch-selector")}>
<span>Branches:</span>
<select
className="select-box"
className={cx("select-box")}
onChange={handleChangeSelect}
value={selectedBranch}
>
Expand Down
38 changes: 20 additions & 18 deletions packages/view/src/components/Detail/Detail.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dayjs from "dayjs";
import classNames from "classnames/bind";

import AuthorIcon from "assets/author.svg";
import ChangedFileIcon from "assets/changed-file.svg";
Expand All @@ -11,10 +12,10 @@ import { useCommitListHide } from "./Detail.hook";
import { getCommitListDetail } from "./Detail.util";
import { FIRST_SHOW_NUM } from "./Detail.const";
import type { DetailProps, DetailSummaryProps, DetailSummaryItem } from "./Detail.type";

import "./Detail.scss";
import styles from "./Detail.module.scss";

const DetailSummary = ({ commitNodeListInCluster }: DetailSummaryProps) => {
const cx = classNames.bind(styles);
const { authorLength, fileLength, commitLength, insertions, deletions } = getCommitListDetail({
commitNodeListInCluster,
});
Expand All @@ -28,24 +29,25 @@ const DetailSummary = ({ commitNodeListInCluster }: DetailSummaryProps) => {
];

return (
<div className="detail__summary__container">
<div className="divider" />
<div className="detail__summary">
<div className={cx("detail__summary__container")}>
<div className={cx("divider")} />
<div className={cx("detail__summary")}>
{summaryItems.map(({ name, count, icon }) => (
<span
key={name}
className="detail__summary__item"
className={cx("detail__summary__item")}
>
{icon}
<strong className={name}>{count.toLocaleString("en")} </strong>
<span className="detail__summary__item__name">{count <= 1 ? name.slice(0, -1) : name}</span>
<strong className={cx({ name })}>{count.toLocaleString("en")} </strong>
<span className={cx("detail__summary__item__name")}>{count <= 1 ? name.slice(0, -1) : name}</span>
</span>
))}
</div>
</div>
);
};
const Detail = ({ selectedData, clusterId, authSrcMap }: DetailProps) => {
const cx = classNames.bind(styles);
const commitNodeListInCluster =
selectedData?.filter((selected) => selected.commitNodeList[0].clusterId === clusterId)[0].commitNodeList ?? [];
const { commitNodeList, toggle, handleToggle } = useCommitListHide(commitNodeListInCluster);
Expand All @@ -59,39 +61,39 @@ const Detail = ({ selectedData, clusterId, authSrcMap }: DetailProps) => {
return (
<>
<DetailSummary commitNodeListInCluster={commitNodeListInCluster} />
<ul className="detail__commit-list__container">
<ul className={cx("detail__commit-list__container")}>
{commitNodeList.map(({ commit }) => {
const { id, message, author, commitDate } = commit;
return (
<li
key={id}
className="commit-item"
className={cx("commit-item")}
>
<div className="commit-detail">
<div className="avatar-message">
<div className={cx("commit-detail")}>
<div className={cx("avatar-message")}>
{authSrcMap && (
<Author
name={author.names.toString()}
src={authSrcMap[author.names.toString()]}
/>
)}
<div className="message-container">
<span className="message">{message}</span>
<div className={cx("message-container")}>
<span className={cx("message")}>{message}</span>
</div>
</div>
<span className="author-date">
<span className={cx("author-date")}>
{author.names[0]}, {dayjs(commitDate).format("YY. M. DD. a h:mm")}
</span>
</div>
<div className="commit-id">
<div className={cx("commit-id")}>
<span
onClick={handleCommitIdCopy(id)}
role="button"
tabIndex={0}
onKeyDown={handleCommitIdCopy(id)}
>
{id.slice(0, 6)}
<span className="commit-id__tooltip">{id}</span>
<span className={cx("commit-id__tooltip")}>{id}</span>
</span>
</div>
</li>
Expand All @@ -101,7 +103,7 @@ const Detail = ({ selectedData, clusterId, authSrcMap }: DetailProps) => {
{isShow && (
<button
type="button"
className="toggle-button"
className={cx("toggle-button")}
onClick={handleToggle}
>
{toggle ? "Hide ..." : "Read More ..."}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import classNames from "classnames/bind";

import { Author } from "components/@common/Author";
import { usePreLoadAuthorImg } from "components/VerticalClusterList/Summary/Summary.hook";
import { getInitData } from "components/VerticalClusterList/Summary/Summary.util";
import { useGlobalData } from "hooks";

import "./FilteredAuthors.scss";
import styles from "./FilteredAuthors.module.scss";

const FilteredAuthors = () => {
const cx = classNames.bind(styles);
const { selectedData } = useGlobalData();
const authSrcMap = usePreLoadAuthorImg();
const selectedClusters = getInitData(selectedData);

return (
<div className="selected-container">
<div className={cx("selected-container")}>
{authSrcMap &&
selectedClusters.map((selectedCluster) => {
return selectedCluster.summary.authorNames.map((authorArray: string[]) => {
Expand Down
10 changes: 6 additions & 4 deletions packages/view/src/components/RefreshButton/RefreshButton.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import "reflect-metadata";
import cn from "classnames";
import { FiRefreshCcw } from "react-icons/fi";
import classNames from "classnames/bind";

import { throttle } from "utils";
import { useGlobalData } from "hooks";

import "./RefreshButton.scss";
import { sendRefreshDataCommand } from "services";

import styles from "./RefreshButton.module.scss";

const RefreshButton = () => {
const cx = classNames.bind(styles);
const { loading, setLoading, selectedBranch } = useGlobalData();

const refreshHandler = throttle(() => {
Expand All @@ -19,11 +21,11 @@ const RefreshButton = () => {
return (
<button
type="button"
className={cn("refresh-button")}
className={cn(cx("refresh-button"))}
onClick={refreshHandler}
>
<FiRefreshCcw
className={cn("refresh-button-icon", { "refresh-button-icon--loading": loading })}
className={cn(cx("refresh-button-icon"), { "refresh-button-icon--loading": loading })}
stroke="white"
/>
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ChangeEvent, MouseEvent } from "react";
import { useRef, useEffect, useState } from "react";
import * as d3 from "d3";
import classNames from "classnames/bind";

import type { ClusterNode, AuthorInfo } from "types";
import { useGlobalData } from "hooks";
Expand All @@ -11,10 +12,10 @@ import { useGetSelectedData } from "../Statistics.hook";
import type { AuthorDataType, MetricType } from "./AuthorBarChart.type";
import { convertNumberFormat, getDataByAuthor, sortDataByAuthor, sortDataByName } from "./AuthorBarChart.util";
import { DIMENSIONS, METRIC_TYPE } from "./AuthorBarChart.const";

import "./AuthorBarChart.scss";
import styles from "./AuthorBarChart.module.scss";

const AuthorBarChart = () => {
const cx = classNames.bind(styles);
const { data: totalData, filteredData, setSelectedData, setFilteredData } = useGlobalData();
const rawData = useGetSelectedData();

Expand Down Expand Up @@ -45,10 +46,10 @@ const AuthorBarChart = () => {

const xAxisGroup = svg
.append("g")
.attr("class", "axis x-axis")
.attr("class", cx("axis x-axis"))
.style("transform", `translateY(${DIMENSIONS.height}px)`);
const yAxisGroup = svg.append("g").attr("class", "axis y-axis");
const barGroup = svg.append("g").attr("class", "bars");
const yAxisGroup = svg.append("g").attr("class", cx("axis y-axis"));
const barGroup = svg.append("g").attr("class", cx("bars"));

// Scales
const xScale = d3
Expand All @@ -73,7 +74,7 @@ const AuthorBarChart = () => {

xAxisGroup
.append("text")
.attr("class", "x-axis-label")
.attr("class", cx("x-axis-label"))
.style("transform", `translate(${DIMENSIONS.width / 2}px, ${DIMENSIONS.margins - 10}px)`)
.text(`${metric} # / Total ${metric} # (%)`);

Expand All @@ -86,9 +87,9 @@ const AuthorBarChart = () => {
.style("left", `${e.pageX - 70}px`)
.style("top", `${e.pageY - 70}px`)
.html(
`<p class="name">${d.name}</p>
`<p class=cx("name")>${d.name}</p>
<p>${metric}:
<span class="selected">
<span class=cx("selected")>
${d[metric].toLocaleString()}
</span>
/ ${totalMetricValues.toLocaleString()}
Expand Down Expand Up @@ -122,7 +123,7 @@ const AuthorBarChart = () => {
(enter) =>
enter
.append("g")
.attr("class", "bar")
.attr("class", cx("bar"))
.append("rect")
.attr("width", xScale.bandwidth())
.attr("height", 0)
Expand Down Expand Up @@ -151,24 +152,24 @@ const AuthorBarChart = () => {
const profileImgSrc: string = await getAuthorProfileImgSrc(data[i].name).then((res: AuthorInfo) => res.src);
bar
.append("image")
.attr("class", "profile-image")
.attr("class", cx("profile-image"))
.attr("xlink:href", profileImgSrc ?? "")
.attr("x", (d: AuthorDataType) => (xScale(d.name) ?? 0) + xScale.bandwidth() / 2 - 7)
.attr("y", 204)
.attr("width", 14)
.attr("height", 14);
});
}, [data, filteredData, metric, prevData, rawData, setFilteredData, setSelectedData, totalData]);
}, [data, filteredData, metric, prevData, rawData, setFilteredData, setSelectedData, totalData, cx]);

const handleChangeMetric = (e: ChangeEvent<HTMLSelectElement>): void => {
setMetric(e.target.value as MetricType);
};

return (
<div className="author-bar-chart__container">
<div className="author-bar-chart__header">
<div className={cx("author-bar-chart__container")}>
<div className={cx("author-bar-chart__header")}>
<select
className="select-box"
className={cx("select-box")}
onChange={handleChangeMetric}
>
{METRIC_TYPE.map((option) => (
Expand All @@ -182,11 +183,11 @@ const AuthorBarChart = () => {
</select>
</div>
<svg
className="author-bar-chart"
className={cx("author-bar-chart")}
ref={svgRef}
/>
<div
className="author-bar-chart__tooltip"
className={cx("author-bar-chart__tooltip")}
ref={tooltipRef}
/>
</div>
Expand Down
Loading