Adding option to "+ New" Button with Python ExApp

Hi, I am trying to write an ExApp in python with custom Frontend. However all tutorials out there do not show what I need. I want the “+ New” Button in the files app to have another option “from url” where I can download a file from url. A dialog should show up where I can enter an url and select some options. After that the request is send to my backend and processed.

So far I looked at the to_gif example but this only adds an option to the files_dropdown_menu. But how can I send JS to the frontend now which shows my dialog?

Apart from that I looked at other Apps not ExApps using addScript function in PHP to register a script which modifies the “+ New” using something like:

import { addNewFileMenuEntry } from '@nextcloud/files'

addNewFileMenuEntry({
  id: 'mynewbutton',
  displayName: 'Create Custom File',
  iconClass: 'icon-add',
  handler: (context, content) => {
    const fileName = 'NewFile.txt'
    const filePath = context.path + '/' + fileName
    console.log(`Creating file at: ${filePath}`)
  }
})

I tried using set_script() from the python api to register that script but the option does not show up. Also I am confused which parameters I have to provide to this method.

Do you know how I can

  1. modify the New Button in Nextcloud to show my option?
  2. show a dialog overlay in nextclouds file app after clicking my new option (or the option in files_dropdown_menu)

I cannot give you a clear answer but the discussion in this topic makes me unsure if it is at the moment achievable to tap into the JS code of the files app. But I am curious if there are other comments/hints.

Regarding the dialog, maybe spawnDoalog might be a good option?

Chris