Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ThreatDataView list view fixer status #39854

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
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ export default function FixerStatusIcon( {
}

if ( fixer && 'status' in fixer && fixer.status === 'in_progress' ) {
return <Spinner color="black" />;
return (
<div className={ styles[ 'icon-spinner' ] }>
<Spinner color="black" />
</div>
);
}

return <Icon icon={ check } className={ styles[ 'icon-check' ] } size={ 28 } />;
Expand All @@ -87,20 +91,28 @@ export default function FixerStatusIcon( {
* @param {boolean} props.fixer - The fixer status.
* @return {string} The component.
*/
function FixerStatusText( { fixer }: { fixer?: ThreatFixStatus } ): string {
function FixerStatusText( { fixer }: { fixer?: ThreatFixStatus } ): JSX.Element {
if ( fixer && fixerStatusIsStale( fixer ) ) {
return __( 'Fixer is taking longer than expected', 'jetpack' );
return (
<span className={ styles[ 'info-spacer' ] }>
{ __( 'Fixer is taking longer than expected', 'jetpack' ) }
</span>
);
}

if ( fixer && 'error' in fixer && fixer.error ) {
return __( 'Error auto-fixing threat', 'jetpack' );
return (
<span className={ styles[ 'info-spacer' ] }>
{ __( 'An error occurred auto-fixing this threat', 'jetpack' ) }
</span>
);
}

if ( fixer && 'status' in fixer && fixer.status === 'in_progress' ) {
return __( 'Auto-fix in progress', 'jetpack' );
return <span className={ styles[ 'spinner-spacer' ] }>{ __( 'Auto-fixing', 'jetpack' ) }</span>;
}

return __( 'Auto-fixable', 'jetpack' );
return <span className={ styles[ 'check-spacer' ] }>{ __( 'Auto-fixable', 'jetpack' ) }</span>;
}

/**
Expand All @@ -111,15 +123,15 @@ function FixerStatusText( { fixer }: { fixer?: ThreatFixStatus } ): string {
*/
export function FixerStatusBadge( { fixer }: { fixer?: ThreatFixStatus } ): JSX.Element {
return (
<div className={ styles[ 'fixer-status-badge' ] }>
<FixerStatusIcon fixer={ fixer } size={ 12 } />
<div className={ styles[ 'fixer-status' ] }>
<FixerStatusIcon fixer={ fixer } />
<FixerStatusText fixer={ fixer } />
</div>
);
}

/**
* FixerStatusText component.
* DataViewFixerStatus component.
* @param {object} props - Component props.
* @param {boolean} props.fixer - The fixer status.
* @param {object} props.view - The view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
min-height: 0;
}

.dataviews-view-table td, .dataviews-view-table th {
white-space: initial;
}
.dataviews-view-table td, .dataviews-view-table th {
white-space: initial;
}

.dataviews-view-table td .components-flex {
gap: 4px;
Expand Down Expand Up @@ -51,26 +51,21 @@
}
}

.fixer-status-badge {
border-radius: 32px;
flex-shrink: 0;
font-size: 12px;
font-style: normal;
font-weight: 600;
line-height: 16px;
padding: calc( var( --spacing-base ) / 2 ); // 4px
padding-right: calc( var( --spacing-base ) * 1.75 ); // 14px
position: relative;
text-align: center;
background: var( --jp-green-0 );
color: var( --jp-green-50 );
.fixer-status {
display: flex;
align-items: center;

> svg {
height: 20px;
margin-top: -2px;
margin-bottom: -2px;
line-height: 0;

.icon-spinner {
margin-left: 1px;
}

.icon-info {
margin-left: -3px;
}

.icon-check {
margin-left: -6px;
}
}

Expand Down Expand Up @@ -103,7 +98,25 @@
font-size: 12px;
}

.icon-spinner {
svg {
margin: 0;
}
}

.spinner-spacer {
margin-left: 8px;
}

.info-spacer {
margin-left: 4px;
}

.check-spacer {
margin-left: -2px;
}

.threat__fixer {
min-width: 48px;
min-width: 54px;
text-align: center;
}
Loading