Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
dex 1117 - Replace progress with pipeline_status in Asset Group (#420)
Browse files Browse the repository at this point in the history
* Replace asset group progress with pipeline_status

* Change px to number and abstract showAlert in AssetGroup
  • Loading branch information
Emily-Ke authored Jul 12, 2022
1 parent 40e3c86 commit 4ec0222
Showing 1 changed file with 31 additions and 22 deletions.
53 changes: 31 additions & 22 deletions src/pages/assetGroup/AssetGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,25 @@ import AGSTable from './AGSTable';

const POLLING_INTERVAL = 5000; // 5 seconds

function isProgressSettled(pipelineStatus) {
const { skipped, failed, complete } = pipelineStatus || {};

return skipped || complete || failed;
}

function deriveRefetchInterval(resultData, query) {
const { complete, status } =
resultData?.data?.progress_preparation || {};
const pipelineStatus = get(
resultData,
'data.pipeline_status.preparation',
{},
);

const error = query.state?.error && { ...query.state.error };
const isSettled = isProgressSettled(pipelineStatus);

const isProgressSettled =
complete || ['failed', 'cancelled'].includes(status) || error;
const isError = Boolean(query.state?.error);

const refetchInterval = isProgressSettled
? false
: POLLING_INTERVAL;
const refetchInterval =
isSettled || isError ? false : POLLING_INTERVAL;

return refetchInterval;
}
Expand Down Expand Up @@ -86,15 +93,17 @@ export default function AssetGroup() {
intl.formatMessage({ id: 'UNNAMED_USER' });
const creatorUrl = `/users/${sightingCreator?.guid}`;

const {
complete: isPreparationProgressComplete,
failed: isPreparationProgressFailed,
cancelled: isPreparationProgressCancelled,
} = get(data, 'progress_preparation', {});
const showPreparationErrorAlert =
isPreparationProgressFailed || isPreparationProgressCancelled;
const showPreparationInProgressAlert =
!showPreparationErrorAlert && !isPreparationProgressComplete;
const pipelineStatusPreparation = get(
data,
'pipeline_status.preparation',
{},
);
const isPreparationFailed = pipelineStatusPreparation.failed;

const showPreparationInProgressAlert = !(
isPreparationFailed ||
isProgressSettled(pipelineStatusPreparation)
);

return (
<MainColumn fullWidth>
Expand Down Expand Up @@ -146,7 +155,7 @@ export default function AssetGroup() {
</Text>
)}
</EntityHeader>
{showPreparationErrorAlert && (
{isPreparationFailed && (
<CustomAlert
titleId="IMAGE_PROCESSING_ERROR"
descriptionId="IMAGE_PROCESSING_ERROR_MESSAGE"
Expand All @@ -157,17 +166,17 @@ export default function AssetGroup() {
<>
<LinearProgress
style={{
borderTopLeftRadius: '4px',
borderTopRightRadius: '4px',
borderTopLeftRadius: 4,
borderTopRightRadius: 4,
}}
/>
<CustomAlert
titleId="PENDING_IMAGE_PROCESSING"
descriptionId="PENDING_IMAGE_PROCESSING_MESSAGE"
severity="info"
style={{
borderTopLeftRadius: '0px',
borderTopRightRadius: '0px',
borderTopLeftRadius: 0,
borderTopRightRadius: 0,
}}
/>
</>
Expand Down

0 comments on commit 4ec0222

Please sign in to comment.