Skip to content

Commit

Permalink
feat: add error message for missing connection folder ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorylegarec committed Oct 1, 2017
1 parent fb90dc5 commit e755543
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/components/KonnectorEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ import KonnectorSync from './KonnectorSync'

import { ACCOUNT_ERRORS } from '../lib/accounts'

const NotExistingDirErrorDescription = ({ t, connector }) => (<DescriptionContent
cssClassesObject={{'coz-error': true}}
title={t('connection.error.NOT_EXISTING_DIRECTORY.title')}
messages={[t('connection.error.NOT_EXISTING_DIRECTORY.description', {name: connector.name})]}
/>)

const GlobalErrorDescription = ({ t, connector }) => (<DescriptionContent
cssClassesObject={{'coz-error': true}}
title={t('account.message.error.global.title')}
messages={[t('account.message.error.global.description', {name: connector.name})]}
/>)

const getErrorDescription = (props) => {
const { error } = props
switch (error.message) {
case ACCOUNT_ERRORS.NOT_EXISTING_DIRECTORY:
return (<NotExistingDirErrorDescription {...props} />)
default:
return (<GlobalErrorDescription {...props} />)
}
}

export const KonnectorEdit = ({ t, account, connector, deleting, disableSuccessTimeout, driveUrl, error, fields, folderPath, isUnloading, lastSync, oAuthTerminated, onCancel, onDelete, onForceConnection, onSubmit, submitting, success }) => {
const warningIcon = <svg className='item-status-icon'>
<use xlinkHref={require('../assets/sprites/icon-warning.svg')} /> }
Expand All @@ -24,11 +46,7 @@ export const KonnectorEdit = ({ t, account, connector, deleting, disableSuccessT
return (
<div className={styles['col-account-edit-content']}>

{ hasErrorExceptLogin && <DescriptionContent
cssClassesObject={{'coz-error': true}}
title={t('account.message.error.global.title')}
messages={[t('account.message.error.global.description', {name: connector.name})]}
/> }
{ hasErrorExceptLogin && getErrorDescription({t, error, connector})}

<Tabs
initialActiveTab={
Expand Down
1 change: 1 addition & 0 deletions src/lib/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const ACCOUNTS_DOCTYPE = 'io.cozy.accounts'

export const ACCOUNT_ERRORS = {
LOGIN_FAILED: 'LOGIN_FAILED',
NOT_EXISTING_DIRECTORY: 'NOT_EXISTING_DIRECTORY',
SUCCESS_TIMEOUT: 'SUCCESS_TIMEOUT'
}

Expand Down
9 changes: 9 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@
"forceConnection": "Synchronize now"
},

"connection": {
"error": {
"NOT_EXISTING_DIRECTORY": {
"title": "Missing destination folder",
"description": "It seems that this account's destination folder has been deleted. Please restore it by disconnecting this account and then reconnect again."
}
}
},

"intent": {
"service": {
"error": {
Expand Down

0 comments on commit e755543

Please sign in to comment.