Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VO-1167] feat: Remove some development flags #3238

Merged
merged 5 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/FolderPicker/FolderPickerListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'

import type { File } from 'components/FolderPicker/types'
import { getFileNameAndExtension } from 'modules/filelist/helpers'
import FileThumbnail from 'modules/filelist/icons/FileThumbnail'

import styles from 'styles/folder-picker.styl'
Expand Down Expand Up @@ -43,6 +44,8 @@ const FolderPickerListItem: FC<FolderPickerListItemProps> = ({
? `${formattedUpdatedAt}${formattedSize ? ` - ${formattedSize}` : ''}`
: undefined

const { title } = getFileNameAndExtension(file, t)

return (
<>
<ListItem
Expand All @@ -62,7 +65,7 @@ const FolderPickerListItem: FC<FolderPickerListItemProps> = ({
}}
/>
</ListItemIcon>
<ListItemText primary={file.name} secondary={secondaryText} />
<ListItemText primary={title} secondary={secondaryText} />
</ListItem>
{showDivider && <Divider />}
</>
Expand Down
3 changes: 1 addition & 2 deletions src/lib/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ const flagsList = () => {
flag('drive.dacc-files-size-by-slug')
flag('drive.breadcrumb.showCompleteBreadcrumbOnPublicPage') // flagName should use kebab case
flag('drive.thumbnails-pdf.enabled')
flag('drive.show-nextcloud-dev')
flag('drive.show-favorites-dev')
flag('drive.hide-nextcloud-dev')
}
5 changes: 1 addition & 4 deletions src/modules/actions/components/addToFavorites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { forwardRef } from 'react'

import { splitFilename } from 'cozy-client/dist/models/file'
import CozyClient from 'cozy-client/types/CozyClient'
import flag from 'cozy-flags'
import { Action } from 'cozy-ui/transpiled/react/ActionsMenu/Actions'
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
Expand All @@ -29,9 +28,7 @@ const addToFavorites = ({
label,
icon,
displayCondition: docs =>
docs.length > 0 &&
docs.every(doc => !doc.cozyMetadata?.favorite) &&
flag('drive.show-favorites-dev'),
docs.length > 0 && docs.every(doc => !doc.cozyMetadata?.favorite),
action: async (files): Promise<void> => {
try {
for (const file of files) {
Expand Down
5 changes: 1 addition & 4 deletions src/modules/actions/components/removeFromFavorites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { forwardRef } from 'react'

import { splitFilename } from 'cozy-client/dist/models/file'
import CozyClient from 'cozy-client/types/CozyClient'
import flag from 'cozy-flags'
import { Action } from 'cozy-ui/transpiled/react/ActionsMenu/Actions'
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
Expand All @@ -29,9 +28,7 @@ const removeFromFavorites = ({
label,
icon,
displayCondition: docs =>
docs.length > 0 &&
docs.every(doc => doc.cozyMetadata?.favorite) &&
flag('drive.show-favorites-dev'),
docs.length > 0 && docs.every(doc => doc.cozyMetadata?.favorite),
action: async (files): Promise<void> => {
try {
for (const file of files) {
Expand Down
40 changes: 3 additions & 37 deletions src/modules/filelist/cells/FileName.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import cx from 'classnames'
import get from 'lodash/get'
import { CozyFile } from 'models'
import React, { useCallback, useMemo } from 'react'
import React, { useCallback } from 'react'
import { Link } from 'react-router-dom'

import { useClient } from 'cozy-client'
import { isDirectory } from 'cozy-client/dist/models/file'
import flag from 'cozy-flags'
import AppIcon from 'cozy-ui/transpiled/react/AppIcon'
import Icon from 'cozy-ui/transpiled/react/Icon'
import CarbonCopyIcon from 'cozy-ui/transpiled/react/Icons/CarbonCopy'
import MidEllipsis from 'cozy-ui/transpiled/react/MidEllipsis'
import { TableCell } from 'cozy-ui/transpiled/react/deprecated/Table'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'

import { TRASH_DIR_ID } from 'constants/config'
import RenameInput from 'modules/drive/RenameInput'
import { getFileNameAndExtension } from 'modules/filelist/helpers'

import styles from 'styles/filelist.styl'

Expand Down Expand Up @@ -93,39 +91,7 @@ const FileName = ({
{ [styles['fil-content-row-disabled']]: isInSyncFromSharing }
)

const { title, filename, extension } = useMemo(() => {
const { filename, extension } = CozyFile.splitFilename(attributes)

if (attributes._id === TRASH_DIR_ID) {
return {
title: t('FileName.trash'),
filename: t('FileName.trash')
}
}

if (attributes._id === 'io.cozy.files.shared-drives-dir') {
return {
title: t('FileName.sharedDrive'),
filename: t('FileName.sharedDrive')
}
}

if (
attributes.cozyMetadata?.createdByApp === 'nextcloud' &&
flag('drive.show-nextcloud-dev')
) {
return {
title: filename,
filename: filename
}
}

return {
title: attributes.name,
filename,
extension
}
}, [attributes, t])
const { title, filename, extension } = getFileNameAndExtension(attributes, t)

return (
<TableCell className={classes}>
Expand Down
43 changes: 43 additions & 0 deletions src/modules/filelist/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { splitFilename } from 'cozy-client/dist/models/file'

import type { File } from 'components/FolderPicker/types'
import { TRASH_DIR_ID } from 'constants/config'
import { isNextcloudShortcut } from 'modules/nextcloud/helpers'

export const getFileNameAndExtension = (
file: File,
t: (key: string) => string
): {
title: string
filename: string
extension?: string
} => {
const { filename, extension } = splitFilename(file)

if (file._id === TRASH_DIR_ID) {
return {
title: t('FileName.trash'),
filename: t('FileName.trash')
}
}

if (file._id === 'io.cozy.files.shared-drives-dir') {
return {
title: t('FileName.sharedDrive'),
filename: t('FileName.sharedDrive')
}
}

if (file._type === 'io.cozy.files' && isNextcloudShortcut(file)) {
return {
title: filename,
filename: filename
}
}

return {
title: file.name,
filename,
extension
}
}
34 changes: 15 additions & 19 deletions src/modules/navigation/AppRoute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const AppRoute = () => (
<Route path="file/:fileId" element={<FilesViewerDrive />} />
</Route>

{flag('drive.show-nextcloud-dev') ? (
{!flag('drive.hide-nextcloud-dev') ? (
<>
<Route
path="nextcloud/:sourceAccount"
Expand All @@ -88,15 +88,13 @@ const AppRoute = () => (
<Route path="delete" element={<NextcloudDeleteView />} />
<Route path="duplicate" element={<NextcloudDuplicateView />} />
</Route>
{flag('drive.show-nextcloud-trash-dev') ? (
<Route
path="nextcloud/:sourceAccount/trash"
element={<NextcloudTrashView />}
>
<Route path="empty" element={<NextcloudTrashEmptyView />} />
<Route path="destroy" element={<NextcloudDestroyView />} />
</Route>
) : null}
<Route
path="nextcloud/:sourceAccount/trash"
element={<NextcloudTrashView />}
>
<Route path="empty" element={<NextcloudTrashEmptyView />} />
<Route path="destroy" element={<NextcloudDestroyView />} />
</Route>
</>
) : null}

Expand Down Expand Up @@ -153,15 +151,13 @@ const AppRoute = () => (
<Route path="file/:fileId" element={<FileOpenerExternal />} />
<Route path="search" element={<SearchView />} />

{flag('drive.show-favorites-dev') ? (
<Route path="favorites" element={<FavoritesView />}>
<Route path="file/:fileId/revision" element={<FileHistory />} />
<Route path="file/:fileId/share" element={<ShareFileView />} />
<Route path="file/:fileId/qualify" element={<QualifyFileView />} />
<Route path="share" element={<ShareDisplayedFolderView />} />
<Route path="move" element={<MoveFilesView />} />
</Route>
) : null}
<Route path="favorites" element={<FavoritesView />}>
<Route path="file/:fileId/revision" element={<FileHistory />} />
<Route path="file/:fileId/share" element={<ShareFileView />} />
<Route path="file/:fileId/qualify" element={<QualifyFileView />} />
<Route path="share" element={<ShareDisplayedFolderView />} />
<Route path="move" element={<MoveFilesView />} />
</Route>
</Route>
</SentryRoutes>
)
Expand Down
5 changes: 2 additions & 3 deletions src/modules/navigation/Nav.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState } from 'react'

import flag from 'cozy-flags'
import UINav from 'cozy-ui/transpiled/react/Nav'
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'

Expand All @@ -21,7 +20,7 @@ export const Nav = () => {
rx={/\/(folder|nextcloud|trash)(\/.*)?/}
clickState={clickState}
/>
{!isDesktop && flag('drive.show-favorites-dev') ? (
{!isDesktop ? (
<NavItem
to="/favorites"
icon="star"
Expand All @@ -38,7 +37,7 @@ export const Nav = () => {
clickState={clickState}
/>
<SharingsNavItem clickState={clickState} />
{isDesktop && flag('drive.show-favorites-dev') ? (
{isDesktop ? (
<FavoriteList clickState={clickState} className="u-mt-half" />
) : null}
</UINav>
Expand Down
3 changes: 0 additions & 3 deletions src/modules/navigation/hooks/helpers.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import flag from 'cozy-flags'

import { computeFileType, computeApp, computePath } from './helpers'
import { TRASH_DIR_ID } from 'constants/config'
import { makeOnlyOfficeFileRoute } from 'modules/views/OnlyOffice/helpers'
Expand Down Expand Up @@ -85,7 +83,6 @@ describe('computeFileType', () => {
createdByApp: 'nextcloud'
}
}
flag.mockReturnValue(true) // mock flag drive.show-nextcloud-dev
expect(computeFileType(file)).toBe('nextcloud')
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { forwardRef } from 'react'

import flag from 'cozy-flags'
import { Action } from 'cozy-ui/transpiled/react/ActionsMenu/Actions'
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
Expand Down Expand Up @@ -48,7 +47,6 @@ export const deleteNextcloudFile = ({
search
})
},
disabled: () => !flag('drive.show-nextcloud-delete-dev'),
Component: forwardRef(function DeleteNextcloudFile(props, ref) {
return (
<ActionsMenuItem {...props} ref={ref}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { forwardRef } from 'react'

import flag from 'cozy-flags'
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
import MovetoIcon from 'cozy-ui/transpiled/react/Icons/Moveto'
Expand All @@ -27,9 +26,7 @@ const moveNextcloud = ({ t, pathname, navigate, search }) => {
search
})
},
disabled: docs =>
docs.some(doc => doc.type === 'directory') ||
!flag('drive.show-nextcloud-move-dev'),
disabled: docs => docs.some(doc => doc.type === 'directory'),
Component: forwardRef(function MoveNextcloud(props, ref) {
return (
<ActionsMenuItem {...props} ref={ref}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { forwardRef } from 'react'

import flag from 'cozy-flags'
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
import LinkOutIcon from 'cozy-ui/transpiled/react/Icons/LinkOut'
Expand All @@ -20,7 +19,6 @@ const shareNextcloudFile = ({ t }) => {
action: docs => {
window.open(docs[0].links.self, '_blank')
},
disabled: () => !flag('drive.show-nextcloud-share-dev'),
Component: forwardRef(function Share(props, ref) {
return (
<ActionsMenuItem {...props} ref={ref}>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/nextcloud/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const isNextcloudShortcut = (file: IOCozyFile): boolean => {
return (
isShortcut(file) &&
file.cozyMetadata?.createdByApp === 'nextcloud' &&
flag('drive.show-nextcloud-dev')
!flag('drive.hide-nextcloud-dev')
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/views/Folder/FolderDuplicateView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const FolderDuplicateView: FC = () => {

return (
<DuplicateModal
showNextcloudFolder={!!flag('drive.show-nextcloud-dev')}
showNextcloudFolder={!flag('drive.hide-nextcloud-dev')}
currentFolder={displayedFolder}
entries={fileResult.data}
onClose={onClose}
Expand Down
7 changes: 3 additions & 4 deletions src/modules/views/Modal/MoveFilesView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react'
import { Navigate, useLocation, useNavigate } from 'react-router-dom'

import { hasQueryBeenLoaded, useQuery } from 'cozy-client'
import flag from 'cozy-flags'

import { LoaderModal } from 'components/LoaderModal'
import useDisplayedFolder from 'hooks/useDisplayedFolder'
Expand Down Expand Up @@ -31,9 +30,9 @@ const MoveFilesView = () => {
navigate('..', { replace: true })
}

const showNextcloudFolder =
flag('drive.show-nextcloud-move-dev') &&
!fileResult.data.some(file => file.type === 'directory')
const showNextcloudFolder = !fileResult.data.some(
file => file.type === 'directory'
)

return (
<MoveModal
Expand Down
3 changes: 1 addition & 2 deletions src/modules/views/Nextcloud/NextcloudFolderView.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import { Outlet, useParams } from 'react-router-dom'

import flag from 'cozy-flags'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'

import { NextcloudBanner } from 'modules/nextcloud/components/NextcloudBanner'
Expand All @@ -24,7 +23,7 @@ const NextcloudFolderView = () => {
})

var queryResults = [nextcloudResult]
if (path === '/' && flag('drive.show-nextcloud-trash-dev')) {
if (path === '/') {
queryResults = [
nextcloudResult,
{
Expand Down
Loading