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

refactor: move apps link out of menu & refactor nav menu data #34313

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

alex-golovanov
Copy link
Contributor

@alex-golovanov alex-golovanov commented Jun 18, 2024

Description

Moved Back to all apps from dropdown menu directly to header.

Additionally renamed NavigationMenuData.ts to useNavigationMenuData.ts and fixed dependency related memoization issues.

image

Fixes #32982

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/9567752111
Commit: 824b2fe
Cypress dashboard.
Tags: @tag.IDE

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • Refactor
    • Removed getNavigationMenu prop from EditorHeader for streamlined navigation menu data retrieval.
    • Updated EditorName to use useNavigationMenuData for navigation menu items.
    • Refactored useNavigationMenuData to use useCallback and useMemo for enhanced performance.
    • Adjusted imports and event handling functions in IDE/Header to use useCallback for better efficiency.

Copy link
Contributor

coderabbitai bot commented Jun 18, 2024

Walkthrough

The recent updates focus on removing the getNavigationMenu prop and refactoring components for improved navigation and better use of hooks like useNavigationMenuData. Significant changes include the removal of outdated prop-based navigation logic, enhancements to navigation menu handling in EditorName, and improved event handling in the header component of the IDE.

Changes

Files Change Summaries
app/client/src/pages/Editor/EditorHeader.tsx Removed the getNavigationMenu prop from EditorHeader, impacting how the navigation menu data is retrieved.
app/client/src/pages/Editor/EditorName/index.tsx Switched from getNavigationMenu to useNavigationMenuData and eliminated various theme and menu item-related imports and types.
app/client/src/pages/Editor/EditorName/useNavigationMenuData.ts Refactored to use hooks (useCallback, useMemo), updated NavigationMenuDataProps without ThemeProp, and renamed GetNavigationMenuData to useNavigationMenuData. Added logic for hasDeletePermission and memoized functions with hooks.
app/client/src/pages/Editor/IDE/Header/index.tsx Updated header component by removing unnecessary imports and implementing useCallback for event handlers. Added APPLICATIONS_URL constant for improved URL handling.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant Header as Header Component
    participant Editor as Editor Component
    participant NavigationHook as useNavigationMenuData

    User->>Header: Clicks on Workspace name
    Header->>Editor: Loads Workspace
    Editor->>NavigationHook: Fetch Navigation Menu Data
    NavigationHook-->>Editor: Returns Navigation Menu Data
    Editor-->>Header: Displays updated menu
    Header-->>User: Shows Workspace content
Loading

Assessment against linked issues

Objective Addressed Explanation
Remove 'Back to all apps' in the app-name dropdown (#32982) The changes do not explicitly mention this removal.
Hyperlink to the workspace name to take the user back (#32982) The updates include linking the workspace name to navigate back to the workspace.

Poem

In the realm of code where changes flow,
Navigation menus come and go.
With hooks that fetch and links that bind,
A smoother path we aimed to find.
The workspace now, with ease, you'll see,
Thanks to thoughtful code from thee.

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.

@alex-golovanov alex-golovanov requested a review from hetunandu June 18, 2024 15:17
@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 18, 2024
@alex-golovanov alex-golovanov added the ok-to-test Required label for CI label Jun 18, 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

Outside diff range and nitpick comments (1)
app/client/src/pages/Editor/EditorHeader.tsx (1)

Line range hint 1-1: Consider using React hooks for state management (useState) and effects (useEffect) consistently across the component to enhance readability and maintain the functional component conventions.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f718bfb and 824b2fe.

Files selected for processing (4)
  • app/client/src/pages/Editor/EditorHeader.tsx (2 hunks)
  • app/client/src/pages/Editor/EditorName/index.tsx (5 hunks)
  • app/client/src/pages/Editor/EditorName/useNavigationMenuData.ts (5 hunks)
  • app/client/src/pages/Editor/IDE/Header/index.tsx (9 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/src/pages/Editor/EditorName/index.tsx
Additional comments not posted (13)
app/client/src/pages/Editor/EditorName/useNavigationMenuData.ts (7)

1-2: Imports for React hooks useCallback and useMemo are correctly added to manage memoization and callback issues as per the PR description.


29-29: The interface NavigationMenuDataProps has been updated to remove the ThemeProp, aligning with the removal of theme-related imports and usage as noted in the AI-generated summary.


34-34: The transformation of GetNavigationMenuData to useNavigationMenuData is a significant improvement. It adheres to React custom hooks naming conventions (useXYZ) and aligns with the functional programming style prevalent in React.


48-50: Introduction of hasDeletePermission using hasDeleteApplicationPermission function is a good practice. It encapsulates permission logic, which enhances code readability and maintainability.


Line range hint 66-87: The exportAppAsJSON function has been correctly refactored to use useCallback for better performance and fewer re-renders. The dependencies listed in the array are appropriate, ensuring that the callback is updated only when necessary.


Line range hint 89-103: The deleteApplication function is properly using useCallback, ensuring that the function is not recreated unless its dependencies change. This is crucial for performance, especially in React components that could re-render often.


105-186: The useMemo hook is used effectively to derive navigationMenuData. This optimizes performance by memoizing the menu data only when its dependencies change. The dependencies array is comprehensive, covering all variables that determine the menu's output.

app/client/src/pages/Editor/EditorHeader.tsx (2)

Line range hint 1-1: All necessary imports are included, and the file adheres to the React functional component structure.


Line range hint 1-1: The handleClickDeploy function is refactored to use useCallback, which is good practice for functions that are passed as props or triggered on events in React components.

app/client/src/pages/Editor/IDE/Header/index.tsx (4)

15-15: The import for Link from "design-system" is correctly added, likely used for navigation links within the IDE header.


Line range hint 169-204: The handlePublish function is refactored to use useCallback, which is correctly implemented. The dependencies are correctly identified, ensuring that the function is only re-created when one of these dependencies changes.


206-215: The handleClickDeploy function's refactoring to use useCallback is appropriate. It ensures that the function is not re-created unnecessarily, which can lead to performance improvements in React applications.


228-231: The use of the Link component to navigate back to the applications URL is a good UX enhancement, making it easier for users to navigate through the application.

@hetunandu
Copy link
Member

/build-deploy-preview

Copy link

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

Copy link

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

@alex-golovanov
Copy link
Contributor Author

/build-deploy-preview

Copy link

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

Copy link

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

@alex-golovanov alex-golovanov merged commit b85c4f5 into release Jun 20, 2024
46 of 47 checks passed
@alex-golovanov alex-golovanov deleted the perf/32982-top-bar-workspace-nav branch June 20, 2024 07:13
ashit-rath added a commit that referenced this pull request Jun 21, 2024
ashit-rath added a commit that referenced this pull request Jun 21, 2024
## Description
Reverted missed out code in
#34367

## 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/9608916182>
> Commit: a252566
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9608916182&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@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
@coderabbitai coderabbitai bot mentioned this pull request Jan 27, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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]: Hyperlink to the workspace name in the top-bar in the IDE.
2 participants