Skip to content

Commit

Permalink
fix: SyncButtonAction for clisk
Browse files Browse the repository at this point in the history
Since we can't "edit" a clisk, because we don't store the credentials
we need to launch the konnector to ba able to fix the issue.
  • Loading branch information
Crash-- committed May 24, 2023
1 parent f1de891 commit d7b7656
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
Expand Up @@ -60,7 +60,9 @@ export const LaunchTriggerAlert = ({
const isInError = !!error
const block = isInError || (!!withMaintenanceDescription && isInMaintenance)
const styles = useStyles({ block })
const isKonnectorRunnable = findKonnectorPolicy(konnector).isRunnable()
const konnectorPolicy = findKonnectorPolicy(konnector)
const isKonnectorRunnable = konnectorPolicy.isRunnable()
const isClick = konnectorPolicy.name === 'clisk'
const isKonnectorDisconnected = isDisconnected(konnector, trigger)

useEffect(() => {
Expand All @@ -69,15 +71,16 @@ export const LaunchTriggerAlert = ({
}
}, [status])

const SyncButtonAction = isInError
? () =>
historyAction(
konnectorRoot
? `${konnectorRoot}/accounts/${getAccountId(trigger)}/edit`
: '/edit',
'push'
)
: () => launch({ autoSuccessTimer: false })
const SyncButtonAction =
isInError && !isClick
? () =>
historyAction(
konnectorRoot
? `${konnectorRoot}/accounts/${getAccountId(trigger)}/edit`
: '/edit',
'push'
)
: () => launch({ autoSuccessTimer: false })
const alertColor = () => {
if (isInError) return undefined
if (isInMaintenance) return 'var(--grey50)'
Expand Down
Expand Up @@ -11,6 +11,7 @@ import SyncIcon from 'cozy-ui/transpiled/react/Icons/Sync'

import { isDisconnected } from '../../helpers/konnectors'
import { getAccountId } from '../../helpers/triggers'
import { findKonnectorPolicy } from '../../konnector-policies'
import { useFlowState } from '../../models/withConnectionFlow'
import withAdaptiveRouter from '../hoc/withRouter'
import useMaintenanceStatus from '../hooks/useMaintenanceStatus'
Expand All @@ -23,20 +24,23 @@ const LaunchTriggerAlertMenu = ({ flow, t, konnectorRoot, historyAction }) => {
data: { isInMaintenance }
} = useMaintenanceStatus(client, konnector)
const isKonnectorDisconnected = isDisconnected(konnector, trigger)
const konnectorPolicy = findKonnectorPolicy(konnector)
const isClick = konnectorPolicy.name === 'clisk'

const anchorRef = useRef()
const [showOptions, setShowOptions] = useState(false)

const isInError = !!error
const SyncButtonAction = isInError
? () =>
historyAction(
konnectorRoot
? `${konnectorRoot}/accounts/${getAccountId(trigger)}/edit`
: '/edit',
'push'
)
: () => launch({ autoSuccessTimer: false })
const SyncButtonAction =
isInError && !isClick
? () =>
historyAction(
konnectorRoot
? `${konnectorRoot}/accounts/${getAccountId(trigger)}/edit`
: '/edit',
'push'
)
: () => launch({ autoSuccessTimer: false })

return (
<>
Expand Down

0 comments on commit d7b7656

Please sign in to comment.