window.OCP.Files.Router.goToRoute(
null,
- { fileid: undefined },
+ { view: view.id, fileid: undefined },
{ dir: join(dir, node.basename), fileid: undefined },
)
return null
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+import type { Navigation } from '../services/Navigation'
+
+import { Permission, type Node } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import InformationSvg from '@mdi/svg/svg/information-variant.svg?raw'
-import { Permission, type Node } from '@nextcloud/files'
import { registerFileAction, FileAction } from '../services/FileAction'
import logger from '../logger.js'
return (nodes[0].root?.startsWith('/files/') && nodes[0].permissions !== Permission.NONE) ?? false
},
- async exec(node: Node) {
+ async exec(node: Node, view: Navigation) {
try {
// TODO: migrate Sidebar to use a Node instead
window?.OCA?.Files?.Sidebar?.open?.(node.path)
+ // Silently update current fileid
+ window.OCP.Files.Router.goToRoute(
+ null,
+ { view: view.id, fileid: node.fileid },
+ { dir: node.dirname },
+ true,
+ )
+
return null
} catch (error) {
logger.error('Error while opening sidebar', { error })
window.OCP.Files.Router.goToRoute(
null,
{ view: 'files', fileid: node.fileid },
- { dir: node.dirname, fileid: node.fileid },
+ { dir: node.dirname },
)
return null
},
return this.selectionStore.selected
},
isSelected() {
- return this.selectedFiles.includes(this.source?.fileid?.toString?.())
+ return this.selectedFiles.includes(this.fileid)
},
cropPreviews() {
},
isActive() {
- return this.fileid === this.currentFileId
+ return this.fileid === this.currentFileId?.toString?.()
},
},
isRenaming() {
this.startRenaming()
},
-
- /**
- * Open the sidebar if the file is active
- */
- isActive(active) {
- const Sidebar = window?.OCA?.Files?.Sidebar
- if (active && Sidebar && Sidebar.file !== this.source.path) {
- Sidebar.open(this.source.path)
- }
- },
},
/**
<script lang="ts">
import { translate, translatePlural } from '@nextcloud/l10n'
-import { getFileListHeaders } from '@nextcloud/files'
+import { getFileListHeaders, type Node } from '@nextcloud/files'
import Vue from 'vue'
import VirtualList from './VirtualList.vue'
return {
FileEntry,
headers: getFileListHeaders(),
+ scrollToIndex: 0,
}
},
return parseInt(this.$route.params.fileid || this.$route.query.fileid) || null
},
- scrollToIndex() {
- if (!this.fileId) {
- return
- }
- const index = this.nodes.findIndex(node => node.fileid === this.fileId)
- if (index === -1) {
- showError(this.t('files', 'File not found'))
- }
- return Math.max(0, index)
- },
-
summaryFile() {
const count = this.files.length
return translatePlural('files', '{count} file', '{count} files', count, { count })
},
mounted() {
- // Open the sidebar on the file if it's in the url and
- // we're just loaded the app for the first time.
- const Sidebar = window?.OCA?.Files?.Sidebar
- const node = this.nodes.find(node => node.fileid === this.fileId)
- if (Sidebar && node) {
- Sidebar.open(node.path)
+ // Scroll to the file if it's in the url
+ if (this.fileId) {
+ const index = this.nodes.findIndex(node => node.fileid === this.fileId)
+ if (index === -1) {
+ showError(this.t('files', 'File not found'))
+ }
+ this.scrollToIndex = Math.max(0, index)
+ }
+
+ // Open the file sidebar if we have the room for it
+ if (document.documentElement.clientWidth > 1024) {
+ // Open the sidebar on the file if it's in the url and
+ // we're just loaded the app for the first time.
+ const Sidebar = window?.OCA?.Files?.Sidebar
+ const node = this.nodes.find(node => node.fileid === this.fileId) as Node
+ if (Sidebar && node) {
+ Sidebar.open(node.path)
+ }
}
},
{
path: '/',
// Pretending we're using the default view
- alias: '/files',
+ redirect: { name: 'filelist' },
},
{
path: '/:view/:fileid?',
this._router = router
}
+ get name(): string | null | undefined {
+ return this._router.currentRoute.name
+ }
+
+ get query(): Dictionary<string | (string | null)[] | null | undefined> {
+ return this._router.currentRoute.query || {}
+ }
+
+ get params(): Dictionary<string> {
+ return this._router.currentRoute.params || {}
+ }
+
/**
* Trigger a route change on the files app
*