Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Add additional global context variables #26610

Open
1 task done
eedwardsSGS opened this issue Aug 23, 2023 · 7 comments
Open
1 task done

[Feature]: Add additional global context variables #26610

eedwardsSGS opened this issue Aug 23, 2023 · 7 comments
Assignees
Labels
Community Reported issues reported by community members Enhancement New feature or request Javascript Product Issues related to users writing javascript in appsmith JS Evaluation Issues related to JS evaluation on the platform Query & JS Pod Issues related to the query & JS Pod

Comments

@eedwardsSGS
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

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.

@eedwardsSGS eedwardsSGS added the Enhancement New feature or request label Aug 23, 2023
@Nikhil-Nandagopal Nikhil-Nandagopal added the Community Reported issues reported by community members label Aug 23, 2023
@pchambless
Copy link

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

@GreenFlux
Copy link

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 Nikhil-Nandagopal added the JS Evaluation Issues related to JS evaluation on the platform label Aug 24, 2023
@github-actions github-actions bot added the Javascript Product Issues related to users writing javascript in appsmith label Aug 24, 2023
@Nikhil-Nandagopal
Copy link
Contributor

@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
Copy link

@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?

@Nikhil-Nandagopal Nikhil-Nandagopal added the Query & JS Pod Issues related to the query & JS Pod label Aug 5, 2024
@magliok-wwt
Copy link

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

  • app
    • name
    • icon
    • pages
      • name
      • isHidden
    • currentPageName
  • workspace
    • name
    • image
    • members
      • userID
      • role
    • environments
      • name
    • currentEnvironmentName

@Nikhil-Nandagopal Nikhil-Nandagopal changed the title [Feature]: Making names accessible as properties [Feature]: Add additional global context to variables Nov 19, 2024
@Nikhil-Nandagopal Nikhil-Nandagopal changed the title [Feature]: Add additional global context to variables [Feature]: Add additional global context variables Nov 19, 2024
@rishabhrathod01
Copy link
Contributor

After a discussion with @carinanfonseca, we decided to initially support currentPageName, workspaceName, and appName using the appsmith context object and later work on the other pages.
Task for the same - #38046

@magliok-wwt
Copy link

After a discussion with @carinanfonseca, we decided to initially support currentPageName, workspaceName, and appName using the appsmith context object and later work on the other pages. Task for the same - #38046

That will at least get some basic use cases addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Reported issues reported by community members Enhancement New feature or request Javascript Product Issues related to users writing javascript in appsmith JS Evaluation Issues related to JS evaluation on the platform Query & JS Pod Issues related to the query & JS Pod
Projects
None yet
Development

No branches or pull requests

10 participants