Skip to content

Commit d360706

Browse files
committed
fix(onlyoffice): remove dead edit toggle button from toolbar
The "Edit" button (next to "Share") was a view->edit toggle, disabled whenever editorMode !== 'view'. Since the provider force-edits as soon as the user has write access on the io.cozy.files document, the button is permanently greyed out wherever it is shown (mobile/desktop, private/public), exactly like the ReadOnlyFab removed previously. Its hidden paywall redirect is also already unreachable (only fires in view mode) and the existing-file paywall is enforced server-side by the stack returning mode: 'view'; document creation keeps its own paywall entry points. So nothing functional is lost. Remove the button, its now-dead helpers and the related i18n keys. NOTE: the OnlyOffice flows need to be clarified again, there are quite a few inconsistencies (force-edit vs paywall vs hasWriteAccess vs stack mode, viewer "open" button without paywall check, etc.).
1 parent 6e57cbe commit d360706

4 files changed

Lines changed: 4 additions & 167 deletions

File tree

src/locales/en.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -569,16 +569,7 @@
569569
"goToHome": "Go to home"
570570
},
571571
"actions": {
572-
"edit": "Edit",
573572
"validate": "Validate"
574-
},
575-
"tooltip": {
576-
"title": "Edit document",
577-
"text": "The document is currently read-only. You can modify it by clicking here.",
578-
"actions": {
579-
"ok": "Ok",
580-
"hide": "Do not display"
581-
}
582573
}
583574
},
584575
"Migration": {

src/modules/views/OnlyOffice/Toolbar/EditButton.jsx

Lines changed: 0 additions & 135 deletions
This file was deleted.

src/modules/views/OnlyOffice/Toolbar/index.jsx

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@ import Sharing from '@/components/EditorToolbar/Sharing'
1616
import { useRedirectLink } from '@/hooks/useRedirectLink'
1717
import PublicToolbarMoreMenu from '@/modules/public/PublicToolbarMoreMenu'
1818
import { useOnlyOfficeContext } from '@/modules/views/OnlyOffice/OnlyOfficeProvider'
19-
import EditButton from '@/modules/views/OnlyOffice/Toolbar/EditButton'
2019
import FileIcon from '@/modules/views/OnlyOffice/Toolbar/FileIcon'
2120
import SummarizeByAIButtonWrapper from '@/modules/views/OnlyOffice/Toolbar/SummarizeByAIButtonWrapper'
22-
import { isOfficeEditingEnabled } from '@/modules/views/OnlyOffice/helpers'
2321
import EditorTitleStart from '@/modules/views/editor/EditorTitleStart'
2422
import { buildFileOrFolderByIdQuery, buildFileWhereByIdQuery } from '@/queries'
2523

2624
const Toolbar = ({ sharingInfos }) => {
27-
const { isMobile, isDesktop } = useBreakpoints()
25+
const { isMobile } = useBreakpoints()
2826
const [searchParams] = useSearchParams(window.location.search)
29-
const { isEditorReady, isReadOnly, isTrashed, fileId, isPublic } =
30-
useOnlyOfficeContext()
27+
const { isEditorReady, isReadOnly, fileId, isPublic } = useOnlyOfficeContext()
3128
const { t } = useI18n()
3229
const { redirectBack, canRedirect } = useRedirectLink({ isPublic })
3330

@@ -77,14 +74,6 @@ const Toolbar = ({ sharingInfos }) => {
7774
isSharingShortcutCreated
7875
}
7976
)
80-
const canEdit =
81-
isEditorReady &&
82-
!isReadOnly &&
83-
!isTrashed &&
84-
isOfficeEditingEnabled(isDesktop)
85-
86-
const showPublicEditButton = isPublic && !isMobile && canEdit
87-
8877
const showSharingLinkButton =
8978
isPublic && !isMobile && isShareNotAdded && !isCozyToCozySharingSynced
9079

@@ -102,23 +91,17 @@ const Toolbar = ({ sharingInfos }) => {
10291
<OpenSharingLinkButton
10392
link={link}
10493
isSharingShortcutCreated={isSharingShortcutCreated}
105-
variant={showPublicEditButton ? 'secondary' : 'primary'}
94+
variant="primary"
10695
/>
10796
)}
108-
{showPublicEditButton && <EditButton />}
10997

11098
{isPublic && !isCozyToCozySharingSynced && (
11199
<PublicToolbarMoreMenu files={[file]} actions={actions} />
112100
)}
113101

114102
<SummarizeByAIButtonWrapper isLoaded={isEditorReady} />
115103

116-
{!isPublic && isEditorReady && (
117-
<>
118-
<Sharing file={file} />
119-
{canEdit && <EditButton />}
120-
</>
121-
)}
104+
{!isPublic && isEditorReady && <Sharing file={file} />}
122105
</>
123106
)
124107
}

src/modules/views/OnlyOffice/Toolbar/index.spec.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ const setup = ({
7777
isPublic = false,
7878
isFromSharing = false,
7979
isMobile = false,
80-
isEditorModeView = false,
8180
sharingInfos = {}
8281
} = {}) => {
8382
const sharingInfosProps = {
@@ -98,7 +97,6 @@ const setup = ({
9897
value={{
9998
fileId: officeDoc.id,
10099
isPublic,
101-
isEditorModeView,
102100
isFromSharing,
103101
isReadOnly,
104102
isEditorReady: true

0 commit comments

Comments
 (0)