owncloud / owncloud/ocis

[OCISDEV-1087] newFileMenu extension icon is ignored unless extension/mimeType is also set

Open
#12,659 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.1k
Forks
274
Avg merge
2d 1h
Merged PRs (30d)
103

Description

## Summary

`ApplicationFileExtension.icon` (`web/packages/web-pkg/src/apps/types.ts`) is silently ignored by the "New file" menu (`CreateAndUpload.vue`) unless the same extension entry also declares an `extension` or `mimeType`.

## Why

The "New file" dropdown renders each `newFileMenu` item's icon via:

```

```

(`web/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue`, `getIconResource` builds `{ type: 'file', extension: fileAction.ext }`)

`ResourceIcon.vue` (`web/packages/web-pkg/src/components/FilesList/ResourceIcon.vue`) resolves the icon purely from a mimeType/extension lookup table (`createDefaultFileIconMapping()` plus an injected `ResourceIconMapping`) — it never reads `ApplicationFileExtension.icon` directly. That mapping is only populated for an extension entry in `announceApplicationsReady` (`web/packages/web-runtime/src/container/bootstrap.ts`) when `fileExtensions.extension` or `fileExtensions.mimeType` is set.

So an app that registers a `newFileMenu` action *without* a real file extension (e.g. because the action opens a modal instead of creating a file of one fixed type) has no way to show a custom icon in this menu — `icon` is simply dead code for this code path, even though the type declares it and other consumers (`useFileActions.ts`'s `editorActions`, via `icon: fileExtension.icon || appInfo.icon`) do read it.

`draw-io` is the only existing extension using `newFileMenu` and it happens to work only because it also sets `extension: 'drawio'`.

## Suggested fix

Have `getIconResource` / `ResourceIcon` (or a new prop) prefer an explicit `fileAction.icon` when present, before falling back to the extension/mimeType lookup — mirroring how `useFileActions.ts`'s `editorActions` already does `icon: fileExtension.icon || appInfo.icon`.

## Repro

Register a `newFileMenu` extension with `icon: 'sparkling-2'` and no `extension`/`mimeType` field (see [owncloud/web-extensions#529](https://github.com/owncloud/web-extensions/issues/529), package `web-app-ai-quick-draft-creator`). The "New" dropdown always shows the generic blank-file icon regardless of the `icon` value.

Contributor guide

Open the contributing guide

Research direction

Start with ApplicationFileExtension in web/packages/web-pkg/src/apps/types.ts and trace getIconResource in web/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue. Read ResourceIcon.vue and announceApplicationsReady in web/packages/web-runtime/src/container/bootstrap.ts to understand the current lookup path, then verify that a newFileMenu action with only icon: 'sparkling-2' displays that icon while existing extension or mimeType fallback behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.