diff --git a/package.json b/package.json index f504946acf..52a414a702 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "cozy-sharing": "^16.0.0", "cozy-stack-client": "^51.0.0", "cozy-tsconfig": "1.2.0", - "cozy-ui": "^113.0.0", + "cozy-ui": "^113.3.0", "cozy-viewer": "^2.6.1", "date-fns": "2.28.0", "es-abstract": "1.20.2", diff --git a/src/components/Sections/actions/groupModeAction.tsx b/src/components/Sections/actions/groupModeAction.tsx index a10d6b2c19..3712a011d1 100644 --- a/src/components/Sections/actions/groupModeAction.tsx +++ b/src/components/Sections/actions/groupModeAction.tsx @@ -17,27 +17,19 @@ import { computeGroupMode, handleSectionAction } from 'components/Sections/utils' - -const StateSwitch = ({ - handleClick, - checked -}: { - handleClick: () => void - checked: boolean -}): JSX.Element => { - return -} +import { useNavigate } from 'react-router-dom' export const groupModeAction = (): (() => Action) => () => ({ name: `sectionAction_group`, Component: React.forwardRef<{ docs?: Section[] }>( function SectionActionComponent(props: { docs?: Section[] }, ref) { + const navigate = useNavigate() const { t } = useI18n() const { isMobile } = useBreakpoints() const { values, save } = useSettings('home', ['shortcutsLayout']) const section = props.docs?.[0] as SectionViewProps['section'] const currentGroupMode = computeGroupMode(isMobile, section) - const handleClick = (): void => + const handleClick = (): void => { handleSectionAction( section, isMobile, @@ -47,17 +39,20 @@ export const groupModeAction = (): (() => Action) => () => ({ values, save ) + if (currentGroupMode === GroupMode.GROUPED) { + navigate('/connected') + } + } return ( - + - - ) diff --git a/src/components/ShortcutLink.jsx b/src/components/ShortcutLink.jsx index a75cade9be..9b0c11db77 100644 --- a/src/components/ShortcutLink.jsx +++ b/src/components/ShortcutLink.jsx @@ -1,7 +1,7 @@ import React from 'react' import get from 'lodash/get' -import { useClient, useFetchShortcut } from 'cozy-client' +import { useClient, useFetchShortcut, useInstanceInfo } from 'cozy-client' import { CozyFile } from 'cozy-doctypes' import SquareAppIcon from 'cozy-ui/transpiled/react/SquareAppIcon' @@ -22,8 +22,9 @@ export const ShortcutLink = ({ // waiting an http request to resolve. const { shortcutInfos } = useFetchShortcut(client, file._id) const { isMobile } = useBreakpoints() - const computedSize = isMobile ? 32 : desktopSize + const instanceInfo = useInstanceInfo() + const computedSize = isMobile ? 32 : desktopSize const { filename } = CozyFile.splitFilename(file) const url = get(shortcutInfos, 'data.attributes.url', '#') @@ -34,6 +35,8 @@ export const ShortcutLink = ({ const icon = get(file, 'attributes.metadata.icon') const iconMimeType = get(file, 'attributes.metadata.iconMimeType') const description = get(file, 'attributes.metadata.description') + const shouldShortcutBadgeHidden = + instanceInfo.context?.data?.hide_shortcut_badge_on_home ?? false return ( } + hideShortcutBadge={shouldShortcutBadgeHidden} /> ) : ( )} diff --git a/src/components/Shortcuts/utils.js b/src/components/Shortcuts/utils.js index dac95ff434..03867ff630 100644 --- a/src/components/Shortcuts/utils.js +++ b/src/components/Shortcuts/utils.js @@ -12,10 +12,8 @@ export const formatShortcuts = (folders, shortcuts) => { return folders .map(folder => ({ id: folder._id, - name: folder.attributes.name, - items: shortcuts.filter( - shortcut => shortcut.attributes.dir_id === folder._id - ) + name: folder.name, + items: shortcuts.filter(shortcut => shortcut.dir_id === folder._id) })) .filter(folder => folder.items.length > 0) } diff --git a/src/components/Shortcuts/utils.spec.js b/src/components/Shortcuts/utils.spec.js index 6488ab4bb2..0cd333a9be 100644 --- a/src/components/Shortcuts/utils.spec.js +++ b/src/components/Shortcuts/utils.spec.js @@ -1,14 +1,11 @@ import { formatShortcuts } from './utils' const directories = [ - { _id: '1', attributes: { name: '1' } }, - { _id: '2', attributes: { name: '2' } } + { _id: '1', name: '1' }, + { _id: '2', name: '2' } ] -const shortcuts = [ - { attributes: { dir_id: '1' } }, - { attributes: { dir_id: '2' } } -] +const shortcuts = [{ dir_id: '1' }, { dir_id: '2' }] const expected = [ { id: '1', name: '1', items: [shortcuts[0]] }, diff --git a/yarn.lock b/yarn.lock index 06eeb1d548..d6667708e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6315,10 +6315,10 @@ cozy-tsconfig@1.2.0: resolved "https://registry.yarnpkg.com/cozy-tsconfig/-/cozy-tsconfig-1.2.0.tgz#17e61f960f139fae4d26cbac2254b9ab632b269e" integrity sha512-TRHnY9goF3FzVlUbP7BcHxuN2XAA4AmppT4fHHZmTKaSwYTByVR1Al+riFMDbce94kJZ1wzl9WNLWQuqzGZ6Cw== -cozy-ui@^113.0.0: - version "113.0.0" - resolved "https://registry.yarnpkg.com/cozy-ui/-/cozy-ui-113.0.0.tgz#5e99de9d2a44a837fa8a69d741b119832a91cb31" - integrity sha512-SoLEPgJSFpIRiTSVPPingNGlzn2S3gbSwnTt7+z84v57PzFVTeOtIo67QucVFKme9DkUagOe+2pDqqCYYK1qTQ== +cozy-ui@^113.3.0: + version "113.3.0" + resolved "https://registry.yarnpkg.com/cozy-ui/-/cozy-ui-113.3.0.tgz#2acd1818a329ec4b8288ca7d603db8580f4ce249" + integrity sha512-D3SMBVBCIA4FFyoiqYeduJtRASlKaLgHAFJ0dSZ4mTc1GcBX++86Y2fU5WcohAtmLtdDoWPD2J4GdhcrzEvYdw== dependencies: "@babel/runtime" "^7.3.4" "@material-ui/core" "4.12.3"