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: IDE tab list search view #34759

Open
wants to merge 12 commits into
base: release
Choose a base branch
from
Open

Conversation

albinAppsmith
Copy link
Collaborator

@albinAppsmith albinAppsmith commented Jul 5, 2024

Description

This PR adds search functionality to the overflow list of tabs.

Fixes #34293

Automation

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

🔍 Cypress test results

Tip

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


Tue, 09 Jul 2024 11:01:02 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a search functionality in the Editor Pane for finding files and queries using fuzzy search.
    • Added an "Add and Search" bar component for easier navigation and addition of new items.
  • Bug Fixes

    • Improved handling of empty search results with a new informative message.
  • Tests

    • Added test suite to validate the fuzzy search functionality.
  • Refactor

    • Updated internal search logic and rendering for a smoother user experience.
    • Streamlined adding new JavaScript objects in the JSEditor.

Copy link
Contributor

coderabbitai bot commented Jul 5, 2024

Walkthrough

The changes introduced a new search feature to the overflow list view in the editor pane of the client application. This involves adding search functionality to components, updating dependencies, and refactoring the rendering logic to display search results. Additionally, a new design-system version is updated, and test cases for the new search functionality are included.

Changes

Files Change Summary
.../package.json Updated the version of design-system from 2.1.42 to 2.1.43.
.../constants/messages.ts Added empty_search_result function to EDITOR_PANE_TEXTS for better search result messages.
.../EditorPane/JS/List.tsx, .../Query/List.tsx Implemented search functionality with new state management, refactored logic, and used AddAndSearchbar component.
.../EditorPane/components/AddAndSearchbar.tsx Introduced AddAndSearchbar component for rendering a search bar and an "Add" button.
.../EditorPane/fuzzySearchInFiles.test.ts, .../EditorPane/utils.ts Added fuzzySearchInFiles function with unit testing for fuzzy searching in files.
.../JSEditor.ts Updated logic for adding a new JavaScript object, now using switchToAddNew() method.

Assessment against linked issues

Objective Addressed Explanation
Add search bar to the list view of overflow list (#34293)

Poem

In the code's flowing stream,
A new search bar does gleam,
Through files it sifts with grace,
In the editor's embrace.
Glowing updates we trust,
In features new and robust.


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 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 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 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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

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 IDE Navigation Issues/feature requests related to IDE navigation, and context switching New Developers Pod Issues that new developers face while exploring the IDE Task A simple Todo labels Jul 5, 2024
@github-actions github-actions bot added the Enhancement New feature or request label Jul 5, 2024
@albinAppsmith albinAppsmith added the ok-to-test Required label for CI label Jul 5, 2024
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f0f24fc and ac04312.

Files ignored due to path filters (1)
  • app/client/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (7)
  • app/client/package.json (1 hunks)
  • app/client/src/ce/constants/messages.ts (1 hunks)
  • app/client/src/pages/Editor/IDE/EditorPane/JS/List.tsx (6 hunks)
  • app/client/src/pages/Editor/IDE/EditorPane/Query/List.tsx (5 hunks)
  • app/client/src/pages/Editor/IDE/EditorPane/components/AddAndSearchbar.tsx (1 hunks)
  • app/client/src/pages/Editor/IDE/EditorPane/fuzzySearchInFiles.test.ts (1 hunks)
  • app/client/src/pages/Editor/IDE/EditorPane/utils.ts (1 hunks)
Files skipped from review due to trivial changes (2)
  • app/client/package.json
  • app/client/src/ce/constants/messages.ts
Additional comments not posted (12)
app/client/src/pages/Editor/IDE/EditorPane/components/AddAndSearchbar.tsx (2)

10-25: LGTM!

The component logic is correct and adheres to best practices.


1-8: Ensure all imported components are used.

The Button and SearchInput components from the design system are used, but the Flex component should be checked for usage.

Verification successful

All imported components are used.

The Flex component is utilized in the file, so there are no issues with unused imports.

  • Flex component usage:
    • <Flex alignItems="center" flexDirection="row" gap="spaces-3" px="spaces-3">
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of Flex component in AddAndSearchbar.tsx

# Test: Ensure that the Flex component is actually used in the file.
rg --type tsx 'Flex' app/client/src/pages/Editor/IDE/EditorPane/components/AddAndSearchbar.tsx

Length of output: 122


Script:

#!/bin/bash
# Description: Verify usage of Flex component in AddAndSearchbar.tsx

# Test: Ensure that the Flex component is actually used in the file.
rg 'Flex' app/client/src/pages/Editor/IDE/EditorPane/components/AddAndSearchbar.tsx

Length of output: 234

app/client/src/pages/Editor/IDE/EditorPane/utils.ts (2)

1-12: Ensure all imported types are used.

The EditorSegmentList type from selectors is used. The FUSE_OPTIONS are correctly defined for fuzzy search.


14-30: LGTM!

The function logic is correct and adheres to best practices.

app/client/src/pages/Editor/IDE/EditorPane/fuzzySearchInFiles.test.ts (2)

1-20: Ensure all imported constants are used.

The PluginType constant from entities is used. The sample data is correctly defined for testing.


22-47: LGTM!

The test cases provide sufficient coverage and are correctly defined.

app/client/src/pages/Editor/IDE/EditorPane/Query/List.tsx (2)

Line range hint 1-22:
Ensure all imported hooks and selectors are used.

The imported hooks and selectors are used correctly. The component defines local state and uses selectors to fetch data.


Line range hint 26-110:
LGTM!

The search functionality is correctly implemented and the rendering logic is updated accordingly.

app/client/src/pages/Editor/IDE/EditorPane/JS/List.tsx (4)

37-39: State and search functionality look good.

The addition of searchTerm state and onSearch function is appropriate for the search functionality. The use of fuzzySearchInFiles to filter files based on the search term is correct.

Also applies to: 47-48, 56-58


69-75: Rendering search bar looks good.

The use of AddAndSearchbar component to render the search bar is appropriate.


Line range hint 89-126:
Rendering search results looks good.

The use of localFiles array to render search results and the message for no search results are appropriate.


1-3: Imports look good, but verify the removal of Button.

The new imports for useState, AddAndSearchbar, and fuzzySearchInFiles are necessary for the new search functionality. Ensure that the Button import removal is consistent with the summary.

Also applies to: 21-23

Verification successful

Verification successful: Button import removed.

The Button import has been successfully removed from app/client/src/pages/Editor/IDE/EditorPane/JS/List.tsx, as verified by the absence of this import in the search results.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the removal of `Button` import.

# Test: Search for `Button` import. Expect: No occurrences of `Button` import.
rg --type-add 'tsx' --type 'tsx' 'import { Button } from'

Length of output: 169


Script:

#!/bin/bash
# Description: Verify the removal of `Button` import.

# Test: Search for `Button` import. Expect: No occurrences of `Button` import.
rg --type-add 'tsx' --type 'tsx' 'import { Button } from'

Length of output: 169


Script:

#!/bin/bash
# Description: Verify the removal of `Button` import.

# Test: Search for `Button` import. Expect: No occurrences of `Button` import.
rg --type-add 'tsx' --type 'tsx' 'import { Button } from'

Length of output: 169


Script:

#!/bin/bash
# Description: Verify the removal of `Button` import.

# Test: Search for `Button` import. Expect: No occurrences of `Button` import.
grep -r 'import { Button } from' .

Length of output: 7385

@albinAppsmith albinAppsmith added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 8, 2024
@albinAppsmith albinAppsmith added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 8, 2024
<SearchInput onChange={onSearch} size="sm" />
{hasAddPermission ? (
<Button
className="t--add-item !min-w-[24px]"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use data-testid for t--add-item instead of className.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will take this up in a separate PR since this change is not introduced by this PR rather this is a change in location. Also, this update will cause updates in some cypress files as well.

@albinAppsmith albinAppsmith added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 9, 2024
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ac04312 and 4569848.

Files selected for processing (1)
  • app/client/cypress/support/Pages/JSEditor.ts (1 hunks)
Additional context used
Path-based instructions (1)
app/client/cypress/support/Pages/JSEditor.ts (1)

Pattern app/client/cypress/**/**.*: Follow best practices for Cypress code and e2e automation.
Avoid using cy.wait in code.
Avoid using cy.pause in code.
Use variables for locators, not strings.
Use data-* attributes for selectors; avoid Xpaths and CSS attributes.
Avoid selectors like .btn.submit or button[type=submit].
Perform logins via API with LoginFromAPI.
Only interact with controlled sites/servers.
Ensure tests can run with it.only and are independent.
Use before, beforeEach, after, afterEach correctly; clean state before tests.
Check new specs for flakiness by running them 10 times on CI.
Use multiple assertions; don't treat Cypress as unit tests.
Use constants for strings.
Include datasource operations in before hooks.

Additional comments not posted (2)
app/client/cypress/support/Pages/JSEditor.ts (2)

108-108: LGTM! The method call PageLeftPane.switchToAddNew() is correctly integrated.

This change replaces the old method of clicking directly on the new JS object element and improves the clarity and maintainability of the code.


109-109: LGTM! The old code is appropriately commented out.

Commenting out the old direct click method helps maintain the context and provides a fallback if needed.

},
];

describe("fuzzySearchInFiles", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add more description scenario name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated it blocks with better descriptions.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4569848 and 557a0b4.

Files selected for processing (1)
  • app/client/src/pages/Editor/IDE/EditorPane/fuzzySearchInFiles.test.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/src/pages/Editor/IDE/EditorPane/fuzzySearchInFiles.test.ts

const canCreateActions = getHasCreateActionPermission(
isFeatureEnabled,
pagePermissions,
);

const { openAddJS } = useJSAdd();

const onSearch = (str: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a bit of nitpicking, typically onSearch is a naming convention used for events, while handlers are prefixed with handle, e.g. handleSearch.

@albinAppsmith albinAppsmith added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 9, 2024
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 557a0b4 and ff0355b.

Files ignored due to path filters (1)
  • app/client/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (3)
  • app/client/package.json (1 hunks)
  • app/client/src/pages/Editor/IDE/EditorPane/JS/List.tsx (6 hunks)
  • app/client/src/pages/Editor/IDE/EditorPane/Query/List.tsx (5 hunks)
Files skipped from review as they are similar to previous changes (3)
  • app/client/package.json
  • app/client/src/pages/Editor/IDE/EditorPane/JS/List.tsx
  • app/client/src/pages/Editor/IDE/EditorPane/Query/List.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request IDE Navigation Issues/feature requests related to IDE navigation, and context switching New Developers Pod Issues that new developers face while exploring the IDE 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] - Add search bar to the list view of overflow list
4 participants