Skip to content
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
5 changes: 5 additions & 0 deletions src/components/Request/RequestPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:inline="inline ? 3 : 0"
:force-name="inline"
:class="{column: inline}"
:variant="variant"
v-model:open="openedMenu">
<template #icon>
<NcIconSvgWrapper :path="mdiPlus" :size="20" />
Expand Down Expand Up @@ -147,6 +148,10 @@ export default {
type: Boolean,
default: false,
},
variant: {
type: String,
default: 'tertiary',
},
},
setup() {
const actionsMenuStore = useActionsMenuStore()
Expand Down
33 changes: 33 additions & 0 deletions src/tests/components/Request/RequestPicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,39 @@ describe('RequestPicker component rules', () => {
})
})

describe('variant prop', () => {
const mountWithVariantStub = (props = {}) => mount(RequestPicker, {
props,
global: {
stubs: {
NcActions: {
name: 'NcActions',
props: ['variant'],
template: '<div class="nc-actions-stub" :data-variant="variant"><slot /></div>',
},
NcActionButton: true,
NcButton: true,
NcDialog: true,
NcTextField: true,
NcLoadingIcon: true,
NcNoteCard: true,
UploadProgress: true,
},
mocks: { t: tSimple },
},
})

it('defaults variant to tertiary', () => {
const w = mountWithVariantStub()
expect(w.find('.nc-actions-stub').attributes('data-variant')).toBe('tertiary')
})

it('passes custom variant to NcActions', () => {
const w = mountWithVariantStub({ variant: 'primary' })
expect(w.find('.nc-actions-stub').attributes('data-variant')).toBe('primary')
})
})

describe('envelope support', () => {
it('enables envelope mode when capabilities indicate is-available true', () => {
getCapabilitiesMock.mockReturnValue({
Expand Down
57 changes: 54 additions & 3 deletions src/tests/views/FilesList/FilesList.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,17 @@ vi.mock('@nextcloud/vue/components/NcAppContent', () => ({
default: { name: 'NcAppContent', template: '<div><slot /></div>' },
}))
vi.mock('@nextcloud/vue/components/NcBreadcrumb', () => ({
default: { name: 'NcBreadcrumb', template: '<div><slot name="icon" /></div>' },
default: {
name: 'NcBreadcrumb',
template: '<div><slot name="icon" /><slot name="menu-icon" /><slot /></div>',
},
}))
vi.mock('@nextcloud/vue/components/NcActionButton', () => ({
default: {
name: 'NcActionButton',
emits: ['click'],
template: '<button class="nc-action-button-stub" @click="$emit(\'click\')"><slot /></button>',
},
}))
vi.mock('@nextcloud/vue/components/NcBreadcrumbs', () => ({
default: { name: 'NcBreadcrumbs', template: '<div><slot /><slot name="actions" /></div>' },
Expand Down Expand Up @@ -141,6 +151,45 @@ describe('FilesList.vue rendering rules', () => {
expect(wrapper.vm.mdiFolder).toBeTruthy()
expect(wrapper.vm.mdiViewGrid).toBeTruthy()
expect(wrapper.vm.mdiViewList).toBeTruthy()
expect(wrapper.vm.mdiChevronDown).toBeTruthy()
expect(wrapper.vm.mdiChevronUp).toBeTruthy()
expect(wrapper.vm.mdiReload).toBeTruthy()
})

it('initialises isMenuOpen as false', async () => {
const filesStore = useFilesStore()
vi.spyOn(filesStore, 'getAllFiles').mockResolvedValue({})

const wrapper = mountComponent()
await flushPromises()

expect(wrapper.vm.isMenuOpen).toBe(false)
})

it('renders RequestPicker before the breadcrumbs in the header', async () => {
const filesStore = useFilesStore()
vi.spyOn(filesStore, 'getAllFiles').mockResolvedValue({})

const wrapper = mountComponent()
await flushPromises()

const header = wrapper.find('.files-list__header')
const firstChild = header.element.children[0]
expect(firstChild.classList.contains('request-picker-stub')).toBe(true)
})

it('calls filesStore.updateAllFiles once more when reload button is clicked', async () => {
const filesStore = useFilesStore()
vi.spyOn(filesStore, 'getAllFiles').mockResolvedValue({})
const updateSpy = vi.spyOn(filesStore, 'updateAllFiles').mockResolvedValue({})

const wrapper = mountComponent()
await flushPromises()

const callsBefore = updateSpy.mock.calls.length
await wrapper.find('.nc-action-button-stub').trigger('click')

expect(updateSpy.mock.calls.length).toBe(callsBefore + 1)
})

it('shows empty-state request action when user can request sign', async () => {
Expand Down Expand Up @@ -186,7 +235,8 @@ describe('FilesList.vue rendering rules', () => {
const wrapper = mountComponent()
await flushPromises()

const iconWithPath = wrapper.findAll('.nc-icon').find((node) => !!node.attributes('data-path'))
const gridButton = wrapper.find('.files-list__header-grid-button')
const iconWithPath = gridButton.findAll('.nc-icon').find((node) => !!node.attributes('data-path'))
expect(iconWithPath?.attributes('data-path')).toBe(wrapper.vm.mdiViewGrid)
})

Expand All @@ -199,7 +249,8 @@ describe('FilesList.vue rendering rules', () => {
const wrapper = mountComponent()
await flushPromises()

const iconWithPath = wrapper.findAll('.nc-icon').find((node) => !!node.attributes('data-path'))
const gridButton = wrapper.find('.files-list__header-grid-button')
const iconWithPath = gridButton.findAll('.nc-icon').find((node) => !!node.attributes('data-path'))
expect(iconWithPath?.attributes('data-path')).toBe(wrapper.vm.mdiViewList)
})
})
34 changes: 29 additions & 5 deletions src/views/FilesList/FilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,40 @@
<template>
<NcAppContent :page-heading="t('libresign', 'Files')">
<div class="files-list__header">
<!-- Request picker -->
<RequestPicker variant="primary" />

<!-- Current folder breadcrumbs -->
<NcBreadcrumbs class="files-list__breadcrumbs">
<NcBreadcrumb :name="t('libresign', 'Files')"
:title="t('libresign', 'Files')"
:force-icon-text="true"
:to="{ name: 'fileslist' }"
:aria-description="t('libresign', 'Files')"
:disable-drop="true"
@click="refresh()">
force-menu
v-model:open="isMenuOpen">
<template #icon>
<NcIconSvgWrapper :size="20"
:svg="viewIcon" />
</template>
<template #menu-icon>
<NcIconSvgWrapper :path="isMenuOpen ? mdiChevronUp : mdiChevronDown" />
</template>
<!-- Reload button -->
<NcActionButton close-after-click @click="refresh()">
<template #icon>
<NcIconSvgWrapper :path="mdiReload" />
</template>
<!-- TRANSLATORS Button inside the breadcrumb dropdown menu that reloads the file list -->
{{ t('libresign', 'Reload content') }}
</NcActionButton>
</NcBreadcrumb>
<template #actions>
<RequestPicker />
</template>
</NcBreadcrumbs>

<NcLoadingIcon v-if="isRefreshing" class="files-list__refresh-icon" />
<NcLoadingIcon v-if="isRefreshing"
class="files-list__refresh-icon"
:name="t('libresign', 'File list is reloading')" />

<NcButton :aria-label="gridViewButtonLabel"
:title="gridViewButtonLabel"
Expand Down Expand Up @@ -75,11 +90,15 @@ import { t } from '@nextcloud/l10n'

import HomeSvg from '@mdi/svg/svg/home.svg?raw'
import {
mdiChevronDown,
mdiChevronUp,
mdiFolder,
mdiReload,
mdiViewGrid,
mdiViewList,
} from '@mdi/js'

import NcActionButton from '@nextcloud/vue/components/NcActionButton'
import NcAppContent from '@nextcloud/vue/components/NcAppContent'
import NcBreadcrumb from '@nextcloud/vue/components/NcBreadcrumb'
import NcBreadcrumbs from '@nextcloud/vue/components/NcBreadcrumbs'
Expand All @@ -99,6 +118,7 @@ import { useSidebarStore } from '../../store/sidebar.js'
export default {
name: 'FilesList',
components: {
NcActionButton,
NcAppContent,
NcButton,
NcBreadcrumb,
Expand All @@ -119,13 +139,17 @@ export default {
filtersStore,
userConfigStore,
sidebarStore,
mdiChevronDown,
mdiChevronUp,
mdiFolder,
mdiReload,
mdiViewGrid,
mdiViewList,
}
},
data() {
return {
isMenuOpen: false,
loading: true,
dirContentsFiltered: [],
}
Expand Down
Loading