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/components/AppLayout.jsx b/src/components/AppLayout.jsx index 7ae16f9..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,16 +109,11 @@ const AppLayout = () => { {currentAccountFolderLink && ( - - - - - {t('Sidebar.documents')} + + + + {t('Sidebar.documents')} + {!isMobile && ( { marginRight: 8 }} /> - - - + )} + + )} 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)} 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 } })