Skip to content

Commit

Permalink
[full-ci] Hide batch actions if only 1 resource has been selected (#7904
Browse files Browse the repository at this point in the history
)
  • Loading branch information
JammingBen authored Nov 3, 2022
1 parent 5e2bfaf commit 987f7e4
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 55 deletions.
9 changes: 7 additions & 2 deletions packages/web-app-files/src/components/AppBar/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<div class="files-app-bar-actions oc-mt-xs">
<div class="oc-flex-1 oc-flex oc-flex-start">
<slot
v-if="showActionsOnSelection || selectedFiles.length === 0"
v-if="!selectedFiles.length || (showActionsOnSelection && selectedFiles.length === 1)"
name="actions"
:limited-screen-space="limitedScreenSpace"
/>
Expand Down Expand Up @@ -66,6 +66,7 @@ import { defineComponent, PropType } from '@vue/composition-api'
import { Resource } from 'web-client'
import { BreadcrumbItem } from '../../helpers/breadcrumbs'
import { SpaceResource } from 'web-client/src/helpers'
import { isLocationTrashActive } from 'web-app-files/src/router'
export default defineComponent({
components: {
Expand Down Expand Up @@ -115,7 +116,11 @@ export default defineComponent({
return last<BreadcrumbItem>(this.breadcrumbs).allowContextActions
},
showBatchActions() {
return this.hasBulkActions
return (
this.hasBulkActions &&
(this.selectedFiles.length > 1 ||
isLocationTrashActive(this.$router, 'files-trash-generic'))
)
},
selectedResourcesAnnouncement() {
if (this.selectedFiles.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ export default defineComponent({
},
showActions() {
return (
!this.selectedFiles.length && !(this.uploadOrFileCreationBlocked && this.isPublicLocation)
)
return !(this.uploadOrFileCreationBlocked && this.isPublicLocation)
},
createFileActionsAvailable() {
Expand Down
11 changes: 11 additions & 0 deletions packages/web-app-files/tests/unit/components/AppBar/AppBar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ describe('AppBar component', () => {
const wrapper = getShallowWrapper(store, {}, { hasBulkActions: true })
expect(wrapper).toMatchSnapshot()
})
it('not if 1 file selected', () => {
const store = createStore({ selected: [selectedFiles[0]] })
const wrapper = getShallowWrapper(store, {}, { hasBulkActions: true })
expect(wrapper).toMatchSnapshot()
})
})
describe('sharesNavigation', () => {
it('if enabled', () => {
Expand Down Expand Up @@ -136,6 +141,12 @@ function getShallowWrapper(
meta: {
title: 'ExampleTitle'
}
},
$router: {
resolve: () => {
return { href: '' }
},
afterEach: jest.fn()
}
},
slots,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,29 @@ exports[`AppBar component renders bulkActions if enabled 1`] = `
</div>
`;

exports[`AppBar component renders bulkActions not if 1 file selected 1`] = `
<div id="files-app-bar" class="">
<oc-hidden-announcer-stub level="polite" announcement="1 item selected. Actions are available above the table."></oc-hidden-announcer-stub>
<div class="files-topbar oc-py-s">
<h1 class="oc-invisible-sr">ExampleTitle</h1>
<div class="oc-flex oc-flex-right">
<!---->
<!---->
<div class="oc-flex">
<view-options-stub></view-options-stub>
<sidebar-toggle-stub></sidebar-toggle-stub>
</div>
</div>
<div class="files-app-bar-actions oc-mt-xs">
<div class="oc-flex-1 oc-flex oc-flex-start">
<!---->
<batch-actions-stub></batch-actions-stub>
</div>
</div>
</div>
</div>
`;

exports[`AppBar component renders by default no breadcrumbs, no bulkactions, no sharesnavigation but viewoptions and sidebartoggle 1`] = `
<div id="files-app-bar" class="">
<oc-hidden-announcer-stub level="polite" announcement="No items selected."></oc-hidden-announcer-stub>
Expand Down
80 changes: 40 additions & 40 deletions tests/acceptance/features/webUIFiles/batchAction.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ Feature: Visibility of the batch actions menu
And user "Alice" has created folder "simple-folder" in the server


Scenario: View batch action menu for a folder on the personal page
Given user "Alice" has logged in using the webUI
When the user marks the folder "simple-folder" using the webUI
Then the following batch action buttons should be visible
| buttonName |
| Cut |
| Copy |
| Delete |


Scenario: View batch action menu for a file on the personal page
Given user "Alice" has created file "lorem.txt" in the server
And user "Alice" has logged in using the webUI
When the user marks the file "lorem.txt" using the webUI
Then the following batch action buttons should be visible
| buttonName |
| Download |
| Delete |
| Cut |
| Copy |




















Scenario: View batch action menu when selecting both file and folder on the personal page
Expand Down Expand Up @@ -59,30 +59,30 @@ Feature: Visibility of the batch actions menu
| Copy |


Scenario: View batch action menu for a folder on the shared with me page (Pending Share)
Given the setting "shareapi_auto_accept_share" of app "core" has been set to "no" in the server
And the administrator has set the default folder for received shares to "Shares" in the server
And user "Alice" has shared folder "simple-folder" with user "Brian" in the server
And user "Brian" has logged in using the webUI
And the user has browsed to the shared-with-me page
When the user marks the folder "simple-folder" using the webUI
Then the following batch action buttons should be visible
| buttonName |
| Accept |
| Decline |


Scenario: View batch action menu for a folder on the shared with me page (Accepted Share)
Given the setting "shareapi_auto_accept_share" of app "core" has been set to "no" in the server
And the administrator has set the default folder for received shares to "Shares" in the server
And user "Alice" has shared folder "simple-folder" with user "Brian" in the server
And user "Brian" has accepted the share "Shares/simple-folder" offered by user "Alice" in the server
And user "Brian" has logged in using the webUI
And the user has browsed to the shared-with-me page
When the user marks the folder "simple-folder" using the webUI
Then the following batch action buttons should be visible
| buttonName |
| Decline |
























Scenario: View batch action menu for a folder on the shared with others page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ Feature: move files
And user "Brian" has created folder "/Shares/testFolder" in the server
And the user has opened folder "Shares"
And the user has opened folder "simple-folder"
When the user batch moves these files into folder "/Shares/testFolder" using the webUI
| file_name |
| testFile.txt |
When the user moves file "testFile.txt" into folder "/Shares/testFolder" using the webUI
Then breadcrumb for folder "Shares" should be displayed on the webUI
And as "Brian" file "/Shares/testFolder/testFile.txt" should exist in the server
11 changes: 5 additions & 6 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const filesAction = `.oc-files-actions-%s-trigger`
const clipboardBtns = '#clipboard-btns'
const breadcrumbRoot = '//nav[contains(@class, "oc-breadcrumb")]/ol/li[1]/a'
const fileRenameInput = '.oc-text-input'
const deleteButton = 'button.oc-files-actions-delete-trigger'
const deleteButtonSidebar = '#oc-files-actions-sidebar .oc-files-actions-delete-trigger'
const actionConfirmationButton = '.oc-modal-body-actions-confirm'
const actionSecondaryConfirmationButton = '.oc-modal-body-actions-secondary'
const versionRevertButton = '//*[@data-testid="file-versions-revert-button"]'
Expand Down Expand Up @@ -392,12 +392,10 @@ export const deleteResource = async (args: deleteResourceArgs): Promise<void> =>
await clickResource({ page, path: folderPaths.join('/') })
}

const resourceCheckbox = page.locator(util.format(checkBox, resourceName))
await sidebar.open({ page, resource: resourceName })
await sidebar.openPanel({ page: page, name: 'actions' })

if (!(await resourceCheckbox.isChecked())) {
await resourceCheckbox.check()
}
await page.locator(deleteButton).first().click()
await page.locator(deleteButtonSidebar).first().click()
await Promise.all([
page.waitForResponse(
(resp) =>
Expand All @@ -407,6 +405,7 @@ export const deleteResource = async (args: deleteResourceArgs): Promise<void> =>
),
page.locator(actionConfirmationButton).click()
])
await sidebar.close({ page: page })
}

export interface downloadResourceVersionArgs {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/support/objects/app-files/utils/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const open = async ({
}

export const close = async ({ page }: { page: Page }): Promise<void> => {
await page.locator('.sidebar-panel.is-active-sub-panel .header__close').click()
await page.locator('.sidebar-panel .header__close').click()
}

export const openPanel = async ({ page, name }: { page: Page; name: string }): Promise<void> => {
Expand Down

0 comments on commit 987f7e4

Please sign in to comment.