jacob-ai-bot / jacob

Just Another Coding Bot
https://jacb.ai
Apache License 2.0
131 stars 20 forks source link

JACoB PR for Issue Add "Create Branch" Button to Dashboard Menu #195

Closed jacob-ai-bot[bot] closed 1 month ago

jacob-ai-bot[bot] commented 1 month ago

Summary:

Description

Currently, the dashboard menu includes a dropdown for selecting branches. To enhance the user experience and streamline the branching process, we propose adding a "Create Branch" button adjacent to the existing branch dropdown. This feature will allow users to create new branches directly from the dashboard without navigating away from the current interface.

Feature Requirements

  1. UI Enhancements

    • Location: Place a "Create Branch" button next to the existing branch dropdown in the dashboard menu.
    • Button Functionality:
      • On click, display a modal prompting the user to:
      • Enter Branch Name: A text input for the new branch's unique name.
      • Select Base Branch: A dropdown listing all existing branches in the repository to choose the base branch. Add a "Create Branch" button and use loading states. Handle error states.
  2. Validation

    • Ensure the new branch name is unique and does not conflict with existing branch names.
    • Validate that the selected base branch exists and is valid.
  3. Backend Integration

    • Route Addition: Add a new route to the GitHub TRPC router for creating a new branch.
      • Function: createBranch
      • Parameters:
      • branchName: The name of the new branch.
      • baseBranch: The name of the base branch.
    • Branch Creation Logic:
      • Use GitHub's API to create the new branch from the specified base branch.
      • Handle any potential errors during branch creation and provide appropriate feedback to the user.
  4. Post-Creation Behavior

    • Once the branch is successfully created:
      • Automatically set the newly created branch as the selected branch in the branch dropdown.
      • Provide a toast success notification to the user confirming the branch creation.

Expected Outcome

Additional Notes

Plan:

Step 1: Edit /src/app/dashboard/[org]/[repo]/components/Header.tsx

Task: Enhance Header Component to Support Branch Creation

Instructions: In '/src/app/dashboard/[org]/[repo]/components/Header.tsx', perform the following:

Exit Criteria: The Header component displays the 'Create Branch' button, properly manages modal visibility and state, and updates the branch dropdown after branch creation.

Step 2: Edit /src/server/api/routers/github.ts

Task: Add 'createBranch' Mutation to GitHub TRPC Router

Instructions: In '/src/server/api/routers/github.ts', add a new protected mutation called 'createBranch' with input parameters 'org', 'repo', 'branchName', and 'baseBranch'. Implement the mutation to:

Exit Criteria: The 'createBranch' mutation successfully creates new branches via the GitHub API and provides clear feedback for success and error states.

Step 3: Create /src/app/dashboard/[org]/[repo]/components/CreateBranchModal.tsx

Task: Implement CreateBranchModal Component with Branch Creation Functionality

Instructions: Create a new component 'CreateBranchModal' in '/src/app/dashboard/[org]/[repo]/components/'. The component should:

Exit Criteria: The 'CreateBranchModal' component allows users to create new branches, handles validation and errors appropriately, and integrates smoothly with the Header component.

jacob-ai-bot[bot] commented 1 month ago

Hello human! đź‘‹

This PR was created by JACoB to address the issue Add "Create Branch" Button to Dashboard Menu

Next Steps

  1. Please review the PR carefully. Auto-generated code can and will contain subtle bugs and mistakes.

  2. If you identify code that needs to be changed, please reject the PR with a specific reason. Be as detailed as possible in your comments. JACoB will take these comments, make changes to the code and push up changes. Please note that this process will take a few minutes.

  3. Once the code looks good, approve the PR and merge the code.