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

fix: runner select all #8256

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
14 changes: 7 additions & 7 deletions packages/insomnia/src/ui/routes/runner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ export const Runner: FC<{}> = () => {

window.main.trackSegmentEvent({ event: SegmentEvent.collectionRunExecute, properties: { plan: currentPlan?.type || 'scratchpad', iterations: iterationCount } });

const selected = new Set(reqList.selectedKeys);
const requests = Array.from(reqList.items)
.filter(item => selected.has(item.id));
const requests = reqList.selectedKeys === 'all'
? reqList.items
: reqList.items.filter(item => (reqList.selectedKeys as Set<Key>).has(item.id));

// convert uploadData to environment data
const userUploadEnvs = uploadData.map(data => {
Expand Down Expand Up @@ -347,7 +347,7 @@ export const Runner: FC<{}> = () => {
navigate(`/organization/${organizationId}/project/${projectId}/workspace/${workspaceId}/debug/request/${requestId}`);
};
const onToggleSelection = () => {
if (Array.from(reqList.selectedKeys).length === Array.from(reqList.items).length) {
if (reqList.selectedKeys === 'all' || Array.from(reqList.selectedKeys).length === Array.from(reqList.items).length) {
// unselect all
reqList.setSelectedKeys(new Set([]));
} else {
Expand Down Expand Up @@ -478,10 +478,10 @@ export const Runner: FC<{}> = () => {
? Array.from(reqList.items)
.filter(item => item.ancestorIds.includes(targetFolderId))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this filter necessary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we can drop it.

.map(item => item.id)
.filter(id => new Set(reqList.selectedKeys).has(id))
.filter(id => reqList.selectedKeys === 'all' || new Set(reqList.selectedKeys).has(id))
: Array.from(reqList.items)
.map(item => item.id)
.filter(id => new Set(reqList.selectedKeys).has(id));
.filter(id => reqList.selectedKeys === 'all' || new Set(reqList.selectedKeys).has(id));

return (
<>
Expand Down Expand Up @@ -600,7 +600,7 @@ export const Runner: FC<{}> = () => {
<Toolbar className="w-full flex-shrink-0 h-[--line-height-sm] border-b border-solid border-[--hl-md] flex items-center px-2">
<span className="mr-2">
{
Array.from(reqList.selectedKeys).length === Array.from(reqList.items).length ?
(reqList.selectedKeys === 'all' || Array.from(reqList.selectedKeys).length === Array.from(reqList.items).length) ?
<span onClick={onToggleSelection}><i style={{ color: 'rgb(74 222 128)' }} className="fa fa-square-check fa-1x h-4 mr-2" /> <span className="cursor-pointer" >Unselect All</span></span> :
Array.from(reqList.selectedKeys).length === 0 ?
<span onClick={onToggleSelection}><i className="fa fa-square fa-1x h-4 mr-2" /> <span className="cursor-pointer" >Select All</span></span> :
Expand Down
Loading