diff --git a/src/modules/public/PublicToolbar.jsx b/src/modules/public/PublicToolbar.jsx
index 490bf4bb36..e483512e1b 100644
--- a/src/modules/public/PublicToolbar.jsx
+++ b/src/modules/public/PublicToolbar.jsx
@@ -12,8 +12,7 @@ const PublicToolbar = ({
sharingInfos,
className
}) => {
- const { loading, discoveryLink, sharing, isSharingShortcutCreated } =
- sharingInfos
+ const { loading, discoveryLink } = sharingInfos
if (loading) return null
return (
@@ -28,12 +27,7 @@ const PublicToolbar = ({
refreshFolderContent={refreshFolderContent}
/>
) : (
-
+
)}
)
diff --git a/src/modules/public/PublicToolbarCozyToCozy.jsx b/src/modules/public/PublicToolbarCozyToCozy.jsx
index b41e8296dc..44099916cb 100644
--- a/src/modules/public/PublicToolbarCozyToCozy.jsx
+++ b/src/modules/public/PublicToolbarCozyToCozy.jsx
@@ -1,3 +1,4 @@
+import PropTypes from 'prop-types'
import React from 'react'
import { useClient } from 'cozy-client'
@@ -8,30 +9,34 @@ import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { BarRightOnMobile } from 'components/Bar'
+import useCurrentFolderId from 'hooks/useCurrentFolderId'
import { download, hr, openExternalLink, select } from 'modules/actions'
import { DownloadFilesButton } from 'modules/public/DownloadFilesButton'
import { OpenExternalLinkButton } from 'modules/public/OpenExternalLinkButton'
import PublicToolbarMoreMenu from 'modules/public/PublicToolbarMoreMenu'
import { useSelectionContext } from 'modules/selection/SelectionProvider'
-const PublicToolbarCozyToCozy = ({
- isSharingShortcutCreated,
- discoveryLink,
- files
-}) => {
+const PublicToolbarCozyToCozy = ({ sharingInfos, files }) => {
+ const { loading, discoveryLink, sharing, isSharingShortcutCreated } =
+ sharingInfos
const { isMobile } = useBreakpoints()
const { t } = useI18n()
const { showAlert } = useAlert()
const client = useClient()
const { showSelectionBar } = useSelectionContext()
const vaultClient = useVaultClient()
+ const currentFolderId = useCurrentFolderId()
+
+ const isOnSharedFolder =
+ !loading &&
+ sharing?.rules?.some(rule => rule.values.includes(currentFolderId))
const actions = makeActions(
[
isMobile && download,
files.length > 1 && select,
((isMobile && files.length > 0) || files.length > 1) && hr,
- openExternalLink
+ isOnSharedFolder && openExternalLink
],
{
t,
@@ -47,7 +52,7 @@ const PublicToolbarCozyToCozy = ({
return (
{!isMobile && files.length > 0 && }
- {!isMobile && !isSharingShortcutCreated && (
+ {!isMobile && !isSharingShortcutCreated && isOnSharedFolder && (
{
const sharingInfos = useSharingInfos()
const { showAlert } = useAlert()
const styles = useFabStyles()
+ const isOnSharedFolder =
+ !sharingInfos.loading &&
+ sharingInfos.sharing?.rules?.some(rule =>
+ rule.values.includes(currentFolderId)
+ )
const filesResult = usePublicFilesQuery(currentFolderId)
const files = filesResult.data
@@ -164,6 +169,9 @@ const PublicFolderView = () => {
!sharingInfos.loading && sharingInfos.isSharingShortcutCreated
// Check if you are sharing Cozy to Cozy (Link sharing is on the `/public` route)
const isPreview = window.location.pathname === '/preview'
+ // Show the sharing banner plugin only on shared links view and cozy to cozy sharing view(not added)
+ const isSharingBannerPluginDisplayed =
+ !isShareAlreadyAdded || (isOnSharedFolder && !isPreview)
const isAddToMyCozyFabDisplayed =
isMobile && isPreview && !isShareAlreadyAdded
@@ -172,7 +180,7 @@ const PublicFolderView = () => {
- {!isShareAlreadyAdded && }
+ {isSharingBannerPluginDisplayed && }
{currentFolderId && (