Skip to content

Commit

Permalink
fix: show GitHub buttons only when repository is selected
Browse files Browse the repository at this point in the history
The Push to Branch and Push & Create PR buttons were showing up whenever
GitHub was connected, even if no specific repository was selected. This
change ensures these buttons only appear when both conditions are met:
1. GitHub is connected (gitHubToken exists)
2. A specific repository is selected (selectedRepository exists)

Otherwise, the Download files button is shown.
  • Loading branch information
openhands-agent committed Dec 20, 2024
1 parent 50b45fb commit 16947ca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frontend/src/components/features/chat/action-suggestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import React from "react";
import { SuggestionItem } from "#/components/features/suggestions/suggestion-item";
import { useAuth } from "#/context/auth-context";
import { DownloadModal } from "#/components/shared/download-modal";
import { useSelector } from "react-redux";

Check failure on line 6 in frontend/src/components/features/chat/action-suggestions.tsx

View workflow job for this annotation

GitHub Actions / Lint frontend

`react-redux` import should occur before import of `#/components/features/suggestions/suggestion-item`
import type { RootState } from "#/store";

interface ActionSuggestionsProps {
onSuggestionsClick: (value: string) => void;
Expand All @@ -12,6 +14,7 @@ export function ActionSuggestions({
onSuggestionsClick,
}: ActionSuggestionsProps) {
const { gitHubToken } = useAuth();
const selectedRepository = useSelector((state: RootState) => state.initialQuery.selectedRepository);

Check failure on line 17 in frontend/src/components/features/chat/action-suggestions.tsx

View workflow job for this annotation

GitHub Actions / Lint frontend

Replace `(state:·RootState)·=>·state.initialQuery.selectedRepository` with `⏎····(state:·RootState)·=>·state.initialQuery.selectedRepository,⏎··`

const [isDownloading, setIsDownloading] = React.useState(false);
const [hasPullRequest, setHasPullRequest] = React.useState(false);
Expand All @@ -27,7 +30,7 @@ export function ActionSuggestions({
onClose={handleDownloadClose}
isOpen={isDownloading}
/>
{gitHubToken ? (
{gitHubToken && selectedRepository ? (
<div className="flex flex-row gap-2 justify-center w-full">
{!hasPullRequest ? (
<>
Expand Down

0 comments on commit 16947ca

Please sign in to comment.