Skip to content

Commit

Permalink
feat(submission): show linter output
Browse files Browse the repository at this point in the history
  • Loading branch information
angristan committed Jul 27, 2021
1 parent 074c7bf commit 665535c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/api/dto/lint-error.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface LintErrorDTO {
message: string;

line: number | null;

column: number | null;

offset: number | null;
}
1 change: 1 addition & 0 deletions src/components/Benchmarks/BenchmarkDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const BenchmarkDetail = ({
qualityScore={jobData.qualityScore}
cyclomaticComplexity={jobData.cyclomaticComplexity}
lintScore={jobData.lintScore}
lintErrors={jobData.lintErrors}
isLoading={isProcessing}
/>
);
Expand Down
35 changes: 35 additions & 0 deletions src/components/Benchmarks/Result.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import Loader from 'react-loader-spinner';
import { LintErrorDTO } from '../../api/dto/lint-error.dto';
interface LayoutProps {
status: string;
message: string;
Expand All @@ -11,6 +12,7 @@ interface LayoutProps {
qualityScore?: number;
cyclomaticComplexity?: number;
lintScore?: number;
lintErrors?: LintErrorDTO[];
isLoading: boolean;
}

Expand All @@ -24,6 +26,7 @@ const Result: React.FC<LayoutProps> = ({
memUsage,
qualityScore,
lintScore,
lintErrors,
isLoading,
cyclomaticComplexity,
}) => {
Expand Down Expand Up @@ -58,6 +61,11 @@ const Result: React.FC<LayoutProps> = ({
value={stdout}
isLoading={isLoading}
/>
<LinterOutput
text={'Linter output'}
lintErrors={lintErrors}
isLoading={isLoading}
/>
<OutputsComponent
text={'Error'}
value={error}
Expand Down Expand Up @@ -97,6 +105,33 @@ const OutputsComponent: React.FC<OutputsComponentProps> = ({ text, value }) => {
}
};

interface LinterOutputProps {
text?: string;
lintErrors?: LintErrorDTO[];
isLoading: boolean;
}

const LinterOutput: React.FC<LinterOutputProps> = ({ text, lintErrors }) => {
if (lintErrors) {
return (
<div className="mt-4">
<b className="dark:text-gray-100">{text}:</b>
<div
className={'h-auto p-4 mt-2 w-full bg-gray-800 rounded-lg text-white'}
>
{lintErrors.map((error, i) => (
<p>
{error.column}:{error.line}: {error.message}
</p>
))}
</div>
</div>
);
} else {
return <div />;
}
};

interface ScoresComponentProps {
status: string | undefined;
qualityScore: number | undefined;
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/submissions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState } from 'react';
import { useMutation, useQuery } from 'react-query';
import { LintErrorDTO } from '../api/dto/lint-error.dto';
import authenticatedRequest from '../components/utils/request';
import { useToken } from './token';

Expand Down Expand Up @@ -67,6 +68,7 @@ function useProcessInterval({
qualityScore: number;
cyclomaticComplexity: number;
lintScore: number;
lintErrors?: LintErrorDTO[];
};
} = await authenticatedRequest({
url: `submissions/${processId}`,
Expand Down

0 comments on commit 665535c

Please sign in to comment.