Skip to content

Commit a1c3b8e

Browse files
committed
fix/to-show-as-dev
1 parent e88a92b commit a1c3b8e

File tree

5 files changed

+43
-30
lines changed

5 files changed

+43
-30
lines changed

src/frontend/package-lock.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/frontend/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"@next/swc-linux-x64-gnu": "15.3.2"
7272
},
7373
"resolutions": {
74-
"react": "19.1.0",
75-
"react-dom": "19.1.0"
74+
"react": "19.0.0",
75+
"react-dom": "19.0.0"
7676
}
7777
}

src/frontend/src/features/forms/components/message-form/drive-attachment.tsx

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,46 @@
1-
import { SVGProps, useCallback } from "react"
1+
import { SVGProps, useCallback, useState } from "react"
22
import { DriveFile } from "@/pages/drive-selection";
33
import { Button, Tooltip } from "@openfun/cunningham-react"
44
import { openPicker, type Item } from "@gouvfr-lasuite/drive-sdk";
55
import { useTranslation } from "react-i18next";
6+
import { Spinner } from "@gouvfr-lasuite/ui-kit";
67

78
type DriveAttachmentProps = {
89
onChange: (attachments: DriveFile[]) => void;
910
}
1011

1112
export const DriveAttachment = ({ onChange }: DriveAttachmentProps) => {
1213
const { t } = useTranslation();
14+
const [isLoading, setIsLoading] = useState(false);
1315

1416
const pick = useCallback(async () => {
15-
const { items } = await openPicker({
16-
url: "http://localhost:3001/sdk",
17+
setIsLoading(true);
18+
const result = await openPicker({
19+
url: "https://fichiers.sardinepq.fr/sdk",
20+
apiUrl: "https://fichiers.sardinepq.fr/api/v1.0",
1721
});
22+
setIsLoading(false);
1823

19-
onChange(items.map((item: Item) => ({
20-
id: item.id,
21-
name: item.title,
22-
url: item.url,
23-
type: item.mimetype,
24-
size: item.size,
25-
created_at: new Date().toISOString(),
26-
})));
24+
if (result.type === "picked") {
25+
onChange(result.items.map((item: Item) => ({
26+
id: item.id,
27+
name: item.title,
28+
url: item.url,
29+
type: item.mimetype,
30+
size: item.size,
31+
created_at: new Date().toISOString(),
32+
})));
33+
}
2734
}, []);
28-
35+
2936
return (
3037
<Tooltip content={t('tooltips.add_attachment_from_drive')}>
3138
<Button
3239
color="tertiary"
33-
icon={<DriveIcon />}
40+
icon={isLoading ? <Spinner size="sm" /> : <DriveIcon />}
3441
type="button"
42+
disabled={isLoading}
43+
aria-busy={isLoading}
3544
onClick={pick}
3645
/>
3746
</Tooltip>

src/frontend/src/features/i18n/translations.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969
"more_options": "More options",
7070
"reply": "Reply",
7171
"forward": "Forward",
72-
"add_attachment_from_drive": "Add attachment from Drive",
73-
"upload_to_drive": "Upload to Drive"
72+
"add_attachment_from_drive": "Add attachment from Fichiers",
73+
"upload_to_drive": "Upload to Fichiers"
7474
},
7575
"thread-view": {
7676
"trashed-banner": {
@@ -92,7 +92,7 @@
9292
"counter_zero": "No attachments",
9393
"counter_one": "{{count}} attachment",
9494
"counter_other": "{{count}} attachments",
95-
"upload_to_drive_success": "Attachment uploaded to Drive"
95+
"upload_to_drive_success": "Attachment uploaded to Fichiers"
9696
},
9797
"message_form": {
9898
"helper_text": {
@@ -298,8 +298,8 @@
298298
"has_attachments": "Cette email contient une pièce jointe",
299299
"more_options": "Plus d'options",
300300
"reply": "Répondre",
301-
"add_attachment_from_drive": "Ajouter un pièce jointe depuis Drive",
302-
"upload_to_drive": "Sauvegarder dans Drive"
301+
"add_attachment_from_drive": "Ajouter un pièce jointe depuis Fichiers",
302+
"upload_to_drive": "Sauvegarder dans Fichiers"
303303
},
304304
"thread-view": {
305305
"trashed-banner": {
@@ -321,7 +321,7 @@
321321
"counter_zero": "Aucune pièce jointe",
322322
"counter_one": "{{count}} pièce jointe",
323323
"counter_other": "{{count}} pièces jointes",
324-
"upload_to_drive_success": "Pièce jointe sauvegardée dans votre Drive"
324+
"upload_to_drive_success": "Pièce jointe sauvegardée dans Fichiers"
325325
},
326326
"message_form": {
327327
"helper_text": {

src/frontend/src/features/layouts/components/thread-view/components/thread-attachment-list/attachment-item.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,20 @@ type DriveUploadButtonProps = {
111111
const DriveUploadButton = ({ attachment }: DriveUploadButtonProps) => {
112112
const [state, setState] = useState<'idle' | 'busy' | 'success'>('idle');
113113
const { t } = useTranslation();
114-
114+
115115
const handleUpload = useCallback(async () => {
116116
setState('busy');
117117
const file = await fetch(AttachmentHelper.getDownloadUrl(attachment), {
118118
credentials: "include",
119119
}).then(res => res.blob());
120-
await openSaver({
121-
files: [{
122-
title: attachment.name,
123-
object: file
124-
}]
125-
}, {
126-
url: "http://localhost:3001/sdk",
127-
})
120+
// await openSaver({
121+
// files: [{
122+
// title: attachment.name,
123+
// object: file
124+
// }]
125+
// }, {
126+
// url: "http://localhost:3001/sdk",
127+
// })
128128
setTimeout(() => {
129129
setState('success');
130130
setTimeout(() => {

0 commit comments

Comments
 (0)