Skip to content

Commit

Permalink
Merge pull request #47181 from nextcloud/fix/new-folder-messae
Browse files Browse the repository at this point in the history
fix(files): Add messages when "new folder" fails or gets cancelled
  • Loading branch information
susnux authored Aug 13, 2024
2 parents 6d19c48 + 7be3a9c commit 84bd79d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
13 changes: 10 additions & 3 deletions apps/files/src/newMenu/newFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { basename } from 'path'
import { emit } from '@nextcloud/event-bus'
import { getCurrentUser } from '@nextcloud/auth'
import { Permission, Folder } from '@nextcloud/files'
import { showSuccess } from '@nextcloud/dialogs'
import { showError, showInfo, showSuccess } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
import axios from '@nextcloud/axios'

Expand Down Expand Up @@ -47,7 +47,11 @@ export const entry = {
order: 0,
async handler(context: Folder, content: Node[]) {
const name = await newNodeName(t('files', 'New folder'), content)
if (name !== null) {
if (name === null) {
showInfo(t('files', 'Creating new folder cancelled'))
return
}
try {
const { fileid, source } = await createNewFolder(context, name.trim())

// Create the folder in the store
Expand All @@ -74,9 +78,12 @@ export const entry = {
// Navigate to the new folder
window.OCP.Files.Router.goToRoute(
null, // use default route
{ view: 'files', fileid: folder.fileid },
{ view: 'files', fileid: String(fileid) },
{ dir: context.path },
)
} catch (error) {
logger.error('Creating new folder failed', { error })
showError('Creating new folder failed')
}
},
} as Entry
4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

0 comments on commit 84bd79d

Please sign in to comment.