Skip to content

Commit

Permalink
fix(files): drop visible and adjust drag-to-scroll feature
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
  • Loading branch information
skjnldsv authored and nextcloud-command committed Oct 19, 2023
1 parent 4876eac commit 4db0388
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 41 deletions.
15 changes: 4 additions & 11 deletions apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
-->

<template>
<tr :class="{'files-list__row--visible': visible, 'files-list__row--active': isActive, 'files-list__row--dragover': dragover, 'files-list__row--loading': isLoading}"
<tr :class="{'files-list__row--dragover': dragover, 'files-list__row--loading': isLoading}"
data-cy-files-list-row
:data-cy-files-list-row-fileid="fileid"
:data-cy-files-list-row-name="source.basename"
Expand All @@ -37,8 +37,7 @@
<span v-if="source.attributes.failed" class="files-list__row--failed" />

<!-- Checkbox -->
<FileEntryCheckbox v-if="visible"
:display-name="displayName"
<FileEntryCheckbox :display-name="displayName"
:fileid="fileid"
:is-loading="isLoading"
:nodes="nodes" />
Expand Down Expand Up @@ -67,8 +66,7 @@
:files-list-width="filesListWidth"
:loading.sync="loading"
:opened.sync="openedMenu"
:source="source"
:visible="visible" />
:source="source" />

<!-- Size -->
<td v-if="!compact && isSizeAvailable"
Expand All @@ -95,8 +93,7 @@
class="files-list__row-column-custom"
:data-cy-files-list-row-column-custom="column.id"
@click="openDetailsIfAvailable">
<CustomElementRender v-if="visible"
:current-view="currentView"
<CustomElementRender :current-view="currentView"
:render="column.render"
:source="source" />
</td>
Expand Down Expand Up @@ -146,10 +143,6 @@ export default Vue.extend({
},
props: {
visible: {
type: Boolean,
default: false,
},
isMtimeAvailable: {
type: Boolean,
default: false,
Expand Down
13 changes: 3 additions & 10 deletions apps/files/src/components/FileEntry/FileEntryActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
-
-->
<template>
<td v-show="visible"
class="files-list__row-actions"
<td class="files-list__row-actions"
data-cy-files-list-row-actions>
<!-- Render actions -->
<CustomElementRender v-for="action in enabledRenderActions"
Expand All @@ -33,8 +32,7 @@
class="files-list__row-action--inline" />

<!-- Menu actions -->
<NcActions v-if="visible"
ref="actionsMenu"
<NcActions ref="actionsMenu"
:boundaries-element="getBoundariesElement"
:container="getBoundariesElement"
:disabled="isLoading || loading !== ''"
Expand Down Expand Up @@ -71,7 +69,6 @@ import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import CustomElementRender from '../CustomElementRender.vue'
import logger from '../../logger.js'
// The registered actions list
Expand Down Expand Up @@ -105,10 +102,6 @@ export default Vue.extend({
type: Object as PropType<Node>,
required: true,
},
visible: {
type: Boolean,
default: false,
},
gridMode: {
type: Boolean,
default: false,
Expand Down Expand Up @@ -153,7 +146,7 @@ export default Vue.extend({
// Enabled action that are displayed inline with a custom render function
enabledRenderActions() {
if (!this.visible || this.gridMode) {
if (this.gridMode) {
return []
}
return this.enabledActions.filter(action => typeof action.renderInline === 'function')
Expand Down
12 changes: 3 additions & 9 deletions apps/files/src/components/FileEntryGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
-->

<template>
<tr :class="{'files-list__row--visible': visible, 'files-list__row--active': isActive, 'files-list__row--dragover': dragover, 'files-list__row--loading': isLoading}"
<tr :class="{'files-list__row--active': isActive, 'files-list__row--dragover': dragover, 'files-list__row--loading': isLoading}"
data-cy-files-list-row
:data-cy-files-list-row-fileid="fileid"
:data-cy-files-list-row-name="source.basename"
Expand All @@ -37,8 +37,7 @@
<span v-if="source.attributes.failed" class="files-list__row--failed" />

<!-- Checkbox -->
<FileEntryCheckbox v-if="visible"
:display-name="displayName"
<FileEntryCheckbox :display-name="displayName"
:fileid="fileid"
:is-loading="isLoading"
:nodes="nodes" />
Expand Down Expand Up @@ -69,8 +68,7 @@
:grid-mode="true"
:loading.sync="loading"
:opened.sync="openedMenu"
:source="source"
:visible="visible" />
:source="source" />
</tr>
</template>

Expand Down Expand Up @@ -115,10 +113,6 @@ export default Vue.extend({
inheritAttrs: false,
props: {
visible: {
type: Boolean,
default: false,
},
source: {
type: [Folder, NcFile, Node] as PropType<Node>,
required: true,
Expand Down
13 changes: 6 additions & 7 deletions apps/files/src/components/FilesListVirtual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,17 @@ export default Vue.extend({
event.preventDefault()
event.stopPropagation()
// If reaching top, scroll up
const firstVisible = this.$refs.table?.$el?.querySelector('.files-list__row--visible') as HTMLElement
const firstSibling = firstVisible?.previousElementSibling as HTMLElement
if ([firstVisible, firstSibling].some(elmt => elmt?.contains(event.target as Node))) {
const tableTop = this.$refs.table.$el.getBoundingClientRect().top
const tableBottom = tableTop + this.$refs.table.$el.getBoundingClientRect().height
// If reaching top, scroll up. Using 100 because of the floating header
if (event.clientY < tableTop + 100) {
this.$refs.table.$el.scrollTop = this.$refs.table.$el.scrollTop - 25
return
}
// If reaching bottom, scroll down
const lastVisible = [...(this.$refs.table?.$el?.querySelectorAll('.files-list__row--visible') || [])].pop() as HTMLElement
const nextSibling = lastVisible?.nextElementSibling as HTMLElement
if ([lastVisible, nextSibling].some(elmt => elmt?.contains(event.target as Node))) {
if (event.clientY > tableBottom - 50) {
this.$refs.table.$el.scrollTop = this.$refs.table.$el.scrollTop + 25
}
},
Expand Down
1 change: 0 additions & 1 deletion apps/files/src/components/VirtualList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<component :is="dataComponent"
v-for="({key, item}, i) in renderedItems"
:key="key"
:visible="true"
:source="item"
:index="i"
v-bind="extraProps" />
Expand Down
4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

0 comments on commit 4db0388

Please sign in to comment.