Skip to content

Commit

Permalink
fix(files): Add messages when "new folder" fails or gets cancelled
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Aug 12, 2024
1 parent b34edf2 commit 656ed0b
Showing 1 changed file with 10 additions and 3 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

0 comments on commit 656ed0b

Please sign in to comment.