Skip to content

Commit

Permalink
fix: update after int test
Browse files Browse the repository at this point in the history
  • Loading branch information
acezard committed May 22, 2024
1 parent 92fe08b commit bb8bd11
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 56 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"homepage": "https://github.com/cozy/cozy-home#readme",
"dependencies": {
"@cozy/minilog": "1.0.0",
"cozy-client": "^45.15.0",
"cozy-client": "^47.2.0",
"cozy-device-helper": "2.7.0",
"cozy-doctypes": "1.83.8",
"cozy-flags": "3.2.2",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sections/SectionView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const computeDisplayMode = (
section: Section
): DisplayMode => {
const layout = section.layout[isMobile ? 'mobile' : 'desktop']
return layout.detailedLine ? DisplayMode.DETAILED : DisplayMode.COMPACT
return layout.detailedLines ? DisplayMode.DETAILED : DisplayMode.COMPACT
}

export const SectionView = ({ section }: SectionViewProps): JSX.Element => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sections/SectionsTypes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DirectoryDataArray, FileData } from 'components/Shortcuts/types'

export interface DeviceSettings {
detailedLine: boolean
detailedLines: boolean
grouped: boolean
}

Expand Down
30 changes: 30 additions & 0 deletions src/components/Sections/fixtures/shortcutsLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"createdByApp": "toutatice",
"desktop": {
"detailedLines": true,
"grouped": false
},
"id": "2a76ec4e152e30fc90c8c91fba4ea9ad",
"mobile": {
"detailedLines": true,
"grouped": false
},
"order": 1,
"originalName": "Applications Toutatice"
},
{
"createdByApp": "toutatice",
"desktop": {
"detailedLines": true,
"grouped": false
},
"id": "2a76ec4e152e30fc90c8c91fba4eaaeb",
"mobile": {
"detailedLines": true,
"grouped": false
},
"order": 2,
"originalName": "Info"
}
]
16 changes: 8 additions & 8 deletions src/components/Sections/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ describe('formatSections', () => {
originalName: 'Name 1',
createdByApp: 'By 1',
mobile: {
detailedLine: false,
detailedLines: false,
grouped: false
},
desktop: {
detailedLine: true,
detailedLines: true,
grouped: true
},
order: 2
Expand All @@ -42,11 +42,11 @@ describe('formatSections', () => {
originalName: 'Name 2',
createdByApp: 'By 2',
mobile: {
detailedLine: true,
detailedLines: true,
grouped: true
},
desktop: {
detailedLine: false,
detailedLines: false,
grouped: true
},
order: 1
Expand All @@ -64,11 +64,11 @@ describe('formatSections', () => {
originalName: 'Name 2',
createdByApp: 'By 2',
mobile: {
detailedLine: true,
detailedLines: true,
grouped: true
},
desktop: {
detailedLine: false,
detailedLines: false,
grouped: true
}
}
Expand All @@ -83,11 +83,11 @@ describe('formatSections', () => {
originalName: 'Name 1',
createdByApp: 'By 1',
mobile: {
detailedLine: false,
detailedLines: false,
grouped: false
},
desktop: {
detailedLine: true,
detailedLines: true,
grouped: true
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Sections/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { DirectoryDataArray } from 'components/Shortcuts/types'

export const _defaultLayout: Omit<SectionSetting, 'id'> = {
mobile: {
detailedLine: false,
detailedLines: false,
grouped: false
},
desktop: {
detailedLine: false,
detailedLines: false,
grouped: false
},
order: Infinity, // This should be used only if no order is defined
Expand Down
43 changes: 5 additions & 38 deletions src/components/Shortcuts/index.jsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,20 @@
import React from 'react'

import { useQuery } from 'cozy-client'
import { useSettings } from 'cozy-client'
import flag from 'cozy-flags'

import { ShortcutsView } from './ShortcutsView'
import { SectionView } from 'components/Sections/SectionView'
import { homeSettingsConn } from 'queries'
import { formatSections } from 'components/Sections/utils'

const TEMP_FIXTURE_DELETE_ASAP = [
{
id: '968dae76ae098d95ef402552fd001fcc',
originalName: 'Applications Toutatice',
createdByApp: 'toutatice',
mobile: {
detailedLine: true,
grouped: false
},
desktop: {
detailedLine: false,
grouped: true
},
order: 3
},
{
id: '968dae76ae098d95ef402552fd0009c0',
originalName: 'Infos',
createdByApp: 'infos',
mobile: {
detailedLine: false,
grouped: true
},
desktop: {
detailedLine: true,
grouped: true
},
order: 1
}
]

export const Shortcuts = ({ shortcutsDirectories }) => {
const homeSettingsResult = useQuery(homeSettingsConn.query, homeSettingsConn)
const { values } = useSettings('home', ['shortcutsLayout'])
const shortcutsLayout = values?.shortcutsLayout

if (flag('home.detailed_sections-dev')) {
const fetchedLayout =
homeSettingsResult.data?.[0]?.shortcutsLayout ?? TEMP_FIXTURE_DELETE_ASAP
if (flag('home.detailed_sections-dev') && shortcutsLayout) {
const formattedSections = formatSections(
shortcutsDirectories,
fetchedLayout
shortcutsLayout
)

return (
Expand Down
19 changes: 14 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5954,16 +5954,16 @@ cozy-bi-auth@0.0.25:
lodash "^4.17.20"
node-jose "^1.1.4"

cozy-client@^45.15.0:
version "45.15.0"
resolved "https://registry.yarnpkg.com/cozy-client/-/cozy-client-45.15.0.tgz#bb95b20f331676ee09e425233c36758cca10ce38"
integrity sha512-/137/DInGvMTitlhqLrtKXa+7Co2dnlbvu1jRwZ9+qaFbKZ1NMCPYi5mBWVcRy2HHqB++ph9HrjXEORVVky0/g==
cozy-client@^47.2.0:
version "47.2.0"
resolved "https://registry.yarnpkg.com/cozy-client/-/cozy-client-47.2.0.tgz#bcfaffc3737546ccf961098259fbf27ce8f54496"
integrity sha512-VkrcsL8Yti6DHz3DhhT9Lh/ayn2NCzqvhvojHWivrZGnxvUX6D6p9dvinNKJguyT8fATlIIfd7hY8ptx7F0yPg==
dependencies:
"@cozy/minilog" "1.0.0"
"@types/jest" "^26.0.20"
"@types/lodash" "^4.14.170"
btoa "^1.2.1"
cozy-stack-client "^45.13.0"
cozy-stack-client "^47.0.0"
date-fns "2.29.3"
json-stable-stringify "^1.0.1"
lodash "^4.17.13"
Expand Down Expand Up @@ -6225,6 +6225,15 @@ cozy-stack-client@^45.13.0:
mime "^2.4.0"
qs "^6.7.0"

cozy-stack-client@^47.0.0:
version "47.0.0"
resolved "https://registry.yarnpkg.com/cozy-stack-client/-/cozy-stack-client-47.0.0.tgz#3319cc78ddf5bcd5ae02c813490f5d47ed39ad32"
integrity sha512-OirSJb2GEvxwGDuL3oEL7wfeQrxWiQwS++H376vMyt6j6MHiJaLWz8Z5K6GnS7H593c52ZgsiOdVxyyYHWBIMQ==
dependencies:
detect-node "^2.0.4"
mime "^2.4.0"
qs "^6.7.0"

cozy-tsconfig@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/cozy-tsconfig/-/cozy-tsconfig-1.2.0.tgz#17e61f960f139fae4d26cbac2254b9ab632b269e"
Expand Down

0 comments on commit bb8bd11

Please sign in to comment.