Skip to content

Commit

Permalink
feat(harvest): Add a maintenance message as a suffix
Browse files Browse the repository at this point in the history
Except for the case of disconnected and unknown
  • Loading branch information
Merkur39 authored and PolariTOON committed Feb 3, 2023
1 parent 1aea052 commit fad4f45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Expand Up @@ -148,7 +148,8 @@ export const LaunchTriggerAlert = ({
konnector,
trigger,
running,
expectingTriggerLaunch
expectingTriggerLaunch,
isInMaintenance
})}
</Typography>
{block && (
Expand Down
15 changes: 10 additions & 5 deletions packages/cozy-harvest-lib/src/components/cards/helpers.js
Expand Up @@ -24,22 +24,27 @@ export const makeLabel = ({
konnector,
trigger,
running,
expectingTriggerLaunch
expectingTriggerLaunch,
isInMaintenance
}) => {
const lastSuccessDate = getLastSuccessDate(trigger)

const mantenanceSuffix = isInMaintenance
? ` · ${t('konnectorBlock.inMaintenance')}`
: ''

if (running || expectingTriggerLaunch) {
return t('card.launchTrigger.lastSync.syncing')
return `${t('card.launchTrigger.lastSync.syncing')}${mantenanceSuffix}`
}

if (lastSuccessDate) {
if (getDifferenceInMinutes(lastSuccessDate) < DEFAULT_TIME) {
return t('card.launchTrigger.lastSync.justNow')
return `${t('card.launchTrigger.lastSync.justNow')}${mantenanceSuffix}`
}

return t('card.launchTrigger.lastSync.afterSomeTimes', {
return `${t('card.launchTrigger.lastSync.afterSomeTimes', {
times: formatLocallyDistanceToNow(lastSuccessDate)
})
})}${mantenanceSuffix}`
}

if (isDisconnected(konnector, trigger)) {
Expand Down

0 comments on commit fad4f45

Please sign in to comment.