Skip to content

Commit a96b0f1

Browse files
authored
Replace OkPy command with problem name and copy button in Timeline (#110)
1 parent e4d1d7a commit a96b0f1

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

  • src/snapshots-app/client/bundles/components/submission/tabs/timeline

src/snapshots-app/client/bundles/components/submission/tabs/timeline/Timeline.jsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import DoneIcon from "@mui/icons-material/Done";
88
import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
99
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
1010
import ArrowForwardIcon from "@mui/icons-material/ArrowForward";
11+
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
1112
import { Tooltip } from "@mui/material";
1213
import InfoTooltip from "../../../common/InfoTooltip";
1314
import Snackbar from "@mui/material/Snackbar";
@@ -128,6 +129,19 @@ function TimelineButtonGroup({
128129
backups[0].question_cli_names,
129130
backups[0].unlock,
130131
);
132+
133+
const problemNames = useMemo(() => {
134+
const questionCliNames = backups[0].question_cli_names;
135+
const joined = questionCliNames.join(", ");
136+
const unlockSuffix = backups[0].unlock ? " (Unlocking)" : "";
137+
138+
if (questionCliNames.length <= 1) {
139+
return "Problem " + joined + unlockSuffix;
140+
} else {
141+
return "Problems " + joined + unlockSuffix;
142+
}
143+
}, [backups]);
144+
131145
const onClickCommand = () => {
132146
copyOkpyCommand(okpyCommand);
133147
setIsSnackbarOpen(true);
@@ -137,15 +151,17 @@ function TimelineButtonGroup({
137151
<div>
138152
<div
139153
style={{
140-
whiteSpace: "pre-wrap",
141-
fontFamily: "Menlo",
142-
fontSize: "0.8rem",
143-
cursor: "pointer",
154+
display: "flex",
155+
alignItems: "center",
144156
marginBottom: "0.5rem",
145157
}}
146-
onClick={onClickCommand}
147158
>
148-
{okpyCommand}
159+
<Tooltip title="Copy OkPy command" placement="top">
160+
<IconButton aria-label="copy" onClick={onClickCommand} size="small">
161+
<ContentCopyIcon />
162+
</IconButton>
163+
</Tooltip>
164+
<div>{problemNames}</div>
149165
</div>
150166

151167
<ButtonGroup

0 commit comments

Comments
 (0)