Skip to content

Commit 6becd86

Browse files
edmunditojbfbell
authored andcommitted
Simplify messaging for sync canceled jobs (#20999)
* Hide stats * Show cancelled icon when it's multiple attempts * Update attempts count to gray * Extract shared attempt functions into utils file * Cleanup component export and scss imports * Fix height glitch when opening and closing log
1 parent ad140b5 commit 6becd86

File tree

9 files changed

+64
-53
lines changed

9 files changed

+64
-53
lines changed

airbyte-webapp/src/components/JobItem/JobItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { AttemptRead, JobStatus, SynchronousJobRead } from "../../core/request/A
99
import { useAttemptLink } from "./attemptLinkUtils";
1010
import ContentWrapper from "./components/ContentWrapper";
1111
import ErrorDetails from "./components/ErrorDetails";
12-
import JobLogs from "./components/JobLogs";
12+
import { JobLogs } from "./components/JobLogs";
1313
import MainInfo from "./components/MainInfo";
1414
import styles from "./JobItem.module.scss";
1515

airbyte-webapp/src/components/JobItem/components/AttemptDetails.module.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@use "../../../scss/colors";
2-
@use "../../../scss/variables";
1+
@use "scss/colors";
2+
@use "scss/variables";
33

44
.container {
55
font-size: 12px;

airbyte-webapp/src/components/JobItem/components/AttemptDetails.tsx

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import dayjs from "dayjs";
33
import React from "react";
44
import { FormattedMessage, useIntl } from "react-intl";
55

6+
import { AttemptRead, AttemptStatus } from "core/request/AirbyteClient";
67
import { formatBytes } from "utils/numberHelper";
78

8-
import { AttemptRead, AttemptStatus } from "../../../core/request/AirbyteClient";
9+
import { getFailureFromAttempt, isCancelledAttempt } from "../utils";
910
import styles from "./AttemptDetails.module.scss";
1011

1112
interface AttemptDetailsProps {
@@ -14,11 +15,7 @@ interface AttemptDetailsProps {
1415
hasMultipleAttempts?: boolean;
1516
}
1617

17-
const getFailureFromAttempt = (attempt: AttemptRead) => {
18-
return attempt.failureSummary && attempt.failureSummary.failures[0];
19-
};
20-
21-
const AttemptDetails: React.FC<AttemptDetailsProps> = ({ attempt, className, hasMultipleAttempts }) => {
18+
export const AttemptDetails: React.FC<AttemptDetailsProps> = ({ attempt, className, hasMultipleAttempts }) => {
2219
const { formatMessage } = useIntl();
2320

2421
if (attempt.status !== AttemptStatus.succeeded && attempt.status !== AttemptStatus.failed) {
@@ -48,35 +45,38 @@ const AttemptDetails: React.FC<AttemptDetailsProps> = ({ attempt, className, has
4845
const hours = Math.abs(date2.diff(date1, "hour"));
4946
const minutes = Math.abs(date2.diff(date1, "minute")) - hours * 60;
5047
const seconds = Math.abs(date2.diff(date1, "second")) - minutes * 60 - hours * 3600;
51-
const isFailed = attempt.status === AttemptStatus.failed;
48+
const isCancelled = isCancelledAttempt(attempt);
49+
const isFailed = attempt.status === AttemptStatus.failed && !isCancelled;
5250

5351
return (
5452
<div className={classNames(styles.container, className)}>
55-
<div className={styles.details}>
56-
{hasMultipleAttempts && (
57-
<strong className={classNames(styles.lastAttempt, { [styles.failed]: isFailed })}>
58-
<FormattedMessage id="sources.lastAttempt" />
59-
</strong>
60-
)}
61-
<span>{formatBytes(attempt?.totalStats?.bytesEmitted)}</span>
62-
<span>
63-
<FormattedMessage
64-
id="sources.countEmittedRecords"
65-
values={{ count: attempt.totalStats?.recordsEmitted || 0 }}
66-
/>
67-
</span>
68-
<span>
69-
<FormattedMessage
70-
id="sources.countCommittedRecords"
71-
values={{ count: attempt.totalStats?.recordsCommitted || 0 }}
72-
/>
73-
</span>
74-
<span>
75-
{hours ? <FormattedMessage id="sources.hour" values={{ hour: hours }} /> : null}
76-
{hours || minutes ? <FormattedMessage id="sources.minute" values={{ minute: minutes }} /> : null}
77-
<FormattedMessage id="sources.second" values={{ second: seconds }} />
78-
</span>
79-
</div>
53+
{!isCancelled && (
54+
<div className={styles.details}>
55+
{hasMultipleAttempts && (
56+
<strong className={classNames(styles.lastAttempt, { [styles.failed]: isFailed })}>
57+
<FormattedMessage id="sources.lastAttempt" />
58+
</strong>
59+
)}
60+
<span>{formatBytes(attempt?.totalStats?.bytesEmitted)}</span>
61+
<span>
62+
<FormattedMessage
63+
id="sources.countEmittedRecords"
64+
values={{ count: attempt.totalStats?.recordsEmitted || 0 }}
65+
/>
66+
</span>
67+
<span>
68+
<FormattedMessage
69+
id="sources.countCommittedRecords"
70+
values={{ count: attempt.totalStats?.recordsCommitted || 0 }}
71+
/>
72+
</span>
73+
<span>
74+
{hours ? <FormattedMessage id="sources.hour" values={{ hour: hours }} /> : null}
75+
{hours || minutes ? <FormattedMessage id="sources.minute" values={{ minute: minutes }} /> : null}
76+
<FormattedMessage id="sources.second" values={{ second: seconds }} />
77+
</span>
78+
</div>
79+
)}
8080
{isFailed && (
8181
<div className={styles.failedMessage}>
8282
{formatMessage(
@@ -93,5 +93,3 @@ const AttemptDetails: React.FC<AttemptDetailsProps> = ({ attempt, className, has
9393
</div>
9494
);
9595
};
96-
97-
export default AttemptDetails;

airbyte-webapp/src/components/JobItem/components/ErrorDetails.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import styled from "styled-components";
44

55
import { AttemptRead } from "core/request/AirbyteClient";
66

7+
import { getFailureFromAttempt, isCancelledAttempt } from "../utils";
8+
79
interface IProps {
810
attempts?: AttemptRead[];
911
}
@@ -20,10 +22,6 @@ const FailureDateDisplay = styled.span`
2022
font-style: italic;
2123
`;
2224

23-
const getFailureFromAttempt = (attempt: AttemptRead) => {
24-
return attempt.failureSummary?.failures[0];
25-
};
26-
2725
const ErrorDetails: React.FC<IProps> = ({ attempts }) => {
2826
const { formatMessage } = useIntl();
2927

@@ -42,8 +40,9 @@ const ErrorDetails: React.FC<IProps> = ({ attempts }) => {
4240

4341
const attempt = attempts[attempts.length - 1];
4442
const failure = getFailureFromAttempt(attempt);
43+
const isCancelled = isCancelledAttempt(attempt);
4544

46-
if (!failure) {
45+
if (!failure || isCancelled) {
4746
return null;
4847
}
4948

airbyte-webapp/src/components/JobItem/components/JobLogs.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import { StatusIcon } from "components/ui/StatusIcon";
77
import { StatusIconStatus } from "components/ui/StatusIcon/StatusIcon";
88
import { Text } from "components/ui/Text";
99

10+
import { AttemptRead, AttemptStatus, SynchronousJobRead } from "core/request/AirbyteClient";
1011
import { JobsWithJobs } from "pages/ConnectionPage/pages/ConnectionItemPage/JobsList";
1112
import { useGetDebugInfoJob } from "services/job/JobService";
1213

13-
import { AttemptRead, AttemptStatus, SynchronousJobRead } from "../../../core/request/AirbyteClient";
1414
import { parseAttemptLink } from "../attemptLinkUtils";
15+
import { isCancelledAttempt } from "../utils";
1516
import styles from "./JobLogs.module.scss";
1617
import Logs from "./Logs";
1718
import { LogsDetails } from "./LogsDetails";
@@ -26,6 +27,11 @@ const mapAttemptStatusToIcon = (attempt: AttemptRead): StatusIconStatus => {
2627
if (isPartialSuccess(attempt)) {
2728
return "warning";
2829
}
30+
31+
if (isCancelledAttempt(attempt)) {
32+
return "cancelled";
33+
}
34+
2935
switch (attempt.status) {
3036
case AttemptStatus.running:
3137
return "loading";
@@ -44,7 +50,7 @@ const jobIsSynchronousJobRead = (job: SynchronousJobRead | JobsWithJobs): job is
4450
return !!(job as SynchronousJobRead)?.logs?.logLines;
4551
};
4652

47-
const JobLogs: React.FC<JobLogsProps> = ({ jobIsFailed, job }) => {
53+
export const JobLogs: React.FC<JobLogsProps> = ({ jobIsFailed, job }) => {
4854
const isSynchronousJobRead = jobIsSynchronousJobRead(job);
4955

5056
const id: number | string = (job as JobsWithJobs).job?.id ?? (job as SynchronousJobRead).id;
@@ -110,5 +116,3 @@ const JobLogs: React.FC<JobLogsProps> = ({ jobIsFailed, job }) => {
110116
</>
111117
);
112118
};
113-
114-
export default JobLogs;

airbyte-webapp/src/components/JobItem/components/LogsDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react";
22
import styled from "styled-components";
33

44
import { AttemptRead, JobDebugInfoRead } from "../../../core/request/AirbyteClient";
5-
import AttemptDetails from "./AttemptDetails";
5+
import { AttemptDetails } from "./AttemptDetails";
66
import DownloadButton from "./DownloadButton";
77
import { LinkToAttemptButton } from "./LinkToAttemptButton";
88
import LogsTable from "./Logs";

airbyte-webapp/src/components/JobItem/components/MainInfo.module.scss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@use "../../../scss/colors";
2-
@use "../../../scss/variables";
1+
@use "scss/colors";
2+
@use "scss/variables";
33

44
.mainView {
55
cursor: pointer;
@@ -44,16 +44,18 @@
4444
.attemptCount {
4545
font-size: 12px;
4646
line-height: 15px;
47-
color: colors.$red;
47+
color: colors.$grey;
4848
}
4949
}
5050

51+
border-bottom: variables.$border-thin solid transparent !important;
52+
5153
&.open:not(.failed) {
52-
border-bottom: variables.$border-thin solid colors.$grey-100;
54+
border-bottom: variables.$border-thin solid colors.$grey-100 !important;
5355
}
5456

5557
&.open.failed {
56-
border-bottom: variables.$border-thin solid colors.$red-50;
58+
border-bottom: variables.$border-thin solid colors.$red-50 !important;
5759
}
5860
}
5961

airbyte-webapp/src/components/JobItem/components/MainInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { AttemptRead, JobStatus, SynchronousJobRead } from "core/request/Airbyte
1212
import { JobsWithJobs } from "pages/ConnectionPage/pages/ConnectionItemPage/JobsList";
1313

1414
import { getJobStatus } from "../JobItem";
15-
import AttemptDetails from "./AttemptDetails";
15+
import { AttemptDetails } from "./AttemptDetails";
1616
import styles from "./MainInfo.module.scss";
1717
import { ResetStreamsDetails } from "./ResetStreamDetails";
1818

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { AttemptFailureReason, AttemptFailureType, AttemptRead } from "core/request/AirbyteClient";
2+
3+
export const getFailureFromAttempt = (attempt: AttemptRead): AttemptFailureReason | undefined =>
4+
attempt.failureSummary?.failures[0];
5+
6+
export const isCancelledAttempt = (attempt: AttemptRead): boolean =>
7+
attempt.failureSummary?.failures.some(({ failureType }) => failureType === AttemptFailureType.manual_cancellation) ??
8+
false;

0 commit comments

Comments
 (0)