Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable28] fix(files): move actions for selected file out from table header #42691

Merged
merged 3 commits into from Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
86 changes: 40 additions & 46 deletions apps/files/src/components/FilesListTableHeader.vue
Expand Up @@ -26,53 +26,47 @@
<NcCheckboxRadioSwitch v-bind="selectAllBind" @update:checked="onToggleAll" />
</th>

<!-- Actions multiple if some are selected -->
<FilesListTableHeaderActions v-if="!isNoneSelected"
:current-view="currentView"
:selected-nodes="selectedNodes" />

<!-- Columns display -->
<template v-else>
<!-- Link to file -->
<th class="files-list__column files-list__row-name files-list__column--sortable"
:aria-sort="ariaSortForMode('basename')">
<!-- Icon or preview -->
<span class="files-list__row-icon" />

<!-- Name -->
<FilesListTableHeaderButton :name="t('files', 'Name')" mode="basename" />
</th>

<!-- Actions -->
<th class="files-list__row-actions" />

<!-- Size -->
<th v-if="isSizeAvailable"
:class="{'files-list__column--sortable': isSizeAvailable}"
class="files-list__column files-list__row-size"
:aria-sort="ariaSortForMode('size')">
<FilesListTableHeaderButton :name="t('files', 'Size')" mode="size" />
</th>

<!-- Mtime -->
<th v-if="isMtimeAvailable"
:class="{'files-list__column--sortable': isMtimeAvailable}"
class="files-list__column files-list__row-mtime"
:aria-sort="ariaSortForMode('mtime')">
<FilesListTableHeaderButton :name="t('files', 'Modified')" mode="mtime" />
</th>

<!-- Custom views columns -->
<th v-for="column in columns"
:key="column.id"
:class="classForColumn(column)"
:aria-sort="ariaSortForMode(column.id)">
<FilesListTableHeaderButton v-if="!!column.sort" :name="column.title" :mode="column.id" />
<span v-else>
{{ column.title }}
</span>
</th>
</template>

<!-- Link to file -->
<th class="files-list__column files-list__row-name files-list__column--sortable"
:aria-sort="ariaSortForMode('basename')">
<!-- Icon or preview -->
<span class="files-list__row-icon" />

<!-- Name -->
<FilesListTableHeaderButton :name="t('files', 'Name')" mode="basename" />
</th>

<!-- Actions -->
<th class="files-list__row-actions" />

<!-- Size -->
<th v-if="isSizeAvailable"
class="files-list__column files-list__row-size"
:class="{ 'files-list__column--sortable': isSizeAvailable }"
:aria-sort="ariaSortForMode('size')">
<FilesListTableHeaderButton :name="t('files', 'Size')" mode="size" />
</th>

<!-- Mtime -->
<th v-if="isMtimeAvailable"
class="files-list__column files-list__row-mtime"
:class="{ 'files-list__column--sortable': isMtimeAvailable }"
:aria-sort="ariaSortForMode('mtime')">
<FilesListTableHeaderButton :name="t('files', 'Modified')" mode="mtime" />
</th>

<!-- Custom views columns -->
<th v-for="column in columns"
:key="column.id"
:class="classForColumn(column)"
:aria-sort="ariaSortForMode(column.id)">
<FilesListTableHeaderButton v-if="!!column.sort" :name="column.title" :mode="column.id" />
<span v-else>
{{ column.title }}
</span>
</th>
</tr>
</template>

Expand Down
15 changes: 3 additions & 12 deletions apps/files/src/components/FilesListTableHeaderActions.vue
Expand Up @@ -20,7 +20,7 @@
-
-->
<template>
<th class="files-list__column files-list__row-actions-batch" colspan="2">
<div class="files-list__column files-list__row-actions-batch">
<NcActions ref="actionsMenu"
:disabled="!!loading || areSomeNodesLoading"
:force-name="true"
Expand All @@ -38,7 +38,7 @@
{{ action.displayName(nodes, currentView) }}
</NcActionButton>
</NcActions>
</th>
</div>
</template>

<script lang="ts">
Expand Down Expand Up @@ -218,15 +218,6 @@ export default Vue.extend({
<style scoped lang="scss">
.files-list__row-actions-batch {
flex: 1 1 100% !important;

// Remove when https://github.com/nextcloud/nextcloud-vue/pull/3936 is merged
::v-deep .button-vue__wrapper {
width: 100%;
span.button-vue__text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
max-width: 100%;
}
</style>
35 changes: 35 additions & 0 deletions apps/files/src/components/FilesListVirtual.vue
Expand Up @@ -33,6 +33,11 @@
}"
:scroll-to-index="scrollToIndex"
:caption="caption">
<template v-if="!isNoneSelected" #header-overlay>
<FilesListTableHeaderActions :current-view="currentView"
:selected-nodes="selectedNodes" />
</template>

<template #before>
<!-- Headers -->
<FilesListHeader v-for="header in sortedHeaders"
Expand Down Expand Up @@ -76,6 +81,7 @@ import { defineComponent } from 'vue'

import { action as sidebarAction } from '../actions/sidebarAction.ts'
import { useUserConfigStore } from '../store/userconfig.ts'
import { useSelectionStore } from '../store/selection.js'

import FileEntry from './FileEntry.vue'
import FileEntryGrid from './FileEntryGrid.vue'
Expand All @@ -85,6 +91,7 @@ import FilesListTableHeader from './FilesListTableHeader.vue'
import filesListWidthMixin from '../mixins/filesListWidth.ts'
import VirtualList from './VirtualList.vue'
import logger from '../logger.js'
import FilesListTableHeaderActions from './FilesListTableHeaderActions.vue'

export default defineComponent({
name: 'FilesListVirtual',
Expand All @@ -94,6 +101,7 @@ export default defineComponent({
FilesListTableFooter,
FilesListTableHeader,
VirtualList,
FilesListTableHeaderActions,
},

mixins: [
Expand All @@ -117,8 +125,10 @@ export default defineComponent({

setup() {
const userConfigStore = useUserConfigStore()
const selectionStore = useSelectionStore()
return {
userConfigStore,
selectionStore,
}
},

Expand Down Expand Up @@ -185,6 +195,14 @@ export default defineComponent({
const virtualListNote = t('files', 'This list is not fully rendered for performance reasons. The files will be rendered as you navigate through the list.')
return `${viewCaption}\n${sortableCaption}\n${virtualListNote}`
},

selectedNodes() {
return this.selectionStore.selected
},

isNoneSelected() {
return this.selectedNodes.length === 0
},
},

watch: {
Expand Down Expand Up @@ -298,6 +316,7 @@ export default defineComponent({
--clickable-area: 44px;
--icon-preview-size: 32px;

position: relative;
overflow: auto;
height: 100%;
will-change: scroll-position;
Expand Down Expand Up @@ -333,6 +352,22 @@ export default defineComponent({
display: block;
}

.files-list__thead-overlay {
position: absolute;
top: 0;
left: var(--row-height); // Save space for a row checkbox
right: 0;
z-index: 1000;

display: flex;
align-items: center;

// Reuse row styles
background-color: var(--color-main-background);
border-bottom: 1px solid var(--color-border);
height: var(--row-height);
}

.files-list__thead,
.files-list__tfoot {
display: flex;
Expand Down
4 changes: 4 additions & 0 deletions apps/files/src/components/VirtualList.vue
@@ -1,5 +1,9 @@
<template>
<div class="files-list" data-cy-files-list>
<div v-if="!!$scopedSlots['header-overlay']" class="files-list__thead-overlay">
<slot name="header-overlay" />
</div>

<!-- Header -->
<div ref="before" class="files-list__before">
<slot name="before" />
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.