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
3 changes: 3 additions & 0 deletions l10n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ msgstr ""
msgid "When an incoming folder is selected, any conflicting files within it will also be overwritten."
msgstr ""

msgid "When an incoming folder is selected, any files within it will also be overwritten."
msgstr ""

msgid "When an incoming folder is selected, the content is written into the existing folder and a recursive conflict resolution is performed."
msgstr ""

Expand Down
8 changes: 8 additions & 0 deletions lib/components/ConflictPicker/ConflictPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ const props = defineProps<{
* If set to true no hint about overwriting directory content will be shown
*/
recursiveUpload?: boolean

/**
* If set tot true a hint is shown that any folder content will be overwritten
*/
isOverwriting?: boolean
}>()

const emit = defineEmits<{
Expand Down Expand Up @@ -185,6 +190,9 @@ function onSubmit() {
<template v-if="recursiveUpload">
{{ t('When an incoming folder is selected, the content is written into the existing folder and a recursive conflict resolution is performed.') }}
</template>
<template v-else-if="isOverwriting">
{{ t('When an incoming folder is selected, any files within it will also be overwritten.') }}
</template>
<template v-else>
{{ t('When an incoming folder is selected, any conflicting files within it will also be overwritten.') }}
</template>
Expand Down
7 changes: 7 additions & 0 deletions lib/conflict-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export interface ConflictPickerOptions {
* You still need to call this function for each directory separately.
*/
recursive?: boolean

/**
* When this is set to true a hint is shown that any folder content will be overwritten.
* This is useful if the operation with conflicts is a move that will not perform any "write-into" logic.
*/
overwriting?: boolean
}

/**
Expand Down Expand Up @@ -84,6 +90,7 @@ export async function openConflictPicker<T extends ConflictInput>(
dirname,
existing,
incoming,
isOverwriting: options?.overwriting === true,
recursiveUpload: options?.recursive === true,
}, {
container: options?.container,
Expand Down
36 changes: 35 additions & 1 deletion tests/components/ConflictPicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import type { ConflictInput, ConflictResolutionResult } from '../../lib/conflict-picker.ts'

import { File as NcFile } from '@nextcloud/files'
import { cleanup, fireEvent, getAllByRole, getByRole, render } from '@testing-library/vue'
import { cleanup, findByText, fireEvent, getAllByRole, getByRole, render } from '@testing-library/vue'
import { readFile } from 'fs/promises'
import { join } from 'path'
import { afterEach, beforeAll, describe, expect, test } from 'vitest'
Expand Down Expand Up @@ -75,6 +75,40 @@ describe('ConflictPicker resolving', () => {
]
})

test('Show override hint', async () => {
const component = render(ConflictPicker, {
props: {
container: getContainer(),
dirname: 'Pictures',
existing: [old1, old2],
incoming: [...images],
},
})

const dialog = getByRole(document.body, 'dialog')
expect(dialog).toBeInstanceOf(HTMLElement)

await expect(findByText(dialog, /folder is selected, any conflicting files within it/)).resolves.not.toThrow()

await component.rerender({
container: getContainer(),
dirname: 'Pictures',
existing: [old1, old2],
incoming: [...images],
isOverwriting: true,
})
await expect(findByText(dialog, /folder is selected, any files within it/)).resolves.not.toThrow()

await component.rerender({
container: getContainer(),
dirname: 'Pictures',
existing: [old1, old2],
incoming: [...images],
recursiveUpload: true,
})
await expect(findByText(dialog, /folder is selected, the content is written into the existing folder/)).resolves.not.toThrow()
})

test('Pick all incoming files', async () => {
const component = render(ConflictPicker, {
props: {
Expand Down
Loading