From d2d953bcbd584d535952400ac43491bf7e9b902b Mon Sep 17 00:00:00 2001 From: Antonin Cezard Date: Tue, 22 Aug 2023 15:49:59 +0200 Subject: [PATCH] feat: Update manifest to add acceptFromFlagship - Also add placeholder route that will handle mobile uploads later --- src/drive/targets/manifest.webapp | 7 +++++++ src/drive/web/modules/navigation/AppRoute.jsx | 2 ++ .../views/Upload/UploadFromFlagship.jsx | 13 ++++++++++++ .../views/Upload/useUploadFromFlagship.js | 20 +++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 src/drive/web/modules/views/Upload/UploadFromFlagship.jsx create mode 100644 src/drive/web/modules/views/Upload/useUploadFromFlagship.js diff --git a/src/drive/targets/manifest.webapp b/src/drive/targets/manifest.webapp index 20c8cf1ea0..809478d059 100644 --- a/src/drive/targets/manifest.webapp +++ b/src/drive/targets/manifest.webapp @@ -175,5 +175,12 @@ "verbs": ["POST"], "description": "Remote-doctype required to send anonymized measures to the DACC shared among mycozy.eu's Cozy." } + }, + "accept_from_flagship": true, + "accept_documents_from_flagship": { + "accepted_mime_types": ["*/*"], + "max_number_of_files": 1, + "max_size_per_file_in_MB": 10, + "route_to_upload": "/#/create?fromFlagshipUpload=true" } } diff --git a/src/drive/web/modules/navigation/AppRoute.jsx b/src/drive/web/modules/navigation/AppRoute.jsx index cfe26a8c7c..aff94b1361 100644 --- a/src/drive/web/modules/navigation/AppRoute.jsx +++ b/src/drive/web/modules/navigation/AppRoute.jsx @@ -26,6 +26,7 @@ import SearchView from '../views/Search/SearchView' import OnlyOfficePaywallView from '../views/OnlyOffice/OnlyOfficePaywallView' import FilesViewerRecent from '../views/Recent/FilesViewerRecent' import { ShareDisplayedFolderView } from 'drive/web/modules/views/Modal/ShareDisplayedFolderView' +import { CreateFromFlagship } from '../views/Upload/UploadFromFlagship' const FilesRedirect = () => { const { folderId } = useParams() @@ -39,6 +40,7 @@ const AppRoute = () => ( {__TARGET__ === 'mobile' && ( } /> )} + } /> } /> } /> diff --git a/src/drive/web/modules/views/Upload/UploadFromFlagship.jsx b/src/drive/web/modules/views/Upload/UploadFromFlagship.jsx new file mode 100644 index 0000000000..4ca80b6585 --- /dev/null +++ b/src/drive/web/modules/views/Upload/UploadFromFlagship.jsx @@ -0,0 +1,13 @@ +import React from 'react' +import { useUploadFromFlagship } from './useUploadFromFlagship' + +export const UploadFromFlagship = () => { + const { loading } = useUploadFromFlagship() + + return ( +
+

Upload From Flagship Page

+

{loading ? 'loading' : 'Ready to call hasFilesToHandle'}

+
+ ) +} diff --git a/src/drive/web/modules/views/Upload/useUploadFromFlagship.js b/src/drive/web/modules/views/Upload/useUploadFromFlagship.js new file mode 100644 index 0000000000..fb91cd959b --- /dev/null +++ b/src/drive/web/modules/views/Upload/useUploadFromFlagship.js @@ -0,0 +1,20 @@ +import { useSearchParams } from 'react-router-dom' +import { useWebviewIntent } from 'cozy-intent' +import { useEffect, useState } from 'react' + +export const useUploadFromFlagship = () => { + const [loading, setLoading] = useState(true) + const [searchParams] = useSearchParams() + const webviewIntent = useWebviewIntent() + const fromFlagshipUpload = searchParams.get('fromFlagshipUpload') + + useEffect(() => { + if (fromFlagshipUpload && webviewIntent) { + setLoading(false) + } + }, [fromFlagshipUpload, webviewIntent]) + + return { + loading + } +}