-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add confirmation modal with context when canceling a job (#13015)
Co-authored-by: Joey Marshment-Howell <[email protected]>
- Loading branch information
1 parent
6950de8
commit 8e344c4
Showing
7 changed files
with
199 additions
and
2 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
airbyte-webapp/src/area/connection/utils/useInitialStreamSync.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import isEqual from "lodash/isEqual"; | ||
|
||
import { StreamStatusJobType, StreamStatusRunState } from "core/api/types/AirbyteClient"; | ||
|
||
import { useStreamsStatuses } from "./useStreamsStatuses"; | ||
export const useInitialStreamSync = (connectionId: string) => { | ||
const { streamStatuses, enabledStreams } = useStreamsStatuses(connectionId); | ||
|
||
const streamsSyncingForFirstTime: string[] = []; | ||
|
||
streamStatuses.forEach((stream) => { | ||
const lastSuccessfulClear = stream.relevantHistory?.find( | ||
(status) => status.jobType === StreamStatusJobType.RESET && status.runState === StreamStatusRunState.COMPLETE | ||
); | ||
const lastSuccessfulSync = stream.relevantHistory?.find( | ||
(status) => status.jobType === StreamStatusJobType.SYNC && status.runState === StreamStatusRunState.COMPLETE | ||
); | ||
// if the stream has never synced before | ||
if (!lastSuccessfulSync) { | ||
streamsSyncingForFirstTime.push(stream.streamName); | ||
} | ||
// if most clear and was more recent than the most recent sync | ||
if ((lastSuccessfulClear?.transitionedAt ?? 0) > (lastSuccessfulSync?.transitionedAt ?? 0)) { | ||
streamsSyncingForFirstTime.push(stream.streamName); | ||
} | ||
}); | ||
|
||
return { | ||
streamsSyncingForFirstTime, | ||
isConnectionInitialSync: isEqual(streamsSyncingForFirstTime.sort(), enabledStreams.sort()), | ||
}; | ||
}; |
51 changes: 51 additions & 0 deletions
51
airbyte-webapp/src/components/connection/ConnectionSync/CancelJobModalBody.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { FormattedMessage } from "react-intl"; | ||
|
||
import { Text } from "components/ui/Text"; | ||
|
||
import { JobConfigType } from "core/api/types/AirbyteClient"; | ||
|
||
interface CancelJobModalBodyProps { | ||
isConnectionInitialSync: boolean; | ||
streamsSyncingForFirstTime: string[]; | ||
configType: JobConfigType; | ||
} | ||
export const CancelJobModalBody: React.FC<CancelJobModalBodyProps> = ({ | ||
isConnectionInitialSync, | ||
streamsSyncingForFirstTime, | ||
configType, | ||
}) => { | ||
if (isConnectionInitialSync) { | ||
return <FormattedMessage id="connection.actions.cancel.confirm.body.initialSync" />; | ||
} | ||
|
||
if (streamsSyncingForFirstTime.length === 1) { | ||
const streamValues = streamsSyncingForFirstTime.map((stream) => { | ||
return ( | ||
<Text key={stream} as="span" size="lg"> | ||
{stream} | ||
</Text> | ||
); | ||
}); | ||
|
||
return ( | ||
<FormattedMessage | ||
id="connection.actions.cancel.confirm.body.streamInitialSync" | ||
values={{ streamValues, count: streamValues.length }} | ||
/> | ||
); | ||
} | ||
const configTypeId = | ||
configType === JobConfigType.sync | ||
? "connection.actions.sync" | ||
: configType === JobConfigType.refresh | ||
? "connection.actions.refresh" | ||
: "connection.actions.clear"; | ||
return ( | ||
<FormattedMessage | ||
id="connection.actions.cancel.body.generic" | ||
values={{ | ||
configType: <FormattedMessage id={configTypeId} />, | ||
}} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters