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

fix: misc Button implementations not using isIconButton prop #37382

Merged
merged 10 commits into from
Nov 14, 2024

Conversation

hetunandu
Copy link
Member

@hetunandu hetunandu commented Nov 14, 2024

Description

Fixes issues introduced when we added min width for buttons in #37367

Automation

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

🔍 Cypress test results

Tip

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


Thu, 14 Nov 2024 05:53:10 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new button for slash commands in the Code Editor, allowing users to easily append commands.
    • Integrated an AI assistance button directly within the Code Editor interface.
  • Improvements

    • Enhanced button properties across various components to support icon button functionality, improving visual consistency and interaction.
  • Bug Fixes

    • Maintained existing functionality for scrolling and external link handling while updating button properties.

@hetunandu hetunandu added the ok-to-test Required label for CI label Nov 14, 2024
Copy link
Contributor

coderabbitai bot commented Nov 14, 2024

Walkthrough

The changes in this pull request involve updates to several components across the application, primarily focusing on the addition of the isIconButton prop to various button elements. This prop indicates that the buttons are intended to function as icon buttons, impacting their styling and behavior. Additionally, the CodeEditor component sees the introduction of a new button for slash commands and the integration of an AskAIButton, enhancing user interaction. Overall, the modifications maintain existing functionalities while improving the user interface.

Changes

File Path Change Summary
app/client/packages/design-system/ads/src/Documentation/components/CodeBlock.tsx Added isIconButton prop to the Button component in CodeBlock.
app/client/src/components/editorComponents/CodeEditor/index.tsx Introduced a new button for slash commands and added AskAIButton. Added method updateValueWithAIResponse.
app/client/src/pages/AppViewer/Navigation/TopStacked.tsx Updated ScrollBtnContainer to include isIconButton prop for scroll buttons.
app/client/src/pages/Editor/CustomWidgetBuilder/Preview/Debugger/helpDropdown.tsx Added isIconButton prop to the Button within PopoverTrigger in HelpDropdown.

Possibly related PRs

Suggested labels

Bug, Design System Product, Task, IDE Product, IDE Pod

Suggested reviewers

  • albinAppsmith
  • ankitakinger
  • jsartisan

🎉 In the land of code, where buttons reside,
isIconButton added, with style and pride.
Slash commands now ready, AI at your call,
Enhancing the editor, we’re having a ball!
Scroll buttons twinkle, in their new attire,
A UI delight, that we all admire! ✨


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.

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.

@hetunandu hetunandu changed the title Fix/code editor slash button size fix: misc Button implementations not using isIconButton prop Nov 14, 2024
@hetunandu hetunandu enabled auto-merge (squash) November 14, 2024 05:12
@github-actions github-actions bot added the Bug Something isn't working label Nov 14, 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 (3)
app/client/packages/design-system/ads/src/Documentation/components/CodeBlock.tsx (1)

Line range hint 11-21: Consider enhancing accessibility for the copy functionality.

The component could benefit from improved accessibility features.

Consider these improvements:

 function CodeBlock({ code }: CodeBlockProps) {
   return (
     <Wrapper
       onClick={() => {
         code && navigator.clipboard.writeText(code.toString());
         toast.show("Copied to clipboard", { kind: "success" });
       }}
+      role="region"
+      aria-label="Code block with copy functionality"
     >
       <Code>{code}</Code>
-      <Button isIconButton kind="tertiary" startIcon="copy-control" />
+      <Button
+        isIconButton
+        kind="tertiary"
+        startIcon="copy-control"
+        aria-label="Copy code to clipboard"
+      />
     </Wrapper>
   );
 }
app/client/src/pages/AppViewer/Navigation/TopStacked.tsx (1)

Line range hint 115-126: Consider DRYing up the ScrollBtnContainer props.

The scroll button configurations are duplicated. Consider extracting common props to reduce duplication.

+ const getScrollButtonProps = (isLeft: boolean) => ({
+   isIconButton: true,
+   kind: "tertiary" as const,
+   size: "sm" as const,
+   startIcon: isLeft ? "left-arrow-2" : "right-arrow-2",
+   onMouseDown: () => startScrolling(isLeft),
+   onMouseLeave: stopScrolling,
+   onMouseUp: stopScrolling,
+   onTouchEnd: stopScrolling,
+   onTouchStart: () => startScrolling(isLeft),
+ });

  {tabsScrollable && (
    <ScrollBtnContainer
      className="left-0 scroll-arrows"
-     isIconButton
-     kind="tertiary"
-     onMouseDown={() => startScrolling(true)}
-     onMouseLeave={stopScrolling}
-     onMouseUp={stopScrolling}
-     onTouchEnd={stopScrolling}
-     onTouchStart={() => startScrolling(true)}
-     size="sm"
-     startIcon="left-arrow-2"
+     {...getScrollButtonProps(true)}
      visible={shouldShowLeftArrow}
    />
  )}

Also applies to: 157-168

app/client/src/components/editorComponents/CodeEditor/index.tsx (1)

Line range hint 1713-1725: Consider simplifying button implementation

The button implementation could be improved for better maintainability:

  1. The visibility logic could be simplified by combining the className conditions
  2. The onClick handler could be extracted to a named method

Consider this refactor:

-className={classNames(
-  "commands-button invisible",
-  !showSlashCommandButton && "!hidden",
-)}
+className={classNames("commands-button invisible", {
+  "!hidden": !showSlashCommandButton
+})}

-onClick={() => {
-  const newValue =
-    typeof this.props.input.value === "string"
-      ? this.props.input.value + "/"
-      : "/";
-  this.updatePropertyValue(newValue);
-}}
+onClick={this.handleSlashCommand}

Add this method to the class:

private handleSlashCommand = () => {
  const newValue = typeof this.props.input.value === "string"
    ? this.props.input.value + "/"
    : "/";
  this.updatePropertyValue(newValue);
};
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 748a5ec and dce8dcd.

📒 Files selected for processing (4)
  • app/client/packages/design-system/ads/src/Documentation/components/CodeBlock.tsx (1 hunks)
  • app/client/src/components/editorComponents/CodeEditor/index.tsx (1 hunks)
  • app/client/src/pages/AppViewer/Navigation/TopStacked.tsx (2 hunks)
  • app/client/src/pages/Editor/CustomWidgetBuilder/Preview/Debugger/helpDropdown.tsx (1 hunks)
🔇 Additional comments (4)
app/client/packages/design-system/ads/src/Documentation/components/CodeBlock.tsx (1)

19-19: LGTM! Button prop addition aligns with sizing fix objectives.

The addition of isIconButton prop correctly addresses the button sizing issue while maintaining the existing copy functionality.

app/client/src/pages/Editor/CustomWidgetBuilder/Preview/Debugger/helpDropdown.tsx (1)

23-28: LGTM! Button changes align with size fix requirements.

The addition of isIconButton prop along with tertiary kind and small size maintains the icon-only appearance while fixing the minimum width issues.

app/client/src/pages/AppViewer/Navigation/TopStacked.tsx (1)

115-115: LGTM! Changes align with button size standardization.

The addition of isIconButton prop to scroll buttons is consistent with the PR's objective of fixing button size issues.

Also applies to: 157-157

app/client/src/components/editorComponents/CodeEditor/index.tsx (1)

1713-1713: Confirm the isIconButton prop addition aligns with design system

The addition of isIconButton prop to the Button component aligns with the PR's objective of fixing button size issues.

Let's verify consistent usage across other icon buttons:

✅ Verification successful

The isIconButton prop is consistently used across the codebase for icon-only buttons

The isIconButton prop is correctly used in this context as it's a well-established pattern in the codebase:

  • It's defined in the Button component's interface (ButtonProps) in the design system
  • Used consistently across 80+ icon-only button instances in the codebase
  • Properly handled in the Button component's styles to adjust padding and width for icon buttons
  • Follows the design system's implementation for icon-only buttons
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other icon button usages to ensure consistency
rg -U 'isIconButton.{0,50}Button' --type ts --type tsx

Length of output: 84


Script:

#!/bin/bash
# Search for other icon button usages with corrected file type
rg -U 'isIconButton' --type typescript --type tsx

# Also search for Button component imports to understand the component's origin
rg -U 'import.*Button' --type typescript

# Search for Button component definition to understand prop interface
ast-grep --pattern 'interface ButtonProps {
  $$$
}'

Length of output: 2762


Script:

#!/bin/bash
# Try with explicit file extension search
rg -U 'isIconButton' -g '*.ts' -g '*.tsx'

# Look for Button component usage patterns
rg -U '<Button.*?>' -g '*.tsx' -A 2

# Search for icon-related button patterns
rg -U 'Button.*icon' -g '*.tsx' -A 2

Length of output: 72526

@hetunandu hetunandu merged commit 035d315 into release Nov 14, 2024
56 of 57 checks passed
@hetunandu hetunandu deleted the fix/code-editor-slash-button-size branch November 14, 2024 05:53
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
…horg#37382)

## Description

Fixes issues introduced when we added min width for buttons in appsmithorg#37367


## Automation

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

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!IMPORTANT]
> 🟣 🟣 🟣 Your tests are running.
> Tests running at:
<https://github.com/appsmithorg/appsmith/actions/runs/11831136814>
> Commit: dce8dcd
> Workflow: `PR Automation test suite`
> Tags: `@tag.Sanity`
> Spec: ``
> <hr>Thu, 14 Nov 2024 05:12:11 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants