Skip to content

Commit

Permalink
fix(FilePicker): Improve choose button text when selecting multiple
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Jan 18, 2024
1 parent d34dc98 commit f449566
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/filepicker-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type { Node } from '@nextcloud/files'

import { basename } from 'path'
import { spawnDialog } from './utils/dialogs'
import { t } from './utils/l10n'
import { n, t } from './utils/l10n'

import IconMove from '@mdi/svg/svg/folder-move.svg?raw'
import IconCopy from '@mdi/svg/svg/folder-multiple.svg?raw'
Expand Down Expand Up @@ -209,10 +209,16 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
const target = node || basename(path)

if (type === FilePickerType.Choose) {
let label = t('Choose')
if (nodes.length === 1) {
label = t('Choose {file}', { file: node })
} else if (this.multiSelect) {
label = n('Choose %n file', 'Choose %n files', nodes.length)
}
buttons.push({
callback: () => {},
label: node && !this.multiSelect ? t('Choose {file}', { file: node }) : t('Choose'),
type: 'primary',
label,
})
}
if (type === FilePickerType.CopyMove || type === FilePickerType.Copy) {
Expand Down

0 comments on commit f449566

Please sign in to comment.