Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handle NOT_EXISTING_DIRECTORY error ✨ #286

Merged
merged 2 commits into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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