From adca07157477e2c2a11350b7c69d0573ac7bd968 Mon Sep 17 00:00:00 2001
From: Song <1667077010@qq.com>
Date: Sun, 20 Jul 2025 00:19:48 +0800
Subject: [PATCH 1/2] fix padding and hover highlight in tabs (#243)
---
src-web/commands/openWorkspaceSettings.tsx | 2 +-
src-web/components/Settings/Settings.tsx | 12 ++++++------
src-web/components/core/Tabs/Tabs.tsx | 10 +++++-----
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src-web/commands/openWorkspaceSettings.tsx b/src-web/commands/openWorkspaceSettings.tsx
index 3ce40ce8..ab978f77 100644
--- a/src-web/commands/openWorkspaceSettings.tsx
+++ b/src-web/commands/openWorkspaceSettings.tsx
@@ -14,7 +14,7 @@ export function openWorkspaceSettings(tab?: WorkspaceSettingsTab) {
id: 'workspace-settings',
title: 'Workspace Settings',
size: 'md',
- className: 'h-[calc(100vh-5rem)] max-h-[40rem]',
+ className: 'h-[calc(100vh-5rem)] !max-h-[40rem]',
noPadding: true,
render: ({ hide }) => (
diff --git a/src-web/components/Settings/Settings.tsx b/src-web/components/Settings/Settings.tsx
index 127ee197..0d908294 100644
--- a/src-web/components/Settings/Settings.tsx
+++ b/src-web/components/Settings/Settings.tsx
@@ -74,22 +74,22 @@ export default function Settings({ hide }: Props) {
onChangeValue={setTab}
tabs={tabs.map((value) => ({ value, label: capitalize(value) }))}
>
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/src-web/components/core/Tabs/Tabs.tsx b/src-web/components/core/Tabs/Tabs.tsx
index b8132da2..b9899515 100644
--- a/src-web/components/core/Tabs/Tabs.tsx
+++ b/src-web/components/core/Tabs/Tabs.tsx
@@ -84,7 +84,7 @@ export function Tabs({
tabListClassName,
addBorders && '!-ml-1',
'flex items-center hide-scrollbars mb-2',
- layout === 'horizontal' && 'h-full overflow-auto px-2',
+ layout === 'horizontal' && 'h-full overflow-auto p-2',
layout === 'vertical' && 'overflow-x-auto overflow-y-visible ',
// Give space for button focus states within overflow boundary.
layout === 'vertical' && 'py-1 -ml-5 pl-3 pr-1',
@@ -100,9 +100,9 @@ export function Tabs({
const isActive = t.value === value;
const btnClassName = classNames(
'h-sm flex items-center rounded whitespace-nowrap',
- '!px-2 ml-[1px]',
- addBorders && 'border',
- isActive ? 'text-text' : 'text-text-subtle hover:text-text',
+ '!px-2 ml-[1px] hocus:text-text',
+ addBorders && 'border hocus:bg-surface-highlight',
+ isActive ? 'text-text' : 'text-text-subtle',
isActive && addBorders
? 'border-surface-active bg-surface-active'
: layout === 'vertical'
@@ -177,7 +177,7 @@ export const TabContent = memo(function TabContent({
{children}
From ca2fe07265dd54625f6b0bd83cd14194e6302377 Mon Sep 17 00:00:00 2001
From: Song <1667077010@qq.com>
Date: Sun, 20 Jul 2025 00:29:42 +0800
Subject: [PATCH 2/2] Optimize request function (#242)
Co-authored-by: Gregory Schier
---
.../src/plugins/Context.ts | 4 +-
.../template-function-request/src/index.ts | 43 +++++++++++++++++++
src-web/components/DynamicForm.tsx | 15 +++++--
3 files changed, 56 insertions(+), 6 deletions(-)
diff --git a/packages/plugin-runtime-types/src/plugins/Context.ts b/packages/plugin-runtime-types/src/plugins/Context.ts
index 5a481b04..b03b6fd2 100644
--- a/packages/plugin-runtime-types/src/plugins/Context.ts
+++ b/packages/plugin-runtime-types/src/plugins/Context.ts
@@ -17,8 +17,8 @@ import type {
SendHttpRequestResponse,
ShowToastRequest,
TemplateRenderRequest,
- TemplateRenderResponse,
} from '../bindings/gen_events.ts';
+import { JsonValue } from '../bindings/serde_json/JsonValue';
export interface Context {
clipboard: {
@@ -59,6 +59,6 @@ export interface Context {
find(args: FindHttpResponsesRequest): Promise;
};
templates: {
- render(args: TemplateRenderRequest): Promise;
+ render(args: TemplateRenderRequest & { data: T }): Promise;
};
}
diff --git a/plugins/template-function-request/src/index.ts b/plugins/template-function-request/src/index.ts
index df5d2ac9..28814558 100755
--- a/plugins/template-function-request/src/index.ts
+++ b/plugins/template-function-request/src/index.ts
@@ -1,3 +1,4 @@
+import type { HttpUrlParameter } from '@yaakapp-internal/models';
import type { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';
export const plugin: PluginDefinition = {
@@ -53,5 +54,47 @@ export const plugin: PluginDefinition = {
);
},
},
+ {
+ name: 'request.param',
+ args: [
+ {
+ name: 'requestId',
+ label: 'Http Request',
+ type: 'http_request',
+ },
+ {
+ name: 'param',
+ label: 'Param Name',
+ type: 'text',
+ },
+ ],
+ async onRender(ctx: Context, args: CallTemplateFunctionArgs): Promise {
+ const paramName = String(args.values.param ?? '');
+ const requestId = String(args.values.requestId ?? 'n/a');
+ const httpRequest = await ctx.httpRequest.getById({ id: requestId });
+ if (httpRequest == null) return null;
+
+ const renderedUrl = await ctx.templates.render({
+ data: httpRequest.url,
+ purpose: args.purpose,
+ });
+
+ const querystring = renderedUrl.split('?')[1] ?? '';
+ const paramsFromUrl: HttpUrlParameter[] = new URLSearchParams(querystring)
+ .entries()
+ .map(([name, value]): HttpUrlParameter => ({ name, value }))
+ .toArray();
+
+ const allParams = [...paramsFromUrl, ...httpRequest.urlParameters];
+ const allEnabledParams = allParams.filter((p) => p.enabled !== false);
+ const foundParam = allEnabledParams.find((p) => p.name === paramName);
+
+ const renderedValue = await ctx.templates.render({
+ data: foundParam?.value ?? '',
+ purpose: args.purpose,
+ });
+ return renderedValue;
+ },
+ },
],
};
diff --git a/src-web/components/DynamicForm.tsx b/src-web/components/DynamicForm.tsx
index 29b17c46..fe46a23a 100644
--- a/src-web/components/DynamicForm.tsx
+++ b/src-web/components/DynamicForm.tsx
@@ -12,7 +12,7 @@ import type {
} from '@yaakapp-internal/plugins';
import classNames from 'classnames';
import { useAtomValue } from 'jotai';
-import { useCallback } from 'react';
+import { useCallback, useEffect } from 'react';
import { useActiveRequest } from '../hooks/useActiveRequest';
import { useRandomKey } from '../hooks/useRandomKey';
import { capitalize } from '../lib/capitalize';
@@ -415,7 +415,7 @@ function FileArg({
disabled={arg.disabled}
help={arg.description}
onChange={({ filePath }) => onChange(filePath)}
- filePath={filePath === '__NULL__' ? null : filePath}
+ filePath={filePath === DYNAMIC_FORM_NULL_ARG ? null : filePath}
directory={!!arg.directory}
/>
);
@@ -432,7 +432,14 @@ function HttpRequestArg({
}) {
const folders = useAtomValue(foldersAtom);
const httpRequests = useAtomValue(httpRequestsAtom);
- const activeRequest = useActiveRequest();
+ const activeHttpRequest = useActiveRequest('http_request');
+
+ useEffect(() => {
+ if (value === DYNAMIC_FORM_NULL_ARG && activeHttpRequest) {
+ onChange(activeHttpRequest.id);
+ }
+ }, [activeHttpRequest, onChange, value]);
+
return (