Skip to content
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
4 changes: 3 additions & 1 deletion electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { autoUpdater } from "electron-updater";
import { release } from "os";
import { join } from "path";

import { version } from "../../package.json";

// Disable GPU Acceleration for Windows 7
if (release().startsWith("6.1")) app.disableHardwareAcceleration();

Expand Down Expand Up @@ -39,7 +41,7 @@ const indexHtml = join(ROOT_PATH.dist, "index.html");

async function createWindow() {
win = new BrowserWindow({
title: "RunTC",
title: "RunTC - " + version,
icon: join(ROOT_PATH.public, "favicon.svg"),
autoHideMenuBar: true,
webPreferences: {
Expand Down
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<link rel="icon" type="image/svg+xml" href="/src/assets/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
<title>RunTC</title>
</head>
<body>
<div id="root"></div>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@vitejs/plugin-react": "^2.0.1",
"allotment": "^1.17.0",
"await-to-js": "^3.0.0",
"compare-versions": "^5.0.1",
"electron": "^20.0.2",
"electron-builder": "^23.3.3",
"electron-log": "^4.4.8",
Expand Down
5 changes: 4 additions & 1 deletion src/components/sidePanel/testcaseList/SelectTestcaseItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ const StyledItem = styled.div<{ selected: boolean }>`
grid-template-columns: 10px minmax(16px, 1fr) max-content;
align-items: center;

height: 40px;
line-height: 40px;

cursor: pointer;
border-radius: 6px;
margin: 0 10px;
padding: 10px 15px;
padding: 0 15px;

${(props) =>
props.selected &&
Expand Down
2 changes: 2 additions & 0 deletions src/components/testcase/TerminalOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const TerminalOutput: FC<OutputProps> = ({ content }) => {

const term = new Terminal({
fontFamily: "consolas",
convertEol: true,
disableStdin: true,
});
const fitAddon = new FitAddon();

Expand Down
108 changes: 97 additions & 11 deletions src/components/testcase/TestcaseInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { Button, Editable, EditableInput, EditablePreview } from "@chakra-ui/react";
import { Button, Editable, EditableInput, EditablePreview, useEditableControls } from "@chakra-ui/react";
import { css } from "@emotion/react";
import styled from "@emotion/styled";
import { FC } from "react";
import { FC, ReactNode } from "react";
import { MdDelete, MdEdit, MdPlayArrow } from "react-icons/md";
import { useRecoilValue } from "recoil";

import useTestcaseCommand from "@/commands/useTestcaseCommand";
import useTestcaseRunner from "@/commands/useTestcaseRunner";
import { testcaseFamily } from "@/states/testcase";
import { TestcaseResult, testcaseResultFamily } from "@/states/testcaseResult";

import { getResultColor, getResultDescription } from "../common/renderResultUtil";

interface TestcaseInfoProps {
testcaseId: string;
Expand All @@ -15,29 +20,110 @@ const TestcaseInfo: FC<TestcaseInfoProps> = ({ testcaseId }) => {
const command = useTestcaseCommand();
const runner = useTestcaseRunner();
const testcase = useRecoilValue(testcaseFamily(testcaseId));
const result = useRecoilValue(testcaseResultFamily(testcaseId));

return (
<StyledTestcaseInfo>
<Name value={testcase.name} onChange={(name) => command.changeValue(testcaseId, { name })} fontSize={20}>
<EditablePreview />
<EditableInput />
</Name>
<Button onClick={() => runner.run(testcaseId)}>Run</Button>
<Button onClick={() => command.remove(testcaseId)}>삭제</Button>
<NameBox>
<Name
value={testcase.name}
placeholder="이름 없음"
onChange={(name) => command.changeValue(testcaseId, { name })}
fontSize={20}>
<WithEditButton>
<EditablePreview
overflow="hidden"
textOverflow="ellipsis"
whiteSpace="nowrap"
display="block"
justifySelf="normal"
/>
</WithEditButton>
<EditableInput />
</Name>
</NameBox>
<ActionBox>
<ActionBoxLeft>
<Button
onClick={() => runner.run(testcaseId)}
variant="outline"
size="sm"
leftIcon={<MdPlayArrow />}
colorScheme="teal"
isLoading={result === "running"}>
실행
</Button>
<Result status={result}>{getResultDescription(result)}</Result>
</ActionBoxLeft>
<Spacer />
<Button
onClick={() => command.remove(testcaseId)}
variant="outline"
size="sm"
leftIcon={<MdDelete />}
colorScheme="red">
삭제
</Button>
</ActionBox>
</StyledTestcaseInfo>
);
};

export default TestcaseInfo;

const StyledTestcaseInfo = styled.div`
const StyledTestcaseInfo = styled.div``;

const NameBox = styled.div`
margin-top: 10px;
height: 40px;
`;

const ActionBox = styled.div`
display: flex;
height: 3.5rem;
margin: 0 8px;
`;

const Name = styled(Editable)`
const ActionBoxLeft = styled.div`
display: flex;
align-items: center;
`;

const Result = styled.div<{ status: TestcaseResult }>`
margin-left: 0.8rem;
font-size: 0.85rem;

${(props) => css`
color: ${getResultColor(props.status)};
`}
`;

const Spacer = styled.div`
flex-grow: 1;
`;

const Name = styled(Editable)`
font-weight: 500;
align-self: center;
margin: 0 10px;
`;

const WithEditButton = ({ children }: { children: ReactNode }) => {
const { isEditing, getEditButtonProps } = useEditableControls();

return isEditing ? (
<></>
) : (
<StyledWithEditButton>
{children}
<Button size="sm" variant="link" {...getEditButtonProps()}>
<MdEdit />
</Button>
</StyledWithEditButton>
);
};

const StyledWithEditButton = styled.div`
display: grid;
grid-template-columns: max-content 20px 1fr;
align-items: center;
`;
4 changes: 3 additions & 1 deletion src/states/executableTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const executableTargetFilenameSelector = selector<string | null>({
return null;
}

return path.split("\\").at(-1) ?? null;
const matches = path.match(/.+[\\/\\]([^\\/\\]+)/);

return matches?.[1] ?? null;
},
});
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"noEmit": true,
"jsx": "react-jsx"
},

"include": ["src"],
"exclude": ["src/**/*.test.ts"],
"references": [{ "path": "./tsconfig.node.json" }],
Expand Down