Skip to content

Commit 2d1bec3

Browse files
committed
fix: Display add tile shortcut if store not installed
Add tile can now : - open shortcut modal (with a flag) - redirect to store (if store installed and not hidden) Let's set these conditions inside the AddTile component to avoid conflicts.
1 parent 17fa222 commit 2d1bec3

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

src/components/AddTile.jsx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import ShortcutCreateModal from './Shortcuts/ShortcutCreateModal'
1313
*
1414
* @returns {JSX.Element} The rendered AddTile component.
1515
*/
16-
const AddTile = () => {
16+
const AddTile = ({ isStoreAvailable }) => {
1717
const client = useClient()
1818
const nativePath = '/discover'
1919
const slug = 'store'
@@ -38,25 +38,29 @@ const AddTile = () => {
3838
)
3939
}
4040

41-
return (
42-
<AppLinker
43-
app={{ slug: 'store' }}
44-
nativePath={nativePath}
45-
href={generateWebLink({
46-
pathname: '/',
47-
cozyUrl: cozyURL.origin,
48-
slug,
49-
hash: nativePath,
50-
subDomainType
51-
})}
52-
>
53-
{({ onClick, href }) => (
54-
<a onClick={onClick} href={href} className={styles['scale-hover']}>
55-
<SquareAppIcon name={t('add_service')} variant="add" />
56-
</a>
57-
)}
58-
</AppLinker>
59-
)
41+
if (isStoreAvailable) {
42+
return (
43+
<AppLinker
44+
app={{ slug: 'store' }}
45+
nativePath={nativePath}
46+
href={generateWebLink({
47+
pathname: '/',
48+
cozyUrl: cozyURL.origin,
49+
slug,
50+
hash: nativePath,
51+
subDomainType
52+
})}
53+
>
54+
{({ onClick, href }) => (
55+
<a onClick={onClick} href={href} className={styles['scale-hover']}>
56+
<SquareAppIcon name={t('add_service')} variant="add" />
57+
</a>
58+
)}
59+
</AppLinker>
60+
)
61+
}
62+
63+
return null
6064
}
6165

6266
export default AddTile

src/components/ApplicationsAndServices.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const ApplicationsAndServices = () => {
3636
<EntrypointLink key={entrypoint.name} entrypoint={entrypoint} />
3737
))}
3838
{isMobile && flag('cozy.assistant.enabled') && <AssistantTile />}
39-
{isStoreAvailable && <AddTile />}
39+
<AddTile isStoreAvailable={isStoreAvailable} />
4040
{showLogout && <LogoutTile />}
4141
</div>
4242
</div>

0 commit comments

Comments
 (0)