Skip to content

Commit

Permalink
feat: Hide shortcut badge when for some context
Browse files Browse the repository at this point in the history
This make the shortcut tile appears more like apps in some case it could be useful
  • Loading branch information
cballevre committed Nov 18, 2024
1 parent b8b0723 commit f181106
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/ShortcutLink.jsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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', '#')

Expand All @@ -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 (
<Link
Expand Down Expand Up @@ -62,13 +65,15 @@ export const ShortcutLink = ({
alt={filename}
/>
}
hideShortcutBadge={shouldShortcutBadgeHidden}
/>
) : (
<SquareAppIcon
name={filename}
variant="shortcut"
display={display}
description={description}
hideShortcutBadge={shouldShortcutBadgeHidden}
/>
)}
</Link>
Expand Down

0 comments on commit f181106

Please sign in to comment.