33 * SPDX-License-Identifier: AGPL-3.0-or-later
44 */
55
6- import type { Folder , NewMenuEntry , Node } from '@nextcloud/files'
6+ import type { IFolder , INode , NewMenuEntry } from '@nextcloud/files'
77import type { ComponentInstance } from 'vue'
88import type { TemplateFile } from '../types.ts'
99
@@ -22,7 +22,7 @@ let TemplatePicker: ComponentInstance & { open: (n: string, t: TemplateFile) =>
2222 *
2323 * @param context
2424 */
25- async function getTemplatePicker ( context : Folder ) {
25+ async function getTemplatePicker ( context : IFolder ) {
2626 if ( TemplatePicker === null ) {
2727 // Create document root
2828 const mountingPoint = document . createElement ( 'div' )
@@ -63,13 +63,18 @@ export function registerTemplateEntries() {
6363 addNewFileMenuEntry ( {
6464 id : `template-new-${ provider . app } -${ index } ` ,
6565 displayName : provider . label ,
66- iconClass : provider . iconClass || 'icon-file' ,
6766 iconSvgInline : provider . iconSvgInline ,
68- enabled ( context : Folder ) : boolean {
69- return ( context . permissions & Permission . CREATE ) !== 0
67+ enabled ( context : IFolder ) : boolean {
68+ if ( context . attributes [ 'is-encrypted' ] ) {
69+ return false
70+ }
71+
72+ // templates are only supported in folders where the user has read and create permissions
73+ return ( context . permissions & Permission . READ ) !== 0
74+ && ( context . permissions & Permission . CREATE ) !== 0
7075 } ,
7176 order : 11 ,
72- async handler ( context : Folder , content : Node [ ] ) {
77+ async handler ( context : IFolder , content : INode [ ] ) {
7378 const templatePicker = getTemplatePicker ( context )
7479 const name = await newNodeName ( `${ provider . label } ${ provider . extension } ` , content , {
7580 label : t ( 'files' , 'Filename' ) ,
0 commit comments