Skip to content

Commit

Permalink
Change approach for batch actions inside contextmenu
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed Nov 4, 2021
1 parent 2f8bf35 commit e8944e8
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 30 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/enhancement-contextmenu-multiple-files
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Contextmenu for multiple files

We have enabled batch actions in the context menu for when multiple resources are selected.

https://github.com/owncloud/web/pull/5973
https://github.com/owncloud/web/issues/5968
30 changes: 27 additions & 3 deletions packages/web-app-files/src/components/FilesList/ContextActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:id="`oc-files-context-actions-${section.name}`"
:key="`section-${section.name}-list`"
class="uk-list oc-mt-s oc-files-context-actions"
:class="{ 'oc-my-s': i === menuSections.length - 1 }"
>
<li
v-for="(action, j) in section.items"
Expand Down Expand Up @@ -75,8 +76,8 @@ export default {
],
props: {
item: {
type: Object,
items: {
type: Array,
required: true
}
},
Expand All @@ -86,6 +87,15 @@ export default {
menuSections() {
const sections = []
if (this.items.length > 1) {
sections.push({
name: 'batch-actions',
items: this.menuItemsBatchActions
})
return sections
}
if (this.menuItemsContext.length) {
sections.push({
name: 'context',
Expand All @@ -109,11 +119,25 @@ export default {
filterParams() {
return {
resource: this.item,
resource: this.items[0],
resources: this.items,
parent: this.currentFolder
}
},
menuItemsBatchActions() {
return [
...this.$_rename_items,
...this.$_move_items,
...this.$_copy_items,
...this.$_restore_items,
...this.$_acceptShare_items,
...this.$_declineShare_items,
...this.$_delete_items,
...this.$_showActions_items
].filter((item) => item.isEnabled(this.filterParams))
},
menuItemsContext() {
const fileHandlers = [
...this.$_fileActions_editorActions,
Expand Down
15 changes: 11 additions & 4 deletions packages/web-app-files/src/views/Favorites.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<quick-actions class="oc-visible@s" :item="props.resource" :actions="app.quickActions" />
</template>
<template #contextMenu="{ resource }">
<context-actions v-if="isHighlightedFile(resource)" :item="resource" />
<context-actions v-if="isResourceInSelection(resource)" :items="selected" />
</template>
<template #footer>
<pagination />
Expand Down Expand Up @@ -67,7 +67,14 @@ import { DavProperties } from 'web-pkg/src/constants'
const visibilityObserver = new VisibilityObserver()
export default {
components: { QuickActions, ListLoader, NoContentMessage, ListInfo, Pagination, ContextActions },
components: {
QuickActions,
ListLoader,
NoContentMessage,
ListInfo,
Pagination,
ContextActions
},
mixins: [
FileActions,
Expand Down Expand Up @@ -176,8 +183,8 @@ export default {
visibilityObserver.observe(component.$el, { onEnter: debounced, onExit: debounced.cancel })
},
isHighlightedFile(resource) {
return resource && resource.id === this.highlightedFile?.id
isResourceInSelection(resource) {
return(this.selected?.includes(resource))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/web-app-files/src/views/Personal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/>
</template>
<template #contextMenu="{ resource }">
<context-actions v-if="isHighlightedFile(resource)" :item="resource" />
<context-actions v-if="isResourceInSelection(resource)" :items="selected" />
</template>
<template #footer>
<pagination />
Expand Down Expand Up @@ -387,8 +387,8 @@ export default {
}
},
isHighlightedFile(resource) {
return resource && resource.id === this.highlightedFile?.id
isResourceInSelection(resource) {
return(this.selected?.includes(resource))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/web-app-files/src/views/PublicFiles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@rowMounted="rowMounted"
>
<template #contextMenu="{ resource }">
<context-actions v-if="isHighlightedFile(resource)" :item="resource" />
<context-actions v-if="isResourceInSelection(resource)" :item="resource" />
</template>
<template #footer>
<pagination />
Expand Down Expand Up @@ -242,8 +242,8 @@ export default {
})
},
isHighlightedFile(resource) {
return resource && resource.id === this.highlightedFile?.id
isResourceInSelection(resource) {
return(this.selected?.includes(resource))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/web-app-files/src/views/SharedViaLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@rowMounted="rowMounted"
>
<template #contextMenu="{ resource }">
<context-actions v-if="isHighlightedFile(resource)" :item="resource" />
<context-actions v-if="isResourceInSelection(resource)" :items="selected" />
</template>
<template #footer>
<pagination />
Expand Down Expand Up @@ -190,8 +190,8 @@ export default {
visibilityObserver.observe(component.$el, { onEnter: debounced, onExit: debounced.cancel })
},
isHighlightedFile(resource) {
return resource && resource.id === this.highlightedFile?.id
isResourceInSelection(resource) {
return(this.selected?.includes(resource))
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/web-app-files/src/views/SharedWithMe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</div>
</template>
<template #contextMenu="{ resource }">
<context-actions v-if="isHighlightedFile(resource)" :item="resource" />
<context-actions v-if="isResourceInSelection(resource)" :item="resource" />
</template>
<template v-if="pendingHasMore" #footer>
<div class="uk-width-1-1 uk-text-center oc-mt">
Expand Down Expand Up @@ -132,7 +132,7 @@
</div>
</template>
<template #contextMenu="{ resource }">
<context-actions v-if="isHighlightedFile(resource)" :item="resource" />
<context-actions v-if="isResourceInSelection(resource)" :items="selected" />
</template>
<template #footer>
<list-info
Expand Down Expand Up @@ -385,8 +385,8 @@ export default {
this.showMorePending = !this.showMorePending
},
isHighlightedFile(resource) {
return resource && resource.id === this.highlightedFile?.id
isResourceInSelection(resource) {
return(this.selected?.includes(resource))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/web-app-files/src/views/SharedWithOthers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@rowMounted="rowMounted"
>
<template #contextMenu="{ resource }">
<context-actions v-if="isHighlightedFile(resource)" :item="resource" />
<context-actions v-if="isResourceInSelection(resource)" :items="selected" />
</template>
<template #footer>
<pagination />
Expand Down Expand Up @@ -195,8 +195,8 @@ export default {
visibilityObserver.observe(component.$el, { onEnter: debounced, onExit: debounced.cancel })
},
isHighlightedFile(resource) {
return resource && resource.id === this.highlightedFile?.id
isResourceInSelection(resource) {
return(this.selected?.includes(resource))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/web-app-files/src/views/Trashbin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
:header-position="headerPosition"
>
<template #contextMenu="{ resource }">
<context-actions v-if="isHighlightedFile(resource)" :item="resource" />
<context-actions v-if="isResourceInSelection(resource)" :items="selected" />
</template>
<template #footer>
<pagination />
Expand Down Expand Up @@ -138,8 +138,8 @@ export default {
methods: {
...mapMutations('Files', ['LOAD_FILES', 'SET_FILE_SELECTION', 'CLEAR_CURRENT_FILES_LIST']),
isHighlightedFile(resource) {
return resource && resource.id === this.highlightedFile?.id
isResourceInSelection(resource) {
return(this.selected?.includes(resource))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ContextActions menu items renders a list of actions for a file 1`] = `
<div id="oc-files-context-menu">
<div id="oc-files-context-menu" item="[object Object]">
<ul id="oc-files-context-actions-context" class="uk-list oc-mt-s oc-files-context-actions">
<li class="oc-files-context-action"><button class="oc-button oc-button-m oc-button-justify-content-center oc-button-gap-m oc-button-passive oc-button-passive-raw oc-text-bold oc-files-actions-markdown-editor-trigger">
<oc-icon-stub name="text" accessiblelabel="" type="span" size="medium" variation="passive"></oc-icon-stub>
Expand Down Expand Up @@ -68,7 +68,7 @@ exports[`ContextActions menu items renders a list of actions for a file 1`] = `
</button></li>
</ul>
<hr>
<ul id="oc-files-context-actions-sidebar" class="uk-list oc-mt-s oc-files-context-actions">
<ul id="oc-files-context-actions-sidebar" class="uk-list oc-mt-s oc-files-context-actions oc-my-s">
<li class="oc-files-context-action"><button class="oc-button oc-button-m oc-button-justify-content-center oc-button-gap-m oc-button-passive oc-button-passive-raw oc-text-bold oc-files-actions-show-details-trigger">
<oc-icon-stub name="info_outline" accessiblelabel="" type="span" size="medium" variation="passive"></oc-icon-stub>
<!----> <span class="oc-files-context-action-label">Details</span>
Expand All @@ -80,7 +80,7 @@ exports[`ContextActions menu items renders a list of actions for a file 1`] = `
`;
exports[`ContextActions menu items renders a list of actions for a folder 1`] = `
<div id="oc-files-context-menu">
<div id="oc-files-context-menu" item="[object Object]">
<ul id="oc-files-context-actions-context" class="uk-list oc-mt-s oc-files-context-actions">
<li class="oc-files-context-action"><button class="oc-button oc-button-m oc-button-justify-content-center oc-button-gap-m oc-button-passive oc-button-passive-raw oc-text-bold oc-files-actions-markdown-editor-trigger">
<oc-icon-stub name="text" accessiblelabel="" type="span" size="medium" variation="passive"></oc-icon-stub>
Expand Down Expand Up @@ -147,7 +147,7 @@ exports[`ContextActions menu items renders a list of actions for a folder 1`] =
</button></li>
</ul>
<hr>
<ul id="oc-files-context-actions-sidebar" class="uk-list oc-mt-s oc-files-context-actions">
<ul id="oc-files-context-actions-sidebar" class="uk-list oc-mt-s oc-files-context-actions oc-my-s">
<li class="oc-files-context-action"><button class="oc-button oc-button-m oc-button-justify-content-center oc-button-gap-m oc-button-passive oc-button-passive-raw oc-text-bold oc-files-actions-show-details-trigger">
<oc-icon-stub name="info_outline" accessiblelabel="" type="span" size="medium" variation="passive"></oc-icon-stub>
<!----> <span class="oc-files-context-action-label">Details</span>
Expand Down

0 comments on commit e8944e8

Please sign in to comment.