-
Notifications
You must be signed in to change notification settings - Fork 14
Feat/add services imports #783
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
Open
KillianCourvoisier
wants to merge
39
commits into
master
Choose a base branch
from
feat/addServicesImports
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
a59694a
feat(Imports): Add Imports components
KillianCourvoisier 81b774e
feat(imports): Add constants imports routes
KillianCourvoisier d9c7f82
feat(imports): Add french and english locales
KillianCourvoisier 75e4fc9
feat(imports): add Redux slice for Imports state
KillianCourvoisier 8041083
feat(imports): add Nextcloud listing UI with account check and store …
KillianCourvoisier 8b111e0
feat(imports/nextcloud): recursive import via downstream
KillianCourvoisier c4b7e0f
WIP - feat(imports/nextcloud): force destination to /Imports/Nextclou…
KillianCourvoisier 34e72d7
feat(nextcloud-import): improve 404 handling and expose failed items …
KillianCourvoisier 718844c
feat(imports/nextcloud): add per-item progress and explicit 404 repor…
KillianCourvoisier c3aaa7e
feat(imports): Add abort import button
KillianCourvoisier 9a488fb
feat(imports): Add parallel downstream (x3 for now)
KillianCourvoisier d582088
feat: Add POST permission for account creation from Settings
KillianCourvoisier cbd9f03
feat(imports): allow Nextcloud account creation directly from Settings
KillianCourvoisier d67f2c8
feat(imports): persist run state and stop import on navigation
KillianCourvoisier 3525efe
feat(imports): improve UI layout and align components with Settings s…
KillianCourvoisier 761d83f
chore: update yarn.lock after rebase
KillianCourvoisier bed996b
feat: Add DELETE permission for accounts in manifest
KillianCourvoisier 6eb5d8d
refactor(imports): align nextcloud account service with cozy-client c…
KillianCourvoisier e725f3e
refactor(imports): align nextcloud provider with cozy-client conventions
KillianCourvoisier 2ba846e
fix(imports): avoid nextcloud UI freeze after user stop
KillianCourvoisier 6a04199
feat(imports): add file-level dedup with per-directory cache for next…
KillianCourvoisier 5fa9e0e
refactor(imports): remove Redux/localStorage for enabled flag and mig…
KillianCourvoisier b814a0b
refactor(imports): split Run.jsx into atomic UI components + CozyDialog
KillianCourvoisier 67d0b2c
fix(imports): Use pageHeaders in imports, change imports icon and rep…
KillianCourvoisier 83c74a5
feat(imports): Hide features behind 'settings.imports' flag
KillianCourvoisier cc7d72f
fix(imports): Rename 'listNextcloudAccounts' to 'findNextcloudAccounts'
KillianCourvoisier 5ee96a7
feat(imports): Split provider.js in multiple service for flat import
KillianCourvoisier 284dcc6
refactor(imports/nextcloud): extract core logic into hooks and remove…
KillianCourvoisier a826817
refactor(imports): Remove Nextcloud account creation from hook
KillianCourvoisier 0e9880b
refactor(imports): Remove useless findNextcloudAccounts function
KillianCourvoisier f04ea68
feat(imports): Add i18n for Nextcloud account dialog texts
KillianCourvoisier 78b12ce
style(imports): Use Stylus module for Nextcloud account dialog and cl…
KillianCourvoisier ce2134c
style(imports): Use Stylus modulew when relevant and cleanup inline s…
KillianCourvoisier 4845294
style(imports): Apply i18n for nextcloud fr and eng texts
KillianCourvoisier 5fa2c88
chore: Update cozy-client and cozy-stack-client to use FailOnConflict
KillianCourvoisier 6615933
refactor(imports): replace nextcloud custom dir creation with ensureD…
KillianCourvoisier 8df5dd2
refactor(import): surface cozy errors as-is in hook
KillianCourvoisier 88a60eb
refactor(imports): cleanup nextcloud error handling and fix abort flow
KillianCourvoisier a2506e0
refactor(imports): remove nextcloud build404Reason and simplify 404 h…
KillianCourvoisier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import React from 'react' | ||
| import { useSelector } from 'react-redux' | ||
|
|
||
| import Typography from 'cozy-ui/transpiled/react/Typography' | ||
| import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' | ||
|
|
||
| import Page from '@/components/Page' | ||
|
|
||
| const History = () => { | ||
| const { t } = useI18n() | ||
| const enabled = useSelector(state => state.importData?.enabled ?? false) | ||
|
|
||
| return ( | ||
| <Page> | ||
| <Typography variant="h3" gutterBottom> | ||
| {t('ImportsHistory.title')} | ||
| </Typography> | ||
| <Typography variant="body1" gutterBottom> | ||
| {enabled | ||
| ? t('ImportsHistory.helper') | ||
| : t('ImportsHistory.disabled_helper')} | ||
| </Typography> | ||
|
|
||
| <div style={{ opacity: 0.7 }}> | ||
| <Typography variant="caption"> | ||
| {t('ImportsHistory.placeholder')} | ||
| </Typography> | ||
| </div> | ||
| </Page> | ||
| ) | ||
| } | ||
|
|
||
| export default History |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import React from 'react' | ||
|
|
||
| import Stack from 'cozy-ui/transpiled/react/Stack' | ||
| import Typography from 'cozy-ui/transpiled/react/Typography' | ||
| import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' | ||
|
|
||
| const ImportErrors = ({ error, failedItems }) => { | ||
| const { t } = useI18n() | ||
|
|
||
| if (!error && (!failedItems || failedItems.length === 0)) { | ||
| return null | ||
| } | ||
|
|
||
| return ( | ||
| <Stack spacing="xs"> | ||
| {error && ( | ||
| <Typography variant="caption" color="error"> | ||
| {String(error)} | ||
| </Typography> | ||
| )} | ||
|
|
||
| {failedItems && failedItems.length > 0 && ( | ||
| <ul style={{ margin: 0, paddingLeft: 18 }}> | ||
| {failedItems.map((item, idx) => { | ||
| const path = | ||
| item.path || item.name || t('ImportsRun.errors.unknown_path') | ||
| const statusCode = | ||
| typeof item.status === 'number' | ||
| ? item.status | ||
| : t('ImportsRun.errors.status_na') | ||
| const reason = item.reason || '' | ||
| const line = reason | ||
| ? `${path} - ${statusCode} (${reason})` | ||
| : `${path} - ${statusCode}` | ||
|
|
||
| return ( | ||
| <li key={idx} style={{ fontSize: 11 }}> | ||
| {line} | ||
| </li> | ||
| ) | ||
| })} | ||
| </ul> | ||
| )} | ||
| </Stack> | ||
| ) | ||
| } | ||
|
|
||
| export default ImportErrors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import React, { useCallback } from 'react' | ||
| import { useNavigate } from 'react-router-dom' | ||
|
|
||
| import Button from 'cozy-ui/transpiled/react/Button' | ||
| import Switch from 'cozy-ui/transpiled/react/Switch' | ||
| import Typography from 'cozy-ui/transpiled/react/Typography' | ||
| import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' | ||
|
|
||
| import styles from './imports.styl' | ||
| import { routes } from '../../constants/routes' | ||
|
|
||
| import { useImports } from '@/components/Imports/ImportsContext' | ||
| import Page from '@/components/Page' | ||
| import { PageHeader } from '@/components/PageHeader' | ||
|
|
||
| const Imports = () => { | ||
| const { t } = useI18n() | ||
| const navigate = useNavigate() | ||
| const { enabled, setEnabled } = useImports() | ||
|
|
||
| const onSwitchChange = useCallback( | ||
| ev => { | ||
| const next = !!ev?.target?.checked | ||
| setEnabled(next) | ||
| }, | ||
| [setEnabled] | ||
| ) | ||
|
|
||
| return ( | ||
| <Page> | ||
| <PageHeader title={t('ImportsView.title')} /> | ||
|
|
||
| <Typography variant="subtitle1" gutterBottom> | ||
| {t('ImportsView.subtitle')} | ||
| </Typography> | ||
|
|
||
| <Typography variant="body2" gutterBottom> | ||
| {t('ImportsView.helper')} | ||
| </Typography> | ||
|
|
||
| <div className={styles['ImportsView-switchRow']}> | ||
| <Switch checked={enabled} onChange={onSwitchChange} /> | ||
| <Typography variant="body1">{t('ImportsView.toggle')}</Typography> | ||
| </div> | ||
|
|
||
| <div className={styles['ImportsView-actionsRow']}> | ||
| <Button | ||
| variant="primary" | ||
| disabled={!enabled} | ||
| onClick={() => navigate(routes.importsRun)} | ||
| > | ||
| {t('ImportsView.action_run')} | ||
| </Button> | ||
| <Button | ||
| variant="secondary" | ||
| disabled={!enabled} | ||
| onClick={() => navigate(routes.importsHistory)} | ||
| > | ||
| {t('ImportsView.action_history')} | ||
| </Button> | ||
| </div> | ||
| </Page> | ||
| ) | ||
| } | ||
|
|
||
| export { Imports } | ||
| export default Imports |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import React from 'react' | ||
|
|
||
| import Box from 'cozy-ui/transpiled/react/Box' | ||
| import Button from 'cozy-ui/transpiled/react/Buttons' | ||
| import Circle from 'cozy-ui/transpiled/react/Circle' | ||
| import Icon from 'cozy-ui/transpiled/react/Icon' | ||
| import CloudRainbowIcon from 'cozy-ui/transpiled/react/Icons/CloudRainbow' | ||
| import Typography from 'cozy-ui/transpiled/react/Typography' | ||
| import { useBreakpoints } from 'cozy-ui/transpiled/react/providers/Breakpoints' | ||
| import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' | ||
|
|
||
| const ImportsContent = () => { | ||
| const { t } = useI18n() | ||
| const { isMobile } = useBreakpoints() | ||
|
|
||
| const onStartImport = () => {} | ||
|
|
||
| return ( | ||
| <Box | ||
| className="u-flex u-flex-column u-flex-items-center u-mh-auto u-mv-0" | ||
| maxWidth={600} | ||
| > | ||
| <Circle size={100} backgroundColor="var(--defaultBackgroundColor)"> | ||
| <Icon icon={CloudRainbowIcon} size={48} /> | ||
| </Circle> | ||
|
|
||
| <Typography className="u-mt-1-half u-mb-2" variant="h3" align="center"> | ||
| {t('ImportsView.subtitle')} | ||
| </Typography> | ||
|
|
||
| <Typography className="u-mb-2" align="center"> | ||
| {t('ImportsView.helper')} | ||
| </Typography> | ||
|
|
||
| <Button | ||
| theme="primary" | ||
| onClick={onStartImport} | ||
| className={isMobile ? 'u-w-100' : ''} | ||
| > | ||
| {t('ImportsView.cta')} | ||
| </Button> | ||
| </Box> | ||
| ) | ||
| } | ||
|
|
||
| export default ImportsContent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import React, { createContext, useContext, useState } from 'react' | ||
|
|
||
| const ImportsContext = createContext(null) | ||
|
|
||
| export const ImportsProvider = ({ children }) => { | ||
| const [enabled, setEnabled] = useState(false) | ||
|
|
||
| const value = { | ||
| enabled, | ||
| setEnabled | ||
| } | ||
|
|
||
| return ( | ||
| <ImportsContext.Provider value={value}>{children}</ImportsContext.Provider> | ||
| ) | ||
| } | ||
|
|
||
| export const useImports = () => { | ||
| const ctx = useContext(ImportsContext) | ||
| if (!ctx) { | ||
| throw new Error('useImports must be used within an ImportsProvider') | ||
| } | ||
| return ctx | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import React from 'react' | ||
|
|
||
| import { LinearProgress } from 'cozy-ui/transpiled/react/Progress' | ||
| import Stack from 'cozy-ui/transpiled/react/Stack' | ||
| import Typography from 'cozy-ui/transpiled/react/Typography' | ||
| import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' | ||
|
|
||
| const ImportsProgress = ({ title, progress, busy, status, summary }) => { | ||
| const { t } = useI18n() | ||
| const hasProgress = progress.total > 0 | ||
|
|
||
| return ( | ||
| <Stack spacing="s"> | ||
| <Typography variant="h5">{title}</Typography> | ||
|
|
||
| {hasProgress && ( | ||
| <div style={{ maxWidth: 500 }}> | ||
| <LinearProgress | ||
| variant="determinate" | ||
| value={ | ||
| progress.total === 0 | ||
| ? 0 | ||
| : Math.min(100, (progress.done / progress.total) * 100) | ||
| } | ||
| className="u-mv-half u-w-100 u-h-half u-bdrs-6" | ||
| /> | ||
|
|
||
| <div | ||
| style={{ | ||
| display: 'flex', | ||
| justifyContent: 'space-between', | ||
| marginTop: 4 | ||
| }} | ||
| > | ||
| <Typography variant="caption"> | ||
| {t('ImportsRun.sections.progress.processed', { | ||
| count: progress.done | ||
| })} | ||
| </Typography> | ||
|
|
||
| <Typography variant="caption"> | ||
| {t('ImportsRun.sections.progress.total', { | ||
| count: progress.total | ||
| })} | ||
| </Typography> | ||
| </div> | ||
|
|
||
| {busy && progress.current && ( | ||
| <Typography variant="caption"> | ||
| {t('ImportsRun.sections.progress.processing', { | ||
| name: progress.current | ||
| })} | ||
| </Typography> | ||
| )} | ||
| </div> | ||
| )} | ||
|
|
||
| {status && <Typography variant="caption">{status}</Typography>} | ||
| {summary && <Typography variant="caption">{summary}</Typography>} | ||
| </Stack> | ||
| ) | ||
| } | ||
|
|
||
| export default ImportsProgress |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import React from 'react' | ||
|
|
||
| import Select from '@/components/Select' | ||
|
|
||
| const ImportsProviderSelect = ({ | ||
| providerOptions, | ||
| providerValue, | ||
| providerFieldProps, | ||
| onChange | ||
| }) => { | ||
| return ( | ||
| <Select | ||
| name="provider" | ||
| options={providerOptions} | ||
| fieldProps={providerFieldProps} | ||
| value={providerValue} | ||
| onChange={sel => { | ||
| onChange(sel ? sel.value : '') | ||
| }} | ||
| isSearchable={false} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| export default ImportsProviderSelect |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.