Skip to content

Commit f1e8a8d

Browse files
susnuxbackportbot[bot]
authored andcommitted
fix(files): only show template picker menu entries if possible
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent dffb132 commit f1e8a8d

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

apps/files/src/newMenu/newFromTemplate.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,18 @@ export function registerTemplateEntries() {
5959
addNewFileMenuEntry({
6060
id: `template-new-${provider.app}-${index}`,
6161
displayName: provider.label,
62-
iconClass: provider.iconClass || 'icon-file',
6362
iconSvgInline: provider.iconSvgInline,
64-
enabled(context: Folder): boolean {
65-
return (context.permissions & Permission.CREATE) !== 0
63+
enabled(context: IFolder): boolean {
64+
if (context.attributes['is-encrypted']) {
65+
return false
66+
}
67+
68+
// templates are only supported in folders where the user has read and create permissions
69+
return (context.permissions & Permission.READ) !== 0
70+
&& (context.permissions & Permission.CREATE) !== 0
6671
},
6772
order: 11,
68-
async handler(context: Folder, content: Node[]) {
73+
async handler(context: IFolder, content: INode[]) {
6974
const templatePicker = getTemplatePicker(context)
7075
const name = await newNodeName(`${provider.label}${provider.extension}`, content, {
7176
label: t('files', 'Filename'),

0 commit comments

Comments
 (0)