Skip to content

Commit

Permalink
fix: 0 attempt jobs in timeline and users with empty string names (#1…
Browse files Browse the repository at this point in the history
…3523)
  • Loading branch information
teallarson committed Aug 15, 2024
1 parent 2f55dd5 commit c674420
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { JobLogOrigins, KNOWN_LOG_ORIGINS, useCleanLogs } from "area/connection/
import { VirtualLogs } from "area/connection/components/JobHistoryItem/VirtualLogs";
import { LinkToAttemptButton } from "area/connection/components/JobLogsModal/LinkToAttemptButton";
import { useAttemptCombinedStatsForJob, useAttemptForJob, useJobInfoWithoutLogs } from "core/api";
import { trackError } from "core/utils/datadog";

import { AttemptStatusIcon } from "./AttemptStatusIcon";
import { DownloadLogsButton } from "./DownloadLogsButton";
Expand All @@ -34,9 +35,14 @@ export const JobLogsModal: React.FC<JobLogsModalProps> = ({ jobId, initialAttemp
const [highlightedMatchIndex, setHighlightedMatchIndex] = useState<number | undefined>(undefined);
const [matchingLines, setMatchingLines] = useState<number[]>([]);
const highlightedMatchingLineNumber = highlightedMatchIndex !== undefined ? highlightedMatchIndex + 1 : undefined;
if (job.attempts.length === 0) {
trackError(new Error(`No attempts for job`), { jobId, eventId });
}

const [selectedAttemptId, setSelectedAttemptId] = useState(
initialAttemptId ?? job.attempts[job.attempts.length - 1].attempt.id
);

const jobAttempt = useAttemptForJob(jobId, selectedAttemptId);
const aggregatedAttemptStats = useAttemptCombinedStatsForJob(jobId, selectedAttemptId, {
refetchInterval() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ interface ConnectionTimelineEventActionsProps {
jobId: number;
eventId?: string;
createdAt: number;
attemptCount?: number;
}

export const ConnectionTimelineEventActions: React.FC<ConnectionTimelineEventActionsProps> = ({
jobId,
eventId,
createdAt,
attemptCount,
}) => {
return (
<div className={styles.eventActions}>
<Text color="grey400">
<FormattedDate value={createdAt * 1000} timeStyle="short" dateStyle="medium" />
</Text>
<JobEventMenu jobId={jobId} eventId={eventId} />
<JobEventMenu jobId={jobId} eventId={eventId} attemptCount={attemptCount} />
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ export const openJobLogsModalFromTimeline = ({
});
};

export const JobEventMenu: React.FC<{ eventId?: string; jobId: number }> = ({ eventId, jobId }) => {
export const JobEventMenu: React.FC<{ eventId?: string; jobId: number; attemptCount?: number }> = ({
eventId,
jobId,
attemptCount,
}) => {
const { formatMessage } = useIntl();
const { connection } = useConnectionEditService();
const { openModal } = useModalService();
Expand Down Expand Up @@ -176,10 +180,12 @@ export const JobEventMenu: React.FC<{ eventId?: string; jobId: number }> = ({ ev
{
displayName: formatMessage({ id: "jobHistory.viewLogs" }),
value: JobMenuOptions.OpenLogsModal,
disabled: attemptCount === 0,
},
{
displayName: formatMessage({ id: "jobHistory.downloadLogs" }),
value: JobMenuOptions.DownloadLogs,
disabled: attemptCount === 0,
},
]}
onChange={onChangeHandler}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const ClearEventItem: React.FC<ClearEventProps> = ({ clearEvent }) => {
createdAt={clearEvent.createdAt}
eventId={clearEvent.id}
jobId={clearEvent.summary.jobId}
attemptCount={clearEvent.summary.attemptsCount}
/>
</ConnectionTimelineEventItem>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { IconType } from "components/ui/Icon";
import { Text } from "components/ui/Text";

import { TimelineEventUser } from "./TimelineEventUser";
import { ConnectionTimelineEventActions } from "../ConnectionTimelineEventActions";
import { ConnectionTimelineEventIcon } from "../ConnectionTimelineEventIcon";
import { ConnectionTimelineEventItem } from "../ConnectionTimelineEventItem";
import { ConnectionTimelineEventSummary } from "../ConnectionTimelineEventSummary";
Expand Down Expand Up @@ -61,11 +60,6 @@ export const JobStartEventItem: React.FC<JobStartEventItemProps> = ({ jobStartEv
</Text>
</Box>
</ConnectionTimelineEventSummary>
<ConnectionTimelineEventActions
createdAt={jobStartEvent.createdAt}
eventId={jobStartEvent.id}
jobId={jobStartEvent.summary.jobId}
/>
</ConnectionTimelineEventItem>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface UserCancelledDescriptionProps {
}

export const TimelineEventUser: React.FC<TimelineEventUserProps> = ({ user }) => {
return <>{user?.name ?? user?.email ?? <FormattedMessage id="connection.timeline.unknownUser" />}</>;
return <>{user?.name?.trim() || user?.email?.trim() || <FormattedMessage id="connection.timeline.unknownUser" />}</>;
};

export const UserCancelledDescription: React.FC<UserCancelledDescriptionProps> = ({ user, jobType }) => {
Expand Down
4 changes: 2 additions & 2 deletions airbyte-webapp/src/views/layout/SideBar/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export const SideBar: React.FC<PropsWithChildren<SideBarProps>> = ({
if (authType === "simple" || authType === "none") {
return formatMessage({ id: "sidebar.defaultUsername" });
}
return user?.name;
}, [authType, user?.name, formatMessage]);
return user?.name?.trim() || user?.email?.trim();
}, [authType, user?.name, user?.email, formatMessage]);

return (
<nav className={classNames(styles.sidebar, { [styles.hidden]: isHidden })}>
Expand Down

0 comments on commit c674420

Please sign in to comment.