From 16e1ccbc3c7339b965b9986b4b783c265c60b86f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Poizat?= Date: Mon, 4 Nov 2024 15:11:46 +0100 Subject: [PATCH 1/4] fix: Display folder link external icon only in desktop --- src/components/AppLayout.jsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/AppLayout.jsx b/src/components/AppLayout.jsx index 7ae16f9..744046b 100644 --- a/src/components/AppLayout.jsx +++ b/src/components/AppLayout.jsx @@ -122,13 +122,15 @@ const AppLayout = () => { {t('Sidebar.documents')} - + {!isMobile && ( + + )} From 768aef6e3668b39d79d895528a10c66290589bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Poizat?= Date: Mon, 4 Nov 2024 16:20:30 +0100 Subject: [PATCH 2/4] fix: TabTitle width is too large and is overflowing the page --- src/components/Atoms/TabTitle.jsx | 2 +- src/components/Atoms/Timetable/CozyDatePickerInline.jsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Atoms/TabTitle.jsx b/src/components/Atoms/TabTitle.jsx index 0ff4c64..15185e7 100644 --- a/src/components/Atoms/TabTitle.jsx +++ b/src/components/Atoms/TabTitle.jsx @@ -25,7 +25,7 @@ export const TabTitle = ({ children }) => { height: 68, minHeight: 68 }} - className="u-p-1 u-w-100 u-flex u-flex-row u-flex-items-center u-flex-justify-between" + className="u-p-1 u-flex u-flex-row u-flex-items-center u-flex-justify-between" > {!isMobile && } diff --git a/src/components/Atoms/Timetable/CozyDatePickerInline.jsx b/src/components/Atoms/Timetable/CozyDatePickerInline.jsx index 1eeaa94..d789612 100644 --- a/src/components/Atoms/Timetable/CozyDatePickerInline.jsx +++ b/src/components/Atoms/Timetable/CozyDatePickerInline.jsx @@ -168,6 +168,7 @@ export const CozyDatePickerInline = ({ date: def, onDateChange }) => { height: '100%', paddingLeft: 16 }} + noWrap > {getStartWeek(date)} - {getEndWeek(date)} From 9f63b4f78c60459858fdf2b461672a5cf5df09e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Poizat?= Date: Mon, 4 Nov 2024 17:16:50 +0100 Subject: [PATCH 3/4] fix: Redirect to correct folder id thanks to accounts and triggers The good way to get the folder id of a pronote account is with accounts and triggers like in this commit. --- manifest.webapp | 5 +++ src/hooks/useCurrentAccountFolderLink.js | 27 +++++++++++----- src/queries/index.js | 39 ++++++++++++++++++------ 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/manifest.webapp b/manifest.webapp index 892ca51..a92ec15 100644 --- a/manifest.webapp +++ b/manifest.webapp @@ -63,6 +63,11 @@ "type": "io.cozy.identities", "description": "Required by Papillon", "verbs": ["GET"] + }, + "triggers": { + "type": "io.cozy.triggers", + "description": "Required by Papillon", + "verbs": ["GET"] } } } diff --git a/src/hooks/useCurrentAccountFolderLink.js b/src/hooks/useCurrentAccountFolderLink.js index 2b68932..a93c791 100644 --- a/src/hooks/useCurrentAccountFolderLink.js +++ b/src/hooks/useCurrentAccountFolderLink.js @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react' -import { buildAccountFolderQuery } from 'src/queries' +import { buildAccountQuery, buildTriggerQuery } from 'src/queries' import { useClient, generateWebLink } from 'cozy-client' @@ -13,21 +13,34 @@ const useCurrentAccountFolderLink = () => { useEffect(() => { const fetchCurrentAccountFolderLink = async () => { - const accountFolderQuery = buildAccountFolderQuery( - currentAccount?.cozyMetadata?.sourceAccountIdentifier + const accountQuery = buildAccountQuery() + + const { data: accountResult } = await client.query( + accountQuery.definition(), + accountQuery.options ) - const { data } = await client.query( - accountFolderQuery.definition(), - accountFolderQuery.options + if (!accountResult[0]?._id) { + return + } + + const triggerQuery = buildTriggerQuery(accountResult[0]._id) + + const { data: triggerResult } = await client.query( + triggerQuery.definition(), + triggerQuery.options ) + if (!triggerResult[0]?.message?.folder_to_save) { + return + } + const webLink = generateWebLink({ cozyUrl: client.getStackClient().uri, slug: 'drive', subDomainType: client.capabilities.flat_subdomains ? 'flat' : 'nested', pathname: '', - hash: `/folder/${data[0]._id}`, + hash: `/folder/${triggerResult[0].message.folder_to_save}`, searchParams: [] }) diff --git a/src/queries/index.js b/src/queries/index.js index 371df2e..207e0ad 100644 --- a/src/queries/index.js +++ b/src/queries/index.js @@ -126,17 +126,38 @@ export const buildPresenceQuery = sourceAccountIdentifier => ({ } }) -export const buildAccountFolderQuery = accountIdentifier => ({ +export const buildAccountQuery = () => ({ definition: () => - Q('io.cozy.files') - .partialIndex({ type: 'directory', trashed: false }) - .referencedBy({ - _id: accountIdentifier, - _type: 'io.cozy.accounts.sourceAccountIdentifier' + Q('io.cozy.accounts') + .where({ + account_type: 'pronote' + }) + .partialIndex({ + account_type: 'pronote' }), options: { - as: 'io.cozy.files/byReferencedAccountIdentifier/' + accountIdentifier, - fetchPolicy: defaultFetchPolicy, - singleDocData: true + as: 'io.cozy.files/account_type/pronote', + fetchPolicy: defaultFetchPolicy + } +}) + +export const buildTriggerQuery = accountId => ({ + definition: () => + Q('io.cozy.triggers') + .where({ + message: { + account: accountId, + konnector: 'pronote' + } + }) + .partialIndex({ + message: { + account: accountId, + konnector: 'pronote' + } + }), + options: { + as: 'io.cozy.triggers/konnector/pronote/account/' + accountId, + fetchPolicy: defaultFetchPolicy } }) From 8657887ea54e761aeee9ce463d447b97803fdf9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Poizat?= Date: Mon, 4 Nov 2024 17:24:22 +0100 Subject: [PATCH 4/4] fix: Do not embed an a element in a element Let's forward the "href" and "_target" props to NavLink to avoid the need of an a element before the NavLink. --- src/components/AppLayout.jsx | 44 ++++++++++++++---------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/src/components/AppLayout.jsx b/src/components/AppLayout.jsx index 744046b..3226a9e 100644 --- a/src/components/AppLayout.jsx +++ b/src/components/AppLayout.jsx @@ -34,12 +34,9 @@ const ExampleRouterNavLink = ({ className, active, activeClassName, - onClick + ...rest }) => ( - + {children} ) @@ -112,28 +109,21 @@ const AppLayout = () => { {currentAccountFolderLink && ( - - - - - {t('Sidebar.documents')} - {!isMobile && ( - - )} - - - + + + + {t('Sidebar.documents')} + {!isMobile && ( + + )} + + )}