Skip to content
Draft
Show file tree
Hide file tree
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
21 changes: 13 additions & 8 deletions src/renderer/components/PRTreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ interface PRTreeViewProps {
onTogglePRSelection: (prId: string, checked: boolean) => void;
onToggleGroupSelection: (prIds: string[], checked: boolean) => void;
onPRClick: (pr: PullRequest) => void;
onCloseGroup: (prIds: string[]) => void;
onCloseGroup: (groupId: string, prIds: string[]) => void;
closingGroupId: string | null;
}

// Helper function to format date and time
Expand Down Expand Up @@ -214,6 +215,7 @@ export function PRTreeView({
onToggleGroupSelection,
onPRClick,
onCloseGroup,
closingGroupId,
}: PRTreeViewProps) {
const treeItems = useMemo(
() => buildTreeItems(prsWithMetadata),
Expand Down Expand Up @@ -414,31 +416,34 @@ export function PRTreeView({
)}
</div>

{item.data.closablePRIds && item.data.closablePRIds.length > 0 && hoveredGroup === item.index && (
{item.data.closablePRIds && item.data.closablePRIds.length > 0 && (hoveredGroup === item.index || closingGroupId === item.index) && (
<div
role="button"
tabIndex={0}
onClick={(event) => {
if (closingGroupId === item.index) return;
event.stopPropagation();
onCloseGroup(item.data.closablePRIds ?? []);
setHoveredGroup(null);
onCloseGroup(item.index as string, item.data.closablePRIds ?? []);
}}
onKeyDown={(event) => {
if (closingGroupId === item.index) return;
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
event.stopPropagation();
onCloseGroup(item.data.closablePRIds ?? []);
setHoveredGroup(null);
onCloseGroup(item.index as string, item.data.closablePRIds ?? []);
}
}}
className={cn(
"ml-3 px-2 py-1 text-xs font-medium rounded border transition-colors cursor-pointer",
"ml-3 px-2 py-1 text-xs font-medium rounded border transition-colors",
closingGroupId === item.index
? "cursor-wait opacity-75"
: "cursor-pointer",
theme === "dark"
? "border-red-500/60 text-red-300 hover:bg-red-900/40"
: "border-red-400 text-red-600 hover:bg-red-50"
)}
>
Close unmerged PRs?
{closingGroupId === item.index ? "Closing..." : "Close unmerged PRs?"}
</div>
)}
</>
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/views/PRListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function PRListView() {
const [showStatusDropdown, setShowStatusDropdown] = useState(false);
const statusDropdownRef = useRef<HTMLDivElement>(null);
const [isClosing, setIsClosing] = useState(false);
const [closingGroupId, setClosingGroupId] = useState<string | null>(null);

const sortBy = prListFilters.sortBy;
const selectedAuthors = useMemo(
Expand Down Expand Up @@ -524,8 +525,10 @@ export default function PRListView() {
}, [closePRIds, closableSelectedPRIds]);

const handleCloseGroup = useCallback(
async (prIds: string[]) => {
async (groupId: string, prIds: string[]) => {
setClosingGroupId(groupId);
await closePRIds(prIds);
setClosingGroupId(null);
},
[closePRIds],
);
Expand Down Expand Up @@ -920,6 +923,7 @@ export default function PRListView() {
onToggleGroupSelection={handleGroupSelection}
onPRClick={handlePRClick}
onCloseGroup={handleCloseGroup}
closingGroupId={closingGroupId}
/>
)}
</div>
Expand Down