Skip to content

Commit bb79d88

Browse files
committed
chore: Fix lint
1 parent 5ff8247 commit bb79d88

File tree

5 files changed

+147
-113
lines changed

5 files changed

+147
-113
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
node_modules/
33
npm-debug.log
44
yarn-error.log
5+
.yarn/install-state.gz
56

67
# Build
78
build/

src/components/App.jsx

Lines changed: 96 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
import React, { useState, useEffect, useCallback } from 'react'
2+
import { useLocation } from 'react-router-dom'
23

4+
import { BarLeft, BarCenter, BarRight } from 'cozy-bar'
5+
import { Q, useClient, useQuery } from 'cozy-client'
36
import { useExternalBridge } from 'cozy-external-bridge/container'
47
import flag from 'cozy-flags'
5-
6-
import styles from '../styles/iframes.styl'
7-
8-
import { useLocation } from 'react-router-dom'
9-
import { Q, useClient, useQuery } from 'cozy-client'
10-
import { BarLeft, BarCenter, BarRight } from 'cozy-bar'
11-
128
import { ShareModal } from 'cozy-sharing'
13-
9+
import BarTitle from 'cozy-ui/transpiled/react/BarTitle'
1410
import Button from 'cozy-ui/transpiled/react/Buttons'
1511
import Icon from 'cozy-ui/transpiled/react/Icon'
16-
import PlusIcon from 'cozy-ui/transpiled/react/Icons/Plus'
1712
import BurgerIcon from 'cozy-ui/transpiled/react/Icons/Burger'
18-
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
13+
import PlusIcon from 'cozy-ui/transpiled/react/Icons/Plus'
14+
import { CircularProgress } from 'cozy-ui/transpiled/react/Progress'
1915
import Typography from 'cozy-ui/transpiled/react/Typography'
20-
import BarTitle from 'cozy-ui/transpiled/react/BarTitle'
21-
import { CircularProgress } from 'cozy-ui/transpiled/react/Progress';
16+
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
17+
18+
import styles from '../styles/iframes.styl'
2219

2320
const App = () => {
2421
const { pathname } = useLocation()
2522
const client = useClient()
2623
const { isMobile } = useBreakpoints()
2724

2825
// State to manage share modal visibility
29-
const [shareModalOpen, setShareModalOpen] = useState(false);
26+
const [shareModalOpen, setShareModalOpen] = useState(false)
3027

3128
// State to manage drive panel visibility (desktop / mobile)
32-
const [driveOpen, setDriveOpen] = useState(false);
29+
const [driveOpen, setDriveOpen] = useState(false)
3330

3431
// Getting the currently opened file based on the URL
3532
const externalId = pathname.includes('/bridge/docs/')
@@ -53,8 +50,8 @@ const App = () => {
5350

5451
// Getting drive controller URL
5552
const isHTTPS = window.location.protocol === 'https:'
56-
const driveURL = `http${isHTTPS ? 's' : ''}://drive.${client.instanceOptions.domain}`;
57-
const [controllerAppUrl, setControllerAppUrl] = useState(driveURL)
53+
const driveURL = `http${isHTTPS ? 's' : ''}://drive.${client.instanceOptions.domain}`
54+
const controllerAppUrl = driveURL
5855
const [controllerHasLoaded, setControllerHasLoaded] = useState(false)
5956
const [embeddedAppHasLoaded, setEmbeddedAppHasLoaded] = useState(false)
6057

@@ -67,80 +64,101 @@ const App = () => {
6764
if (!currentlyOpenedFile) return
6865
if (!controllerApp.current) return
6966
const directory = currentlyOpenedFile.dir_id
70-
controllerApp.current.contentWindow.postMessage('openFolder:' + directory, '*');
71-
controllerApp.current.contentWindow.postMessage('selectedFile:' + currentlyOpenedFile.id, '*');
67+
controllerApp.current.contentWindow.postMessage(
68+
'openFolder:' + directory,
69+
'*'
70+
)
71+
controllerApp.current.contentWindow.postMessage(
72+
'selectedFile:' + currentlyOpenedFile.id,
73+
'*'
74+
)
7275
}, [currentlyOpenedFile])
7376

7477
// Call synchronization when loaded and on file change (if link opened from Iframe)
7578
useEffect(() => {
76-
updateOpenedFileInController();
77-
}, [currentlyOpenedFile, controllerHasLoaded])
79+
updateOpenedFileInController()
80+
}, [currentlyOpenedFile, controllerHasLoaded, updateOpenedFileInController])
7881

7982
// Intercept messages from both iframes
8083
useEffect(() => {
8184
window.onmessage = function (e) {
82-
if (e.data == undefined || e.data == null || typeof e.data !== "string") return;
85+
if (e.data == undefined || e.data == null || typeof e.data !== 'string')
86+
return
8387
// CONTROLLER : Has loaded
84-
if (e.data === "loaded") {
88+
if (e.data === 'loaded') {
8589
// Save loaded state
8690
if (!controllerHasLoaded) {
87-
setControllerHasLoaded(true);
91+
setControllerHasLoaded(true)
8892
}
8993
// Inform controller that we are in shell (to enable shell specific features)
90-
if (!controllerApp.current) return;
91-
controllerApp.current.contentWindow.postMessage('inShell:true', '*');
94+
if (!controllerApp.current) return
95+
controllerApp.current.contentWindow.postMessage('inShell:true', '*')
9296
// Sync opened file in controller
93-
updateOpenedFileInController();
97+
updateOpenedFileInController()
9498
}
9599

96100
// EMBEDDED : Has loaded
97-
if (e.data === "embedded") {
98-
setEmbeddedAppHasLoaded(true);
101+
if (e.data === 'embedded') {
102+
setEmbeddedAppHasLoaded(true)
99103
}
100104

101105
// CONTROLLER : Open file request
102-
if (e.data.startsWith("openFile:")) {
106+
if (e.data.startsWith('openFile:')) {
103107
// Get fileId
104-
const fileId = e.data.split("openFile:")[1].trim();
108+
const fileId = e.data.split('openFile:')[1].trim()
105109
// Ask EMBEDDED app to open the file in its router
106-
embeddedApp.current.contentWindow.postMessage('openFile:' + fileId, '*');
110+
embeddedApp.current.contentWindow.postMessage('openFile:' + fileId, '*')
107111
}
108112

109113
// EMBEDDED : Share file request
110-
if (e.data === ("shareFile")) {
114+
if (e.data === 'shareFile') {
111115
// Open share modal (knows file from currentlyOpenedFile state)
112-
setShareModalOpen(true);
116+
setShareModalOpen(true)
113117
}
114-
};
115-
}, [])
118+
}
119+
}, [controllerHasLoaded, updateOpenedFileInController])
116120

117121
// Function to create a new document from the CONTROLLER app
118122
const createNewDocument = () => {
119-
if (!embeddedApp.current) return;
123+
if (!embeddedApp.current) return
120124
// Ask EMBEDDED app to create a new document
121-
embeddedApp.current.contentWindow.postMessage('newDoc', '*');
125+
embeddedApp.current.contentWindow.postMessage('newDoc', '*')
122126
}
123127

124128
// Sanitize path for display
125-
const path = currentlyOpenedFile ? currentlyOpenedFile.path.replace(currentlyOpenedFile.name, '') : '';
126-
const sanitizedPath = path.endsWith('/') ? path.slice(0, -1) : path;
129+
const path = currentlyOpenedFile
130+
? currentlyOpenedFile.path.replace(currentlyOpenedFile.name, '')
131+
: ''
132+
const sanitizedPath = path.endsWith('/') ? path.slice(0, -1) : path
127133

128134
return (
129-
<div className={`${styles["iframesContainer"]} ${styles["iframesContainer--" + (isMobile ? "mobile" : "desktop")]}`}>
135+
<div
136+
className={`${styles['iframesContainer']} ${styles['iframesContainer--' + (isMobile ? 'mobile' : 'desktop')]}`}
137+
>
130138
<BarLeft>
131139
<Button
132140
label={
133141
!controllerHasLoaded ? (
134142
<CircularProgress size={20} />
135143
) : (
136-
<Icon icon={BurgerIcon} size={20} color="var(--primaryTextColor)" />
144+
<Icon
145+
icon={BurgerIcon}
146+
size={20}
147+
color="var(--primaryTextColor)"
148+
/>
137149
)
138150
}
139-
variant={"text"}
151+
variant="text"
140152
color="inherit"
141153
size="large"
142154
onClick={() => setDriveOpen(!driveOpen)}
143-
style={{ padding: 0, width: 42, height: 42, margin: "0 8px", marginLeft: !isMobile ? -8 : 4 }}
155+
style={{
156+
padding: 0,
157+
width: 42,
158+
height: 42,
159+
margin: '0 8px',
160+
marginLeft: !isMobile ? -8 : 4
161+
}}
144162
disabled={!controllerHasLoaded}
145163
/>
146164
</BarLeft>
@@ -149,20 +167,30 @@ const App = () => {
149167
<BarCenter>
150168
{currentlyOpenedFile.path ? (
151169
<a
152-
style={{ color: 'inherit', textDecoration: 'none', marginLeft: 4 }}
153-
onClick={(e) => {
154-
e.preventDefault();
170+
style={{
171+
color: 'inherit',
172+
textDecoration: 'none',
173+
marginLeft: 4
174+
}}
175+
onClick={e => {
176+
e.preventDefault()
155177
// Ask CONTROLLER app to open the parent folder
156-
if (!controllerApp.current) return;
157-
controllerApp.current.contentWindow.postMessage('openFolder:' + currentlyOpenedFile.dir_id, '*');
178+
if (!controllerApp.current) return
179+
controllerApp.current.contentWindow.postMessage(
180+
'openFolder:' + currentlyOpenedFile.dir_id,
181+
'*'
182+
)
158183
}}
159184
href="#"
160185
className="u-flex u-flex-column"
161186
>
162-
<Typography variant="subtitle2">{currentlyOpenedFile.name}</Typography>
187+
<Typography variant="subtitle2">
188+
{currentlyOpenedFile.name}
189+
</Typography>
163190
{sanitizedPath && sanitizedPath !== '/' ? (
164191
<Typography variant="caption">{sanitizedPath}</Typography>
165-
) : (<></>
192+
) : (
193+
<></>
166194
)}
167195
</a>
168196
) : (
@@ -171,24 +199,22 @@ const App = () => {
171199
</BarCenter>
172200
) : (
173201
<BarCenter>
174-
<BarTitle>
175-
Docs
176-
</BarTitle>
202+
<BarTitle>Docs</BarTitle>
177203
</BarCenter>
178204
)}
179205

180-
{!isMobile &&
206+
{!isMobile && (
181207
<BarRight>
182208
<Button
183-
label={"Nouveau document"}
184-
variant={"primary"}
209+
label="Nouveau document"
210+
variant="primary"
185211
size="small"
186212
startIcon={<Icon icon={PlusIcon} />}
187213
onClick={() => createNewDocument()}
188-
className={"u-mr-1"}
214+
className="u-mr-1"
189215
/>
190216
</BarRight>
191-
}
217+
)}
192218

193219
{shareModalOpen && currentlyOpenedFile && (
194220
<ShareModal
@@ -200,10 +226,20 @@ const App = () => {
200226
)}
201227

202228
{embeddedAppHasLoaded && (
203-
<iframe ref={controllerApp} className={`${styles["controllerApp"]} ${styles["controllerApp--" + (isMobile ? "mobile" : "desktop")]} ${driveOpen ? styles["open"] : ""}`} id="controllerApp" src={controllerAppUrl}></iframe>
229+
<iframe
230+
ref={controllerApp}
231+
className={`${styles['controllerApp']} ${styles['controllerApp--' + (isMobile ? 'mobile' : 'desktop')]} ${driveOpen ? styles['open'] : ''}`}
232+
id="controllerApp"
233+
src={controllerAppUrl}
234+
></iframe>
204235
)}
205236

206-
<iframe ref={embeddedApp} className={`${styles["embeddedApp"]} ${styles["embeddedApp--" + (isMobile ? "mobile" : "desktop")]}`} id="embeddedApp" src={isReady ? urlToLoad : null}></iframe>
237+
<iframe
238+
ref={embeddedApp}
239+
className={`${styles['embeddedApp']} ${styles['embeddedApp--' + (isMobile ? 'mobile' : 'desktop')]}`}
240+
id="embeddedApp"
241+
src={isReady ? urlToLoad : null}
242+
></iframe>
207243
</div>
208244
)
209245
}

src/components/AppLayout.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import React from 'react'
2-
import { Outlet, useLocation } from 'react-router-dom'
2+
import { Outlet } from 'react-router-dom'
33

4-
import { BarComponent, BarCenter } from 'cozy-bar'
5-
import { Q, useQuery, generateWebLink, useClient } from 'cozy-client'
6-
import BarTitle from 'cozy-ui/transpiled/react/BarTitle'
7-
import Typography from 'cozy-ui/transpiled/react/Typography'
4+
import { BarComponent } from 'cozy-bar'
85

96
const AppLayout = () => {
107
return (

src/components/AppProviders.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { CozyProvider } from 'cozy-client'
55
import { RealTimeQueries } from 'cozy-client'
66
import { DataProxyProvider } from 'cozy-dataproxy-lib'
77
import { WebviewIntentProvider } from 'cozy-intent'
8-
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'
98
import SharingProvider from 'cozy-sharing'
10-
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'
119
import AlertProvider from 'cozy-ui/transpiled/react/providers/Alert'
10+
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'
11+
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'
1212
import { I18n } from 'cozy-ui/transpiled/react/providers/I18n'
1313

1414
const AppProviders = ({ client, lang, polyglot, children }) => {

0 commit comments

Comments
 (0)