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: Overflow tabs list view #34150

Merged
merged 21 commits into from
Jun 25, 2024
Merged

feat: Overflow tabs list view #34150

merged 21 commits into from
Jun 25, 2024

Conversation

albinAppsmith
Copy link
Collaborator

@albinAppsmith albinAppsmith commented Jun 10, 2024

Description

This PR implements the new design for the list view.

Fixes #33432

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9660135881
Commit: fb8addb
Cypress dashboard.
Tags: @tag.Sanity, @tag.IDE

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced AddTab component to add new JavaScript or Query tabs.
    • Added ScreenModeToggle for switching between full-screen and split-screen modes.
    • Added FileTab component for improved tab interactions.
    • Introduced List component for conditional rendering based on editor state.
  • Bug Fixes

    • Corrected test assertions and tab names in JSRender.test.tsx and QueryRender.test.tsx.
    • Fixed tab closure and interaction flow in IDE_Add_Pane_Interactions_spec.ts.
  • Refactor

    • Simplified selector functions and updated component imports for better readability and performance.
  • Tests

    • Updated tests to include currentEntity props and use sanitizeString for tab titles.

@github-actions github-actions bot added IDE Navigation Issues/feature requests related to IDE navigation, and context switching IDE Pod Issues that new developers face while exploring the IDE Task A simple Todo labels Jun 10, 2024
@albinAppsmith
Copy link
Collaborator Author

/build-deploy-preview skip-test=true

@albinAppsmith albinAppsmith added the ok-to-test Required label for CI label Jun 10, 2024
@github-actions github-actions bot added the Enhancement New feature or request label Jun 10, 2024
@albinAppsmith albinAppsmith requested a review from hetunandu June 10, 2024 17:47
Copy link

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

Copy link
Contributor

coderabbitai bot commented Jun 10, 2024

Walkthrough

The changes span several areas of the IDE's file tab management and rendering. Key updates include the addition of new components (AddTab, ScreenModeToggle), refactoring existing functions and hooks to simplify and optimize state handling, and updating tests and selectors to accommodate these changes. The updates also included improvements to string sanitization and tab item rendering to enhance the UI for overflow tabs as per the design specifications.

Changes

File(s) Change Summary
.../EditorPane/JS/hooks.ts Added import for JSBlankState and updated useJSSegmentRoutes
.../selectors/appIDESelectors.ts Refactored selectJSSegmentEditorTabs and selectQuerySegmentEditorTabs to directly accept state
.../EditorPane/EditorPaneSegments.tsx Updated EditorTabs import and conditional rendering based on ideViewMode
.../EditorTabs/AddTab.tsx Introduced AddTab component for adding new JS or Query tabs
.../EditorTabs/*test*.tsx, FileTabs.tsx Updated tests to include currentEntity prop and utilization of sanitizeString
.../IDE/EditorTabs/index.tsx, AddButton.tsx, Container.tsx, ListButton.tsx, SearchableFilesList.tsx Refactored components and imports to improve file tab management
.../EditorTabs/ScreenModeToggle.tsx New ScreenModeToggle component for toggling screen modes
.../hooks.ts, URLUtils.ts Updated useIDETabClickHandlers and added sanitizeString function
.../cypress/e2e/.../IDE_Add_Pane_Interactions_spec.ts, FileTabs.ts Updated locators and tab closures for interactions in cypress tests

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant IDE
    participant EditorPane
    participant EditorState
    User ->> IDE: New Tab Click
    IDE ->> EditorPane: Render AddTab Component
    EditorPane ->> EditorState: Create New Tab
    EditorState -->> IDE: Updated Tab State
    IDE ->> User: New Tab Rendered
    User ->> IDE: Toggle Fullscreen
    IDE ->> EditorPane: Trigger ScreenModeToggle Component
    EditorPane ->> EditorState: Update ViewMode
    EditorState -->> IDE: Updated ViewMode State
    IDE ->> User: Fullscreen Mode Activated
Loading

Assessment against linked issues

Objective (Issue #33432) Addressed Explanation
Implement new UI for overflow tabs
Simplify tab state management

Poem

In the world of code, swift and bright,
Tabs overflow with gleaming light,
A toggle here, a new tab there,
IDE with ease to spare.
Through refactored paths we roam,
Building up a coder's home.
🎩✨🐰

Warning

Review ran into problems

Problems (1)
  • Git: Failed to clone repository. Please contact CodeRabbit support.

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.

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: 6

Outside diff range and nitpick comments (4)
app/client/src/pages/Editor/IDE/EditorTabs/index.tsx (2)

67-77: Use useCallback effectively.

The useCallback hook is used here to memoize the toggleEditorMode function. While this is generally a good practice to avoid unnecessary re-renders, consider if the complexity added by useCallback is justified given the simplicity of the function.


96-158: Review the main render block for potential optimizations.

The main render block of the EditorTabs component is quite dense and handles multiple conditions. Consider breaking it down into smaller, more manageable components or using more descriptive helper functions to improve readability.

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

41-41: Ensure proper import usage.

The import of QueriesBlankState is added. Ensure that this component is used appropriately within the file and that its import is necessary.


Line range hint 215-215: Avoid redundant double-negation.

The use of double-negation (!!) is unnecessary and can be simplified.

- description: !!fileOperation.isBeta ? (
+ description: fileOperation.isBeta ? (
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 212a7af and 914614d.

Files selected for processing (7)
  • app/client/src/ce/pages/Editor/IDE/EditorPane/Query/hooks.tsx (2 hunks)
  • app/client/src/pages/Editor/IDE/EditorPane/EditorPaneSegments.tsx (2 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/FileTabs.test.tsx (3 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/FileTabs.tsx (4 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/index.tsx (1 hunks)
  • app/client/src/pages/Editor/IDE/MainPane/index.tsx (2 hunks)
  • app/client/src/pages/Editor/IDE/hooks.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/src/pages/Editor/IDE/hooks.ts
Additional context used
Biome
app/client/src/ce/pages/Editor/IDE/EditorPane/Query/hooks.tsx

[error] 215-215: Avoid redundant double-negation. (lint/complexity/noExtraBooleanCast)

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

Additional comments not posted (9)
app/client/src/pages/Editor/IDE/MainPane/index.tsx (3)

6-10: Ensure that the new imports are used appropriately within the file.


15-15: The usage of useSelector to fetch ideViewMode is correct and follows Redux best practices.


25-25: Conditional rendering based on ideViewMode is implemented correctly. This ensures that EditorTabs is only rendered in FullScreen mode.

app/client/src/pages/Editor/IDE/EditorPane/EditorPaneSegments.tsx (3)

Line range hint 9-22: The imports and constants are correctly added and used. Ensure that EditorViewMode and getIDEViewMode are properly utilized in the component logic.


26-26: The ideViewMode is fetched correctly using Redux's useSelector. This is a good practice for managing state in React applications.


37-37: The conditional rendering logic is correct, ensuring that EditorTabs is only rendered in SplitScreen mode.

app/client/src/pages/Editor/IDE/EditorTabs/FileTabs.test.tsx (1)

21-21: The addition of the currentTab prop in the test cases is appropriate. It ensures that the tests reflect the updated component interface and functionality.

Also applies to: 44-44, 59-59

app/client/src/pages/Editor/IDE/EditorTabs/FileTabs.tsx (2)

21-22: The addition of currentTab and newTabClickCallback props is correctly handled in the component's destructuring and usage. This enhances the component's flexibility and functionality.

Also applies to: 28-29


70-70: The conditional class application based on currentTab and the handling of the 'New Tab' click are implemented correctly. These changes improve user interaction and component responsiveness.

Also applies to: 89-91

Comment on lines 40 to 161
} else if (showListView) {
setShowListView(false);
}
}, [files, segmentMode]);

const toggleEditorMode = useCallback(() => {
const newMode =
ideViewMode === EditorViewMode.SplitScreen
? EditorViewMode.FullScreen
: EditorViewMode.SplitScreen;

AnalyticsUtil.logEvent("EDITOR_MODE_CHANGE", {
to: newMode,
});
dispatch(setIdeEditorViewMode(newMode));
}, [ideViewMode, dispatch]);

const handleHamburgerClick = () => {
if (files.length === 0 && segmentMode !== EditorEntityTabState.Add) return;
setShowListView(!showListView);
};

if (!isSideBySideEnabled) return null;
if (segment === EditorEntityTab.UI) return null;

const onTabClick = (tab: EntityItem) => {
setShowListView(false);
tabClickHandler(tab);
};

const newTabClickHandler = () => {
setShowListView(false);
};

return (
<>
<Container>
{ideViewMode === EditorViewMode.SplitScreen && (
<ToggleButton
icon="hamburger"
isSelected={showListView}
onClick={handleHamburgerClick}
size="md"
/>
)}
<FileTabs
currentTab={activeTab}
navigateToTab={onTabClick}
newTabClickCallback={newTabClickHandler}
onClose={closeClickHandler}
tabs={files}
/>
{files.length > 0 ? <AddButton /> : null}
<Tooltip
content={
ideViewMode === EditorViewMode.SplitScreen
? createMessage(MAXIMIZE_BUTTON_TOOLTIP)
: createMessage(MINIMIZE_BUTTON_TOOLTIP)
}
>
<Button
className="ml-auto !min-w-[24px]"
data-testid={
ideViewMode === EditorViewMode.SplitScreen
? "t--ide-maximize"
: "t--ide-minimize"
}
id={
ideViewMode === EditorViewMode.SplitScreen
? "editor-mode-maximize"
: "editor-mode-minimize"
}
isIconButton
kind="tertiary"
onClick={toggleEditorMode}
startIcon={
ideViewMode === EditorViewMode.SplitScreen
? "maximize-v3"
: "minimize-v3"
}
/>
</Tooltip>
</Container>
{showListView && ideViewMode === EditorViewMode.SplitScreen && (
<ListContainer
bg="var(--ads-v2-color-bg)"
className="absolute top-[78px] albin"
h="calc(100% - 78px)"
w="100%"
zIndex="10"
>
<ListQuery />
</ListContainer>
)}
{ideViewMode === EditorViewMode.SplitScreen && <Announcement />}
</>
);
};

export default EditorTabs;
Copy link
Contributor

@coderabbitai coderabbitai bot Jun 10, 2024

Choose a reason for hiding this comment

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

Refactor suggestion for EditorTabs component.

The EditorTabs component is quite large and handles multiple responsibilities, including state management, event handling, and UI rendering. Consider breaking it down into smaller, more manageable components or hooks to improve readability and maintainability.

Copy link
Member

Choose a reason for hiding this comment

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

I agree here. We should break up things like overflow, add and the EditorMode Toggle buttons

Copy link
Contributor

Choose a reason for hiding this comment

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

@hetunandu, great to hear that you agree with the refactoring suggestion! Here’s a possible approach to breaking down the EditorTabs component:

  1. Overflow Handling: Create a TabOverflowHandler component that manages the visibility and interactions of tabs when they exceed the available space.
  2. Add Button: This can be encapsulated into an AddTabButton component that handles the logic and UI for adding new tabs.
  3. Editor Mode Toggle: A ToggleEditorModeButton component could be responsible for switching between different editor modes and encapsulating the associated logic and UI.

Each component can then be used within EditorTabs to clean up the main component and make each piece easier to manage and test independently. If you need further detailed breakdowns or assistance with this, feel free to ask!

app/client/src/pages/Editor/IDE/EditorTabs/index.tsx Outdated Show resolved Hide resolved
Comment on lines 84 to 85
if (!isSideBySideEnabled) return null;
if (segment === EditorEntityTab.UI) return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Handle conditional rendering more explicitly.

The return of null based on isSideBySideEnabled could be handled more explicitly at the beginning of the component to avoid deep nesting and improve readability.

+ if (!isSideBySideEnabled || segment === EditorEntityTab.UI) return null;
- if (!isSideBySideEnabled) return null;
- if (segment === EditorEntityTab.UI) return null;
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!isSideBySideEnabled) return null;
if (segment === EditorEntityTab.UI) return null;
if (!isSideBySideEnabled || segment === EditorEntityTab.UI) return null;

app/client/src/pages/Editor/IDE/EditorTabs/index.tsx Outdated Show resolved Hide resolved
Copy link

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

@hetunandu
Copy link
Member

While testing I found that the overflow list on JS segment also shows API overflow list.
Screenshot 2024-06-12 at 4 56 01 PM

Copy link
Member

@hetunandu hetunandu left a comment

Choose a reason for hiding this comment

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

Refactors and fix the issue with JS segment seeing the wrong overflow list

Comment on lines 40 to 161
} else if (showListView) {
setShowListView(false);
}
}, [files, segmentMode]);

const toggleEditorMode = useCallback(() => {
const newMode =
ideViewMode === EditorViewMode.SplitScreen
? EditorViewMode.FullScreen
: EditorViewMode.SplitScreen;

AnalyticsUtil.logEvent("EDITOR_MODE_CHANGE", {
to: newMode,
});
dispatch(setIdeEditorViewMode(newMode));
}, [ideViewMode, dispatch]);

const handleHamburgerClick = () => {
if (files.length === 0 && segmentMode !== EditorEntityTabState.Add) return;
setShowListView(!showListView);
};

if (!isSideBySideEnabled) return null;
if (segment === EditorEntityTab.UI) return null;

const onTabClick = (tab: EntityItem) => {
setShowListView(false);
tabClickHandler(tab);
};

const newTabClickHandler = () => {
setShowListView(false);
};

return (
<>
<Container>
{ideViewMode === EditorViewMode.SplitScreen && (
<ToggleButton
icon="hamburger"
isSelected={showListView}
onClick={handleHamburgerClick}
size="md"
/>
)}
<FileTabs
currentTab={activeTab}
navigateToTab={onTabClick}
newTabClickCallback={newTabClickHandler}
onClose={closeClickHandler}
tabs={files}
/>
{files.length > 0 ? <AddButton /> : null}
<Tooltip
content={
ideViewMode === EditorViewMode.SplitScreen
? createMessage(MAXIMIZE_BUTTON_TOOLTIP)
: createMessage(MINIMIZE_BUTTON_TOOLTIP)
}
>
<Button
className="ml-auto !min-w-[24px]"
data-testid={
ideViewMode === EditorViewMode.SplitScreen
? "t--ide-maximize"
: "t--ide-minimize"
}
id={
ideViewMode === EditorViewMode.SplitScreen
? "editor-mode-maximize"
: "editor-mode-minimize"
}
isIconButton
kind="tertiary"
onClick={toggleEditorMode}
startIcon={
ideViewMode === EditorViewMode.SplitScreen
? "maximize-v3"
: "minimize-v3"
}
/>
</Tooltip>
</Container>
{showListView && ideViewMode === EditorViewMode.SplitScreen && (
<ListContainer
bg="var(--ads-v2-color-bg)"
className="absolute top-[78px] albin"
h="calc(100% - 78px)"
w="100%"
zIndex="10"
>
<ListQuery />
</ListContainer>
)}
{ideViewMode === EditorViewMode.SplitScreen && <Announcement />}
</>
);
};

export default EditorTabs;
Copy link
Member

Choose a reason for hiding this comment

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

I agree here. We should break up things like overflow, add and the EditorMode Toggle buttons

app/client/src/pages/Editor/IDE/EditorTabs/index.tsx Outdated Show resolved Hide resolved
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 914614d and f98571d.

Files selected for processing (4)
  • app/client/src/pages/Editor/IDE/EditorPane/JS/List.tsx (1 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/List.tsx (1 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/ScreenModeToggle.tsx (1 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/index.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/src/pages/Editor/IDE/EditorPane/JS/List.tsx
Files skipped from review as they are similar to previous changes (1)
  • app/client/src/pages/Editor/IDE/EditorTabs/index.tsx
Additional comments not posted (3)
app/client/src/pages/Editor/IDE/EditorTabs/List.tsx (2)

10-19: The styling in ListContainer is well-defined and adheres to design specifications.


21-35: The conditional rendering logic in the List component is clear and functional. Ensure that the segment definitions (EditorEntityTab.QUERIES and others) are consistently used across the application.

Verification successful

The provided script encountered regex errors due to the inclusion of characters like ], and }, which are not part of the segment names. This led to incorrect parsing of the segment definitions. To address this, we need to refine the script to correctly extract and verify the segment definitions.

Next Steps

  1. Correct the Regex to Extract Segment Names Properly: Adjust the regex pattern to accurately capture the segment names without trailing characters.
  2. Re-run the Verification: Use the refined script to verify the consistent use of segment definitions across the codebase.

Refined Shell Script

Let's refine and re-run the shell script to ensure accurate extraction and verification of segment definitions.


The refined script successfully extracted and verified the segment definitions and their usage across the codebase. The segments EditorEntityTab.JS, EditorEntityTab.QUERIES, and EditorEntityTab.UI were consistently used, confirming that the conditional rendering logic in the List component is correctly implemented.

  • The segments are defined and used in various files such as selectors, reducers, hooks, and test files.
  • No inconsistencies were found in the usage of these segments.

This confirms that the segment definitions are consistently used across the application.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the consistent use of segment definitions across the application.

# Search for `EditorEntityTab.QUERIES` and other segment definitions to ensure consistent usage.
rg --type typescript "EditorEntityTab.QUERIES"

Length of output: 81



Script:

#!/bin/bash
# Description: Verify the consistent use of segment definitions across the application.

# Step 1: Search for all segment definitions in EditorEntityTab.
rg --type ts "EditorEntityTab" > segment_definitions.txt

# Step 2: Extract segment definitions and search for their usages.
while read -r line; do
  if [[ $line =~ EditorEntityTab\.(.*) ]]; then
    segment=${BASH_REMATCH[1]}
    rg --type ts "EditorEntityTab.$segment" >> segment_usages.txt
  fi
done < segment_definitions.txt

# Output the results for review.
cat segment_definitions.txt
cat segment_usages.txt

Length of output: 14873



Script:

#!/bin/bash
# Description: Verify the consistent use of segment definitions across the application.

# Step 1: Search for all segment definitions in EditorEntityTab.
rg --type ts "EditorEntityTab" > segment_definitions.txt

# Step 2: Extract segment definitions and search for their usages.
while read -r line; do
  if [[ $line =~ EditorEntityTab\.([A-Z_]+) ]]; then
    segment=${BASH_REMATCH[1]}
    rg --type ts "EditorEntityTab.$segment" >> segment_usages.txt
  fi
done < segment_definitions.txt

# Output the results for review.
cat segment_definitions.txt
cat segment_usages.txt

Length of output: 17043

app/client/src/pages/Editor/IDE/EditorTabs/ScreenModeToggle.tsx (1)

15-62: The ScreenModeToggle component is implemented correctly, using best practices for state management and UI responsiveness. Verify that the createMessage function properly handles dynamic content for tooltips.

Verification successful

The search results indicate that the createMessage function is used extensively throughout the codebase. Given this wide usage, it is crucial to ensure that createMessage is correctly implemented to handle dynamic content appropriately.

To verify this, we need to locate the implementation of the createMessage function and review its code. This will help us determine if it can handle dynamic content as expected.


The previous script did not locate the implementation of the createMessage function. To proceed, we should refine our search approach. Instead of looking for a function definition, we can search for the export statement related to createMessage to identify its module and then inspect the module for the function implementation.


The createMessage function is exported from three different files:

  1. app/client/src/ce/constants/messages.ts
  2. app/client/packages/design-system/widgets-old/src/constants/messages.tsx
  3. app/client/cypress/support/Objects/CommonErrorMessages.ts

To verify the correct handling of dynamic content, we need to inspect the implementation of createMessage in these files.


The createMessage function implementation in all three files is as follows:

export function createMessage(
  format: (...strArgs: any[]) => string,
  ...args: any[]
) {
  return format(...args);
}

This function takes a formatting function (format) and a list of arguments (args). It applies the formatting function to the arguments, which suggests that it can handle dynamic content as long as the provided formatting function is capable of doing so.

Given this, the createMessage function appears to be correctly implemented to handle dynamic content. Therefore, the ScreenModeToggle component's use of createMessage for tooltips is appropriate and should work as expected.

  • : The createMessage function is implemented correctly to handle dynamic content, ensuring that the ScreenModeToggle component's tooltips will display the appropriate messages.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct handling of dynamic content in `createMessage`.

# Search for the `createMessage` function usage and ensure it handles dynamic content appropriately.
rg --type typescript "createMessage"

Length of output: 71



Script:

#!/bin/bash
# Description: Verify the correct handling of dynamic content in `createMessage`.

# Search for the `createMessage` function usage and ensure it handles dynamic content appropriately.
rg --type ts "createMessage"

Length of output: 205584



Script:

#!/bin/bash
# Description: Locate the implementation of the `createMessage` function to verify its handling of dynamic content.

# Search for the definition of the `createMessage` function in the TypeScript files.
ast-grep --lang ts --pattern 'function createMessage($$) { $$ }'

Length of output: 66



Script:

#!/bin/bash
# Description: Locate the module where `createMessage` is exported to verify its implementation.

# Search for the export statement of `createMessage` in the TypeScript files.
rg --type ts "export .* createMessage"

Length of output: 304



Script:

#!/bin/bash
# Description: Inspect the implementation of `createMessage` in the identified files to verify its handling of dynamic content.

# Display the implementation of `createMessage` from each identified file.
for file in app/client/src/ce/constants/messages.ts app/client/packages/design-system/widgets-old/src/constants/messages.tsx app/client/cypress/support/Objects/CommonErrorMessages.ts; do
  echo "File: $file"
  rg --pcre2 --context 10 "function createMessage" $file
done

Length of output: 2257

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 f98571d and 22b2dfb.

Files selected for processing (9)
  • app/client/src/IDE/Components/FileTab.tsx (1 hunks)
  • app/client/src/pages/Editor/IDE/EditorPane/EditorPaneSegments.tsx (2 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/AddButton.tsx (1 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/Container.tsx (1 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/FileTabs.tsx (2 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/ListButton.tsx (2 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/SearchableFilesList.tsx (2 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/StyledComponents.tsx (2 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/index.tsx (1 hunks)
Files skipped from review due to trivial changes (2)
  • app/client/src/pages/Editor/IDE/EditorTabs/Container.tsx
  • app/client/src/pages/Editor/IDE/EditorTabs/StyledComponents.tsx
Files skipped from review as they are similar to previous changes (3)
  • app/client/src/pages/Editor/IDE/EditorPane/EditorPaneSegments.tsx
  • app/client/src/pages/Editor/IDE/EditorTabs/FileTabs.tsx
  • app/client/src/pages/Editor/IDE/EditorTabs/index.tsx
Additional comments not posted (8)
app/client/src/pages/Editor/IDE/EditorTabs/ListButton.tsx (2)

12-12: Updated import for ListTitle aligns with the new design requirements for the overflow tabs list view.


53-53: Usage of ListTitle in the JSX ensures the overflow tabs' titles are displayed as per the new UI specifications.

app/client/src/pages/Editor/IDE/EditorTabs/AddButton.tsx (3)

1-2: Importing forwardRef is essential for the new functionality allowing AddButton to accept refs, enhancing its reusability and integration with other components.


12-65: Proper use of forwardRef to enhance component integration with other parts of the application by allowing it to handle refs.


15-19: Addition of newTabClickCallback and onClose props enhances the component's functionality by handling tab creation and closing actions dynamically.

app/client/src/IDE/Components/FileTab.tsx (1)

1-97: The FileTab component is well-implemented, with appropriate use of styled components, conditional rendering, and event handling, aligning with the design specifications.

app/client/src/pages/Editor/IDE/EditorTabs/SearchableFilesList.tsx (2)

16-16: Updated import for ListTitle supports the new design requirements for the searchable files list.


67-67: Correct usage of ListTitle in the JSX ensures that file titles are displayed in line with the new UI specifications.

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 22b2dfb and ad3f4e7.

Files selected for processing (2)
  • app/client/src/pages/Editor/IDE/EditorTabs/AddButton.tsx (1 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/index.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • app/client/src/pages/Editor/IDE/EditorTabs/AddButton.tsx
  • app/client/src/pages/Editor/IDE/EditorTabs/index.tsx

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 ad3f4e7 and d31c64f.

Files selected for processing (2)
  • app/client/src/pages/Editor/IDE/EditorTabs/AddTab.tsx (1 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/index.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/src/pages/Editor/IDE/EditorTabs/index.tsx
Additional comments not posted (5)
app/client/src/pages/Editor/IDE/EditorTabs/AddTab.tsx (5)

1-1: Imports are correctly specified and organized.

Also applies to: 3-4


10-16: Component definition and props are correctly implemented with appropriate types.


19-19: Conditional rendering based on segmentMode is implemented correctly.


21-24: Event handling logic in onCloseClick is correctly implemented to stop event propagation and handle the close action.


36-36: Export statement for the AddTab component is correctly implemented.

@albinAppsmith albinAppsmith added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 25, 2024
Copy link

⚠️ Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

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 7d07044 and 296c976.

Files selected for processing (7)
  • app/client/cypress/e2e/Regression/ClientSide/IDE/IDE_Add_Pane_Interactions_spec.ts (1 hunks)
  • app/client/cypress/support/Pages/IDE/FileTabs.ts (1 hunks)
  • app/client/src/IDE/Components/FileTab.tsx (1 hunks)
  • app/client/src/pages/Editor/IDE/EditorPane/JS/JSRender.test.tsx (4 hunks)
  • app/client/src/pages/Editor/IDE/EditorPane/Query/QueryRender.test.tsx (17 hunks)
  • app/client/src/pages/Editor/IDE/EditorTabs/FileTabs.test.tsx (5 hunks)
  • app/client/src/utils/URLUtils.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/src/pages/Editor/IDE/EditorPane/Query/QueryRender.test.tsx
Files skipped from review as they are similar to previous changes (2)
  • app/client/src/IDE/Components/FileTab.tsx
  • app/client/src/pages/Editor/IDE/EditorTabs/FileTabs.test.tsx
Additional context used
Biome
app/client/src/utils/URLUtils.ts

[error] 21-23: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

Additional comments not posted (5)
app/client/cypress/support/Pages/IDE/FileTabs.ts (2)

2-2: LGTM: Improved consistency in tab identifiers.

The use of sanitizeString from URLUtils to standardize tab names in Cypress locators is a good practice. This change enhances the consistency and reliability of tests by ensuring that tab identifiers are uniformly formatted.

Also applies to: 6-7


Line range hint 2-30: Good use of Cypress best practices in FileTabs class.

The methods within the FileTabs class are well-implemented, making good use of the ObjectsRegistry for DOM interactions and handling various tab-related operations effectively.

app/client/src/utils/URLUtils.ts (1)

43-45: Well-implemented string sanitization utility.

The sanitizeString function is effectively designed to ensure string values are safe and consistent for use as identifiers or parts of URLs by converting to lowercase and replacing non-alphanumeric characters with underscores.

app/client/cypress/e2e/Regression/ClientSide/IDE/IDE_Add_Pane_Interactions_spec.ts (1)

71-71: Consistent usage of tab naming in tests.

The update to use "new_query" in the closeTab method call aligns with the standardized naming conventions, ensuring consistency across the test suite.

app/client/src/pages/Editor/IDE/EditorPane/JS/JSRender.test.tsx (1)

154-154: Enhanced assertions for active tab state in tests.

The updates to assert the active state of JavaScript object tabs in various scenarios enhance the robustness of the tests. This is crucial for ensuring that the UI correctly reflects the expected state based on user interactions or state changes.

Also applies to: 204-204, 248-248, 286-286

@albinAppsmith albinAppsmith requested a review from hetunandu June 25, 2024 09:40
@albinAppsmith albinAppsmith added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 25, 2024
Copy link

⚠️ Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

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 296c976 and fb8addb.

Files selected for processing (1)
  • app/client/src/pages/Editor/IDE/EditorTabs/FileTabs.test.tsx (4 hunks)
Additional comments not posted (4)
app/client/src/pages/Editor/IDE/EditorTabs/FileTabs.test.tsx (4)

4-7: Review of new imports:

The imports at lines 4 and 7 have been added to support the new functionalities and data structures used in the tests. These imports are correctly placed and are necessary for the test's functionality.


19-24: Review of activeEntity setup:

The activeEntity object setup is well-defined and matches the expected structure required by the FileTabs component. This setup is crucial for testing the component with different states.


29-38: Review of the test case "renders tabs correctly":

This test verifies that each tab is rendered with the correct content. The use of sanitizeString for generating test IDs is a good practice as it ensures that the IDs are consistent and valid HTML attributes. The test is well-structured and covers the basic rendering logic of the component.


66-74: Review of the test case "check for close click":

This test effectively simulates a user clicking the close button on a tab and checks if the onClose function is called with the correct key. The test is well-structured and provides necessary coverage for the close functionality of the tabs.
[APROVED]

@albinAppsmith albinAppsmith merged commit 519b53e into release Jun 25, 2024
46 checks passed
@albinAppsmith albinAppsmith deleted the overflow-tabs-list-view branch June 25, 2024 10:30
albinAppsmith added a commit that referenced this pull request Jul 1, 2024
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Jul 10, 2024
## Description

This PR implements the new design for the list view.


Fixes appsmithorg#33432  

## Automation

/ok-to-test tags="@tag.Sanity, @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/9660135881>
> Commit: fb8addb
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9660135881&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity, @tag.IDE`

<!-- 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**
  - Introduced `AddTab` component to add new JavaScript or Query tabs.
- Added `ScreenModeToggle` for switching between full-screen and
split-screen modes.
  - Added `FileTab` component for improved tab interactions.
- Introduced `List` component for conditional rendering based on editor
state.

- **Bug Fixes**
- Corrected test assertions and tab names in `JSRender.test.tsx` and
`QueryRender.test.tsx`.
- Fixed tab closure and interaction flow in
`IDE_Add_Pane_Interactions_spec.ts`.

- **Refactor**
- Simplified selector functions and updated component imports for better
readability and performance.

- **Tests**
- Updated tests to include `currentEntity` props and use
`sanitizeString` for tab titles.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@coderabbitai coderabbitai bot mentioned this pull request Oct 29, 2024
2 tasks
This was referenced Dec 27, 2024
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 IDE 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] - New UI for overflow tabs
2 participants