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: disable branch reset while initializing #23703

Merged
merged 3 commits into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import {
IconExternalLink,
IconMoreVertical,
IconShield,
TooltipContent_Shadcn_,
TooltipTrigger_Shadcn_,
Tooltip_Shadcn_,
} from 'ui'
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import BranchStatusBadge from './BranchStatusBadge'
Expand Down Expand Up @@ -115,6 +118,8 @@ export const BranchRow = ({
}
)

const isBranchActiveHealthy = data?.status === 'ACTIVE_HEALTHY'

const [showBranchModeSwitch, setShowBranchModeSwitch] = useState(false)

const { mutate: updateBranch, isLoading: isUpdating } = useBranchUpdateMutation({
Expand Down Expand Up @@ -259,29 +264,53 @@ export const BranchRow = ({
<Button type="text" icon={<IconMoreVertical />} className="px-1" />
</DropdownMenuTrigger>
<DropdownMenuContent className="p-0 w-56" side="bottom" align="end">
<DropdownMenuItem
className="gap-x-2"
onSelect={() => setShowConfirmResetModal(true)}
onClick={() => setShowConfirmResetModal(true)}
>
<RefreshCw size={14} />
Reset Branch
</DropdownMenuItem>
<DropdownMenuItem
className="gap-x-2"
onSelect={() => setShowBranchModeSwitch(true)}
onClick={() => setShowBranchModeSwitch(true)}
>
{branch.persistent ? (
<>
<Clock size={14} /> Switch to ephemeral
</>
) : (
<>
<Infinity size={14} className="scale-110" /> Switch to persistent
</>
<Tooltip_Shadcn_>
<TooltipTrigger_Shadcn_ asChild={isBranchActiveHealthy} className="w-full">
<DropdownMenuItem
className="gap-x-2"
onSelect={() => setShowConfirmResetModal(true)}
onClick={() => setShowConfirmResetModal(true)}
disabled={isResetting || !isBranchActiveHealthy}
>
<RefreshCw size={14} />
Reset Branch
</DropdownMenuItem>
</TooltipTrigger_Shadcn_>
{!isBranchActiveHealthy && (
<TooltipContent_Shadcn_ side="top">
Branch is still initializing. Please wait for the branch to become healthy
before resetting
</TooltipContent_Shadcn_>
)}
</DropdownMenuItem>
</Tooltip_Shadcn_>

<Tooltip_Shadcn_>
<TooltipTrigger_Shadcn_ asChild={isBranchActiveHealthy} className="w-full">
<DropdownMenuItem
className="gap-x-2"
onSelect={() => setShowBranchModeSwitch(true)}
onClick={() => setShowBranchModeSwitch(true)}
disabled={!isBranchActiveHealthy}
>
{branch.persistent ? (
<>
<Clock size={14} /> Switch to ephemeral
</>
) : (
<>
<Infinity size={14} className="scale-110" /> Switch to persistent
</>
)}
</DropdownMenuItem>
</TooltipTrigger_Shadcn_>
{!isBranchActiveHealthy && (
<TooltipContent_Shadcn_ side="top">
Branch is still initializing. Please wait for the branch to become healthy
before switching modes
</TooltipContent_Shadcn_>
)}
</Tooltip_Shadcn_>

<DropdownMenuItem
className="gap-x-2"
onSelect={() => onSelectDeleteBranch?.()}
Expand Down
Loading