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 currentPageName, workspaceName and appName to appsmith context object #38046

Closed
1 task done
rishabhrathod01 opened this issue Dec 9, 2024 · 2 comments · Fixed by #38114
Closed
1 task done
Assignees
Labels
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 QA Pod Issues under the QA Pod QA Needs QA attention Query & JS Pod Issues related to the query & JS Pod

Comments

@rishabhrathod01
Copy link
Contributor

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.currentPageName }} (or similar) should return the name of the page the function is called on.

Why should this be worked 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.

@rishabhrathod01 rishabhrathod01 added the Enhancement New feature or request label Dec 9, 2024
@rishabhrathod01 rishabhrathod01 added the JS Evaluation Issues related to JS evaluation on the platform label Dec 9, 2024
@github-actions github-actions bot added Javascript Product Issues related to users writing javascript in appsmith Query & JS Pod Issues related to the query & JS Pod labels Dec 9, 2024
@sneha122 sneha122 self-assigned this Dec 17, 2024
@Nikhil-Nandagopal
Copy link
Contributor

We want to add the current environment variable as well to this.

@sneha122
Copy link
Contributor

We want to add the current environment variable as well to this.

@Nikhil-Nandagopal Created separate feature request for environment variable as making changes in current Pr was causing cyclic dependency issues of dependencies and we may need to do CE and EE split to resolve this. Taking it up separately as it has its own complexities. #38306

sneha122 pushed a commit that referenced this issue Dec 23, 2024
#38114)

## Description

Add currentPageName, AppName and workspace name to appsmith context
object

Fixes #38046

## Automation

/ok-to-test tags="@tag.JS"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/12462985063>
> Commit: eec4292
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12462985063&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.JS`
> Spec:
> <hr>Mon, 23 Dec 2024 09:14:06 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced `AppsmithEntity` interface with new properties:
`currentPageName`, `workspaceName`, and `appName`.
- Updated `getUnevaluatedDataTree` selector to accept additional
parameters, providing more contextual information about the current
application state.
- Introduced a new internal selector to retrieve the current page's
name.

- **Bug Fixes**
- Adjusted expected hint text in autocomplete tests for JavaScript
objects to align with updated behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: “sneha122” <“sneha@appsmith.com”>
@appsmith-bot appsmith-bot added the QA Needs QA attention label Dec 23, 2024
@github-actions github-actions bot added the QA Pod Issues under the QA Pod label Dec 23, 2024
NandanAnantharamu pushed a commit that referenced this issue Dec 27, 2024
#38114)

## Description

Add currentPageName, AppName and workspace name to appsmith context
object

Fixes #38046

## Automation

/ok-to-test tags="@tag.JS"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/12462985063>
> Commit: eec4292
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12462985063&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.JS`
> Spec:
> <hr>Mon, 23 Dec 2024 09:14:06 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced `AppsmithEntity` interface with new properties:
`currentPageName`, `workspaceName`, and `appName`.
- Updated `getUnevaluatedDataTree` selector to accept additional
parameters, providing more contextual information about the current
application state.
- Introduced a new internal selector to retrieve the current page's
name.

- **Bug Fixes**
- Adjusted expected hint text in autocomplete tests for JavaScript
objects to align with updated behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: “sneha122” <“sneha@appsmith.com”>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 QA Pod Issues under the QA Pod QA Needs QA attention Query & JS Pod Issues related to the query & JS Pod
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants