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

feat: show slash command prompt on focus in property pane #31920

Merged
merged 7 commits into from Mar 22, 2024

Conversation

sneha122
Copy link
Contributor

@sneha122 sneha122 commented Mar 19, 2024

Description

This PR adds builds on top of existing slash command menu feature. Today when we enter JS mode for any of the properties and type in / command, we are able to see the following menu.
Screenshot 2024-03-21 at 1 31 26 PM

With the changes in this PR, now whenever we switch to JS mode for data property of Table and JSON form widgets, if we focus on the input box, we should be able to see the menu with options showing up as shown below:

Screen.Recording.2024-03-20.at.10.58.30.AM.mov

Limitations:

  • This feature is only implemented for Table and JSON form widgets data property, based on mixpanel results we can further decide to include it for all or not.

Fixes #31900
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

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

🔍 Cypress test results

Important

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/8386142777
Commit: 90bea1f91b3d864c984548b11ec4d3a5bd70b3f7
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

Summary by CodeRabbit

  • New Features
    • Enhanced the code editor to dynamically show a slash command menu for certain widgets, improving the user editing experience.
    • Introduced logic to selectively enable slash command functionality for table and JSON widgets, specifically for the data property.
  • Enhancements
    • Updated the code editor hint system to support additional context, including datasource information and feature flags, enriching the autocomplete and suggestion capabilities.
  • Bug Fixes
    • Fixed an issue where unnecessary bindings were applied to widgets, ensuring cleaner and more relevant code generation.

Summary by CodeRabbit

  • New Features
    • Enhanced CodeEditor with advanced properties to support diverse functionalities including AI assistance and plugin integrations.
    • Introduced a function to determine the visibility of the slash command menu based on widget types.
    • Added specific widget properties for table and JSON widgets to enable focused functionalities.
    • Implemented a new feature flag to toggle learnability and ease of initial use improvements.
  • Tests
    • Added tests for Property Pane Suggestions functionality to ensure reliable autocomplete features.
  • Chores
    • Improved PropertyPane interaction by adding a method for focusing and asserting auto-save in text fields.

@sneha122 sneha122 requested a review from a team as a code owner March 19, 2024 12:24
@sneha122 sneha122 requested review from jsartisan and removed request for a team March 19, 2024 12:24
Copy link
Contributor

coderabbitai bot commented Mar 19, 2024

Walkthrough

Walkthrough

The recent updates focus on enhancing the slash command menu functionality within the code editor, particularly for specific widget types and properties. A new constant and function have been introduced to determine the appropriateness of displaying the slash command menu, primarily targeting table and JSON widgets and their data property. Additionally, the CodeEditor component now accommodates a more complex showHint method, and logic has been adjusted to prevent unnecessary binding for certain widget types, improving the user experience and interaction with dynamic properties.

Changes

Files Change Summary
.../CodeEditor/constants.ts Added SlashCommandMenuOnFocusWidgetProps constant for enhanced functionality on table and JSON widgets.
.../CodeEditor/codeEditorUtils.ts Introduced shouldShowSlashCommandMenu function to determine the display of the slash command menu.
.../CodeEditor/index.tsx Enhanced showHint method to accept a more comprehensive object including multiple new properties.
.../cypress/e2e/Regression/ClientSide/Autocomplete/PropertyPaneSlashCommand_spec.ts Introduced tests for Property Pane Suggestions functionality in client-side autocomplete.
.../cypress/support/Pages/PropertyPane.ts Added FocusIntoTextField method to focus on text field & handle auto-save in PropertyPane class.

Assessment against linked issues

Objective Addressed Explanation
Property pane data property on focus shows slash command prompt (Issue #31900)

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>.
    • Generate unit-tests 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 tests 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@sneha122 sneha122 marked this pull request as draft March 19, 2024 12:25
@github-actions github-actions bot added the Enhancement New feature or request label Mar 19, 2024
@sneha122
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

Copy link

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

@sneha122
Copy link
Contributor Author

Keeping in draft state, because we still need to decide whether to add this behind a flag or release it to everyone

@sneha122 sneha122 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Mar 20, 2024
@sneha122 sneha122 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Mar 20, 2024
@github-actions github-actions bot added Activation - learnability Activation - learnability Integrations Pod Issues related to a specific integration Task A simple Todo labels Mar 21, 2024
@sneha122 sneha122 removed the request for review from jsartisan March 21, 2024 08:05
@sneha122
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

Copy link

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

@sneha122 sneha122 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Mar 21, 2024
@AmanAgarwal041 AmanAgarwal041 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Mar 21, 2024
Comment on lines +1 to +37
import { featureFlagIntercept } from "../../../../support/Objects/FeatureFlags";
import {
agHelper,
locators,
entityExplorer,
propPane,
draggableWidgets,
} from "../../../../support/Objects/ObjectsCore";
import EditorNavigation, {
EntityType,
} from "../../../../support/Pages/EditorNavigation";

describe("Property Pane Suggestions", { tags: ["@tag.JS"] }, () => {
before(() => {
featureFlagIntercept({
ab_learnability_ease_of_initial_use_enabled: true,
});
entityExplorer.DragDropWidgetNVerify(draggableWidgets.TABLE, 200, 200);
});

it("1. Should show Property Pane Suggestions on / command & when typing {{}}", () => {
EditorNavigation.SelectEntityByName("Table1", EntityType.Widget);
propPane.ToggleJSMode("Table data", true);
propPane.FocusIntoTextField("Table data");
agHelper.GetElementsNAssertTextPresence(locators._hints, "Add a binding");
agHelper.GetNClickByContains(locators._hints, "Add a binding");
propPane.ValidatePropertyFieldValue("Table data", "{{}}");

entityExplorer.DragDropWidgetNVerify(draggableWidgets.JSONFORM, 600, 400);
EditorNavigation.SelectEntityByName("JSONForm1", EntityType.Widget);
propPane.ToggleJSMode("Source data", true);
propPane.FocusIntoTextField("Source data");
agHelper.GetElementsNAssertTextPresence(locators._hints, "Add a binding");
agHelper.GetNClickByContains(locators._hints, "Add a binding");
propPane.ValidatePropertyFieldValue("Source data", "{{}}");
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to write integration test for this rather than E2E test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rishabhrathod01 Thanks a lot for proactively checking the test and making this suggestion. I tried this out and it seems a little tricky to write integration test for this mainly because, it involves two components: 1. Code editor (we need to focus on it) 2. Menu popup itself (Where we verify if it opened up or not)
The main issue with menu popup is that its html content appears outside propertyPane / CodeEditor component and it wont be possible in react testing library to locate this html outside code editor / property pane component.

Secondly this is experimental feature behind a flag and we may choose to keep it or revert it based on mixpanel results, hence it does not make sense to invest efforts on this to write integration test. If we decide to keep this feature in future, we can take a relook at it and add integration tests then. Please let me know what you think

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. Let's go with E2E test.

@sneha122
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@sneha122 sneha122 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Mar 22, 2024
Copy link

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

Copy link

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

Copy link
Contributor

@rishabhrathod01 rishabhrathod01 left a comment

Choose a reason for hiding this comment

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

Changes look good to me. I have tested it on DP.

Comment on lines +1 to +37
import { featureFlagIntercept } from "../../../../support/Objects/FeatureFlags";
import {
agHelper,
locators,
entityExplorer,
propPane,
draggableWidgets,
} from "../../../../support/Objects/ObjectsCore";
import EditorNavigation, {
EntityType,
} from "../../../../support/Pages/EditorNavigation";

describe("Property Pane Suggestions", { tags: ["@tag.JS"] }, () => {
before(() => {
featureFlagIntercept({
ab_learnability_ease_of_initial_use_enabled: true,
});
entityExplorer.DragDropWidgetNVerify(draggableWidgets.TABLE, 200, 200);
});

it("1. Should show Property Pane Suggestions on / command & when typing {{}}", () => {
EditorNavigation.SelectEntityByName("Table1", EntityType.Widget);
propPane.ToggleJSMode("Table data", true);
propPane.FocusIntoTextField("Table data");
agHelper.GetElementsNAssertTextPresence(locators._hints, "Add a binding");
agHelper.GetNClickByContains(locators._hints, "Add a binding");
propPane.ValidatePropertyFieldValue("Table data", "{{}}");

entityExplorer.DragDropWidgetNVerify(draggableWidgets.JSONFORM, 600, 400);
EditorNavigation.SelectEntityByName("JSONForm1", EntityType.Widget);
propPane.ToggleJSMode("Source data", true);
propPane.FocusIntoTextField("Source data");
agHelper.GetElementsNAssertTextPresence(locators._hints, "Add a binding");
agHelper.GetNClickByContains(locators._hints, "Add a binding");
propPane.ValidatePropertyFieldValue("Source data", "{{}}");
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. Let's go with E2E test.

@sneha122 sneha122 merged commit bd8850a into release Mar 22, 2024
88 checks passed
@sneha122 sneha122 deleted the feat/slash-command-propmt-on-focus branch March 22, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Activation - learnability Activation - learnability Enhancement New feature or request Integrations Pod Issues related to a specific integration ok-to-test Required label for CI Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Property pane data property on focus shows slash command prompt
3 participants