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: 2 additions & 2 deletions frontend/src/components/card/ProblemCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import styled from 'styled-components';
import { Problem } from '../../api/Problem';
import { LargeText, SelectedItemText, Text } from '../core/Text';
import { LargeText, SelectedItemText, SingleLineText } from '../core/Text';
import { getDifficultyDisplayButton } from '../core/Button';
import { SelectedItemContainer } from '../core/Container';
import { DivLink } from '../core/Link';
Expand Down Expand Up @@ -52,7 +52,7 @@ function ProblemCard(props: ProblemCardProps) {
<InnerContent>
<TitleText>{problem.name}</TitleText>
{getDifficultyDisplayButton(problem.difficulty, true)}
<Text>{`${problem.description.substring(0, 80)}...`}</Text>
<SingleLineText>{problem.description}</SingleLineText>

{problem.problemTags.map((tag) => (
<ProblemTagContainer key={tag.name}>
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/core/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,11 @@ export const SelectedItemText = styled.p`
display: inline;
margin: 0 10px;
`;

export const SingleLineText = styled(Text)`
display: -webkit-box;
-webkit-line-clamp: 1;
overflow: hidden;
-webkit-box-orient: vertical;
word-break: break-all;
`;
9 changes: 7 additions & 2 deletions frontend/src/components/problem/editor/ProblemDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,15 @@ function ProblemDisplay(props: ProblemDisplayParams) {
<TopButtonsContainer>
<InvertedSmallButton
onClick={() => {
// eslint-disable-next-line no-alert
if (JSON.stringify(problem) === JSON.stringify(newProblem)
// eslint-disable-next-line no-alert
|| window.confirm('Go back? Your unsaved changes will be lost.')) {
history.goBack();
// Use the return link if available; otherwise, use dashboard.
if (history.action !== 'POP') {
history.goBack();
} else {
history.push('/');
}
}
}}
>
Expand Down
27 changes: 15 additions & 12 deletions frontend/src/views/ProblemPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,21 @@ function ProblemPage() {
return;
}

setLoading(true);
getSingleProblem(params.id, token!)
.then((res) => {
res.testCases.forEach((testCase) => {
// eslint-disable-next-line no-param-reassign
testCase.id = generateRandomId();
});
setProblem(res);
})
.catch((err) => setError(err.message))
.finally(() => setLoading(false));
}, [params, token]);
// Checks added to ensure problem fetched only once.
if (!problem && !loading) {
setLoading(true);
getSingleProblem(params.id, token!)
.then((res) => {
res.testCases.forEach((testCase) => {
// eslint-disable-next-line no-param-reassign
testCase.id = generateRandomId();
});
setProblem(res);
})
.catch((err) => setError(err.message))
.finally(() => setLoading(false));
}
}, [params, token, problem, loading]);

if (!problem) {
if (error && !loading) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/VerifiedProblemsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function VerifiedProblemsPage() {
return (
<Content>
<LargeText>Verified Problems</LargeText>
<TextLink to="/game/create">Create new problem &#8594;</TextLink>
<TextLink to="/problem/create">Create new problem &#8594;</TextLink>

<FilteredProblemList problems={verifiedProblems} />

Expand Down