mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 22:45:25 +00:00
* fix: persist scroll * fix: persist scroll * chore: style * fix: remove persisted variabled from localstorage on boot * fix: persist scroll in request tabs * fix: persist scroll in folder tabs * fix: hooks for container and editor scrolls * fix: persist scroll position in response tabs * fix: persist scroll for different request bodies * fix: persist scroll for collection tabs * fix: test cases * test: scroll persists tests * tests: resolved coderabbit comments for tests * tests: resolved coderabbit comments for tests * fix: remove only * fix: test cases * fix: flaky create collection path as name * move scrollbar tests * test cases * test cases * test cases * test cases * test cases * fix: moved redundant code to common useTrackScroll function * chore: spaces * fix: move usetrackscroll to hook * chore: cleanup un-needed setTimeout * fix: linting issues * chore: example fix * fix: test cases * fix: test cases * fix: flaky scroll tests cases * chore: revert prop name change * chore: blank commit * chore: blank commit --------- Co-authored-by: shubh-bruno <shubh-bruno@shubh-bruno.local> Co-authored-by: Sid <siddharth@usebruno.com>
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import React, { useMemo } from 'react';
|
|
import get from 'lodash/get';
|
|
import CodeEditor from 'components/CodeEditor';
|
|
import { useTheme } from 'providers/Theme';
|
|
import { useSelector } from 'react-redux';
|
|
import { parseBulkKeyValue, serializeBulkKeyValue } from 'utils/common/bulkKeyValueUtils';
|
|
|
|
const BulkEditor = ({ params, onChange, onToggle, onSave, onRun }) => {
|
|
const preferences = useSelector((state) => state.app.preferences);
|
|
const { displayedTheme } = useTheme();
|
|
|
|
const parsedParams = useMemo(() => serializeBulkKeyValue(params), [params]);
|
|
|
|
const handleEdit = (value) => {
|
|
const parsed = parseBulkKeyValue(value);
|
|
onChange(parsed);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<div className="h-[200px]">
|
|
<CodeEditor
|
|
mode="text/plain"
|
|
theme={displayedTheme}
|
|
font={get(preferences, 'font.codeFont', 'default')}
|
|
fontSize={get(preferences, 'font.codeFontSize')}
|
|
value={parsedParams}
|
|
onEdit={handleEdit}
|
|
onSave={onSave}
|
|
onRun={onRun}
|
|
/>
|
|
</div>
|
|
<div className="flex btn-action justify-between items-center mt-3">
|
|
<button className="text-link select-none ml-auto" data-testid="key-value-edit-toggle" onClick={onToggle}>
|
|
Key/Value Edit
|
|
</button>
|
|
</div>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default BulkEditor;
|