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

Intergrate YorkieIntelligence into ToolBar #301

Merged
merged 12 commits into from
Aug 20, 2024

Conversation

beberiche
Copy link
Contributor

@beberiche beberiche commented Aug 19, 2024

What this PR does / why we need it:
This PR integrates the YorkieIntelligence component within the ToolBar component and renames FormatBar to ToolBar. This change helps in resolving rendering issues during text drag operations and streamlines the component structure.

Which issue(s) this PR fixes:

Fixes #267
(Maybe will be fixed #272

Special notes for your reviewer:

  • The YorkieIntelligence component is now part of ToolBar, which resolves rendering issues when dragging text.
  • Unnecessary state values were removed, and the component's structure and styling were redesigned for better performance.
  • An activation state has been added to the YorkieIntelligence component, which allows for dynamic styling and click events based on its active status.
스크린샷 2024-08-17 오후 1 33 38 스크린샷 2024-08-17 오후 1 31 27

Does this PR introduce a user-facing change?:

Merge `yorkieIntelligence` component into `ToolBar` and rename `formatBar` to `ToolBar`

Checklist:

  • Added relevant tests or not required
  • Didn't break anything

Summary by CodeRabbit

  • New Features

    • Introduced a new ToolBar component, enhancing editing functionality.
    • Added a ButtonGroup to the ToolBar for improved interaction with formatting options.
  • UI Enhancements

    • Adjusted styling for the TooltipToggleButton, resulting in a more compact button appearance.
    • Enhanced footer visibility toggle in the YorkieIntelligence component for better user experience.
  • Refactor

    • Renamed components and state variables for clarity, transitioning from "FormatBar" to "ToolBar".
    • Streamlined logic by removing unnecessary state management in the YorkieIntelligence component.
    • Simplified the DocumentIndex component by removing unused features and dependencies.

Copy link
Contributor

coderabbitai bot commented Aug 19, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The recent changes streamline the codebase by refactoring components related to the formatting toolbar and integrating the YorkieIntelligence component. The FormatBar has been renamed to ToolBar, enhancing overall clarity and user interaction. Additionally, unnecessary state management has been removed, and visual adjustments have been made to improve user experience while maintaining code maintainability.

Changes

Files Change Summary
frontend/src/components/editor/Editor.tsx, frontend/src/components/editor/ToolBar.tsx Renamed FormatBar to ToolBar, updated state management, and modified positioning logic to improve clarity and layout.
frontend/src/components/editor/YorkieIntelligence.tsx Removed unnecessary state variables, simplified footer visibility logic, and replaced Popper with a toggle button for enhanced user interaction.
frontend/src/pages/workspace/document/Index.tsx Removed references to YorkieIntelligence and associated logic, simplifying the component structure.
frontend/src/components/common/TooltipToggleButton.tsx Adjusted CSS styling by changing the button's margin and removing padding, impacting layout and spacing.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ToolBar
    participant YorkieIntelligence

    User->>ToolBar: Interact with formatting options
    ToolBar->>YorkieIntelligence: Update formatting state
    YorkieIntelligence-->>User: Display updated interface
Loading

Assessment against linked issues

Objective Addressed Explanation
Integrate YorkieIntelligence into the FormatBar component (#[267])
Ensure Yorkie Intelligence button disappears in read-only mode (#[272]) The changes do not address the visibility of the button in read-only mode, as there was no logic implemented for that scenario.

Possibly related PRs

  • Intergrate YorkieIntelligence into ToolBar #301: This PR integrates the YorkieIntelligence component into the ToolBar, which is relevant to the changes in the TooltipToggleButton.tsx file where CSS styling adjustments were made, potentially affecting the layout of components that include tooltips.
  • Add shortcut for text formatting and FormatBar component #263: This PR introduces a TooltipToggleButton component, which is directly related to the changes in TooltipToggleButton.tsx as it also involves the implementation of a toggle button with tooltip functionality.
  • Apply the design of sidebar #306: While this PR focuses on sidebar design, it may indirectly relate to the overall UI changes in the TooltipToggleButton.tsx file, as both involve enhancing user interface components.
  • Apply design changes for document title update feature #357: This PR applies design changes for the document title update feature, which may relate to the overall UI consistency and styling adjustments in the TooltipToggleButton.tsx file.

Suggested reviewers

  • devleejb

🐇 In a world of code so bright,
Tools now shine with new delight.
Buttons toggle, states align,
Formatting's ease is now divine!
With every change, we hop and cheer,
For clarity and joy are here! 🌟


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 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.

CodeRabbit Configuration 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.

@beberiche beberiche changed the title intergration yorkie intelligence into ToolBar Intergrate YorkieIntelligence into ToolBar Aug 19, 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, codebase verification and nitpick comments (2)
frontend/src/components/editor/YorkieIntelligence.tsx (2)

1-7: Ensure consistent import order.

Consider grouping similar imports together for better readability, such as placing all React imports together, followed by external library imports, and then local imports.

import { useEffect, useState } from "react";
import { useSelector } from "react-redux";
import { Button, Typography } from "@mui/material";
import { createPortal } from "react-dom";

import { INTELLIGENCE_FOOTER_ID } from "../../constants/intelligence";
import YorkieIntelligenceFooter from "./YorkieIntelligenceFooter";
import { selectSetting } from "../../store/settingSlice";

30-47: Enhance button accessibility.

Consider adding aria-pressed to the Button to improve accessibility, indicating the toggle state to screen readers.

<Button
  onClick={handleFooterOpen}
+ aria-pressed={footerOpen}
  sx={{
    padding: "3px 5px",
    border: "none",
    "&:hover": {
      border: "none",
    },
    filter: activated ? "none" : "grayscale(100%)",
    pointerEvents: activated ? "auto" : "none",
    opacity: activated ? 1 : 0.7,
  }}
>
  <img src="/yorkie.png" height={20} alt="yorkie_img" />
  <Typography variant="subtitle1" fontSize={14}>
    Yorkie Intelligence
  </Typography>
</Button>
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between aaa1270 and 7c9e5b1.

Files selected for processing (6)
  • frontend/src/components/common/TooltipToggleButton.tsx (1 hunks)
  • frontend/src/components/editor/Editor.tsx (4 hunks)
  • frontend/src/components/editor/FormatBar.tsx (4 hunks)
  • frontend/src/components/editor/YorkieIntelligence.tsx (1 hunks)
  • frontend/src/hooks/useFormatUtils.ts (3 hunks)
  • frontend/src/pages/workspace/document/Index.tsx (2 hunks)
Files skipped from review due to trivial changes (2)
  • frontend/src/components/common/TooltipToggleButton.tsx
  • frontend/src/pages/workspace/document/Index.tsx
Additional comments not posted (12)
frontend/src/components/editor/YorkieIntelligence.tsx (2)

50-53: Verify portal rendering logic.

Ensure that intelligenceFooterPivot is correctly set and available when the portal is rendered. If intelligenceFooterPivot is null, the portal will fail to render.


13-13: Verify Redux selector usage.

Ensure that the selectSetting selector is correctly implemented and returns the expected structure. This is crucial for the yorkieIntelligence property to be accessed correctly.

Verification successful

Redux Selector Implementation Verified

The selectSetting selector correctly accesses the setting slice, which includes the yorkieIntelligence property. The settingSlice in frontend/src/store/settingSlice.ts defines yorkieIntelligence as part of the state, confirming that the selector's usage in YorkieIntelligence.tsx is appropriate and should function as expected.

  • frontend/src/store/settingSlice.ts: The settingSlice includes yorkieIntelligence.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the `selectSetting` selector.

# Test: Search for the `selectSetting` function definition. Expect: Correct structure returning `yorkieIntelligence`.
ast-grep --lang typescript --pattern $'const selectSetting = $_ => $_' 

Length of output: 175


Script:

#!/bin/bash
# Description: Check the structure of the `setting` slice to verify it contains `yorkieIntelligence`.

# Search for the `setting` slice definition and check if `yorkieIntelligence` is part of it.
rg 'setting' -A 10 --type=typescript

Length of output: 71


Script:

#!/bin/bash
# Description: Check the structure of the `setting` slice to verify it contains `yorkieIntelligence`.

# Search for the `setting` slice definition and check if `yorkieIntelligence` is part of it.
rg 'setting' -A 10

Length of output: 24463

frontend/src/components/editor/FormatBar.tsx (4)

1-4: Imports are well-organized and appropriate.

The imports are necessary for the functionality of the ToolBar component, including the newly integrated YorkieIntelligence.


6-8: ToolBarProps interface is correctly defined.

The interface accurately represents the properties required for the ToolBar component, ensuring type safety and clarity.


86-86: Export statement is correctly updated to ToolBar.

The export statement reflects the refactoring changes, ensuring the component is correctly exported.


Line range hint 11-86: ToolBar function refactoring is consistent and logical.

The refactoring from FormatBar to ToolBar is well-executed, with appropriate updates to state management and UI elements. The integration of YorkieIntelligence enhances the toolbar's functionality.

Ensure that all instances of ToolBar usage in the codebase are updated to reflect the new component name and structure.

Verification successful

To address the issue with the previous script, I'll adjust the approach to search for ToolBar usage across all files and filter for .tsx files. Let's proceed with this strategy.


ToolBar component usage verified in the codebase

The ToolBar component is correctly imported and used within the same file, indicating that the refactoring from FormatBar to ToolBar has been applied accurately in this context. If there are concerns about its usage in other parts of the codebase, further manual verification might be necessary.

  • The ToolBar component is used in frontend/src/components/editor/FormatBar.tsx.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all instances of `ToolBar` usage in the codebase.

# Test: Search for the component usage. Expect: Only occurrences of the new name `ToolBar`.
rg --type tsx 'ToolBar'

Length of output: 51


Script:

#!/bin/bash
# Description: Verify all instances of `ToolBar` usage in the codebase.

# Find all .tsx files and search for the usage of `ToolBar`
fd --extension tsx --exec rg 'ToolBar' {}

Length of output: 841

frontend/src/hooks/useFormatUtils.ts (2)

9-9: ToolBarState interface renaming is appropriate.

The renaming from FormatBarState to ToolBarState aligns with the component's refactoring and maintains clarity in state management.


Line range hint 125-136: Parameter update to onChangeToolBarState is consistent.

The update aligns with the refactoring changes, ensuring consistency in state management across the application.

frontend/src/components/editor/Editor.tsx (4)

17-19: Import statement for ToolBar is correctly updated.

The import statement reflects the refactoring changes, ensuring the correct component is imported.


31-31: toolBarState initialization is correctly updated.

The state initialization reflects the refactoring changes and aligns with the component's requirements.


76-87: updateFormatBar function logic is consistent and correct.

The function logic aligns with the updated state management and ensures correct toolbar positioning.


188-189: Rendering logic for ToolBar is correctly implemented.

The rendering condition ensures that the ToolBar is displayed based on the updated state, aligning with the component's visibility requirements.

@devleejb devleejb self-requested a review August 19, 2024 10:00
frontend/src/pages/workspace/document/Index.tsx Outdated Show resolved Hide resolved
frontend/src/pages/workspace/document/Index.tsx Outdated Show resolved Hide resolved
frontend/src/components/editor/YorkieIntelligence.tsx Outdated Show resolved Hide resolved
frontend/src/components/editor/YorkieIntelligence.tsx Outdated Show resolved Hide resolved
frontend/src/components/editor/FormatBar.tsx Outdated Show resolved Hide resolved
frontend/src/components/editor/FormatBar.tsx Outdated Show resolved Hide resolved
frontend/src/components/editor/Editor.tsx Outdated Show resolved Hide resolved
frontend/src/components/editor/Editor.tsx Outdated Show resolved Hide resolved
frontend/src/components/editor/FormatBar.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 7c9e5b1 and addf19c.

Files selected for processing (1)
  • frontend/src/pages/workspace/document/Index.tsx (2 hunks)
Additional comments not posted (2)
frontend/src/pages/workspace/document/Index.tsx (2)

Line range hint 1-1: Remove unused imports if any.

Ensure that all imports are necessary for the current functionality of the component.


Line range hint 1-1: Verify the impact of removing YorkieIntelligence and selectSetting.

Ensure that the removal of these references does not affect other parts of the application, especially any functionality that might have depended on these components or settings.

- change Box to Divider
- set up flex using stack component
- remove TooltipToggleButton style margin and minWidth
- remove style pointerEvents and, use disabled attribute
- remove true check (activated)
- change type assertion(intelligenceFooterPivot) to if conditional statement
- change naming showFormatBar -> showToolBar
- add set up Transition (Effect: Fade, delay: 300ms)
@beberiche beberiche force-pushed the fix/intergration_yorkie_intelligence branch from addf19c to 635c4d1 Compare August 19, 2024 15:07
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 addf19c and 635c4d1.

Files selected for processing (5)
  • frontend/src/components/common/TooltipToggleButton.tsx (1 hunks)
  • frontend/src/components/editor/Editor.tsx (4 hunks)
  • frontend/src/components/editor/ToolBar.tsx (1 hunks)
  • frontend/src/components/editor/YorkieIntelligence.tsx (1 hunks)
  • frontend/src/pages/workspace/document/Index.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • frontend/src/components/common/TooltipToggleButton.tsx
  • frontend/src/components/editor/Editor.tsx
  • frontend/src/pages/workspace/document/Index.tsx
Additional comments not posted (10)
frontend/src/components/editor/YorkieIntelligence.tsx (5)

1-7: Imports look good.

The imports are appropriate and align with the component's functionality.


8-13: State management and Redux integration look good.

The use of useState and useSelector is appropriate for managing local and global state.


14-25: Effect and event handler are well-implemented.

The useEffect hook correctly manages DOM element references, and the handleFooterOpen function effectively toggles the state.


30-50: Button component logic is well-implemented.

The conditional styling and disabled state provide clear user feedback based on the component's active status.


51-51: createPortal usage is appropriate.

The createPortal function is correctly used for rendering the YorkieIntelligenceFooter component outside the parent DOM hierarchy.

frontend/src/components/editor/ToolBar.tsx (5)

1-6: Imports look good.

The imports are appropriate and align with the component's functionality.


8-16: Component structure and props interface are well-defined.

The ToolBarProps interface and component structure ensure type safety and clarity in the component's usage.


17-28: Debounce logic is well-implemented.

The use of useDebounce effectively manages UI transitions, reducing unnecessary renders.


30-50: Popover configuration is appropriate.

The Popover component is well-configured for the toolbar's functionality, ensuring proper display and interaction.


51-102: UI organization and interaction handling are well-executed.

The Stack and ToggleButtonGroup components effectively organize the UI and handle user interactions with formatting options.

@beberiche
Copy link
Contributor Author

beberiche commented Aug 19, 2024

@devleejb
I changed code for comments!
Please check again

@hackerwins hackerwins requested a review from devleejb August 20, 2024 01:11
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 635c4d1 and 97727e7.

Files selected for processing (2)
  • frontend/src/components/editor/Editor.tsx (4 hunks)
  • frontend/src/components/editor/YorkieIntelligence.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • frontend/src/components/editor/Editor.tsx
  • frontend/src/components/editor/YorkieIntelligence.tsx

- improve intelligence footer pivot error when changing selection after text formatting
Copy link
Member

@devleejb devleejb left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution.

We actually use a scaling factor (https://mui.com/material-ui/customization/spacing/) for padding, margin, and spacing. However, I think it’s okay for now since these values will be adjusted when the design is finalized.

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 97727e7 and c401148.

Files selected for processing (1)
  • frontend/src/components/editor/YorkieIntelligence.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/editor/YorkieIntelligence.tsx

@devleejb devleejb merged commit 2734563 into main Aug 20, 2024
2 checks passed
@devleejb devleejb deleted the fix/intergration_yorkie_intelligence branch August 20, 2024 07:26
@beberiche beberiche added the enhancement 🌟 New feature or request label Oct 5, 2024
minai621 pushed a commit that referenced this pull request Nov 5, 2024
* fix(yorkie_intelligence): integrate YorkieIntelligence into FormatBar

* refactor(formatBar) : change naming formatBar -> toolBar

* chore(index.tsx): remove unused code

* chore(ToolBar): rename FormatBar to ToolBar

- change Box to Divider
- set up flex using stack component
- remove TooltipToggleButton style margin and minWidth

* chore(YorkieIntelligence): change setting activated

- remove style pointerEvents and, use disabled attribute
- remove true check (activated)

* chore(Editor): remove true check edtiorStore.cmView

* chore(YorkieIntelligence): remove variable activated

- change type assertion(intelligenceFooterPivot) to if conditional statement

* refactor(YorkieIntelligence): add set up debousing for showToolBar

- change naming showFormatBar -> showToolBar
- add set up Transition (Effect: Fade, delay: 300ms)

* refactor(YorkieIntelligence): remove unnecessary selectionchange event listener

* chore(Editor): adjust position of toolbar in Editor.tsx

* fix(YorkieIntelligence): improve intelligence footer pivot handling

- improve intelligence footer pivot error when changing selection after text formatting

* �Change `TODO` comment

---------

Co-authored-by: devleejb <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌟 New feature or request
Projects
Status: Done
Status: Backlog
2 participants