Skip to content

Commit

Permalink
feat: add autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
WitoDelnat committed Sep 7, 2023
1 parent 59e0219 commit 7a37375
Show file tree
Hide file tree
Showing 19 changed files with 405 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const ProblemRenderer: React.FC<IProps> = props => {
[selectedProblem, node.problem, groupByFilterValue]
);

const absent = useMemo(() => node.problem.baselineState === 'absent', [node]);
const hasFix = useMemo(() => node.problem.fixes && node.problem.fixes.length > 0, [node]);

const isUnderReview = useMemo(() => {
return Boolean(
typeof suppressionBindings?.isUnderReview == 'function' && suppressionBindings.isUnderReview(node.problem)
Expand All @@ -51,7 +54,7 @@ const ProblemRenderer: React.FC<IProps> = props => {
return (
<Row
$isSelected={isSelected}
$isSuppressed={suppressed}
$isSuppressed={suppressed || absent}
$isUnderReview={isUnderReview}
$secondary={groupByFilterValue === 'group-by-rule'}
onClick={onClick}
Expand Down Expand Up @@ -84,22 +87,9 @@ const ProblemRenderer: React.FC<IProps> = props => {
)}
</div>

<Tooltip
mouseEnterDelay={TOOLTIP_DELAY}
title={groupByFilterValue === 'group-by-file' ? 'File content line' : 'Resource content line'}
>
<ProblemStartLine $isSelected={isSelected}>
{
node.problem.locations[groupByFilterValue === 'group-by-file' ? 0 : 1].physicalLocation?.region
?.startLine
}
</ProblemStartLine>
</Tooltip>

<ProblemIcon level={node.problem.level ?? 'error'} style={{fontSize: '8px', marginRight: '-8px'}} />

<ProblemText $isSuppressed={suppressed}>{node.problem.message.text}</ProblemText>

<ProblemText $isSuppressed={suppressed || absent}>{node.problem.message.text}</ProblemText>
{suppressed ? '(suppressed)' : ''}
{node.problem.taxa?.length ? (
<TagsContainer>
{node.problem.taxa.map(framework => (
Expand All @@ -119,11 +109,11 @@ const ProblemRenderer: React.FC<IProps> = props => {
)}

<ActionsContainer onClick={e => e.stopPropagation()}>
{onAutofixHandler && (
<Tooltip mouseEnterDelay={TOOLTIP_DELAY} title="Autofix">
{onAutofixHandler && hasFix && !absent ? (
<Tooltip mouseEnterDelay={TOOLTIP_DELAY} title="Autofix">
<Icon name="magic-wand" onClick={() => onAutofixHandler(node.problem)} />
</Tooltip>
)}
) : null}

{showSuppressionCTA ? (
<Tooltip
Expand Down
Loading

0 comments on commit 7a37375

Please sign in to comment.