Hi everyone!
Iām developing a custom app for Nextcloud 33 and Iām stuck on something that should be simple: adding a custom action to the Files app context menu (the 3-dot menu you see next to files).
What I want to achieve
Add a āPrintā¦ā entry to the context menu, similar to the built-in actions like:
- Download
- Rename
- Delete
- etc.
The print functionality itself works fine - I just need a way for users to trigger it from the Files interface.
What Iāve tried
I followed the official `@nextcloud/files` documentation and implemented it like this:
JavaScript/TypeScript:
```typescript
import { registerFileAction } from ā@nextcloud/filesā
const printAction = {
id: 'printserver-print',
displayName: () => 'Print',
iconSvgInline: () => '<svg>...</svg>',
enabled: ({ nodes }) => nodes.length === 1,
exec: async ({ nodes }) => {
// Open print dialog
}
}
registerFileAction(printAction)
```
PHP side:
- Registered event listener for `LoadAdditionalScriptsEvent`
- Loading script with `Util::addInitScript()` for early execution
- Script loads successfully, no errors in console
The Problem
Everything *seems* to work:
- Script loads without errors
- `registerFileAction()` executes successfully
- My action appears in the `getFileActions()` registry (I can see it in the console)
- The print backend works when called directly
**
BUT:**
- The action never appears in the actual context menu
- The callbacks (`enabled()`, `displayName()`) are never invoked
Interesting observation
When I check `getFileActions()` in the browser console, I only see:
```javascript
[ācontacts-importā, āprintserver-printā]
```
But the context menu shows dozens of actions (Download, Rename, Delete, etc.) - none of which appear in this registry!
This makes me think: Is `@nextcloud/files` even the right API for the context menu?
I also tested with a .vcf file - the Contacts app uses the same `@nextcloud/files` API, but the āImportā action doesnāt appear in the menu either.
My Questions
1. Is there a different API for the Files app context menu? Maybe a server-side registration or legacy system?
2. What is `@nextcloud/files` actually for? Viewer integrations? Inline actions? Something else?
3. Are there working examples of apps that successfully add actions to the Files context menu in NC33?
4. Should I consider an alternative approach? Like a button in the toolbar instead?
**
Environment**
- Nextcloud 33.0.2 (fresh test installation)
- @nextcloud/files 3.10.1
- PHP 8.2.32
- Tested on clean system with only my test app
What Iāve researched
- Read the official docs: https://nextcloud.github.io/nextcloud-files/
- Analyzed the Contacts app implementation
- Looked at core Files app code (`apps/files/src/actions/`)
- Tested 7 different registration approaches
- Confirmed early script loading works
Iām really stuck here and would appreciate any pointers! Has anyone successfully added custom actions to the Files app context menu recently?
Thanks in advance!