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
35 changes: 33 additions & 2 deletions apps/files/src/components/FileEntryMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,34 @@ import type { PropType } from 'vue'
import type { FileSource } from '../types.ts'

import { openConflictPicker } from '@nextcloud/dialogs'
import { FileType, Folder, getFileActions, File as NcFile, Node, NodeStatus, Permission } from '@nextcloud/files'
import { FileType, Folder, getFileActions, File as NcFile, Node, NodeStatus, Permission, type View } from '@nextcloud/files'
import { t } from '@nextcloud/l10n'
import { extname } from '@nextcloud/paths'
import { isPublicShare } from '@nextcloud/sharing/public'
import { generateUrl } from '@nextcloud/router'
import { getConflicts, getUploader } from '@nextcloud/upload'
import { vOnClickOutside } from '@vueuse/components'
import { relative } from 'path'
import { storeToRefs } from 'pinia'
import Vue, { computed, defineComponent } from 'vue'

import { action as sidebarAction } from '../actions/sidebarAction.ts'
import { onDropInternalFiles } from '../services/DropService.ts'
import { useActiveStore } from '../store/active.ts'
import { getDragAndDropPreview } from '../utils/dragUtils.ts'
import { hashCode } from '../utils/hashUtils.ts'
import { isDownloadable } from '../utils/permissions.ts'
import logger from '../logger.ts'

Vue.directive('onClickOutside', vOnClickOutside)

type FileActionContext = {
nodes: Node[]
view: View
folder: Folder
contents: Node[]
}

const actions = getFileActions()

export default defineComponent({
Expand Down Expand Up @@ -59,6 +68,15 @@ export default defineComponent({
}
},

setup() {
const { activeFolder, activeView } = storeToRefs(useActiveStore())

return {
activeFolder,
activeView,
}
},

data() {
return {
dragover: false,
Expand Down Expand Up @@ -229,6 +247,19 @@ export default defineComponent({
}
},

fileActionView(): View {
return this.activeView ?? this.currentView
},

fileActionContext(): FileActionContext {
return {
nodes: [this.source],
view: this.fileActionView,
folder: this.activeFolder!,
contents: this.nodes,
}
},

/**
* Sorted actions that are enabled for this node
*/
Expand All @@ -246,7 +277,7 @@ export default defineComponent({
// In case something goes wrong, since we don't want to break
// the entire list, we filter out actions that throw an error.
try {
return action.enabled([this.source], this.currentView)
return (action.enabled as (context: FileActionContext) => boolean)(this.fileActionContext)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the comments @susnux
i'll update accordingly.

} catch (error) {
logger.error('Error while checking action', { action, error })
return false
Expand Down
7 changes: 7 additions & 0 deletions apps/files/src/components/FilesListVirtual.vue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unrelated and rather a UI feature that must go to master first

Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ export default defineComponent({
display: flex;
align-items: center;
text-align: start;
cursor: pointer;
// Fill cell height and width
width: 100%;
height: 100%;
Expand All @@ -826,8 +827,13 @@ export default defineComponent({
}
}
span.files-list__row-name-link {
cursor: pointer;
}
.files-list__row-name-text {
color: var(--color-main-text);
cursor: pointer;
// Make some space for the outline
padding: var(--default-grid-baseline) calc(2 * var(--default-grid-baseline));
padding-inline-start: -10px;
Expand Down Expand Up @@ -998,6 +1004,7 @@ export default defineComponent({
.files-list__row-name-text {
margin: 0;
cursor: pointer;
// Ensure that the outline is not too close to the text.
margin-inline-start: -4px;
padding: 0px 4px;
Expand Down