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

fix: add max length to js run function name #38363

Merged

Conversation

alex-golovanov
Copy link
Contributor

@alex-golovanov alex-golovanov commented Dec 25, 2024

Description

Fixes issue where JS run function name can take up too much space in toolbar.

Fixes #38150

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12491948782
Commit: c11b60d
Cypress dashboard.
Tags: @tag.IDE
Spec:


Wed, 25 Dec 2024 10:35:52 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a character limit for function names in the JSFunctionRun component, ensuring names are truncated to a maximum of 30 characters for improved UI consistency.
  • Bug Fixes

    • Added a test case to verify that function names exceeding the character limit are correctly truncated.
  • Documentation

    • Updated constants to define the maximum length for function names.

Copy link
Contributor

coderabbitai bot commented Dec 25, 2024

Walkthrough

The pull request addresses a UI issue in the JavaScript Editor Toolbar where long function names cause the Run button to extend beyond the current view. The changes introduce a constant JS_FUNCTION_RUN_NAME_LENGTH set to 30 characters and implement a truncation mechanism using Lodash's truncate function. This ensures that function names are consistently displayed within a fixed length, improving the user interface's readability and preventing layout disruptions.

Changes

File Change Summary
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/constants.ts Added JS_FUNCTION_RUN_NAME_LENGTH constant set to 30
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionRun.tsx Imported truncate from Lodash and applied name truncation to button label
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionRun.test.tsx Added test case to verify function name truncation

Assessment against linked issues

Objective Addressed Explanation
Prevent Run button overflow in Splitpane mode
Handle long function names gracefully

Possibly related PRs

Suggested labels

Bug, Medium, Release, IDE Product, JS Objects, Javascript Product, ok-to-test, Needs Triaging

Suggested reviewers

  • albinAppsmith
  • hetunandu

Poem

Code flows like a river, smooth and bright
Truncate the names, keep the view just right
Thirty characters dance with grace
No more buttons lost in digital space
UI harmony restored with might! 🖥️✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Bug Something isn't working IDE Navigation Issues/feature requests related to IDE navigation, and context switching IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage Release labels Dec 25, 2024
@alex-golovanov
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@alex-golovanov alex-golovanov added the ok-to-test Required label for CI label Dec 25, 2024
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/12491947765.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 38363.
recreate: .

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionRun.tsx (1)

71-73: Concise truncation logic.
Truncating the function label ensures the UI remains tidy. Consider whether a tooltip or ellipsis might further improve clarity for users when names are cut short.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f078ec0 and c11b60d.

📒 Files selected for processing (3)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionRun.test.tsx (2 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionRun.tsx (3 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/constants.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/constants.ts
🔇 Additional comments (5)
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionRun.tsx (2)

2-2: Good use of lodash truncate.
This is a straightforward approach for limiting the displayed length of a string.


20-20: Clear separation of constants.
Importing the maximum length constant from a dedicated file improves maintainability and consistency.

app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionRun.test.tsx (3)

6-6: Imported utility ensures consistency across tests.
Centralizing action parsing into a single utility function makes the tests more reliable.


8-9: Aligned import order with usage.
These imports keep the test’s purpose clear and reflect the production component setup.


85-106: Robust test for truncation logic.
Verifying the label length in the rendered component ensures that the UI constraint is reliably enforced. This test effectively checks real-world usage scenarios.

Copy link

Deploy-Preview-URL: https://ce-38363.dp.appsmith.com

@alex-golovanov alex-golovanov merged commit 1be746c into release Dec 25, 2024
46 checks passed
@alex-golovanov alex-golovanov deleted the fix/38150-js-run-function-trigger-name-length branch December 25, 2024 12:17
NandanAnantharamu pushed a commit that referenced this pull request Dec 27, 2024
## Description
Fixes issue where JS run function name can take up too much space in
toolbar.

Fixes #38150 

## Automation

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

### 🔍 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/12491948782>
> Commit: c11b60d
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12491948782&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.IDE`
> Spec:
> <hr>Wed, 25 Dec 2024 10:35:52 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

## Summary by CodeRabbit

- **New Features**
- Introduced a character limit for function names in the `JSFunctionRun`
component, ensuring names are truncated to a maximum of 30 characters
for improved UI consistency.

- **Bug Fixes**
- Added a test case to verify that function names exceeding the
character limit are correctly truncated.

- **Documentation**
	- Updated constants to define the maximum length for function names.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Feb 7, 2025
## Description
Fixes issue where JS run function name can take up too much space in
toolbar.

Fixes appsmithorg#38150 

## Automation

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

### 🔍 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/12491948782>
> Commit: c11b60d
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12491948782&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.IDE`
> Spec:
> <hr>Wed, 25 Dec 2024 10:35:52 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

## Summary by CodeRabbit

- **New Features**
- Introduced a character limit for function names in the `JSFunctionRun`
component, ensuring names are truncated to a maximum of 30 characters
for improved UI consistency.

- **Bug Fixes**
- Added a test case to verify that function names exceeding the
character limit are correctly truncated.

- **Documentation**
	- Updated constants to define the maximum length for function names.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working IDE Navigation Issues/feature requests related to IDE navigation, and context switching IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Release
Projects
None yet
2 participants