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

feat: hide quick actions for files in embed mode #10071

Merged
merged 1 commit into from
Nov 27, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/unreleased/enhancement-embed-mode-actions
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ We've added three new actions available in the embed mode. These actions are "Sh

https://github.com/owncloud/web/pull/9841
https://github.com/owncloud/web/pull/9981
https://github.com/owncloud/web/pull/10071
https://github.com/owncloud/web/issues/9768
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="oc-flex">
<div v-if="!isEmbedModeEnabled" class="oc-flex">
<oc-button
v-for="action in filteredActions"
:key="action.label($gettext)"
Expand All @@ -23,6 +23,7 @@ import { computed, defineComponent } from 'vue'
import {
useAbility,
useClientService,
useEmbedMode,
usePasswordPolicyService,
useStore
} from '@ownclouders/web-pkg'
Expand All @@ -47,6 +48,7 @@ export default defineComponent({
const clientService = useClientService()
const passwordPolicyService = usePasswordPolicyService()
const language = useGettext()
const { isEnabled: isEmbedModeEnabled } = useEmbedMode()

const filteredActions = computed(() =>
pickBy(props.actions, (action) => action.displayed(props.item, store, ability) === true)
Expand All @@ -58,7 +60,8 @@ export default defineComponent({
passwordPolicyService,
store,
language,
filteredActions
filteredActions,
isEmbedModeEnabled
}
}
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { useEmbedMode } from '@ownclouders/web-pkg'
import QuickActions from '../../../../src/components/FilesList/QuickActions.vue'
import { defaultComponentMocks, defaultPlugins, shallowMount } from 'web-test-helpers'
import { mock } from 'jest-mock-extended'
import { ref } from 'vue'

jest.mock('@ownclouders/web-pkg', () => ({
...jest.requireActual('@ownclouders/web-pkg'),
useEmbedMode: jest.fn()
}))

const collaboratorAction = {
displayed: jest.fn(() => true),
Expand All @@ -25,10 +33,6 @@ const testItem = {
}

describe('QuickActions', () => {
afterEach(() => {
jest.clearAllMocks()
})

describe('when multiple actions are provided', () => {
const { wrapper } = getWrapper()

Expand Down Expand Up @@ -67,9 +71,18 @@ describe('QuickActions', () => {
})
})
})

it('does not show actions in embed mode', () => {
const { wrapper } = getWrapper({ embedModeEnabled: true })
expect(wrapper.findAll('.oc-button').length).toBe(0)
})
})

function getWrapper() {
function getWrapper({ embedModeEnabled = false } = {}) {
jest
.mocked(useEmbedMode)
.mockReturnValue(mock<ReturnType<typeof useEmbedMode>>({ isEnabled: ref(embedModeEnabled) }))

return {
wrapper: shallowMount(QuickActions, {
props: {
Expand Down