diff --git a/src/components/FolderPicker/FolderPickerListItem.tsx b/src/components/FolderPicker/FolderPickerListItem.tsx index 6f62dece4f..1e5df6665c 100644 --- a/src/components/FolderPicker/FolderPickerListItem.tsx +++ b/src/components/FolderPicker/FolderPickerListItem.tsx @@ -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' @@ -43,6 +44,8 @@ const FolderPickerListItem: FC = ({ ? `${formattedUpdatedAt}${formattedSize ? ` - ${formattedSize}` : ''}` : undefined + const { title } = getFileNameAndExtension(file, t) + return ( <> = ({ }} /> - + {showDivider && } diff --git a/src/lib/flags.js b/src/lib/flags.js index 12e2055ebf..d4bd65f8e7 100644 --- a/src/lib/flags.js +++ b/src/lib/flags.js @@ -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') } diff --git a/src/modules/actions/components/addToFavorites.tsx b/src/modules/actions/components/addToFavorites.tsx index 61fe56b8e4..6fa51ab4ce 100644 --- a/src/modules/actions/components/addToFavorites.tsx +++ b/src/modules/actions/components/addToFavorites.tsx @@ -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' @@ -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 => { try { for (const file of files) { diff --git a/src/modules/actions/components/removeFromFavorites.tsx b/src/modules/actions/components/removeFromFavorites.tsx index 4e7f56e5b0..f5e0f2e1d0 100644 --- a/src/modules/actions/components/removeFromFavorites.tsx +++ b/src/modules/actions/components/removeFromFavorites.tsx @@ -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' @@ -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 => { try { for (const file of files) { diff --git a/src/modules/filelist/cells/FileName.jsx b/src/modules/filelist/cells/FileName.jsx index 021867ba56..2375771844 100644 --- a/src/modules/filelist/cells/FileName.jsx +++ b/src/modules/filelist/cells/FileName.jsx @@ -1,12 +1,10 @@ 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' @@ -14,8 +12,8 @@ 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' @@ -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 ( diff --git a/src/modules/filelist/helpers.ts b/src/modules/filelist/helpers.ts new file mode 100644 index 0000000000..7bb7ce63df --- /dev/null +++ b/src/modules/filelist/helpers.ts @@ -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 + } +} diff --git a/src/modules/navigation/AppRoute.jsx b/src/modules/navigation/AppRoute.jsx index 1092a6325f..36e868da98 100644 --- a/src/modules/navigation/AppRoute.jsx +++ b/src/modules/navigation/AppRoute.jsx @@ -78,7 +78,7 @@ const AppRoute = () => ( } /> - {flag('drive.show-nextcloud-dev') ? ( + {!flag('drive.hide-nextcloud-dev') ? ( <> ( } /> } /> - {flag('drive.show-nextcloud-trash-dev') ? ( - } - > - } /> - } /> - - ) : null} + } + > + } /> + } /> + ) : null} @@ -153,15 +151,13 @@ const AppRoute = () => ( } /> } /> - {flag('drive.show-favorites-dev') ? ( - }> - } /> - } /> - } /> - } /> - } /> - - ) : null} + }> + } /> + } /> + } /> + } /> + } /> + ) diff --git a/src/modules/navigation/Nav.jsx b/src/modules/navigation/Nav.jsx index 73e4f71ce7..9a1f621a92 100644 --- a/src/modules/navigation/Nav.jsx +++ b/src/modules/navigation/Nav.jsx @@ -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' @@ -21,7 +20,7 @@ export const Nav = () => { rx={/\/(folder|nextcloud|trash)(\/.*)?/} clickState={clickState} /> - {!isDesktop && flag('drive.show-favorites-dev') ? ( + {!isDesktop ? ( { clickState={clickState} /> - {isDesktop && flag('drive.show-favorites-dev') ? ( + {isDesktop ? ( ) : null} diff --git a/src/modules/navigation/hooks/helpers.spec.js b/src/modules/navigation/hooks/helpers.spec.js index 2b8eee14d9..193593807b 100644 --- a/src/modules/navigation/hooks/helpers.spec.js +++ b/src/modules/navigation/hooks/helpers.spec.js @@ -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' @@ -85,7 +83,6 @@ describe('computeFileType', () => { createdByApp: 'nextcloud' } } - flag.mockReturnValue(true) // mock flag drive.show-nextcloud-dev expect(computeFileType(file)).toBe('nextcloud') }) diff --git a/src/modules/nextcloud/components/actions/deleteNextcloudFile.tsx b/src/modules/nextcloud/components/actions/deleteNextcloudFile.tsx index 704b30c0e4..1aa1694eb5 100644 --- a/src/modules/nextcloud/components/actions/deleteNextcloudFile.tsx +++ b/src/modules/nextcloud/components/actions/deleteNextcloudFile.tsx @@ -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' @@ -48,7 +47,6 @@ export const deleteNextcloudFile = ({ search }) }, - disabled: () => !flag('drive.show-nextcloud-delete-dev'), Component: forwardRef(function DeleteNextcloudFile(props, ref) { return ( diff --git a/src/modules/nextcloud/components/actions/moveNextcloud.jsx b/src/modules/nextcloud/components/actions/moveNextcloud.jsx index c5c2c93899..2de49f7087 100644 --- a/src/modules/nextcloud/components/actions/moveNextcloud.jsx +++ b/src/modules/nextcloud/components/actions/moveNextcloud.jsx @@ -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' @@ -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 ( diff --git a/src/modules/nextcloud/components/actions/shareNextcloudFile.jsx b/src/modules/nextcloud/components/actions/shareNextcloudFile.jsx index 0241a61648..d293c1bc47 100644 --- a/src/modules/nextcloud/components/actions/shareNextcloudFile.jsx +++ b/src/modules/nextcloud/components/actions/shareNextcloudFile.jsx @@ -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' @@ -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 ( diff --git a/src/modules/nextcloud/helpers.ts b/src/modules/nextcloud/helpers.ts index 361f79557f..f3703512f6 100644 --- a/src/modules/nextcloud/helpers.ts +++ b/src/modules/nextcloud/helpers.ts @@ -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') ) } diff --git a/src/modules/views/Folder/FolderDuplicateView.tsx b/src/modules/views/Folder/FolderDuplicateView.tsx index b8c39f3de7..a62b9b336e 100644 --- a/src/modules/views/Folder/FolderDuplicateView.tsx +++ b/src/modules/views/Folder/FolderDuplicateView.tsx @@ -38,7 +38,7 @@ const FolderDuplicateView: FC = () => { return ( { 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 ( { }) var queryResults = [nextcloudResult] - if (path === '/' && flag('drive.show-nextcloud-trash-dev')) { + if (path === '/') { queryResults = [ nextcloudResult, {