Only render log status info when it's available

[MAILPOET-5436]
This commit is contained in:
 Ján Mikláš
2024-07-01 09:33:37 +02:00
committed by Aschepikov
parent b725f7af17
commit 61f992a823
2 changed files with 20 additions and 10 deletions

View File

@ -79,6 +79,9 @@
} }
.mailpoet-analytics-activity-modal-status-info { .mailpoet-analytics-activity-modal-status-info {
margin-top: 8px;
max-width: 220px; max-width: 220px;
&:not(:empty) {
margin-top: 8px;
}
} }

View File

@ -28,6 +28,15 @@ export const headers = [
}, },
]; ];
function StatusInfo({ info }: { info: string | null }): JSX.Element {
if (!info) {
return null;
}
return (
<div className="mailpoet-analytics-activity-modal-status-info">{info}</div>
);
}
export function transformLogsToRows( export function transformLogsToRows(
logs: Log[], logs: Log[],
steps: Steps, steps: Steps,
@ -59,15 +68,18 @@ export function transformLogsToRows(
display: ( display: (
<> <>
<AutomationRunStatus status={log.status} /> <AutomationRunStatus status={log.status} />
<div className="mailpoet-analytics-activity-modal-status-info"> <StatusInfo info={log.error && log.error.message} />
{log.error && log.error.message}
</div>
</> </>
), ),
}, },
]) ])
: []; : [];
if (nextStep) { if (nextStep) {
// translators: "Time left: 1 hour" or "Time left: 1 minute", uses WordPress' human_time_diff() to get the value
const timeLeft = sprintf(
__('Time left: %s', 'mailpoet'),
nextStep.time_left,
);
items.push([ items.push([
{ {
display: <StepCell name={nextStep.name} data={nextStep.step} />, display: <StepCell name={nextStep.name} data={nextStep.step} />,
@ -85,12 +97,7 @@ export function transformLogsToRows(
display: ( display: (
<> <>
<AutomationRunStatus status="running" /> <AutomationRunStatus status="running" />
<div className="mailpoet-analytics-activity-modal-status-info"> <StatusInfo info={timeLeft} />
{
// translators: "Time left: 1 hour" or "Time left: 1 minute", uses WordPress' human_time_diff() to get the value
sprintf(__('Time left: %s', 'mailpoet'), nextStep.time_left)
}
</div>
</> </>
), ),
}, },