Skip to content

Commit

Permalink
feat(sharing): use @nextcloud/sharing to detect is public share
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <[email protected]>
  • Loading branch information
elzody committed Sep 17, 2024
1 parent fdfca61 commit 156736f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,4 @@ export {

export { default as isDocument } from './isDocument.js'
export { default as isPdf } from './isPdf.js'
export { default as isPublic } from './isPublicPage.js'
export { default as isDownloadHidden } from './isDownloadHidden.js'
16 changes: 0 additions & 16 deletions src/helpers/isPublicPage.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { isPublicShare } from '@nextcloud/sharing/public'
import {
isPublic,
isPdf,
isDocument,
isDownloadHidden,
Expand All @@ -13,7 +13,7 @@ import { getCapabilities } from './services/capabilities.ts'
import NewFileMenu from './view/NewFileMenu.js'

document.addEventListener('DOMContentLoaded', () => {
if (!isPublic() || !OCA.Viewer) {
if (!isPublicShare() || !OCA.Viewer) {
return
}

Expand Down
13 changes: 6 additions & 7 deletions src/view/FilesAppIntegration.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { generateUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { getFilePickerBuilder, spawnDialog } from '@nextcloud/dialogs'
import { isPublicShare } from '@nextcloud/sharing/public'
import axios from '@nextcloud/axios'
import { emit } from '@nextcloud/event-bus'
import { getCurrentDirectory } from '../helpers/filesApp.js'
Expand All @@ -17,8 +18,6 @@ import {
} from '@nextcloud/files'
import SaveAs from '../components/Modal/SaveAs.vue'

const isPublic = document.getElementById('isPublic') && document.getElementById('isPublic').value === '1'

export default {

fileNode: undefined,
Expand Down Expand Up @@ -126,7 +125,7 @@ export default {
return
}

if (isPublic) {
if (isPublicShare()) {
console.error('[FilesAppIntegration] Sharing is not supported')
return
}
Expand All @@ -150,7 +149,7 @@ export default {
},

insertGraphic(insertFile) {
if (isPublic) {
if (isPublicShare()) {
console.error('[FilesAppIntegration] insertGraphic is not supported')
}

Expand Down Expand Up @@ -322,7 +321,7 @@ export default {
}
entry.append(label)

const isFileOwner = !isPublic && this.getFileModel() && typeof this.getFileModel().get('shareOwner') === 'undefined'
const isFileOwner = !isPublicShare() && this.getFileModel() && typeof this.getFileModel().get('shareOwner') === 'undefined'
const canEdit = this.getFileModel() && !!(this.getFileModel().get('permissions') & OC.PERMISSION_UPDATE)
if (isFileOwner && canEdit && !view.IsCurrentView) {
const removeButton = $('<div class="icon-close" title="' + t('richdocuments', 'Remove user') + '"/>')
Expand Down Expand Up @@ -406,7 +405,7 @@ export default {
return
}

if (isPublic || !OCA?.Files?.Sidebar) {
if (isPublicShare() || !OCA?.Files?.Sidebar) {
console.error('[FilesAppIntegration] Versions are not supported')
return
}
Expand Down Expand Up @@ -491,7 +490,7 @@ export default {
},

async getFileNode(forceFetch = false) {
if (isPublic) {
if (isPublicShare()) {
return
}

Expand Down
4 changes: 2 additions & 2 deletions src/view/Office.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import {
generateUrl,
imagePath,
} from '@nextcloud/router'
import { isPublicShare, getSharingToken } from '@nextcloud/sharing/public'
import { getCapabilities } from './../services/capabilities.ts'
import {
generateCSSVarTokens,
Expand All @@ -117,7 +118,6 @@ import saveAs from '../mixins/saveAs.js'
import uiMention from '../mixins/uiMention.js'
import version from '../mixins/version.js'
import { getCurrentUser, getGuestNickname } from '@nextcloud/auth'
import { getSharingToken } from '@nextcloud/sharing/public'
import { shouldAskForGuestName } from '../helpers/guestName.js'
const FRAME_DOCUMENT = 'FRAME_DOCUMENT'
Expand Down Expand Up @@ -231,7 +231,7 @@ export default {
return !!window.TESTING
},
isPublic() {
return document.getElementById('isPublic')?.value === '1'
return isPublicShare()
},
shareToken() {
return getSharingToken()
Expand Down

0 comments on commit 156736f

Please sign in to comment.