mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 08:44:07 -04:00
Merge pull request #50904 from nextcloud/fix/files-rename-folder
fix(files): do not show extension warning for folders renaming
This commit is contained in:
commit
bdc043dd04
4 changed files with 70 additions and 7 deletions
|
|
@ -7,7 +7,7 @@ import type { RenamingStore } from '../types'
|
|||
|
||||
import axios, { isAxiosError } from '@nextcloud/axios'
|
||||
import { emit, subscribe } from '@nextcloud/event-bus'
|
||||
import { NodeStatus } from '@nextcloud/files'
|
||||
import { FileType, NodeStatus } from '@nextcloud/files'
|
||||
import { DialogBuilder } from '@nextcloud/dialogs'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import { basename, dirname, extname } from 'path'
|
||||
|
|
@ -103,10 +103,10 @@ export const useRenamingStore = function(...args) {
|
|||
const oldName = this.renamingNode.basename
|
||||
const oldEncodedSource = this.renamingNode.encodedSource
|
||||
|
||||
// Check for extension change
|
||||
// Check for extension change for files
|
||||
const oldExtension = extname(oldName)
|
||||
const newExtension = extname(newName)
|
||||
if (oldExtension !== newExtension) {
|
||||
if (oldExtension !== newExtension && this.renamingNode.type === FileType.File) {
|
||||
const proceed = await showWarningDialog(oldExtension, newExtension)
|
||||
if (!proceed) {
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
import type { User } from '@nextcloud/cypress'
|
||||
import { calculateViewportHeight, getRowForFile, haveValidity, renameFile, triggerActionForFile } from './FilesUtils'
|
||||
import { calculateViewportHeight, createFolder, getRowForFile, haveValidity, renameFile, triggerActionForFile } from './FilesUtils'
|
||||
|
||||
describe('files: Rename nodes', { testIsolation: true }, () => {
|
||||
let user: User
|
||||
|
|
@ -193,4 +193,67 @@ describe('files: Rename nodes', { testIsolation: true }, () => {
|
|||
.findByRole('textbox', { name: 'Filename' })
|
||||
.should('not.exist')
|
||||
})
|
||||
|
||||
it('shows warning on extension change', () => {
|
||||
getRowForFile('file.txt').should('be.visible')
|
||||
|
||||
triggerActionForFile('file.txt', 'rename')
|
||||
getRowForFile('file.txt')
|
||||
.findByRole('textbox', { name: 'Filename' })
|
||||
.should('be.visible')
|
||||
.type('{selectAll}file.md')
|
||||
.should(haveValidity(''))
|
||||
.type('{enter}')
|
||||
|
||||
// See warning dialog
|
||||
cy.findByRole('dialog', { name: 'Change file extension' })
|
||||
.should('be.visible')
|
||||
.findByRole('button', { name: /use/i })
|
||||
.click()
|
||||
|
||||
// See it is renamed
|
||||
getRowForFile('file.md').should('be.visible')
|
||||
})
|
||||
|
||||
it('shows warning on extension change and allow cancellation', () => {
|
||||
getRowForFile('file.txt').should('be.visible')
|
||||
|
||||
triggerActionForFile('file.txt', 'rename')
|
||||
getRowForFile('file.txt')
|
||||
.findByRole('textbox', { name: 'Filename' })
|
||||
.should('be.visible')
|
||||
.type('{selectAll}file.md')
|
||||
.should(haveValidity(''))
|
||||
.type('{enter}')
|
||||
|
||||
// See warning dialog
|
||||
cy.findByRole('dialog', { name: 'Change file extension' })
|
||||
.should('be.visible')
|
||||
.findByRole('button', { name: /keep/i })
|
||||
.click()
|
||||
|
||||
// See it is not renamed
|
||||
getRowForFile('file.txt').should('be.visible')
|
||||
getRowForFile('file.md').should('not.exist')
|
||||
})
|
||||
|
||||
it('does not show warning on folder renaming with a dot', () => {
|
||||
createFolder('folder.2024')
|
||||
|
||||
getRowForFile('folder.2024').should('be.visible')
|
||||
|
||||
triggerActionForFile('folder.2024', 'rename')
|
||||
getRowForFile('folder.2024')
|
||||
.findByRole('textbox', { name: 'Folder name' })
|
||||
.should('be.visible')
|
||||
.type('{selectAll}folder.2025')
|
||||
.should(haveValidity(''))
|
||||
.type('{enter}')
|
||||
|
||||
// See warning dialog
|
||||
cy.get('[role=dialog]').should('not.exist')
|
||||
|
||||
// See it is not renamed
|
||||
getRowForFile('folder.2025').should('be.visible')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
4
dist/files-main.js
vendored
4
dist/files-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-main.js.map
vendored
2
dist/files-main.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue