mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #60187 from nextcloud/fix/template-picker
fix(files): only show template picker menu entries if possible
This commit is contained in:
commit
63680bdce5
3 changed files with 14 additions and 9 deletions
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import type { Folder, NewMenuEntry, Node } from '@nextcloud/files'
|
||||
import type { IFolder, INode, NewMenuEntry } from '@nextcloud/files'
|
||||
import type { ComponentInstance } from 'vue'
|
||||
import type { TemplateFile } from '../types.ts'
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ let TemplatePicker: ComponentInstance & { open: (n: string, t: TemplateFile) =>
|
|||
*
|
||||
* @param context
|
||||
*/
|
||||
async function getTemplatePicker(context: Folder) {
|
||||
async function getTemplatePicker(context: IFolder) {
|
||||
if (TemplatePicker === null) {
|
||||
// Create document root
|
||||
const mountingPoint = document.createElement('div')
|
||||
|
|
@ -63,13 +63,18 @@ export function registerTemplateEntries() {
|
|||
addNewFileMenuEntry({
|
||||
id: `template-new-${provider.app}-${index}`,
|
||||
displayName: provider.label,
|
||||
iconClass: provider.iconClass || 'icon-file',
|
||||
iconSvgInline: provider.iconSvgInline,
|
||||
enabled(context: Folder): boolean {
|
||||
return (context.permissions & Permission.CREATE) !== 0
|
||||
enabled(context: IFolder): boolean {
|
||||
if (context.attributes['is-encrypted']) {
|
||||
return false
|
||||
}
|
||||
|
||||
// templates are only supported in folders where the user has read and create permissions
|
||||
return (context.permissions & Permission.READ) !== 0
|
||||
&& (context.permissions & Permission.CREATE) !== 0
|
||||
},
|
||||
order: 11,
|
||||
async handler(context: Folder, content: Node[]) {
|
||||
async handler(context: IFolder, content: INode[]) {
|
||||
const templatePicker = getTemplatePicker(context)
|
||||
const name = await newNodeName(`${provider.label}${provider.extension}`, content, {
|
||||
label: t('files', 'Filename'),
|
||||
|
|
|
|||
4
dist/files-init.js
vendored
4
dist/files-init.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-init.js.map
vendored
2
dist/files-init.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue