Fix response filtering

This commit is contained in:
Gregory Schier
2024-10-21 07:26:50 -07:00
parent 57c3a86799
commit b9f397e04a
3 changed files with 10 additions and 7 deletions

View File

@@ -558,9 +558,9 @@ impl PluginManager {
content_type: &str,
) -> Result<FilterResponse> {
let plugin_name = if content_type.to_lowercase().contains("json") {
"filter-jsonpath"
"@yaakapp/filter-jsonpath"
} else {
"filter-xpath"
"@yaakapp/filter-xpath"
};
let plugin = self

View File

@@ -41,6 +41,7 @@ export function HTMLOrTextViewer({ response, pretty, textViewerClassName }: Prop
className={textViewerClassName}
onSaveResponse={saveResponse.mutate}
responseId={response.id}
requestId={response.requestId}
/>
);
}

View File

@@ -28,6 +28,7 @@ interface Props {
text: string;
language: EditorProps['language'];
responseId: string;
requestId: string;
onSaveResponse: () => void;
}
@@ -37,20 +38,21 @@ export function TextViewer({
language,
text,
responseId,
requestId,
pretty,
className,
onSaveResponse,
}: Props) {
const [filterTextMap, setFilterTextMap] = useFilterText();
const [showLargeResponse, toggleShowLargeResponse] = useToggle();
const filterText = filterTextMap[responseId] ?? null;
const filterText = filterTextMap[requestId] ?? null;
const copy = useCopy();
const debouncedFilterText = useDebouncedValue(filterText, 200);
const setFilterText = useCallback(
(v: string | null) => {
setFilterTextMap((m) => ({ ...m, [responseId]: v }));
setFilterTextMap((m) => ({ ...m, [requestId]: v }));
},
[setFilterTextMap, responseId],
[setFilterTextMap, requestId],
);
const isSearching = filterText != null;
@@ -75,7 +77,7 @@ export function TextViewer({
nodes.push(
<div key="input" className="w-full !opacity-100">
<Input
key={responseId}
key={requestId}
validate={!filteredResponse.error}
hideLabel
autoFocus
@@ -110,7 +112,7 @@ export function TextViewer({
filteredResponse.error,
isSearching,
language,
responseId,
requestId,
setFilterText,
toggleSearch,
]);