appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
34.75k stars 3.76k forks source link

[Feature]: Add additional global context variables #26610

Open eedwardsSGS opened 1 year ago

eedwardsSGS commented 1 year ago

Is there an existing issue for this?

Summary

The following information should be accessible as properties under the Appsmith namespace.

Workspace name App name Page name

For example {{ appsmith.pageName }} (or similar) should return the name of the page the function is called on.

Why should this be worked on?

This allows for scripting to be written without knowing what page it will end up on. For example we have a script that uses navigateTo() to navigate to the same page the user is already on and update the query parameters. This works great, but we have to tweak it for each page or refer to a variable in a JSObject that has the page's name. If we could programmatically collect the page's name, then we could copy that script to each of our pages without having to edit it.

Workspace name is also very useful as many users use it as a kind of test/production environment split, If you could write scripts that notice that you are in a specific workspace, you could cause certain things to function differently if you are in test mode or production mode.

pchambless commented 1 year ago

These features would greatly help some internal and external processes including DB lookups and configurations... Great Idea!

GreenFlux commented 1 year ago

Great idea @eedwardsSGS !

@Nikhil-Nandagopal , could we also expose the list of users, or emails in the workspace? That would be really helpful for select widgets, validation, etc.

Nikhil-Nandagopal commented 1 year ago

@GreenFlux I believe exposing the list of users / emails is a security risk so we intentionally don't do it. appname/pagename however shouldn't pose the same concern. @bharath31 could you have a look at this?

GreenFlux commented 1 year ago

@Nikhil-Nandagopal , I thought that at first as well. But then I realized we already expose the email list in the share modal. I even double checked as an app user (not editor or admin), and I can still see the full list of names (and emails, in the tooltip). Why can't we make this info more convenient to reference in the editor, if it's already exposed to even end users?

I think we should only be concerned about exposing the list to public app users. Would it be possible to make the list of emails available in the editor, without it being automatically loaded into client browsers for public users?

magliok-wwt commented 2 weeks ago

I cannot +1 this hard enough. This is an absolute must for us, I can't imagine how people are handling when user interfaces, links, etc. ( outside data connections ) change per Workspace and/or Environment.

I would want to add that also having an {{ appsmith.environmentName }} would be very helpful - if we're looking at adding these

I would love for them to be objects, not just names, because I'm sure there are properties there beyond "name" that we'd want to access.

so more:

appsmith