aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2023-09-21 17:33:44 +0200
committerGitHub <noreply@github.com>2023-09-21 17:33:44 +0200
commit472440b296f405a159fc3363bd0ea250fda4f972 (patch)
tree7f1ccc37569261bf08785aadb66d2aa62138013b /apps
parentef87ff18487d4d78a392f7e44cd9f094a0a73371 (diff)
parentbf467ad7f78c681c45649034cc443a53ebe41cfc (diff)
downloadnextcloud-server-472440b296f405a159fc3363bd0ea250fda4f972.tar.gz
nextcloud-server-472440b296f405a159fc3363bd0ea250fda4f972.zip
Merge pull request #40551 from nextcloud/fix/init-script
Diffstat (limited to 'apps')
-rw-r--r--apps/comments/lib/Listener/LoadAdditionalScripts.php1
-rw-r--r--apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts6
-rw-r--r--apps/comments/src/actions/inlineUnreadCommentsAction.ts14
-rw-r--r--apps/comments/src/comments.js1
-rw-r--r--apps/comments/src/init.ts25
-rw-r--r--apps/files/lib/Controller/ViewController.php1
-rw-r--r--apps/files/src/actions/deleteAction.ts4
-rw-r--r--apps/files/src/actions/downloadAction.ts4
-rw-r--r--apps/files/src/actions/editLocallyAction.ts6
-rw-r--r--apps/files/src/actions/favoriteAction.ts4
-rw-r--r--apps/files/src/actions/openFolderAction.ts4
-rw-r--r--apps/files/src/actions/openInFilesAction.ts6
-rw-r--r--apps/files/src/actions/renameAction.ts4
-rw-r--r--apps/files/src/actions/sidebarAction.ts4
-rw-r--r--apps/files/src/actions/viewInFolderAction.ts4
-rw-r--r--apps/files/src/components/FileEntry.vue15
-rw-r--r--apps/files/src/components/FilesListVirtual.vue4
-rw-r--r--apps/files/src/init.ts59
-rw-r--r--apps/files/src/main.ts23
-rw-r--r--apps/files/src/newMenu/newFolder.ts4
-rw-r--r--apps/files/src/services/DavProperties.ts130
-rw-r--r--apps/files/src/services/Favorites.ts19
-rw-r--r--apps/files/src/services/Files.ts7
-rw-r--r--apps/files/src/services/Recent.ts3
-rw-r--r--apps/files_external/lib/Listener/LoadAdditionalListener.php2
-rw-r--r--apps/files_external/src/actions/enterCredentialsAction.ts4
-rw-r--r--apps/files_external/src/actions/inlineStorageCheckAction.ts4
-rw-r--r--apps/files_external/src/actions/openInFilesAction.ts4
-rw-r--r--apps/files_external/src/init.ts (renamed from apps/files_external/src/main.ts)16
-rw-r--r--apps/files_sharing/src/actions/sharingStatusAction.ts15
-rw-r--r--apps/files_trashbin/src/services/trashbin.ts8
-rw-r--r--apps/systemtags/src/init.ts2
32 files changed, 164 insertions, 243 deletions
diff --git a/apps/comments/lib/Listener/LoadAdditionalScripts.php b/apps/comments/lib/Listener/LoadAdditionalScripts.php
index e43ca5f2bbe..e82f18cfbe4 100644
--- a/apps/comments/lib/Listener/LoadAdditionalScripts.php
+++ b/apps/comments/lib/Listener/LoadAdditionalScripts.php
@@ -42,5 +42,6 @@ class LoadAdditionalScripts implements IEventListener {
// TODO: make sure to only include the sidebar script when
// we properly split it between files list and sidebar
Util::addScript(Application::APP_ID, 'comments');
+ Util::addInitScript(Application::APP_ID, 'init');
}
}
diff --git a/apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts b/apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts
index 9ce192bb477..aabbf42fadb 100644
--- a/apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts
+++ b/apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts
@@ -44,7 +44,8 @@ describe('Inline unread comments action display name tests', () => {
expect(action).toBeInstanceOf(FileAction)
expect(action.id).toBe('comments-unread')
- expect(action.displayName([file], view)).toBe('1 new comment')
+ expect(action.displayName([file], view)).toBe('')
+ expect(action.title!([file], view)).toBe('1 new comment')
expect(action.iconSvgInline([], view)).toBe('<svg>SvgMock</svg>')
expect(action.enabled!([file], view)).toBe(true)
expect(action.inline!(file, view)).toBe(true)
@@ -64,7 +65,8 @@ describe('Inline unread comments action display name tests', () => {
},
})
- expect(action.displayName([file], view)).toBe('2 new comments')
+ expect(action.displayName([file], view)).toBe('')
+ expect(action.title!([file], view)).toBe('2 new comments')
})
})
diff --git a/apps/comments/src/actions/inlineUnreadCommentsAction.ts b/apps/comments/src/actions/inlineUnreadCommentsAction.ts
index e29e7d50b28..b537923b30e 100644
--- a/apps/comments/src/actions/inlineUnreadCommentsAction.ts
+++ b/apps/comments/src/actions/inlineUnreadCommentsAction.ts
@@ -19,15 +19,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-import { FileAction, Node, registerFileAction } from '@nextcloud/files'
+import { FileAction, Node } from '@nextcloud/files'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
-import commentProcessingSvg from '@mdi/svg/svg/comment-processing.svg?raw'
+import CommentProcessingSvg from '@mdi/svg/svg/comment-processing.svg?raw'
+
import logger from '../logger'
export const action = new FileAction({
id: 'comments-unread',
- displayName(nodes: Node[]) {
+ title(nodes: Node[]) {
const unread = nodes[0].attributes['comments-unread'] as number
if (unread >= 0) {
return n('comments', '1 new comment', '{unread} new comments', unread, { unread })
@@ -35,7 +36,10 @@ export const action = new FileAction({
return t('comments', 'Comment')
},
- iconSvgInline: () => commentProcessingSvg,
+ // Empty string when rendered inline
+ displayName: () => '',
+
+ iconSvgInline: () => CommentProcessingSvg,
enabled(nodes: Node[]) {
const unread = nodes[0].attributes['comments-unread'] as number|undefined
@@ -57,5 +61,3 @@ export const action = new FileAction({
order: -140,
})
-
-registerFileAction(action)
diff --git a/apps/comments/src/comments.js b/apps/comments/src/comments.js
index 0c0d2b866ee..ed9db7d4725 100644
--- a/apps/comments/src/comments.js
+++ b/apps/comments/src/comments.js
@@ -24,6 +24,5 @@
import './app.js'
import './templates.js'
import './activitytabviewplugin.js'
-import './actions/inlineUnreadCommentsAction.ts'
window.OCA.Comments = OCA.Comments
diff --git a/apps/comments/src/init.ts b/apps/comments/src/init.ts
new file mode 100644
index 00000000000..448720d34d2
--- /dev/null
+++ b/apps/comments/src/init.ts
@@ -0,0 +1,25 @@
+/**
+ * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @license AGPL-3.0-or-later
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+import { registerFileAction } from '@nextcloud/files'
+import { action } from './actions/inlineUnreadCommentsAction'
+
+registerFileAction(action)
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index 8fe7eea01a0..ca0760fd5e2 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -217,6 +217,7 @@ class ViewController extends Controller {
}
// Load the files we need
+ \OCP\Util::addInitScript('files', 'init');
\OCP\Util::addStyle('files', 'merged');
\OCP\Util::addScript('files', 'merged-index', 'files');
\OCP\Util::addScript('files', 'main');
diff --git a/apps/files/src/actions/deleteAction.ts b/apps/files/src/actions/deleteAction.ts
index 04c139fe38e..18c18178cb7 100644
--- a/apps/files/src/actions/deleteAction.ts
+++ b/apps/files/src/actions/deleteAction.ts
@@ -20,7 +20,7 @@
*
*/
import { emit } from '@nextcloud/event-bus'
-import { Permission, Node, View, registerFileAction, FileAction } from '@nextcloud/files'
+import { Permission, Node, View, FileAction } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import axios from '@nextcloud/axios'
import TrashCanSvg from '@mdi/svg/svg/trash-can.svg?raw'
@@ -62,5 +62,3 @@ export const action = new FileAction({
order: 100,
})
-
-registerFileAction(action)
diff --git a/apps/files/src/actions/downloadAction.ts b/apps/files/src/actions/downloadAction.ts
index ce9f22450e9..0b1c88fa985 100644
--- a/apps/files/src/actions/downloadAction.ts
+++ b/apps/files/src/actions/downloadAction.ts
@@ -20,7 +20,7 @@
*
*/
import { generateUrl } from '@nextcloud/router'
-import { registerFileAction, FileAction, Permission, Node, FileType, View } from '@nextcloud/files'
+import { FileAction, Permission, Node, FileType, View } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import ArrowDownSvg from '@mdi/svg/svg/arrow-down.svg?raw'
@@ -86,5 +86,3 @@ export const action = new FileAction({
order: 30,
})
-
-registerFileAction(action)
diff --git a/apps/files/src/actions/editLocallyAction.ts b/apps/files/src/actions/editLocallyAction.ts
index c8e6f295544..f52f8191df8 100644
--- a/apps/files/src/actions/editLocallyAction.ts
+++ b/apps/files/src/actions/editLocallyAction.ts
@@ -22,7 +22,7 @@
import { encodePath } from '@nextcloud/paths'
import { generateOcsUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
-import { registerFileAction, FileAction, Permission, type Node } from '@nextcloud/files'
+import { FileAction, Permission, type Node } from '@nextcloud/files'
import { showError } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
import axios from '@nextcloud/axios'
@@ -66,7 +66,3 @@ export const action = new FileAction({
order: 25,
})
-
-if (!/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)) {
- registerFileAction(action)
-}
diff --git a/apps/files/src/actions/favoriteAction.ts b/apps/files/src/actions/favoriteAction.ts
index 1309539bad2..34d34039101 100644
--- a/apps/files/src/actions/favoriteAction.ts
+++ b/apps/files/src/actions/favoriteAction.ts
@@ -21,7 +21,7 @@
*/
import { emit } from '@nextcloud/event-bus'
import { generateUrl } from '@nextcloud/router'
-import { Permission, type Node, View, registerFileAction, FileAction } from '@nextcloud/files'
+import { Permission, type Node, View, FileAction } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import axios from '@nextcloud/axios'
import Vue from 'vue'
@@ -101,5 +101,3 @@ export const action = new FileAction({
order: -50,
})
-
-registerFileAction(action)
diff --git a/apps/files/src/actions/openFolderAction.ts b/apps/files/src/actions/openFolderAction.ts
index 2694667222d..f802ea4ad6d 100644
--- a/apps/files/src/actions/openFolderAction.ts
+++ b/apps/files/src/actions/openFolderAction.ts
@@ -20,7 +20,7 @@
*
*/
import { join } from 'path'
-import { Permission, Node, FileType, View, registerFileAction, FileAction, DefaultType } from '@nextcloud/files'
+import { Permission, Node, FileType, View, FileAction, DefaultType } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import FolderSvg from '@mdi/svg/svg/folder.svg?raw'
@@ -66,5 +66,3 @@ export const action = new FileAction({
default: DefaultType.HIDDEN,
order: -100,
})
-
-registerFileAction(action)
diff --git a/apps/files/src/actions/openInFilesAction.ts b/apps/files/src/actions/openInFilesAction.ts
index ed3b781548c..235b59046d7 100644
--- a/apps/files/src/actions/openInFilesAction.ts
+++ b/apps/files/src/actions/openInFilesAction.ts
@@ -20,9 +20,7 @@
*
*/
import { translate as t } from '@nextcloud/l10n'
-import { FileType, type Node } from '@nextcloud/files'
-
-import { registerFileAction, FileAction, DefaultType } from '@nextcloud/files'
+import { type Node, FileType, FileAction, DefaultType } from '@nextcloud/files'
/**
* TODO: Move away from a redirect and handle
@@ -53,5 +51,3 @@ export const action = new FileAction({
order: -1000,
default: DefaultType.HIDDEN,
})
-
-registerFileAction(action)
diff --git a/apps/files/src/actions/renameAction.ts b/apps/files/src/actions/renameAction.ts
index 001bedfc73a..81d6b6384b0 100644
--- a/apps/files/src/actions/renameAction.ts
+++ b/apps/files/src/actions/renameAction.ts
@@ -20,7 +20,7 @@
*
*/
import { emit } from '@nextcloud/event-bus'
-import { Permission, type Node, registerFileAction, FileAction } from '@nextcloud/files'
+import { Permission, type Node, FileAction } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import PencilSvg from '@mdi/svg/svg/pencil.svg?raw'
@@ -45,5 +45,3 @@ export const action = new FileAction({
order: 10,
})
-
-registerFileAction(action)
diff --git a/apps/files/src/actions/sidebarAction.ts b/apps/files/src/actions/sidebarAction.ts
index aa265d6709a..32cd8e6d433 100644
--- a/apps/files/src/actions/sidebarAction.ts
+++ b/apps/files/src/actions/sidebarAction.ts
@@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-import { Permission, type Node, View, registerFileAction, FileAction, FileType } from '@nextcloud/files'
+import { Permission, type Node, View, FileAction, FileType } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import InformationSvg from '@mdi/svg/svg/information-variant.svg?raw'
@@ -73,5 +73,3 @@ export const action = new FileAction({
order: -50,
})
-
-registerFileAction(action)
diff --git a/apps/files/src/actions/viewInFolderAction.ts b/apps/files/src/actions/viewInFolderAction.ts
index a5a5896df0c..c306f93b0af 100644
--- a/apps/files/src/actions/viewInFolderAction.ts
+++ b/apps/files/src/actions/viewInFolderAction.ts
@@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-import { Node, FileType, Permission, View, registerFileAction, FileAction } from '@nextcloud/files'
+import { Node, FileType, Permission, View, FileAction } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import FolderMoveSvg from '@mdi/svg/svg/folder-move.svg?raw'
@@ -64,5 +64,3 @@ export const action = new FileAction({
order: 80,
})
-
-registerFileAction(action)
diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue
index 83b991dcd50..f9320a55e15 100644
--- a/apps/files/src/components/FileEntry.vue
+++ b/apps/files/src/components/FileEntry.vue
@@ -130,12 +130,13 @@
:class="'files-list__row-action-' + action.id"
:close-after-click="true"
:data-cy-files-list-row-action="action.id"
+ :title="action.title?.([source], currentView)"
@click="onActionClick(action)">
<template #icon>
<NcLoadingIcon v-if="loading === action.id" :size="18" />
<CustomSvgIconRender v-else :svg="action.iconSvgInline([source], currentView)" />
</template>
- {{ action.displayName([source], currentView) }}
+ {{ actionDisplayName(action) }}
</NcActionButton>
</NcActions>
</td>
@@ -180,7 +181,7 @@ import { debounce } from 'debounce'
import { emit } from '@nextcloud/event-bus'
import { extname } from 'path'
import { generateUrl } from '@nextcloud/router'
-import { getFileActions, DefaultType, FileType, formatFileSize, Permission, Folder, File, Node } from '@nextcloud/files'
+import { getFileActions, DefaultType, FileType, formatFileSize, Permission, Folder, File, Node, FileAction } from '@nextcloud/files'
import { Type as ShareType } from '@nextcloud/sharing'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { translate } from '@nextcloud/l10n'
@@ -918,6 +919,16 @@ export default Vue.extend({
return document.querySelector('.app-content > .files-list')
},
+ actionDisplayName(action: FileAction) {
+ if (this.filesListWidth < 768 && action.inline && typeof action.title === 'function') {
+ // if an inline action is rendered in the menu for
+ // lack of space we use the title first if defined
+ const title = action.title([this.source], this.currentView)
+ if (title) return title
+ }
+ return action.displayName([this.source], this.currentView)
+ },
+
t: translate,
formatFileSize,
},
diff --git a/apps/files/src/components/FilesListVirtual.vue b/apps/files/src/components/FilesListVirtual.vue
index cd41a179ce9..e5a37986cac 100644
--- a/apps/files/src/components/FilesListVirtual.vue
+++ b/apps/files/src/components/FilesListVirtual.vue
@@ -454,10 +454,6 @@ export default Vue.extend({
// Remove bold from default button styling
font-weight: normal;
}
- &:not(:hover, :focus, :active) .button-vue__wrapper {
- // Also apply color-text-maxcontrast to non-active button
- color: var(--color-text-maxcontrast);
- }
}
}
diff --git a/apps/files/src/init.ts b/apps/files/src/init.ts
new file mode 100644
index 00000000000..64e3846979e
--- /dev/null
+++ b/apps/files/src/init.ts
@@ -0,0 +1,59 @@
+/**
+ * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @license AGPL-3.0-or-later
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+import { action as deleteAction } from './actions/deleteAction'
+import { action as downloadAction } from './actions/downloadAction'
+import { action as editLocallyAction } from './actions/editLocallyAction'
+import { action as favoriteAction } from './actions/favoriteAction'
+import { action as openFolderAction } from './actions/openFolderAction'
+import { action as openInFilesAction } from './actions/openInFilesAction'
+import { action as renameAction } from './actions/renameAction'
+import { action as sidebarAction } from './actions/sidebarAction'
+import { action as viewInFolderAction } from './actions/viewInFolderAction'
+import { entry as newFolderEntry } from './newMenu/newFolder'
+
+import registerFavoritesView from './views/favorites'
+import registerRecentView from './views/recent'
+import registerFilesView from './views/files'
+import registerPreviewServiceWorker from './services/ServiceWorker.js'
+import { addNewFileMenuEntry, registerFileAction } from '@nextcloud/files'
+
+// Register file actions
+registerFileAction(deleteAction)
+registerFileAction(downloadAction)
+registerFileAction(editLocallyAction)
+registerFileAction(favoriteAction)
+registerFileAction(openFolderAction)
+registerFileAction(openInFilesAction)
+registerFileAction(renameAction)
+registerFileAction(sidebarAction)
+registerFileAction(viewInFolderAction)
+
+// Register new menu entry
+addNewFileMenuEntry(newFolderEntry)
+
+// Register files views
+registerFavoritesView()
+registerFilesView()
+registerRecentView()
+
+// Register preview service worker
+registerPreviewServiceWorker()
diff --git a/apps/files/src/main.ts b/apps/files/src/main.ts
index 8bcfacf953a..38bec4ad087 100644
--- a/apps/files/src/main.ts
+++ b/apps/files/src/main.ts
@@ -1,17 +1,6 @@
import './templates.js'
import './legacy/filelistSearch.js'
-import './actions/deleteAction'
-import './actions/downloadAction'
-import './actions/editLocallyAction'
-import './actions/favoriteAction'
-import './actions/openFolderAction'
-import './actions/openInFilesAction.js'
-import './actions/renameAction'
-import './actions/sidebarAction'
-import './actions/viewInFolderAction'
-import './newMenu/newFolder'
-
import Vue from 'vue'
import { createPinia, PiniaVuePlugin } from 'pinia'
import { getNavigation } from '@nextcloud/files'
@@ -19,10 +8,6 @@ import { getRequestToken } from '@nextcloud/auth'
import FilesListView from './views/FilesList.vue'
import NavigationView from './views/Navigation.vue'
-import registerFavoritesView from './views/favorites'
-import registerRecentView from './views/recent'
-import registerFilesView from './views/files'
-import registerPreviewServiceWorker from './services/ServiceWorker.js'
import router from './router/router'
import RouterService from './services/RouterService'
import SettingsModel from './models/Setting.js'
@@ -80,11 +65,3 @@ const FilesList = new ListView({
pinia,
})
FilesList.$mount('#app-content-vue')
-
-// Init legacy and new files views
-registerFavoritesView()
-registerFilesView()
-registerRecentView()
-
-// Register preview service worker
-registerPreviewServiceWorker()
diff --git a/apps/files/src/newMenu/newFolder.ts b/apps/files/src/newMenu/newFolder.ts
index 1bf178de183..33fd113b7c3 100644
--- a/apps/files/src/newMenu/newFolder.ts
+++ b/apps/files/src/newMenu/newFolder.ts
@@ -62,7 +62,7 @@ export const getUniqueName = (name: string, names: string[]): string => {
return newName
}
-const entry = {
+export const entry = {
id: 'newFolder',
displayName: t('files', 'New folder'),
if: (context: Folder) => (context.permissions & Permission.CREATE) !== 0,
@@ -92,5 +92,3 @@ const entry = {
emit('files:node:rename', folder)
},
} as Entry
-
-addNewFileMenuEntry(entry)
diff --git a/apps/files/src/services/DavProperties.ts b/apps/files/src/services/DavProperties.ts
deleted file mode 100644
index 79a80706925..00000000000
--- a/apps/files/src/services/DavProperties.ts
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-import logger from '../logger'
-
-type DavProperty = { [key: string]: string }
-
-declare global {
- interface Window {
- OC: any;
- _nc_dav_properties: string[];
- _nc_dav_namespaces: DavProperty;
- }
-}
-
-const defaultDavProperties = [
- 'd:getcontentlength',
- 'd:getcontenttype',
- 'd:getetag',
- 'd:getlastmodified',
- 'd:quota-available-bytes',
- 'd:resourcetype',
- 'nc:has-preview',
- 'nc:is-encrypted',
- 'nc:mount-type',
- 'nc:share-attributes',
- 'oc:comments-unread',
- 'oc:favorite',
- 'oc:fileid',
- 'oc:owner-display-name',
- 'oc:owner-id',
- 'oc:permissions',
- 'oc:share-types',
- 'oc:size',
- 'ocs:share-permissions',
-]
-
-const defaultDavNamespaces = {
- d: 'DAV:',
- nc: 'http://nextcloud.org/ns',
- oc: 'http://owncloud.org/ns',
- ocs: 'http://open-collaboration-services.org/ns',
-}
-
-/**
- * TODO: remove and move to @nextcloud/files
- * @param prop
- * @param namespace
- */
-export const registerDavProperty = function(prop: string, namespace: DavProperty = { nc: 'http://nextcloud.org/ns' }): void {
- if (typeof window._nc_dav_properties === 'undefined') {
- window._nc_dav_properties = defaultDavProperties
- window._nc_dav_namespaces = defaultDavNamespaces
- }
-
- const namespaces = { ...window._nc_dav_namespaces, ...namespace }
-
- // Check duplicates
- if (window._nc_dav_properties.find(search => search === prop)) {
- logger.error(`${prop} already registered`, { prop })
- return
- }
-
- if (prop.startsWith('<') || prop.split(':').length !== 2) {
- logger.error(`${prop} is not valid. See example: 'oc:fileid'`, { prop })
- return
- }
-
- const ns = prop.split(':')[0]
- if (!namespaces[ns]) {
- logger.error(`${prop} namespace unknown`, { prop, namespaces })
- return
- }
-
- window._nc_dav_properties.push(prop)
- window._nc_dav_namespaces = namespaces
-}
-
-/**
- * Get the registered dav properties
- */
-export const getDavProperties = function(): string {
- if (typeof window._nc_dav_properties === 'undefined') {
- window._nc_dav_properties = defaultDavProperties
- }
-
- return window._nc_dav_properties.map(prop => `<${prop} />`).join(' ')
-}
-
-/**
- * Get the registered dav namespaces
- */
-export const getDavNameSpaces = function(): string {
- if (typeof window._nc_dav_namespaces === 'undefined') {
- window._nc_dav_namespaces = defaultDavNamespaces
- }
-
- return Object.keys(window._nc_dav_namespaces).map(ns => `xmlns:${ns}="${window._nc_dav_namespaces[ns]}"`).join(' ')
-}
-
-/**
- * Get the default PROPFIND request payload
- */
-export const getDefaultPropfind = function() {
- return `<?xml version="1.0"?>
- <d:propfind ${getDavNameSpaces()}>
- <d:prop>
- ${getDavProperties()}
- </d:prop>
- </d:propfind>`
-}
diff --git a/apps/files/src/services/Favorites.ts b/apps/files/src/services/Favorites.ts
index 633ba718560..800feb2c80a 100644
--- a/apps/files/src/services/Favorites.ts
+++ b/apps/files/src/services/Favorites.ts
@@ -20,14 +20,11 @@
*
*/
import type { ContentsWithRoot } from '@nextcloud/files'
-import type { FileStat, ResponseDataDetailed, DAVResultResponseProps } from 'webdav'
+import type { FileStat, ResponseDataDetailed } from 'webdav'
-import { File, Folder, davParsePermissions } from '@nextcloud/files'
-import { generateRemoteUrl } from '@nextcloud/router'
-import { getCurrentUser } from '@nextcloud/auth'
+import { Folder, getDavNameSpaces, getDavProperties, davGetDefaultPropfind } from '@nextcloud/files'
-import { getClient, rootPath } from './WebdavClient'
-import { getDavNameSpaces, getDavProperties, getDefaultPropfind } from './DavProperties'
+import { getClient } from './WebdavClient'
import { resultToNode } from './Files'
const client = getClient()
@@ -42,21 +39,15 @@ const reportPayload = `<?xml version="1.0"?>
</oc:filter-rules>
</oc:filter-files>`
-interface ResponseProps extends DAVResultResponseProps {
- permissions: string,
- fileid: number,
- size: number,
-}
-
export const getContents = async (path = '/'): Promise<ContentsWithRoot> => {
- const propfindPayload = getDefaultPropfind()
+ const propfindPayload = davGetDefaultPropfind()
// Get root folder
let rootResponse
if (path === '/') {
rootResponse = await client.stat(path, {
details: true,
- data: getDefaultPropfind(),
+ data: propfindPayload,
}) as ResponseDataDetailed<FileStat>
}
diff --git a/apps/files/src/services/Files.ts b/apps/files/src/services/Files.ts
index fba65ac44ae..c09be2d72ac 100644
--- a/apps/files/src/services/Files.ts
+++ b/apps/files/src/services/Files.ts
@@ -22,13 +22,12 @@
import type { ContentsWithRoot } from '@nextcloud/files'
import type { FileStat, ResponseDataDetailed, DAVResultResponseProps } from 'webdav'
-import { cancelable, CancelablePromise } from 'cancelable-promise'
-import { File, Folder, davParsePermissions } from '@nextcloud/files'
+import { CancelablePromise } from 'cancelable-promise'
+import { File, Folder, davParsePermissions, davGetDefaultPropfind } from '@nextcloud/files'
import { generateRemoteUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { getClient, rootPath } from './WebdavClient'
-import { getDefaultPropfind } from './DavProperties'
import { hashCode } from '../utils/hashUtils'
import logger from '../logger'
@@ -76,7 +75,7 @@ export const resultToNode = function(node: FileStat): File | Folder {
export const getContents = (path = '/'): Promise<ContentsWithRoot> => {
const controller = new AbortController()
- const propfindPayload = getDefaultPropfind()
+ const propfindPayload = davGetDefaultPropfind()
return new CancelablePromise(async (resolve, reject, onCancel) => {
onCancel(() => controller.abort())
diff --git a/apps/files/src/services/Recent.ts b/apps/files/src/services/Recent.ts
index 7a585d28fc5..ecd43b90ecc 100644
--- a/apps/files/src/services/Recent.ts
+++ b/apps/files/src/services/Recent.ts
@@ -22,12 +22,11 @@
import type { ContentsWithRoot } from '@nextcloud/files'
import type { FileStat, ResponseDataDetailed, DAVResultResponseProps } from 'webdav'
-import { File, Folder, Permission, davParsePermissions } from '@nextcloud/files'
+import { Folder, Permission, getDavNameSpaces, getDavProperties } from '@nextcloud/files'
import { generateRemoteUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { getClient, rootPath } from './WebdavClient'
-import { getDavNameSpaces, getDavProperties } from './DavProperties'
import { resultToNode } from './Files'
const client = getClient(generateRemoteUrl('dav'))
diff --git a/apps/files_external/lib/Listener/LoadAdditionalListener.php b/apps/files_external/lib/Listener/LoadAdditionalListener.php
index e5cb5e96d0a..5f56a14c4ce 100644
--- a/apps/files_external/lib/Listener/LoadAdditionalListener.php
+++ b/apps/files_external/lib/Listener/LoadAdditionalListener.php
@@ -50,6 +50,8 @@ class LoadAdditionalListener implements IEventListener {
$allowUserMounting = $this->config->getAppValue('files_external', 'allow_user_mounting', 'no') === 'yes';
$this->initialState->provideInitialState('allowUserMounting', $allowUserMounting);
+
+ Util::addInitScript(Application::APP_ID, 'init');
Util::addScript(Application::APP_ID, 'main', 'files');
}
}
diff --git a/apps/files_external/src/actions/enterCredentialsAction.ts b/apps/files_external/src/actions/enterCredentialsAction.ts
index 49b0ab4076e..eeb2f5f8793 100644
--- a/apps/files_external/src/actions/enterCredentialsAction.ts
+++ b/apps/files_external/src/actions/enterCredentialsAction.ts
@@ -31,7 +31,7 @@ import axios from '@nextcloud/axios'
import LoginSvg from '@mdi/svg/svg/login.svg?raw'
import Vue from 'vue'
-import { registerFileAction, FileAction, DefaultType } from '@nextcloud/files'
+import { FileAction, DefaultType } from '@nextcloud/files'
import { STORAGE_STATUS, isMissingAuthConfig } from '../utils/credentialsUtils'
import { isNodeExternalStorage } from '../utils/externalStorageUtils'
@@ -106,5 +106,3 @@ export const action = new FileAction({
default: DefaultType.DEFAULT,
inline: () => true,
})
-
-registerFileAction(action)
diff --git a/apps/files_external/src/actions/inlineStorageCheckAction.ts b/apps/files_external/src/actions/inlineStorageCheckAction.ts
index fa2f567b1f7..46e38eab47e 100644
--- a/apps/files_external/src/actions/inlineStorageCheckAction.ts
+++ b/apps/files_external/src/actions/inlineStorageCheckAction.ts
@@ -32,7 +32,7 @@ import '../css/fileEntryStatus.scss'
import { getStatus, type StorageConfig } from '../services/externalStorage'
import { isMissingAuthConfig, STORAGE_STATUS } from '../utils/credentialsUtils'
import { isNodeExternalStorage } from '../utils/externalStorageUtils'
-import { registerFileAction, FileAction } from '@nextcloud/files'
+import { FileAction } from '@nextcloud/files'
export const action = new FileAction({
id: 'check-external-storage',
@@ -92,5 +92,3 @@ export const action = new FileAction({
order: 10,
})
-
-registerFileAction(action)
diff --git a/apps/files_external/src/actions/openInFilesAction.ts b/apps/files_external/src/actions/openInFilesAction.ts
index 0359e81998d..8033caed123 100644
--- a/apps/files_external/src/actions/openInFilesAction.ts
+++ b/apps/files_external/src/actions/openInFilesAction.ts
@@ -25,7 +25,7 @@ import type { StorageConfig } from '../services/externalStorage'
import { generateUrl } from '@nextcloud/router'
import { translate as t } from '@nextcloud/l10n'
-import { registerFileAction, FileAction, DefaultType } from '@nextcloud/files'
+import { FileAction, DefaultType } from '@nextcloud/files'
import { STORAGE_STATUS } from '../utils/credentialsUtils'
export const action = new FileAction({
@@ -71,5 +71,3 @@ export const action = new FileAction({
order: -1000,
default: DefaultType.HIDDEN,
})
-
-registerFileAction(action)
diff --git a/apps/files_external/src/main.ts b/apps/files_external/src/init.ts
index c85dd371f51..ccce2448dfe 100644
--- a/apps/files_external/src/main.ts
+++ b/apps/files_external/src/init.ts
@@ -19,18 +19,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-import { translate as t } from '@nextcloud/l10n'
import { loadState } from '@nextcloud/initial-state'
+import { translate as t } from '@nextcloud/l10n'
+import { View, getNavigation, Column, registerFileAction } from '@nextcloud/files'
import FolderNetworkSvg from '@mdi/svg/svg/folder-network.svg?raw'
-import './actions/enterCredentialsAction'
-import './actions/inlineStorageCheckAction'
-import './actions/openInFilesAction'
+import { action as enterCredentialsAction } from './actions/enterCredentialsAction'
+import { action as inlineStorageCheckAction } from './actions/inlineStorageCheckAction'
+import { action as openInFilesAction } from './actions/openInFilesAction'
import { getContents } from './services/externalStorage'
-import { View, getNavigation, Column } from '@nextcloud/files'
const allowUserMounting = loadState('files_external', 'allowUserMounting', false)
+// Register view
const Navigation = getNavigation()
Navigation.register(new View({
id: 'extstoragemounts',
@@ -73,3 +74,8 @@ Navigation.register(new View({
getContents,
}))
+
+// Register actions
+registerFileAction(enterCredentialsAction)
+registerFileAction(inlineStorageCheckAction)
+registerFileAction(openInFilesAction)
diff --git a/apps/files_sharing/src/actions/sharingStatusAction.ts b/apps/files_sharing/src/actions/sharingStatusAction.ts
index 054d6617ac9..01052676aa4 100644
--- a/apps/files_sharing/src/actions/sharingStatusAction.ts
+++ b/apps/files_sharing/src/actions/sharingStatusAction.ts
@@ -47,17 +47,28 @@ export const action = new FileAction({
displayName(nodes: Node[]) {
const node = nodes[0]
const shareTypes = Object.values(node?.attributes?.['share-types'] || {}).flat() as number[]
- if (shareTypes.length > 0) {
+ const ownerId = node?.attributes?.['owner-id']
+
+ if (shareTypes.length > 0
+ || (ownerId && ownerId !== getCurrentUser()?.uid)) {
return t('files_sharing', 'Shared')
}
+ return ''
+ },
+
+ title(nodes: Node[]) {
+ const node = nodes[0]
const ownerId = node?.attributes?.['owner-id']
+ const ownerDisplayName = node?.attributes?.['owner-display-name']
+
if (ownerId && ownerId !== getCurrentUser()?.uid) {
- return t('files_sharing', 'Shared')
+ return t('files_sharing', 'Shared by {ownerDisplayName}', { ownerDisplayName })
}
return ''
},
+
iconSvgInline(nodes: Node[]) {
const node = nodes[0]
const shareTypes = Object.values(node?.attributes?.['share-types'] || {}).flat() as number[]
diff --git a/apps/files_trashbin/src/services/trashbin.ts b/apps/files_trashbin/src/services/trashbin.ts
index 5e7a31b2448..9aef75ef6d5 100644
--- a/apps/files_trashbin/src/services/trashbin.ts
+++ b/apps/files_trashbin/src/services/trashbin.ts
@@ -19,12 +19,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-import { File, Folder, davParsePermissions, type ContentsWithRoot } from '@nextcloud/files'
-import { generateRemoteUrl, generateUrl } from '@nextcloud/router'
-import { getCurrentUser } from '@nextcloud/auth'
import type { FileStat, ResponseDataDetailed } from 'webdav'
+import type { ContentsWithRoot } from '@nextcloud/files'
-import { getDavNameSpaces, getDavProperties } from '../../../files/src/services/DavProperties'
+import { File, Folder, davParsePermissions, getDavNameSpaces, getDavProperties } from '@nextcloud/files'
+import { generateRemoteUrl, generateUrl } from '@nextcloud/router'
+import { getCurrentUser } from '@nextcloud/auth'
import client, { rootPath } from './client'
diff --git a/apps/systemtags/src/init.ts b/apps/systemtags/src/init.ts
index 3dbb606dc87..aa8312c9875 100644
--- a/apps/systemtags/src/init.ts
+++ b/apps/systemtags/src/init.ts
@@ -23,7 +23,7 @@
import './actions/inlineSystemTagsAction.js'
import { translate as t } from '@nextcloud/l10n'
-import { Column, Node, View, getNavigation } from '@nextcloud/files'
+import { View, getNavigation } from '@nextcloud/files'
import TagMultipleSvg from '@mdi/svg/svg/tag-multiple.svg?raw'
import { getContents } from './services/systemtags.js'