Skip to content

Commit 94b9c2f

Browse files
committed
feat: Use entrypoints helpers from cozy-client
We also select only entrypoints we want.
1 parent 73c15aa commit 94b9c2f

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

src/components/AppsMenu/AppsMenuContent.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import AppItemPlaceholder from 'components/AppsMenu/components/AppItemPlaceholde
1313
import useI18n from 'components/useI18n'
1414
import { getApps, getHomeApp, isFetchingApps } from 'lib/reducers'
1515
import styles from 'styles/apps-menu.styl'
16-
import { buildEntrypoints } from 'components/AppsMenu/helper'
16+
import { getEntrypoints } from 'components/AppsMenu/helper'
1717

1818
const AppsMenuContent = ({
1919
isFetchingApps,
@@ -50,7 +50,7 @@ const AppsMenuContent = ({
5050
? sortApplicationsList(displayedApps, flag('apps.sort'))
5151
: displayedApps
5252

53-
const entrypoints = buildEntrypoints(apps)
53+
const entrypoints = getEntrypoints(apps)
5454

5555
return (
5656
<div className={styles['apps-menu-grid']}>

src/components/AppsMenu/helper.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1-
export const buildEntrypoints = apps => {
2-
return apps.flatMap(app => {
3-
if (!app.entrypoints) return []
4-
5-
return app.entrypoints.map(entrypoint => ({
6-
...entrypoint,
7-
slug: app.slug
8-
}))
9-
})
1+
import { models } from 'cozy-client'
2+
3+
const {
4+
applications: { selectEntrypoints, filterEntrypoints }
5+
} = models
6+
7+
// We get only the entrypoints we want:
8+
// - Drive onlyoffice
9+
export const getEntrypoints = apps => {
10+
const driveApp = apps.find(app => app.slug === 'drive') || {}
11+
12+
const driveEntrypoints = driveApp.entrypoints || []
13+
14+
const selectedEntrypoints = selectEntrypoints(driveEntrypoints, [
15+
'new-file-type-text',
16+
'new-file-type-sheet',
17+
'new-file-type-slide'
18+
])
19+
const filteredEntrypoints = filterEntrypoints(selectedEntrypoints)
20+
21+
return filteredEntrypoints.map(entrypoint => ({
22+
...entrypoint,
23+
slug: driveApp.slug
24+
}))
1025
}

0 commit comments

Comments
 (0)