mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-22 16:03:39 +01:00
feat: listeners for cmd+s ctr+s in SingleLineEditor
This commit is contained in:
parent
2e3b296021
commit
0e041d460c
@ -5,7 +5,7 @@ import { IconTrash } from '@tabler/icons';
|
|||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { addFormUrlEncodedParam, updateFormUrlEncodedParam, deleteFormUrlEncodedParam } from 'providers/ReduxStore/slices/collections';
|
import { addFormUrlEncodedParam, updateFormUrlEncodedParam, deleteFormUrlEncodedParam } from 'providers/ReduxStore/slices/collections';
|
||||||
import SingleLineEditor from 'components/SingleLineEditor';
|
import SingleLineEditor from 'components/SingleLineEditor';
|
||||||
import { sendRequest } from 'providers/ReduxStore/slices/collections/actions';
|
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
|
||||||
import StyledWrapper from './StyledWrapper';
|
import StyledWrapper from './StyledWrapper';
|
||||||
|
|
||||||
const FormUrlEncodedParams = ({ item, collection }) => {
|
const FormUrlEncodedParams = ({ item, collection }) => {
|
||||||
@ -21,6 +21,7 @@ const FormUrlEncodedParams = ({ item, collection }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onSave = () => dispatch(saveRequest(item.uid, collection.uid));
|
||||||
const handleRun = () => dispatch(sendRequest(item, collection.uid));
|
const handleRun = () => dispatch(sendRequest(item, collection.uid));
|
||||||
const handleParamChange = (e, _param, type) => {
|
const handleParamChange = (e, _param, type) => {
|
||||||
const param = cloneDeep(_param);
|
const param = cloneDeep(_param);
|
||||||
@ -86,7 +87,8 @@ const FormUrlEncodedParams = ({ item, collection }) => {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<SingleLineEditor
|
<SingleLineEditor
|
||||||
value={param.value}
|
value={param.value}
|
||||||
|
onSave={onSave}
|
||||||
onChange={(newValue) => handleParamChange({
|
onChange={(newValue) => handleParamChange({
|
||||||
target: {
|
target: {
|
||||||
value: newValue
|
value: newValue
|
||||||
|
@ -5,7 +5,7 @@ import { IconTrash } from '@tabler/icons';
|
|||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { addMultipartFormParam, updateMultipartFormParam, deleteMultipartFormParam } from 'providers/ReduxStore/slices/collections';
|
import { addMultipartFormParam, updateMultipartFormParam, deleteMultipartFormParam } from 'providers/ReduxStore/slices/collections';
|
||||||
import SingleLineEditor from 'components/SingleLineEditor';
|
import SingleLineEditor from 'components/SingleLineEditor';
|
||||||
import { sendRequest } from 'providers/ReduxStore/slices/collections/actions';
|
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
|
||||||
import StyledWrapper from './StyledWrapper';
|
import StyledWrapper from './StyledWrapper';
|
||||||
|
|
||||||
const MultipartFormParams = ({ item, collection }) => {
|
const MultipartFormParams = ({ item, collection }) => {
|
||||||
@ -21,6 +21,7 @@ const MultipartFormParams = ({ item, collection }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onSave = () => dispatch(saveRequest(item.uid, collection.uid));
|
||||||
const handleRun = () => dispatch(sendRequest(item, collection.uid));
|
const handleRun = () => dispatch(sendRequest(item, collection.uid));
|
||||||
const handleParamChange = (e, _param, type) => {
|
const handleParamChange = (e, _param, type) => {
|
||||||
const param = cloneDeep(_param);
|
const param = cloneDeep(_param);
|
||||||
@ -86,6 +87,7 @@ const MultipartFormParams = ({ item, collection }) => {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<SingleLineEditor
|
<SingleLineEditor
|
||||||
|
onSave={onSave}
|
||||||
value={param.value}
|
value={param.value}
|
||||||
onChange={(newValue) => handleParamChange({
|
onChange={(newValue) => handleParamChange({
|
||||||
target: {
|
target: {
|
||||||
|
@ -5,7 +5,7 @@ import { IconTrash } from '@tabler/icons';
|
|||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { addQueryParam, updateQueryParam, deleteQueryParam } from 'providers/ReduxStore/slices/collections';
|
import { addQueryParam, updateQueryParam, deleteQueryParam } from 'providers/ReduxStore/slices/collections';
|
||||||
import SingleLineEditor from 'components/SingleLineEditor';
|
import SingleLineEditor from 'components/SingleLineEditor';
|
||||||
import { sendRequest } from 'providers/ReduxStore/slices/collections/actions';
|
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
|
||||||
|
|
||||||
import StyledWrapper from './StyledWrapper';
|
import StyledWrapper from './StyledWrapper';
|
||||||
|
|
||||||
@ -22,6 +22,7 @@ const QueryParams = ({ item, collection }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onSave = () => dispatch(saveRequest(item.uid, collection.uid));
|
||||||
const handleRun = () => dispatch(sendRequest(item, collection.uid));
|
const handleRun = () => dispatch(sendRequest(item, collection.uid));
|
||||||
const handleParamChange = (e, _param, type) => {
|
const handleParamChange = (e, _param, type) => {
|
||||||
const param = cloneDeep(_param);
|
const param = cloneDeep(_param);
|
||||||
@ -89,7 +90,8 @@ const QueryParams = ({ item, collection }) => {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<SingleLineEditor
|
<SingleLineEditor
|
||||||
value={param.value}
|
value={param.value}
|
||||||
|
onSave={onSave}
|
||||||
onChange={(newValue) => handleParamChange({
|
onChange={(newValue) => handleParamChange({
|
||||||
target: {
|
target: {
|
||||||
value: newValue
|
value: newValue
|
||||||
|
@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { requestUrlChanged, updateRequestMethod } from 'providers/ReduxStore/slices/collections';
|
import { requestUrlChanged, updateRequestMethod } from 'providers/ReduxStore/slices/collections';
|
||||||
|
import { saveRequest } from 'providers/ReduxStore/slices/collections/actions';
|
||||||
import HttpMethodSelector from './HttpMethodSelector';
|
import HttpMethodSelector from './HttpMethodSelector';
|
||||||
import { useTheme } from 'providers/Theme';
|
import { useTheme } from 'providers/Theme';
|
||||||
import SendIcon from 'components/Icons/Send';
|
import SendIcon from 'components/Icons/Send';
|
||||||
@ -14,6 +15,7 @@ const QueryUrl = ({ item, collection, handleRun }) => {
|
|||||||
const method = item.draft ? get(item, 'draft.request.method') : get(item, 'request.method');
|
const method = item.draft ? get(item, 'draft.request.method') : get(item, 'request.method');
|
||||||
const url = item.draft ? get(item, 'draft.request.url') : get(item, 'request.url');
|
const url = item.draft ? get(item, 'draft.request.url') : get(item, 'request.url');
|
||||||
|
|
||||||
|
const onSave = () => dispatch(saveRequest(item.uid, collection.uid));
|
||||||
const onUrlChange = (value) => {
|
const onUrlChange = (value) => {
|
||||||
dispatch(
|
dispatch(
|
||||||
requestUrlChanged({
|
requestUrlChanged({
|
||||||
@ -42,6 +44,7 @@ const QueryUrl = ({ item, collection, handleRun }) => {
|
|||||||
<div className="flex items-center flex-grow input-container h-full">
|
<div className="flex items-center flex-grow input-container h-full">
|
||||||
<SingleLineEditor
|
<SingleLineEditor
|
||||||
value={url}
|
value={url}
|
||||||
|
onSave={onSave}
|
||||||
onChange={(newValue) => onUrlChange(newValue)}
|
onChange={(newValue) => onUrlChange(newValue)}
|
||||||
onRun={handleRun}
|
onRun={handleRun}
|
||||||
collection={collection}
|
collection={collection}
|
||||||
|
@ -4,7 +4,7 @@ import cloneDeep from 'lodash/cloneDeep';
|
|||||||
import { IconTrash } from '@tabler/icons';
|
import { IconTrash } from '@tabler/icons';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { addRequestHeader, updateRequestHeader, deleteRequestHeader } from 'providers/ReduxStore/slices/collections';
|
import { addRequestHeader, updateRequestHeader, deleteRequestHeader } from 'providers/ReduxStore/slices/collections';
|
||||||
import { sendRequest } from 'providers/ReduxStore/slices/collections/actions';
|
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
|
||||||
import SingleLineEditor from 'components/SingleLineEditor';
|
import SingleLineEditor from 'components/SingleLineEditor';
|
||||||
import StyledWrapper from './StyledWrapper';
|
import StyledWrapper from './StyledWrapper';
|
||||||
|
|
||||||
@ -21,6 +21,7 @@ const RequestHeaders = ({ item, collection }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onSave = () => dispatch(saveRequest(item.uid, collection.uid));
|
||||||
const handleRun = () => dispatch(sendRequest(item, collection.uid));
|
const handleRun = () => dispatch(sendRequest(item, collection.uid));
|
||||||
const handleHeaderValueChange = (e, _header, type) => {
|
const handleHeaderValueChange = (e, _header, type) => {
|
||||||
const header = cloneDeep(_header);
|
const header = cloneDeep(_header);
|
||||||
@ -85,8 +86,9 @@ const RequestHeaders = ({ item, collection }) => {
|
|||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<SingleLineEditor
|
<SingleLineEditor
|
||||||
value={header.value}
|
value={header.value}
|
||||||
|
onSave={onSave}
|
||||||
onChange={(newValue) => handleHeaderValueChange({
|
onChange={(newValue) => handleHeaderValueChange({
|
||||||
target: {
|
target: {
|
||||||
value: newValue
|
value: newValue
|
||||||
|
@ -22,7 +22,6 @@ class SingleLineEditor extends Component {
|
|||||||
this.editor = CodeMirror(this.editorRef.current, {
|
this.editor = CodeMirror(this.editorRef.current, {
|
||||||
lineWrapping: false,
|
lineWrapping: false,
|
||||||
lineNumbers: false,
|
lineNumbers: false,
|
||||||
autofocus: true,
|
|
||||||
mode: "brunovariables",
|
mode: "brunovariables",
|
||||||
brunoVarInfo: {
|
brunoVarInfo: {
|
||||||
variables: getEnvironmentVariables(this.props.collection),
|
variables: getEnvironmentVariables(this.props.collection),
|
||||||
@ -54,7 +53,9 @@ class SingleLineEditor extends Component {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'Cmd-S': () => {
|
'Cmd-S': () => {
|
||||||
|
console.log('cmd-s');
|
||||||
if (this.props.onSave) {
|
if (this.props.onSave) {
|
||||||
|
console.log('cmd-s +');
|
||||||
this.props.onSave();
|
this.props.onSave();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user