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, content_type: &str,
) -> Result<FilterResponse> { ) -> Result<FilterResponse> {
let plugin_name = if content_type.to_lowercase().contains("json") { let plugin_name = if content_type.to_lowercase().contains("json") {
"filter-jsonpath" "@yaakapp/filter-jsonpath"
} else { } else {
"filter-xpath" "@yaakapp/filter-xpath"
}; };
let plugin = self let plugin = self

View File

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

View File

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