Skip to content

Commit

Permalink
feat: Add prefix paper to all routes
Browse files Browse the repository at this point in the history
With the merge of cozy-mespapiers-lib we had this prefix.
We wanted to take advantage of this work to simplify the url,
but several apps/libs use redirection urls including this prefix.

In the end, it doesn't change much...
The fix is faster if you put it back on the app.
  • Loading branch information
Merkur39 committed Jun 10, 2024
1 parent b0c0c80 commit 3e9fc5c
Show file tree
Hide file tree
Showing 21 changed files with 103 additions and 83 deletions.
2 changes: 1 addition & 1 deletion manifest.webapp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@
"accepted_mime_types": ["application/pdf", "image/jpeg", "image/png"],
"max_number_of_files": 1,
"max_size_per_file_in_MB": 10,
"route_to_upload": "/#/create?fromFlagshipUpload=true"
"route_to_upload": "/#/paper/create?fromFlagshipUpload=true"
}
}
2 changes: 1 addition & 1 deletion src/components/Actions/DeleteConfirm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const DeleteConfirm = ({ files, isLast, onClose, children }) => {
}
onClose()
if (isLast || isMultiSelectionActive) {
navigate('/', { replace: true })
navigate('/paper', { replace: true })
}
}, [
clearQualification,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Actions/Items/open.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const open = () => {
cozyUrl: client.getStackClient().uri,
subDomainType: client.getInstanceOptions().subdomain,
pathname: '/',
hash: `/files/${qualificationLabel}/${fileId}`
hash: `/paper/files/${qualificationLabel}/${fileId}`
})

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Actions/Items/select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const select = ({ hideActionsMenu, addMultiSelectionFile }) => {
cozyUrl: client.getStackClient().uri,
subDomainType: client.getInstanceOptions().subdomain,
pathname: '/',
hash: '/multiselect'
hash: '/paper/multiselect'
})

return (
Expand Down
131 changes: 73 additions & 58 deletions src/components/AppRouter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,80 +42,95 @@ export const AppRouter = props => {
<Route errorElement={<ErrorBoundary />}>
<Route element={<CreatePaperDataBackupRoute />}>
<Route element={<AppLayout />} errorElement={<ErrorBoundary />}>
<Route path="/" element={<OutletWrapper Component={Home} />}>
<Route path="editcontact/:fileId" element={<ContactEdit />} />
<Route
path="installAppIntent"
element={<InstallAppFromIntent />}
/>
<Route
path="installKonnectorIntent"
element={<InstallKonnectorFromIntent />}
/>
<Route path="create" element={<PlaceholdersSelector />} />
<Route
path="create/:qualificationLabel"
element={<CreatePaperModalWrapper />}
/>
<Route
path="forward/:fileId"
element={<ForwardModalByRoute />}
/>
<Route path="paper">
<Route index element={<OutletWrapper Component={Home} />} />
<Route element={<OutletWrapper Component={Home} />}>
<Route
path="editcontact/:fileId"
element={<ContactEdit />}
/>
<Route
path="installAppIntent"
element={<InstallAppFromIntent />}
/>
<Route
path="installKonnectorIntent"
element={<InstallKonnectorFromIntent />}
/>
<Route path="create" element={<PlaceholdersSelector />} />
<Route
path="create/:qualificationLabel"
element={<CreatePaperModalWrapper />}
/>
<Route
path="forward/:fileId"
element={<ForwardModalByRoute />}
/>
<Route
path="multiselect"
element={<OutletWrapper Component={MultiselectView} />}
>
<Route
path="forward/:fileId"
element={<ForwardModalByRoute />}
/>
<Route
path="share"
element={<ShareBottomSheetByRoute />}
/>
<Route
path="view/:fileId"
element={
<OutletWrapper Component={FilesViewerWithQuery} />
}
>
{fileViewerRoutes.map(Component => Component)}
</Route>
</Route>
</Route>
<Route
path="multiselect"
element={<OutletWrapper Component={MultiselectView} />}
path="files/:qualificationLabel"
element={
<OutletWrapper Component={ConditionnalPapersList} />
}
>
<Route
path="forward/:fileId"
element={<ForwardModalByRoute />}
/>
<Route path="share" element={<ShareBottomSheetByRoute />} />
<Route
path="view/:fileId"
path="editcontact/:fileId"
element={<ContactEdit />}
/>
<Route
path="installAppIntent"
element={<InstallAppFromIntent />}
/>
<Route
path="installKonnectorIntent"
element={<InstallKonnectorFromIntent />}
/>
<Route path="create" element={<PlaceholdersSelector />} />
<Route
path="create/:qualificationLabel"
element={<CreatePaperModalWrapper />}
/>
<Route
path=":fileId"
element={
<OutletWrapper Component={FilesViewerWithQuery} />
}
>
{fileViewerRoutes.map(Component => Component)}
</Route>
<Route
path="harvest/:connectorSlug/*"
element={<HarvestRoutes />}
/>
</Route>
</Route>
<Route
path="files/:qualificationLabel"
element={<OutletWrapper Component={ConditionnalPapersList} />}
>
<Route
path="forward/:fileId"
element={<ForwardModalByRoute />}
/>
<Route path="share" element={<ShareBottomSheetByRoute />} />
<Route path="editcontact/:fileId" element={<ContactEdit />} />
<Route
path="installAppIntent"
element={<InstallAppFromIntent />}
/>
<Route
path="installKonnectorIntent"
element={<InstallKonnectorFromIntent />}
/>
<Route path="create" element={<PlaceholdersSelector />} />
<Route
path="create/:qualificationLabel"
element={<CreatePaperModalWrapper />}
/>
<Route
path=":fileId"
element={<OutletWrapper Component={FilesViewerWithQuery} />}
>
{fileViewerRoutes.map(Component => Component)}
</Route>
<Route
path="harvest/:connectorSlug/*"
element={<HarvestRoutes />}
/>
</Route>

<Route path="*" element={<Navigate to="/" replace />} />
<Route path="*" element={<Navigate to="/paper" replace />} />
</Route>
</Route>
</Route>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Contexts/MultiSelectionProvider.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('MultiSelectionProvider', () => {
expect(result.current.allMultiSelectionFiles).toEqual([fileMock01])

// isMultiSelectionActive => false
useLocation.mockReturnValue({ pathname: '/' })
useLocation.mockReturnValue({ pathname: '/paper' })

rerender()

Expand Down
2 changes: 1 addition & 1 deletion src/components/CreatePaperDataBackupRoute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const CreatePaperDataBackupRoute = () => {
)

if (qualificationLabel) {
navigate(`/create/${qualificationLabel}`)
navigate(`/paper/create/${qualificationLabel}`)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/ForwardFab/ForwardFab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ForwardFab = () => {
)

const hideForwardFabTooltip = settings?.[0]?.hideForwardFabTooltip
const isHome = pathname === '/'
const isHome = pathname === '/paper'

const open =
isHome && countPaperCreatedByMesPapiers === 1 && !hideForwardFabTooltip
Expand All @@ -54,7 +54,7 @@ const ForwardFab = () => {
className="u-mr-half"
onClick={() => {
hideTooltip()
navigate(`/multiselect`)
navigate(`/paper/multiselect`)
}}
aria-label={t('Home.Fab.forwardPaper')}
>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Harvest/CannotConnectModal/ExtraContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const ExtraContent = () => {
variant="secondary"
label={t('Harvest.cannotConnectModal.button')}
onClick={() =>
navigate(`/files/${qualificationLabel}/create/${qualificationLabel}`)
navigate(
`/paper/files/${qualificationLabel}/create/${qualificationLabel}`
)
}
fullWidth
startIcon={<Icon icon="camera" />}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Multiselect/ForwardModalByRoute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const ForwardModalByRoute = () => {
file={file}
onForward={() =>
isMultiSelectionActive
? navigate('/', { replace: true })
? navigate('/paper', { replace: true })
: navigate('..', { replace: true })
}
onClose={() => navigate('..', { replace: true })}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Multiselect/ShareBottomSheet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ShareBottomSheet = ({ onClose, fileId, docs }) => {
variant: 'filled'
})
if (isMultiSelectionActive) {
navigate('/', { replace: true })
navigate('/paper', { replace: true })
} else {
navigate('..', { replace: true })
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Papers/PaperItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const PaperItem = ({
const route = isMultiSelectionActive
? `multiselect/view`
: `files/${paperTheme}`
navigate(`/${route}/${paper._id}`, {
navigate(`/paper/${route}/${paper._id}`, {
state: { background: `${pathname}${search}` }
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/PapersFab/PapersFab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const PapersFab = () => {

const handleClick = () => {
return generalActions.length === 0
? navigate('/create')
? navigate('/paper/create')
: setShowGeneralMenu(prev => !prev)
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/PapersFab/PapersFab.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('PapersFabWrapper', () => {
fireEvent.click(btn)

expect(mockNavigate).toBeCalledTimes(1)
expect(mockNavigate).toBeCalledWith('/create')
expect(mockNavigate).toBeCalledWith('/paper/create')
})
})

Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchResult/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const makeFlexsearchResultLineOnClick = ({
if (isMultiSelectionActive) {
changeCurrentMultiSelectionFile(doc)
} else {
navigate(`/files/${qualificationLabel}/${doc._id}`, {
navigate(`/paper/files/${qualificationLabel}/${doc._id}`, {
state: navigateState
})
}
Expand Down
11 changes: 7 additions & 4 deletions src/components/SearchResult/helpers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('makeFlexsearchResultLineOnClick', () => {
getInstanceOptions: () => ({ subdomain: 'cozy' })
}
const navigate = jest.fn()
const navigateState = { background: '/search' }
const navigateState = { background: '/paper/search' }
const changeCurrentMultiSelectionFile = jest.fn()

beforeEach(() => {
Expand Down Expand Up @@ -67,9 +67,12 @@ describe('makeFlexsearchResultLineOnClick', () => {
})
onClick()

expect(navigate).toHaveBeenCalledWith('/files/qualificationLabel/fileId', {
state: { background: '/search' }
})
expect(navigate).toHaveBeenCalledWith(
'/paper/files/qualificationLabel/fileId',
{
state: { background: '/paper/search' }
}
)
})

it('should return a function that changes the current multi selection file when the doc is a file and the multi selection is active', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Viewer/SelectFileButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const SelectFileButton = ({ file }) => {
const icon = <Icon icon="select-all" />

const handleClick = () => {
navigate(`/multiselect`)
navigate(`/paper/multiselect`)
addMultiSelectionFile(file)
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Views/CreatePaperModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const CreatePaperModal = () => {
}, [fromFlagshipUpload, navigate, webviewIntent])

const onSubmit = () => {
navigate(`/files/${qualificationLabel}`)
navigate(`/paper/files/${qualificationLabel}`)
}

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Views/PapersList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ConditionnalPapersList = props => {
flag('hide.healthTheme.enabled') &&
getThemeByItem({ label: params.qualificationLabel })?.label === 'health'
) {
return <Navigate replace to="/" />
return <Navigate replace to="/paper" />
}

return <PapersList {...props} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Views/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const buildURLSearchParamsForInstallKonnectorFromIntent = (
) => {
const paramsObj = {
// Useful for redirecting on the route(harvest) opening the login modal
redirectAfterInstall: `/files/${qualificationLabel}/harvest/`,
redirectAfterInstall: `/paper/files/${qualificationLabel}/harvest/`,
...(konnectorCriteria.name && {
slug: konnectorCriteria.name
}),
Expand Down
4 changes: 2 additions & 2 deletions src/notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ class ExpirationNotification extends NotificationView {
}

getExtraAttributes() {
let paperLink = ''
let paperLink = 'paper'

if (!this.#hasMultipleExpiredFiles) {
const file = this.filesInfo[0].file
if (file) {
paperLink = `files/${file.metadata.qualification.label}/${file._id}`
paperLink = `paper/files/${file.metadata.qualification.label}/${file._id}`
}
}

Expand Down

0 comments on commit 3e9fc5c

Please sign in to comment.