Request pane context (#69)

This commit is contained in:
Gregory Schier
2024-09-02 14:36:55 -07:00
committed by GitHub
parent e6d7f4a928
commit 002acd05ee
12 changed files with 200 additions and 76 deletions

View File

@@ -1,6 +1,9 @@
import type { HttpRequest } from '@yaakapp/api';
import type { PairEditorRef } from './core/PairEditor';
import { PairOrBulkEditor } from './core/PairOrBulkEditor';
import { VStack } from './core/Stacks';
import { useOnFocusParamValue } from './RequestEditorContext';
import { useRef } from 'react';
type Props = {
forceUpdateKey: string;
@@ -9,9 +12,24 @@ type Props = {
};
export function UrlParametersEditor({ pairs, forceUpdateKey, onChange }: Props) {
const pairEditor = useRef<PairEditorRef>(null);
useOnFocusParamValue(
(name) => {
const pairIndex = pairs.findIndex((p) => p.name === name);
if (pairIndex >= 0) {
pairEditor.current?.focusValue(pairIndex);
} else {
console.log("Couldn't find pair to focus", { name, pairs });
}
},
[pairs],
);
return (
<VStack className="h-full">
<PairOrBulkEditor
ref={pairEditor}
preferenceName="url_parameters"
valueAutocompleteVariables
nameAutocompleteVariables