mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-26 11:21:30 +01:00
Merge main into proxy branch (formatting and docs)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "@yaak/action-send-folder",
|
||||
"displayName": "Send All",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "Send all HTTP requests in a folder sequentially in tree order",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mountain-loop/yaak.git",
|
||||
"directory": "plugins/action-send-folder"
|
||||
},
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"build": "yaakcli build",
|
||||
"dev": "yaakcli dev"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { PluginDefinition } from '@yaakapp/api';
|
||||
import type { PluginDefinition } from "@yaakapp/api";
|
||||
|
||||
export const plugin: PluginDefinition = {
|
||||
folderActions: [
|
||||
{
|
||||
label: 'Send All',
|
||||
icon: 'send_horizontal',
|
||||
label: "Send All",
|
||||
icon: "send_horizontal",
|
||||
async onSelect(ctx, args) {
|
||||
const targetFolder = args.folder;
|
||||
|
||||
@@ -17,8 +17,8 @@ export const plugin: PluginDefinition = {
|
||||
// Build the send order to match tree ordering:
|
||||
// sort siblings by sortPriority then updatedAt, and traverse folders depth-first.
|
||||
const compareByOrder = (
|
||||
a: Pick<typeof allFolders[number], 'sortPriority' | 'updatedAt'>,
|
||||
b: Pick<typeof allFolders[number], 'sortPriority' | 'updatedAt'>,
|
||||
a: Pick<(typeof allFolders)[number], "sortPriority" | "updatedAt">,
|
||||
b: Pick<(typeof allFolders)[number], "sortPriority" | "updatedAt">,
|
||||
) => {
|
||||
if (a.sortPriority === b.sortPriority) {
|
||||
return a.updatedAt > b.updatedAt ? 1 : -1;
|
||||
@@ -26,7 +26,10 @@ export const plugin: PluginDefinition = {
|
||||
return a.sortPriority - b.sortPriority;
|
||||
};
|
||||
|
||||
const childrenByFolderId = new Map<string, Array<typeof allFolders[number] | typeof allRequests[number]>>();
|
||||
const childrenByFolderId = new Map<
|
||||
string,
|
||||
Array<(typeof allFolders)[number] | (typeof allRequests)[number]>
|
||||
>();
|
||||
for (const folder of allFolders) {
|
||||
if (folder.folderId == null) continue;
|
||||
const children = childrenByFolderId.get(folder.folderId) ?? [];
|
||||
@@ -44,9 +47,9 @@ export const plugin: PluginDefinition = {
|
||||
const collectRequests = (folderId: string) => {
|
||||
const children = (childrenByFolderId.get(folderId) ?? []).slice().sort(compareByOrder);
|
||||
for (const child of children) {
|
||||
if (child.model === 'folder') {
|
||||
if (child.model === "folder") {
|
||||
collectRequests(child.id);
|
||||
} else if (child.model === 'http_request') {
|
||||
} else if (child.model === "http_request") {
|
||||
requestsToSend.push(child);
|
||||
}
|
||||
}
|
||||
@@ -55,9 +58,9 @@ export const plugin: PluginDefinition = {
|
||||
|
||||
if (requestsToSend.length === 0) {
|
||||
await ctx.toast.show({
|
||||
message: 'No requests in folder',
|
||||
icon: 'info',
|
||||
color: 'info',
|
||||
message: "No requests in folder",
|
||||
icon: "info",
|
||||
color: "info",
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -79,15 +82,15 @@ export const plugin: PluginDefinition = {
|
||||
// Show summary toast
|
||||
if (errorCount === 0) {
|
||||
await ctx.toast.show({
|
||||
message: `Sent ${successCount} request${successCount !== 1 ? 's' : ''}`,
|
||||
icon: 'send_horizontal',
|
||||
color: 'success',
|
||||
message: `Sent ${successCount} request${successCount !== 1 ? "s" : ""}`,
|
||||
icon: "send_horizontal",
|
||||
color: "success",
|
||||
});
|
||||
} else {
|
||||
await ctx.toast.show({
|
||||
message: `Sent ${successCount}, failed ${errorCount}`,
|
||||
icon: 'alert_triangle',
|
||||
color: 'warning',
|
||||
icon: "alert_triangle",
|
||||
color: "warning",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user