Show file contents in UI in node

Description

I’d like to show the contents of the file in the UI for this node (in a non-editable mode in the code editor):

Just below the “Encoding” field, as a facility for the programmer.

This is a derivative of the new Code node, that I built so that my team can easier deploy new configuration changes to n8n in k8s.

Information on your n8n setup

  • n8n version: 0.200.1
  • Database you’re using (default: SQLite): sqlite3
  • Running n8n with the execution process [own(default), main]: dockerfile
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: docker

However, I can’t find anything in the Typescript API to do so. How can I make this happen?

Hey @haf,

We don’t really have a design pattern for that but have you tried using a text field that uses loadOptions then in the loadOptions method read the file and return the contents?

It may not be possible but I think this would be the best way to check.

I think this could work. Then it would show the file as configured? But what about when I change the file path? Will loadOptions reload the configured properties, i.e. show the new content? What if the file changes on disk?

Another (slightly hacky) suggestion would be to use parameter hints. This is the small text that shows beneath some parameters.
The param hint could contain a link, that opens the file in a new tab (“Preview the file”). From there, browser extensions could handle formatting that file in a viewable way.

Wouldn’t that require a webserver to serve the file raw?

Sorry @haf - my focus at n8n is product design so was just speaking from a UX standpoint. I am not sure of the technical viability of my proposal. Apologies :slight_smile:

1 Like

Hey @haf,

They would need to reload the data if it is possible, It is just a theory at the moment to get around something we don’t currently have a direct option for. I really like the idea though as it could extend to CSV or JSON files if you were to load them as a config source for a workflow just to double check the data.

Hiya @Jon

Ah, yes from a UI standpoint you could then cater for the two aspects of data in n8n:

  • workflow run data from ‘executions’
  • contextual / runtime-decided data that is as-config and visible in the nodes themselves

Perhaps move this thread to a feature request then?

1 Like

Hey @haf,

Solid plan, Just moved it.