Skip to content

Commit

Permalink
fix: Hide path in OnlyOffice editor in public
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Sep 7, 2023
1 parent 541d5f5 commit b857399
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/drive/web/modules/views/OnlyOffice/Editor.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ jest.mock('cozy-ui/transpiled/react/hooks/useBreakpoints', () => ({
jest.mock('cozy-client/dist/hooks/useQuery', () => jest.fn())

jest.mock('cozy-flags')
jest.mock(
'drive/web/modules/views/OnlyOffice/Toolbar/HomeLinker',
() =>
({ children }) =>
<div>{children}</div>
)

const client = createMockClient({})
client.plugins = {
Expand All @@ -49,7 +55,8 @@ client.plugins = {
const setup = ({
isMobile = false,
isEditorModeView = true,
isReadOnly = false
isReadOnly = false,
isPublic = false
} = {}) => {
useBreakpoints.mockReturnValue({ isMobile })
const root = render(
Expand All @@ -66,7 +73,7 @@ const setup = ({
<OnlyOfficeContext.Provider
value={{
fileId: '123',
isPublic: 'false',
isPublic,
isReadOnly,
isEditorReady: true,
isEditorModeView
Expand Down
7 changes: 4 additions & 3 deletions src/drive/web/modules/views/OnlyOffice/Toolbar/FileName.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const useStyles = makeStyles(theme => ({
}
}))

const FileName = ({ fileWithPath }) => {
const FileName = ({ fileWithPath, isPublic }) => {
const muiStyles = useStyles()
const { isMobile } = useBreakpoints()
const { isReadOnly } = useContext(OnlyOfficeContext)
Expand Down Expand Up @@ -66,7 +66,7 @@ const FileName = ({ fileWithPath }) => {
{fileWithPath.name}
</Typography>
)}
{fileWithPath.displayedPath && !isMobile && (
{fileWithPath.displayedPath && !isMobile && !isPublic && (
<Link
data-testid="onlyoffice-filename-path"
to={`/folder/${fileWithPath.dir_id}`}
Expand All @@ -82,7 +82,8 @@ const FileName = ({ fileWithPath }) => {
}

FileName.propTypes = {
fileWithPath: PropTypes.object.isRequired
fileWithPath: PropTypes.object.isRequired,
isPublic: PropTypes.bool
}

export default React.memo(FileName)
2 changes: 1 addition & 1 deletion src/drive/web/modules/views/OnlyOffice/Toolbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const Toolbar = () => {
{!isMobile && fileWithPath.class && (
<FileIcon fileClass={fileWithPath.class} />
)}
<FileName fileWithPath={fileWithPath} />
<FileName fileWithPath={fileWithPath} isPublic={isPublic} />
</div>
{isReadOnly && <ReadOnly />}
{!isPublic && isEditorReady && <Sharing fileWithPath={fileWithPath} />}
Expand Down

0 comments on commit b857399

Please sign in to comment.