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

chore: Git mod - quick action bar control #37912

Merged
merged 3 commits into from
Dec 5, 2024

Conversation

ashit-rath
Copy link
Contributor

@ashit-rath ashit-rath commented Dec 3, 2024

Description

Git modularisation - Bottom quick action bar control

Note to Reviewer:

  • The BranchButton component is commented out right now since it was not part of the modularisation
  • I have modified the logic for AutocommitStatusbar as I found there was a bug with the percentage calculation, please review

Fixes #37801

Automation

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

🔍 Cypress test results

Tip

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


Wed, 04 Dec 2024 06:02:45 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced AutocommitStatusbar component to display autocommit progress.
    • Added ConnectButton for initiating Git connection actions.
    • Launched QuickActionButton for customizable Git action buttons.
    • Implemented QuickActions component for managing various Git operations.
  • Tests

    • Comprehensive test suites added for AutocommitStatusbar, ConnectButton, QuickActionButton, and QuickActions components to ensure functionality and reliability.
    • Enhanced test coverage for helper functions managing Git button statuses and string manipulation.

These updates enhance user interaction with Git functionalities within the application.

@ashit-rath ashit-rath requested a review from brayn003 December 3, 2024 10:07
@ashit-rath ashit-rath self-assigned this Dec 3, 2024
Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

Walkthrough

This pull request introduces several new components and their corresponding test suites for a Git Quick Action Bar in a React application. Key components include AutocommitStatusbar, ConnectButton, QuickActionButton, and QuickActions, each designed to facilitate various Git operations. The changes also enhance test coverage for these components, ensuring proper functionality and user interactions. Additionally, utility functions for determining button statuses and capitalizing text have been added, further supporting the overall functionality of the Git integration.

Changes

File Path Change Summary
app/client/src/git/components/QuickActions/AutocommitStatusbar.tsx New component for displaying autocommit progress with props for completion state and callback.
app/client/src/git/components/QuickActions/AutocommitStatusbar.test.tsx New test suite validating the behavior of AutocommitStatusbar under various conditions.
app/client/src/git/components/QuickActions/ConnectButton.tsx New component for Git connection actions with permission checks and modal invocation.
app/client/src/git/components/QuickActions/ConnectButton.test.tsx New test suite for ConnectButton, covering rendering and interaction scenarios.
app/client/src/git/components/QuickActions/QuickActionButton.tsx New component for a customizable button with loading and tooltip support.
app/client/src/git/components/QuickActions/QuickActionButton.test.tsx New test suite for QuickActionButton, validating rendering and interaction functionalities.
app/client/src/git/components/QuickActions/helpers.ts New utility functions getPullBtnStatus and capitalizeFirstLetter for managing button states.
app/client/src/git/components/QuickActions/helper.test.ts New test suite for the helper functions, ensuring robust validation of their logic.
app/client/src/git/components/QuickActions/index.tsx New component aggregating Git action buttons, managing user interactions and rendering logic.
app/client/src/git/components/QuickActions/index.test.tsx New test suite for QuickActions, covering various scenarios based on Git connection status.

Assessment against linked issues

Objective Addressed Explanation
Create/Migrate component for Git Quick Action Bar (37801)
Create/Migrate components for Git Connect Btn (37801)
Create/Migrate components for Git Autocommit Progress (37801)
Components must not be passing props to each other (37801)
Components should assume external data from props (37801)
Please add jest test cases too (37801)

Possibly related PRs

Suggested labels

Enhancement, Bug, Git Product, Git Platform, ok-to-test

Suggested reviewers

  • sagar-qa007
  • ankitakinger
  • ApekshaBhosale

"In the land of code where Git does roam,
New buttons and tests find their home.
With progress bars and connections anew,
The Quick Actions shine, all thanks to you!
So let’s commit our joy and cheer,
For a smoother Git flow, we hold dear!" 🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between eddc35d and e9e901f.

📒 Files selected for processing (1)
  • app/client/src/git/components/QuickActions/QuickActionButton.test.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/git/components/QuickActions/QuickActionButton.test.tsx

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.

@github-actions github-actions bot added Packages & Git Pod All issues belonging to Packages and Git Packages Pod issues that belong to the packages pod Task A simple Todo skip-changelog Adding this label to a PR prevents it from being listed in the changelog labels Dec 3, 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: 7

🧹 Outside diff range and nitpick comments (9)
app/client/src/git/components/QuickActions/index.tsx (1)

128-128: Uncomment the BranchButton component if it's ready.

If BranchButton is functional, consider uncommenting it to include it in the Quick Actions.

app/client/src/git/components/QuickActions/ConnectButton.tsx (1)

45-57: Simplify tooltip content logic.

Consider simplifying the tooltipContent generation for better readability.

app/client/src/git/components/QuickActions/QuickActionButton.tsx (1)

27-28: Use clearer styling for disabled state.

Replace manual opacity and cursor styles with the :disabled selector for consistency.

app/client/src/git/components/QuickActions/QuickActionButton.test.tsx (2)

16-22: Add TypeScript types to mock component props

The Tooltip mock could benefit from proper TypeScript types instead of using Record<string, unknown>.

-  Tooltip: ({ children, content }: Record<string, unknown>) => (
+  Tooltip: ({ children, content, }: { children: React.ReactNode; content: React.ReactNode }) => (

24-111: Consider adding error case tests

The test suite covers happy paths well, but consider adding tests for:

  • Invalid icon names
  • Undefined onClick handler
  • Invalid count values (negative numbers)
app/client/src/git/components/QuickActions/ConnectButton.test.tsx (1)

78-83: Extract analytics source as a constant

Consider extracting "BOTTOM_BAR_GIT_CONNECT_BUTTON" as a constant to improve maintainability and reusability.

+const ANALYTICS_SOURCE = "BOTTOM_BAR_GIT_CONNECT_BUTTON";

 expect(AnalyticsUtil.logEvent).toHaveBeenCalledWith(
   "GS_CONNECT_GIT_CLICK",
   {
-    source: "BOTTOM_BAR_GIT_CONNECT_BUTTON",
+    source: ANALYTICS_SOURCE,
   },
 );
app/client/src/git/components/QuickActions/helper.test.ts (1)

9-12: Consider using proper TypeScript interface for gitStatus

Instead of using Record<string, unknown>, define a proper interface for better type safety and documentation.

interface GitStatus {
  behindCount: number;
  isClean: boolean;
}
app/client/src/git/components/QuickActions/index.test.tsx (2)

24-44: Add TypeScript interface for component props

Consider defining a proper interface for the component props instead of using implicit typing.

interface QuickActionsProps {
  isGitConnected: boolean;
  gitStatus: GitStatus;
  pullFailed: boolean;
  // ... other props
}

23-108: Consider adding error scenario test cases

The rendering tests are good, but consider adding test cases for:

  • Network error scenarios
  • Invalid git status responses
  • Error states during git operations
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 008a946 and a1abdc8.

📒 Files selected for processing (10)
  • app/client/src/git/components/QuickActions/AutocommitStatusbar.test.tsx (1 hunks)
  • app/client/src/git/components/QuickActions/AutocommitStatusbar.tsx (1 hunks)
  • app/client/src/git/components/QuickActions/ConnectButton.test.tsx (1 hunks)
  • app/client/src/git/components/QuickActions/ConnectButton.tsx (1 hunks)
  • app/client/src/git/components/QuickActions/QuickActionButton.test.tsx (1 hunks)
  • app/client/src/git/components/QuickActions/QuickActionButton.tsx (1 hunks)
  • app/client/src/git/components/QuickActions/helper.test.ts (1 hunks)
  • app/client/src/git/components/QuickActions/helpers.ts (1 hunks)
  • app/client/src/git/components/QuickActions/index.test.tsx (1 hunks)
  • app/client/src/git/components/QuickActions/index.tsx (1 hunks)
🔇 Additional comments (4)
app/client/src/git/components/QuickActions/AutocommitStatusbar.tsx (2)

46-76: Ensure intervals are cleared correctly to prevent memory leaks.

Verify that intervals are properly managed within the useEffect hook.


79-86: Confirm that completion logic updates percentage as intended.

Check that setting percentage to 100% upon completion behaves as expected.

app/client/src/git/components/QuickActions/helper.test.ts (1)

141-191: LGTM! Comprehensive test coverage for capitalizeFirstLetter

The test suite thoroughly covers all edge cases and scenarios.

app/client/src/git/components/QuickActions/index.test.tsx (1)

109-334: LGTM! Comprehensive event handling test coverage

The test suite thoroughly covers all button interactions and analytics events.

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/src/git/components/QuickActions/AutocommitStatusbar.tsx (3)

14-20: Consider refining the progress increment calculation.

The current setup uses fixed values for STEPS and PROGRESS_INCREMENT. Consider deriving PROGRESS_INCREMENT from MAX_PROGRESS_PERCENTAGE and STEPS for more precise control:

-const PROGRESS_INCREMENT = 10;
-const STEPS = 9;
+const STEPS = 9;
+const PROGRESS_INCREMENT = MAX_PROGRESS_PERCENTAGE / STEPS;

21-37: Consider using more specific selectors.

The nested selectors (> div > div, > div > p) could be more specific to prevent potential styling conflicts:

-  > div > div {
+  > div.statusbar-container > div.progress-bar {
     margin-top: 0px;
     width: ${PROGRESSBAR_WIDTH}px;
     margin-right: var(--ads-v2-spaces-4);
   }

-  > div > p {
+  > div.statusbar-container > p.status-message {
     margin-top: 0;
   }

39-118: Consider adding error boundary protection.

Given that this component manages intervals and state updates, consider wrapping it with an error boundary to gracefully handle any potential runtime errors.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a1abdc8 and eddc35d.

📒 Files selected for processing (2)
  • app/client/src/git/components/QuickActions/AutocommitStatusbar.test.tsx (1 hunks)
  • app/client/src/git/components/QuickActions/AutocommitStatusbar.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/git/components/QuickActions/AutocommitStatusbar.test.tsx
🔇 Additional comments (3)
app/client/src/git/components/QuickActions/AutocommitStatusbar.tsx (3)

1-12: LGTM! Clean imports and well-defined interface.

The imports are well-organized and the interface follows TypeScript best practices.


111-111: Review hardcoded active prop.

The active prop is hardcoded to false. Consider making this configurable through component props if the status bar's active state needs to vary based on different conditions.


77-77: Verify the dependency array comment.

The comment about removing 'percentage' from dependencies should be verified. If 'percentage' was intentionally removed to prevent unnecessary re-renders, consider documenting this decision more explicitly.

✅ Verification successful

The comment about removing 'percentage' from dependencies is correct and justified.

The incrementPercentage effect only needs to react to changes in the completed prop. Including percentage in the dependency array would cause unnecessary re-runs of the effect since percentage is updated within the effect itself through setPercentage. The cleanup logic properly handles interval clearing, making this a safe optimization.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar patterns in other components
ast-grep --pattern 'useEffect(function $name() { $$$}, [$deps])'

Length of output: 66


Script:

#!/bin/bash
# Let's try a different pattern to match useEffect with dependencies
rg -U "useEffect\([^)]+\),\s*\[[^\]]*\]" app/client/src/git/components/QuickActions/AutocommitStatusbar.tsx

# Also get the surrounding context to understand the usage
rg -B 5 -A 5 "percentage.*from dependencies" app/client/src/git/components/QuickActions/AutocommitStatusbar.tsx

Length of output: 480


Script:

#!/bin/bash
# Let's look at the full useEffect implementation to understand if percentage is used inside
rg -B 10 -A 10 "useEffect\(.*\{\s*if\s*\(intervalRef\.current\)" app/client/src/git/components/QuickActions/AutocommitStatusbar.tsx

Length of output: 133


Script:

#!/bin/bash
# Let's try a simpler pattern to get the full component implementation
rg -U "^.*useEffect.*\{.*\}.*\[.*\]" --multiline app/client/src/git/components/QuickActions/AutocommitStatusbar.tsx

Length of output: 117


Script:

#!/bin/bash
# Let's get the entire file content to analyze the component
cat app/client/src/git/components/QuickActions/AutocommitStatusbar.tsx

Length of output: 3019

@ashit-rath ashit-rath added the ok-to-test Required label for CI label Dec 4, 2024
@ashit-rath ashit-rath merged commit 80f2000 into release Dec 5, 2024
44 of 47 checks passed
@ashit-rath ashit-rath deleted the chore/git-mod-quick-action-bar branch December 5, 2024 09:08
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Dec 9, 2024
## Description
Git modularisation - Bottom quick action bar control

Note to Reviewer: 
- The `BranchButton` component is commented out right now since it was
not part of the modularisation
- I have modified the logic for `AutocommitStatusbar` as I found there
was a bug with the percentage calculation, please review


Fixes appsmithorg#37801 

## Automation

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

### 🔍 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/12153277180>
> Commit: e9e901f
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12153277180&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Wed, 04 Dec 2024 06:02:45 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Release Notes

- **New Features**
- Introduced `AutocommitStatusbar` component to display autocommit
progress.
	- Added `ConnectButton` for initiating Git connection actions.
	- Launched `QuickActionButton` for customizable Git action buttons.
- Implemented `QuickActions` component for managing various Git
operations.

- **Tests**
- Comprehensive test suites added for `AutocommitStatusbar`,
`ConnectButton`, `QuickActionButton`, and `QuickActions` components to
ensure functionality and reliability.
- Enhanced test coverage for helper functions managing Git button
statuses and string manipulation.

These updates enhance user interaction with Git functionalities within
the application.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@coderabbitai coderabbitai bot mentioned this pull request Dec 30, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI Packages & Git Pod All issues belonging to Packages and Git Packages Pod issues that belong to the packages pod skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Git mod - Components - Quick action bar
2 participants