Skip to content

Commit eef0d1e

Browse files
author
Travis CI User
committed
publish: Merge pull request #281 from cozy/feat/add-translate-apps
generated from commit 7e07ec9
1 parent 8f74c95 commit eef0d1e

File tree

15 files changed

+685
-681
lines changed

15 files changed

+685
-681
lines changed

en/cozy-client/api/cozy-client/modules/models.konnectorFolder/index.html

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,6 +3289,13 @@
32893289
buildFolderPermission
32903290
</a>
32913291

3292+
</li>
3293+
3294+
<li class="md-nav__item">
3295+
<a href="#buildmainfolderpath" title="buildMainFolderPath" class="md-nav__link">
3296+
buildMainFolderPath
3297+
</a>
3298+
32923299
</li>
32933300

32943301
<li class="md-nav__item">
@@ -3396,7 +3403,7 @@ <h3 id="buildfolderpath">buildFolderPath<a class="headerlink" href="#buildfolder
33963403
<p><code>string</code></p>
33973404
<p>The result path</p>
33983405
<p><em>Defined in</em></p>
3399-
<p><a href="https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/konnectorFolder.js#L154">packages/cozy-client/src/models/konnectorFolder.js:154</a></p>
3406+
<p><a href="https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/konnectorFolder.js#L158">packages/cozy-client/src/models/konnectorFolder.js:158</a></p>
34003407
<hr />
34013408
<h3 id="buildfolderpermission">buildFolderPermission<a class="headerlink" href="#buildfolderpermission" title="Permanent link">&para;</a></h3>
34023409
<p><strong>buildFolderPermission</strong>(<code>folder</code>): <code>any</code></p>
@@ -3423,7 +3430,52 @@ <h3 id="buildfolderpermission">buildFolderPermission<a class="headerlink" href="
34233430
<p><code>any</code></p>
34243431
<p>Permission object</p>
34253432
<p><em>Defined in</em></p>
3426-
<p><a href="https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/konnectorFolder.js#L266">packages/cozy-client/src/models/konnectorFolder.js:266</a></p>
3433+
<p><a href="https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/konnectorFolder.js#L314">packages/cozy-client/src/models/konnectorFolder.js:314</a></p>
3434+
<hr />
3435+
<h3 id="buildmainfolderpath">buildMainFolderPath<a class="headerlink" href="#buildmainfolderpath" title="Permanent link">&para;</a></h3>
3436+
<p><strong>buildMainFolderPath</strong>(<code>konnector</code>, <code>magicFolders?</code>): <code>string</code></p>
3437+
<p>Build konnector main folder path for a given konnector.</p>
3438+
<p>If konnector.folders[0].defaultDir exists, it is used as default directory.</p>
3439+
<p>Occurrences of following strings in base directory are replaced by:</p>
3440+
<ul>
3441+
<li><code>$administrative</code>: Administrative folder</li>
3442+
<li><code>$photos</code>: Photos folder</li>
3443+
</ul>
3444+
<p>Occurrences of following strings in path are replaced by:</p>
3445+
<ul>
3446+
<li><code>$konnector</code>: Konnector name</li>
3447+
</ul>
3448+
<p>If no konnectors.folders[0].defaultDir is set, the default dir used is</p>
3449+
<ul>
3450+
<li><code>$administrative/$konnector</code></li>
3451+
</ul>
3452+
<p><em>Parameters</em></p>
3453+
<table>
3454+
<thead>
3455+
<tr>
3456+
<th align="left">Name</th>
3457+
<th align="left">Type</th>
3458+
<th align="left">Description</th>
3459+
</tr>
3460+
</thead>
3461+
<tbody>
3462+
<tr>
3463+
<td align="left"><code>konnector</code></td>
3464+
<td align="left"><code>IOCozyKonnector</code></td>
3465+
<td align="left">Konnector document</td>
3466+
</tr>
3467+
<tr>
3468+
<td align="left"><code>magicFolders</code></td>
3469+
<td align="left"><code>Object</code></td>
3470+
<td align="left">Object containing a mapping from folder identifiers (ex: $administrative) to their localized values (ex: Administratif).</td>
3471+
</tr>
3472+
</tbody>
3473+
</table>
3474+
<p><em>Returns</em></p>
3475+
<p><code>string</code></p>
3476+
<p>The result path</p>
3477+
<p><em>Defined in</em></p>
3478+
<p><a href="https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/konnectorFolder.js#L204">packages/cozy-client/src/models/konnectorFolder.js:204</a></p>
34273479
<hr />
34283480
<h3 id="createdirectorybypath">createDirectoryByPath<a class="headerlink" href="#createdirectorybypath" title="Permanent link">&para;</a></h3>
34293481
<p><strong>createDirectoryByPath</strong>(<code>client</code>, <code>path</code>): <code>Promise</code>&lt;<code>IOCozyFolder</code>&gt;</p>
@@ -3454,7 +3506,7 @@ <h3 id="createdirectorybypath">createDirectoryByPath<a class="headerlink" href="
34543506
<p><code>Promise</code>&lt;<code>IOCozyFolder</code>&gt;</p>
34553507
<p>Directory attributes</p>
34563508
<p><em>Defined in</em></p>
3457-
<p><a href="https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/konnectorFolder.js#L102">packages/cozy-client/src/models/konnectorFolder.js:102</a></p>
3509+
<p><a href="https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/konnectorFolder.js#L107">packages/cozy-client/src/models/konnectorFolder.js:107</a></p>
34583510
<hr />
34593511
<h3 id="ensurekonnectorfolder">ensureKonnectorFolder<a class="headerlink" href="#ensurekonnectorfolder" title="Permanent link">&para;</a></h3>
34603512
<p><strong>ensureKonnectorFolder</strong>(<code>client</code>, <code>options</code>): <code>Promise</code>&lt;<code>IOCozyFolder</code>&gt;</p>
@@ -3539,7 +3591,7 @@ <h3 id="findkonnectoraccountfolderbyreference">findKonnectorAccountFolderByRefer
35393591
<p><em>Returns</em></p>
35403592
<p><code>Promise</code>&lt;<code>IOCozyFolder</code>&gt;</p>
35413593
<p><em>Defined in</em></p>
3542-
<p><a href="https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/konnectorFolder.js#L374">packages/cozy-client/src/models/konnectorFolder.js:374</a></p>
3594+
<p><a href="https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/konnectorFolder.js#L422">packages/cozy-client/src/models/konnectorFolder.js:422</a></p>
35433595
<hr />
35443596
<h3 id="statdirectorybypath">statDirectoryByPath<a class="headerlink" href="#statdirectorybypath" title="Permanent link">&para;</a></h3>
35453597
<p><strong>statDirectoryByPath</strong>(<code>client</code>, <code>path</code>): <code>Promise</code>&lt;<code>IOCozyFolder</code>&gt;</p>
@@ -3571,7 +3623,7 @@ <h3 id="statdirectorybypath">statDirectoryByPath<a class="headerlink" href="#sta
35713623
<p><code>Promise</code>&lt;<code>IOCozyFolder</code>&gt;</p>
35723624
<p>Created io.cozy.files document</p>
35733625
<p><em>Defined in</em></p>
3574-
<p><a href="https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/konnectorFolder.js#L117">packages/cozy-client/src/models/konnectorFolder.js:117</a></p>
3626+
<p><a href="https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/konnectorFolder.js#L122">packages/cozy-client/src/models/konnectorFolder.js:122</a></p>
35753627

35763628

35773629

en/cozy-home/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"@sentry/react": "7.119.0",
3838
"comlink": "4.4.1",
3939
"cozy-client": "^51.6.0",
40-
"cozy-dataproxy-lib": "^1.9.0",
41-
"cozy-device-helper": "2.7.0",
40+
"cozy-dataproxy-lib": "^2.3.0",
41+
"cozy-device-helper": "3.7.1",
4242
"cozy-devtools": "^1.2.1",
4343
"cozy-doctypes": "1.83.8",
4444
"cozy-flags": "4.0.0",

en/cozy-home/src/components/Applications.jsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { memo, useEffect, useRef } from 'react'
1+
import React, { memo } from 'react'
22
import memoize from 'lodash/memoize'
33
import uniqBy from 'lodash/uniqBy'
44
import { useQuery } from 'cozy-client'
@@ -60,42 +60,32 @@ const getApplicationsList = data => {
6060
}
6161
}
6262

63-
export const Applications = ({ onAppsFetched }) => {
63+
export const Applications = () => {
6464
const showLogout = !!flag('home.mainlist.show-logout')
6565
const { t } = useI18n()
6666

67-
const { data } = useQuery(appsConn.query, appsConn)
67+
const { data: apps } = useQuery(appsConn.query, appsConn)
6868

6969
const homeMagicFolderConn = mkHomeMagicFolderConn(t)
70+
7071
const magicHomeFolder = useQuery(
7172
homeMagicFolderConn.query,
7273
homeMagicFolderConn
7374
)
75+
7476
const magicHomeFolderId = magicHomeFolder?.data?.[0]?._id
7577
const homeShortcutsConn = mkHomeShorcutsConn(magicHomeFolderId)
7678
const { data: shortcuts } = useQuery(homeShortcutsConn.query, {
7779
...homeShortcutsConn,
7880
enabled: !!magicHomeFolderId
7981
})
8082

81-
const didLoad = useRef(false)
82-
83-
useEffect(() => {
84-
const isReady =
85-
didLoad.current === false && onAppsFetched && isValidData(data)
86-
87-
if (isReady) {
88-
onAppsFetched(data)
89-
didLoad.current = true
90-
}
91-
}, [data, onAppsFetched])
92-
9383
return (
9484
<div className="app-list-wrapper u-m-auto u-w-100">
9585
<Divider className="u-mv-0" />
9686

9787
<div className="app-list u-w-100 u-mv-3 u-mt-2-t u-mb-1-t u-mh-auto u-flex-justify-center">
98-
{getApplicationsList(data)}
88+
{getApplicationsList(apps)}
9989

10090
{shortcuts &&
10191
shortcuts.map((shortcut, index) => (

en/cozy-home/src/components/FooterLogo/FooterLogo.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { useClient, useQuery } from 'cozy-client'
3-
import { buildContextQuery } from 'queries'
3+
import { makeContextQuery } from 'queries'
44
import Divider from 'cozy-ui/transpiled/react/Divider'
55
import { useCozyTheme } from 'cozy-ui/transpiled/react/providers/CozyTheme'
66

@@ -9,8 +9,10 @@ export const FooterLogo = () => {
99
const { type } = useCozyTheme()
1010
const rootURL = client.getStackClient().uri
1111

12-
const contextQuery = buildContextQuery()
13-
const { data } = useQuery(contextQuery.definition, contextQuery.options)
12+
const { data } = useQuery(
13+
makeContextQuery.definition,
14+
makeContextQuery.options
15+
)
1416

1517
const logos = data?.logos?.home?.light || []
1618
const secondaries = logos.filter(logos => logos.type === 'secondary')

en/cozy-home/src/components/Home.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { Announcements } from 'components/Announcements/Announcements'
1818

1919
import styles from './styles.styl'
2020

21-
const Home = ({ setAppsReady, wrapper }) => {
21+
const Home = ({ wrapper }) => {
2222
const { pathname } = useLocation()
2323
const { isMobile } = useBreakpoints()
2424

@@ -38,7 +38,7 @@ const Home = ({ setAppsReady, wrapper }) => {
3838
getFlagshipMetadata().immersive
3939
})}
4040
>
41-
<Applications onAppsFetched={setAppsReady} />
41+
<Applications />
4242
<Shortcuts />
4343
{flag('home.detailed-services-dev') ? (
4444
<GroupedServices />

en/cozy-home/src/components/Sections/SectionView.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState, useRef } from 'react'
22
import cx from 'classnames'
33

4+
import { useQuery } from 'cozy-client'
45
import type { IOCozyKonnector } from 'cozy-client/types/types'
56
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
67
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
@@ -17,6 +18,7 @@ import {
1718
} from 'components/Sections/SectionsTypes'
1819
import { useSections } from './SectionsContext'
1920
import CandidateServiceTile from 'components/CandidateServiceTile'
21+
import { makeTriggersWithJobStatusQuery } from 'queries'
2022

2123
export const SectionBody = ({ section }: SectionViewProps): JSX.Element => {
2224
const { isMobile } = useBreakpoints()
@@ -26,6 +28,13 @@ export const SectionBody = ({ section }: SectionViewProps): JSX.Element => {
2628
const shouldOpenStoreModal = section.type === 'category' && section.pristine
2729
const { isRunning, isInMaintenance } = useSections()
2830

31+
// This query is useful to fetch the triggers' current_state, used to display
32+
// the konnector icon. The data is fetched from the store in KonnectorTile
33+
useQuery(
34+
makeTriggersWithJobStatusQuery.definition(),
35+
makeTriggersWithJobStatusQuery.options
36+
)
37+
2938
return (
3039
<div
3140
className={cx(

en/cozy-home/src/containers/App.jsx

Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* global __SIMULATE_FLAGSHIP__ */
2-
import React, { useEffect, useState } from 'react'
2+
import React, { useState } from 'react'
33
import { Navigate, Route } from 'react-router-dom'
44

5-
import flag, { enable as enableFlags } from 'cozy-flags'
5+
import flag from 'cozy-flags'
66
import minilog from 'cozy-minilog'
77
import { useQuery } from 'cozy-client'
88
import { useWebviewIntent } from 'cozy-intent'
@@ -25,12 +25,10 @@ import IntentRedirect from 'components/IntentRedirect'
2525
import MoveModal from 'components/MoveModal'
2626
import StoreRedirection from 'components/StoreRedirection'
2727
import BackupNotification from 'components/BackupNotification/BackupNotification'
28-
import appEntryPoint from 'components/appEntryPoint'
2928
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
3029
import { BackgroundContainer } from 'components/BackgroundContainer'
3130
import { FLAG_FAB_BUTTON_ENABLED } from 'components/AddButton/helpers'
3231
import { MainView } from 'components/MainView'
33-
import { toFlagNames } from './toFlagNames'
3432
import { Konnector } from 'components/Konnector'
3533
import DefaultRedirectionSnackbar from 'components/DefaultRedirectionSnackbar/DefaultRedirectionSnackbar'
3634
import ReloadFocus from './ReloadFocus'
@@ -39,27 +37,22 @@ import { formatShortcuts } from 'components/Shortcuts/utils'
3937
import {
4038
mkHomeMagicFolderConn,
4139
mkHomeCustomShorcutsConn,
42-
mkHomeCustomShorcutsDirConn,
43-
contextQuery
40+
mkHomeCustomShorcutsDirConn
4441
} from 'queries'
42+
import { useFetchInitialData } from 'hooks/useFetchInitialData'
4543
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
4644
import SectionDialog from 'components/Sections/SectionDialog'
4745
import { SentryRoutes } from 'lib/sentry'
46+
import '../flags'
4847

4948
window.flag = window.flag || flag
5049
window.minilog = minilog
5150

52-
const App = ({ accounts, konnectors, triggers }) => {
51+
const App = () => {
5352
const { isMobile } = useBreakpoints()
5453
const [contentWrapper, setContentWrapper] = useState(undefined)
55-
const [isFetching, setIsFetching] = useState(
56-
[accounts, konnectors, triggers].some(collection =>
57-
['pending', 'loading'].includes(collection.fetchStatus)
58-
)
59-
)
60-
const [hasError, setHasError] = useState(false)
61-
const [isReady, setIsReady] = useState(false)
62-
const [appsReady, setAppsReady] = useState(false)
54+
55+
const [didInit, setDidInit] = useState(false)
6356
const webviewIntent = useWebviewIntent()
6457
const theme = useCozyTheme()
6558

@@ -93,48 +86,28 @@ const App = ({ accounts, konnectors, triggers }) => {
9386
const shortcutsDirectories = canHaveShortcuts
9487
? formatShortcuts(folders, customHomeShortcuts)
9588
: null
96-
const context = useQuery(contextQuery.definition, contextQuery.options)
89+
90+
const { isFetching, hasError } = useFetchInitialData()
9791

9892
const showAssistantForMobile = isFlagshipApp()
9993
? flag('cozy.searchbar.enabled-for-flagship')
10094
: flag('cozy.searchbar.enabled') && isMobile
10195

102-
useEffect(() => {
103-
setIsFetching(
104-
[accounts, konnectors, triggers, context].some(collection =>
105-
['pending', 'loading'].includes(collection.fetchStatus)
106-
)
107-
)
108-
setHasError(
109-
[accounts, konnectors, triggers, context].find(
110-
collection => collection.fetchStatus === 'failed'
111-
)
112-
)
113-
}, [accounts, konnectors, triggers, context])
114-
115-
if (context?.attributes?.features) {
116-
const flags = toFlagNames(context.attributes.features)
117-
enableFlags(flags)
118-
}
119-
120-
useEffect(() => {
121-
setIsReady(
122-
appsReady &&
123-
!hasError &&
124-
!isFetching &&
125-
shortcutsDirectories !== undefined
126-
)
127-
}, [appsReady, hasError, isFetching, shortcutsDirectories])
128-
129-
useEffect(() => {
130-
if (isReady && webviewIntent) {
96+
if (
97+
!didInit &&
98+
!hasError &&
99+
!isFetching &&
100+
shortcutsDirectories !== undefined
101+
) {
102+
if (webviewIntent) {
131103
webviewIntent.call('setTheme', theme.variant)
132104
webviewIntent.call('hideSplashScreen')
133105
}
134-
if (isReady && !webviewIntent && __SIMULATE_FLAGSHIP__) {
106+
if (!webviewIntent && __SIMULATE_FLAGSHIP__) {
135107
document.getElementById('splashscreen').style.display = 'none'
136108
}
137-
}, [isReady, theme, webviewIntent])
109+
setDidInit(true)
110+
}
138111

139112
return (
140113
<>
@@ -145,7 +118,7 @@ const App = ({ accounts, konnectors, triggers }) => {
145118
<Corner />
146119
<div
147120
className="u-flex u-flex-column u-flex-content-start u-flex-content-stretch u-w-100 u-m-auto u-pos-relative"
148-
ref={isReady ? div => setContentWrapper(div) : null}
121+
ref={didInit ? div => setContentWrapper(div) : null}
149122
>
150123
<MoveModal />
151124
<HeroHeader />
@@ -167,7 +140,6 @@ const App = ({ accounts, konnectors, triggers }) => {
167140
element={
168141
<Home
169142
wrapper={contentWrapper}
170-
setAppsReady={() => setAppsReady(true)}
171143
shortcutsDirectories={shortcutsDirectories}
172144
/>
173145
}
@@ -206,4 +178,4 @@ const App = ({ accounts, konnectors, triggers }) => {
206178
)
207179
}
208180

209-
export default appEntryPoint(App)
181+
export default App

0 commit comments

Comments
 (0)