Skip to content

Commit

Permalink
Merge pull request #286 from gregorylegarec/feat/missing-folder-message
Browse files Browse the repository at this point in the history
feat: handle NOT_EXISTING_DIRECTORY error ✨
  • Loading branch information
CPatchane authored Oct 3, 2017
2 parents 7e51788 + 64195c5 commit 785ba96
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 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('connection.error.default.title')}
messages={[t('connection.error.default.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
17 changes: 13 additions & 4 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@
"bill": "Find your datas in the Drive app at this location:"
},
"error": {
"global": {
"title": "An error occured",
"description": "Unfortunately, something went wrong when trying to connect to %{name}. Please retry or contact the Cozy support on our [forum](https://forum.cozy.io/)."
},
"server": "Apologies, our server had an hiccup, do you mind starting again?",
"bad_credentials": "Sorry, you entered an incorrect login or password.",
"delete": "Apologies, our server had an hiccup, do you mind starting again?"
Expand All @@ -112,6 +108,19 @@
"forceConnection": "Synchronize now"
},

"connection": {
"error": {
"default": {
"title": "An error occured",
"description": "Unfortunately, something went wrong when trying to connect to %{name}. Please retry or contact the Cozy support on our [forum](https://forum.cozy.io/)."
},
"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 785ba96

Please sign in to comment.