Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36,982 changes: 15,871 additions & 21,111 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"dependencies": {
"@nextcloud/auth": "^2.1.0",
"@nextcloud/axios": "^2.3.0",
"@nextcloud/dialogs": "^5.0.0-beta.4",
"@nextcloud/dialogs": "^6.3.1",
"@nextcloud/event-bus": "^3.1.0",
"@nextcloud/files": "^3.0.0-beta.22",
"@nextcloud/files": "^3.12.2",
"@nextcloud/l10n": "^2.1.0",
"@nextcloud/logger": "^2.5.0",
"@nextcloud/router": "^2.1.2",
"@nextcloud/typings": "^1.7.0",
"@nextcloud/vue": "^8.0.0-beta.5",
"@nextcloud/vue": "^8.23.1",
"focus-trap": "^7.5.2",
"p-queue": "^7.4.1",
"pinia": "^2.1.6",
Expand All @@ -47,6 +47,7 @@
"@nextcloud/sharing": "^0.1.0",
"@nextcloud/webpack-vue-config": "^5.5.1",
"@vue/tsconfig": "^0.4.0",
"babel-loader": "^9.1.3",
"css-loader": "^6.8.1",
"sass": "^1.66.1",
"sass-loader": "^13.3.2",
Expand Down
21 changes: 20 additions & 1 deletion src/action.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
import { registerFileAction } from '@nextcloud/files'
import { action as statusAtion } from './actions/sharingStatusAction'
import { action as popupAction } from './actions/sharingPopupAction'
import { action as popupMenuAction } from './actions/sharingPopupMenuAction'

/**
* The app is built against @nextcloud/files v3, but on NC33 core reads file
* actions from the version-scoped window._nc_files_scope.v4_0.fileActions Map,
* not the legacy window._nc_fileactions global that v3 writes to. Register
* directly into that Map (first registration per id wins).
*
* @param {object} action the file action to register (needs a string `id`)
*/
function registerFileAction(action) {
const filesScope = (window._nc_files_scope ??= {})
const v4 = (filesScope.v4_0 ??= {})
const actions = (v4.fileActions ??= new Map())

if (actions.has(action.id)) {
return
}

actions.set(action.id, action)
}

registerFileAction(statusAtion)
registerFileAction(popupAction)
registerFileAction(popupMenuAction)
69 changes: 31 additions & 38 deletions src/actions/sharingPopupAction.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FileAction, Permission } from '@nextcloud/files'
import { Permission } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'

export const action = new FileAction({
export const action = {
id: 'sharing-popup',
displayName(nodes) {
displayName({ nodes }) {
const node = nodes[0]
const sharedWithMe = node?.attributes?.['mount-type'] === 'shared'

Expand All @@ -20,15 +20,15 @@ export const action = new FileAction({
return ''
},

title(nodes) {
title() {
return t('nmcsharing', 'Show sharing options')
},

iconSvgInline() {
return ''
},

enabled(nodes) {
enabled({ nodes }) {
if (nodes.length !== 1) {
return false
}
Expand Down Expand Up @@ -57,41 +57,34 @@ export const action = new FileAction({
// return (node.permissions & Permission.SHARE) !== 0
},

async exec(node, view, dir) {
// You need read permissions to see the sidebar
if ((node.permissions & Permission.READ) !== 0) {
setTimeout(() => {
const currentUrl = window.location.search

if (currentUrl.includes('popup')) {
document.querySelector('#app-sidebar-vue').style.width = '0%'
}
})
window.OCA.Files.Sidebar.close()

window.OCA.Files.Sidebar.setActiveTab('sharing-manage')
window.OCA.Files.Sidebar.setActiveTab('sharing')
window.OCA.Files.Sidebar.setFullScreenMode(true)

// TODO: migrate Sidebar to use a Node instead
window.OCA.Files.Sidebar.open(node.path)

try {
// Silently update current fileid
window.OCP.Files.Router.goToRoute(
null,
{ view: view.id, fileid: node.fileid },
{ ...window.OCP.Files.Router.query, dir, popup: 'true' },
true,
)

return null
} catch (error) {
return false
}
async exec({ nodes }) {
const node = nodes[0]

// You need read permissions to share
if ((node.permissions & Permission.READ) === 0) {
return false
}

const openSharingPopup = window.OCA?.Nmcsharing?.openSharingPopup
if (typeof openSharingPopup !== 'function') {
return false
}

// Open the MagentaCLOUD sharing popup modal for this node.
// The popup is mounted by files_sharing_popup.js, which exposes the
// opener globally; it expects a legacy FileInfo shape, so map the Node.
openSharingPopup({
id: node.fileid,
name: node.basename,
path: node.dirname,
size: node.size,
permissions: node.permissions,
mime: node.mime,
})

return null
},

inline: () => true,

})
}
67 changes: 29 additions & 38 deletions src/actions/sharingPopupMenuAction.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { FileAction, Permission } from '@nextcloud/files'
import { Permission } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'

export const action = new FileAction({
export const action = {
id: 'sharing-popup-menu',
displayName(nodes) {
displayName() {
return t('files_sharing', 'Share')
},

title(nodes) {
title() {
return t('nmcsharing', 'Show sharing options')
},

iconSvgInline() {
return ''
},

enabled(nodes) {
enabled({ nodes }) {
if (nodes.length !== 1) {
return false
}
Expand All @@ -42,41 +42,32 @@ export const action = new FileAction({
return (node.permissions & Permission.SHARE) !== 0
},

async exec(node, view, dir) {
// You need read permissions to see the sidebar
if ((node.permissions & Permission.READ) !== 0) {
setTimeout(() => {
const currentUrl = window.location.search

if (currentUrl.includes('popup')) {
document.querySelector('#app-sidebar-vue').style.width = '0%'
}
})
window.OCA.Files.Sidebar.close()

window.OCA.Files.Sidebar.setActiveTab('sharing-manage')
window.OCA.Files.Sidebar.setActiveTab('sharing')
window.OCA.Files.Sidebar.setFullScreenMode(true)

// TODO: migrate Sidebar to use a Node instead
window.OCA.Files.Sidebar.open(node.path)

try {
// Silently update current fileid
window.OCP.Files.Router.goToRoute(
null,
{ view: view.id, fileid: node.fileid },
{ ...window.OCP.Files.Router.query, dir, popup: 'true' },
true,
)

return null
} catch (error) {
return false
}
async exec({ nodes }) {
const node = nodes[0]

// You need read permissions to share
if ((node.permissions & Permission.READ) === 0) {
return false
}

const openSharingPopup = window.OCA?.Nmcsharing?.openSharingPopup
if (typeof openSharingPopup !== 'function') {
return false
}

// Open the MagentaCLOUD sharing popup modal for this node.
openSharingPopup({
id: node.fileid,
name: node.basename,
path: node.dirname,
size: node.size,
permissions: node.permissions,
mime: node.mime,
})

return null
},

order: -61,

})
}
44 changes: 18 additions & 26 deletions src/actions/sharingStatusAction.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FileAction, Permission } from '@nextcloud/files'
import { Permission } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'

export const action = new FileAction({
export const action = {
id: 'sharing-manage',
displayName() {
return t('nmcsharing', 'Manage shares')
Expand All @@ -15,7 +15,7 @@ export const action = new FileAction({
return ''
},

enabled(nodes) {
enabled({ nodes }) {
if (nodes.length !== 1) {
return false
}
Expand Down Expand Up @@ -44,33 +44,25 @@ export const action = new FileAction({
// return (node.permissions & Permission.SHARE) !== 0
},

async exec(node, view, dir) {
// You need read permissions to see the sidebar
if ((node.permissions & Permission.READ) !== 0) {

window.OCA.Files.Sidebar.close()
async exec({ nodes }) {
const node = nodes[0]

window.OCA.Files.Sidebar.setActiveTab('sharing')
window.OCA.Files.Sidebar.setActiveTab('sharing-manage')
// You need read permissions to see the sidebar
if ((node.permissions & Permission.READ) === 0) {
return false
}

try {
// Silently update current fileid
window.OCP.Files.Router.goToRoute(
null,
{ view: view.id, fileid: node.fileid },
{ dir },
true,
)
// NC33 exposes the sidebar via window.OCA.Files._sidebar() (what files v4's
// getSidebar wraps); call it directly since the app is on @nextcloud/files v3.
const sidebar = window.OCA?.Files?._sidebar?.()
if (!sidebar) {
return false
}

// TODO: migrate Sidebar to use a Node instead
await window.OCA.Files.Sidebar.open(node.path)
sidebar.open(node, 'sharing')

return null
} catch (error) {
return false
}
}
return null
},

order: -60,
})
}
11 changes: 0 additions & 11 deletions src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<template>
<li :class="{'sharing-entry--share': share}" class="sharing-entry sharing-entry__link">
<div class="sharing-entry__desc" @click.prevent="toggleQuickShareSelect">
<span class="sharing-entry__title" :title="plainTitle" v-html="title">

Check warning on line 26 in src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

'v-html' directive can lead to XSS attack

Check warning on line 26 in src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

Require self-closing on HTML elements (<span>)
</span>
<p v-if="subtitle && false">
{{ subtitle }}
Expand Down Expand Up @@ -184,7 +184,6 @@
// Are we waiting for password/expiration date
pending: false,

ExternalLegacyLinkActions: OCA.Sharing.ExternalLinkActions.state,
ExternalShareActions: OCA.Sharing.ExternalShareActions.state,
}
},
Expand Down Expand Up @@ -295,8 +294,8 @@
},
async set(enabled) {
// TODO: directly save after generation to make sure the share is always protected
Vue.set(this.share, 'password', enabled ? await GeneratePassword() : '')

Check warning on line 297 in src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

Caution: `Vue` also has a named export `set`. Check if you meant to write `import {set} from 'vue'` instead
Vue.set(this.share, 'newPassword', this.share.password)

Check warning on line 298 in src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

Caution: `Vue` also has a named export `set`. Check if you meant to write `import {set} from 'vue'` instead
},
},

Expand All @@ -305,9 +304,9 @@
return null
}

const expirationTime = moment(this.share.passwordExpirationTime)

Check warning on line 307 in src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

The global property or function moment was deprecated in Nextcloud 18.0.0

if (expirationTime.diff(moment()) < 0) {

Check warning on line 309 in src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

The global property or function moment was deprecated in Nextcloud 18.0.0
return false
}

Expand Down Expand Up @@ -433,16 +432,6 @@
return t('files_sharing', 'Copy public link of "{title}" to clipboard', { title: this.title })
},

/**
* External additionnai actions for the menu
*
* @deprecated use OCA.Sharing.ExternalShareActions
* @return {Array}
*/
externalLegacyLinkActions() {
return this.ExternalLegacyLinkActions.actions
},

/**
* Additional actions for the menu
*
Expand Down
Loading
Loading