diff --git a/packages/bruno-app/src/components/CodeEditor/StyledWrapper.js b/packages/bruno-app/src/components/CodeEditor/StyledWrapper.js index 9853280a1..fe0f4cc19 100644 --- a/packages/bruno-app/src/components/CodeEditor/StyledWrapper.js +++ b/packages/bruno-app/src/components/CodeEditor/StyledWrapper.js @@ -4,7 +4,7 @@ const StyledWrapper = styled.div` div.CodeMirror { background: ${(props) => props.theme.codemirror.bg}; border: solid 1px ${(props) => props.theme.codemirror.border}; - font-family: ${(props) => props.font ? props.font : "default"}; + font-family: ${(props) => (props.font ? props.font : 'default')}; } .CodeMirror-overlayscroll-horizontal div, diff --git a/packages/bruno-app/src/components/Preferences/General/index.js b/packages/bruno-app/src/components/Preferences/General/index.js index a622dd6b6..b6719b69c 100644 --- a/packages/bruno-app/src/components/Preferences/General/index.js +++ b/packages/bruno-app/src/components/Preferences/General/index.js @@ -8,13 +8,15 @@ const General = ({ close }) => { const dispatch = useDispatch(); const [sslVerification, setSslVerification] = useState(preferences.request.sslVerification); + const [timeout, setTimeout] = useState(preferences.request.timeout); const handleSave = () => { dispatch( savePreferences({ ...preferences, request: { - sslVerification + sslVerification, + timeout } }) ).then(() => { @@ -22,19 +24,35 @@ const General = ({ close }) => { }); }; + const handleTimeoutChange = (value) => { + const validTimeout = isNaN(Number(value)) ? timeout : Number(value); + setTimeout(validTimeout); + }; + return (
+ setSslVerification(!sslVerification)} - className="mr-3 mousetrap" + className="mousetrap h-4 w-4 mr-0" /> -
+
+ + handleTimeoutChange(e.target.value)} + type="text" + className="block textbox w-1/6" + />
diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js index 405ca7b73..f2b81f9fd 100644 --- a/packages/bruno-electron/src/ipc/network/index.js +++ b/packages/bruno-electron/src/ipc/network/index.js @@ -206,6 +206,8 @@ const registerNetworkIpc = (mainWindow) => { }); const preferences = getPreferences(); + const timeout = get(preferences, 'request.timeout', 0); + request.timeout = timeout; const sslVerification = get(preferences, 'request.sslVerification', true); const httpsAgentRequestFields = {}; if (!sslVerification) { @@ -517,6 +519,8 @@ const registerNetworkIpc = (mainWindow) => { const preparedRequest = prepareGqlIntrospectionRequest(endpoint, envVars, request, collectionRoot); const preferences = getPreferences(); + const timeout = get(preferences, 'request.timeout', 0); + request.timeout = timeout; const sslVerification = get(preferences, 'request.sslVerification', true); if (!sslVerification) { @@ -695,6 +699,8 @@ const registerNetworkIpc = (mainWindow) => { }); const preferences = getPreferences(); + const timeout = get(preferences, 'request.timeout', 0); + request.timeout = timeout; const sslVerification = get(preferences, 'request.sslVerification', true); // proxy configuration diff --git a/packages/bruno-electron/src/store/preferences.js b/packages/bruno-electron/src/store/preferences.js index 20bc1d4d5..0a94f4cb0 100644 --- a/packages/bruno-electron/src/store/preferences.js +++ b/packages/bruno-electron/src/store/preferences.js @@ -3,7 +3,8 @@ const Store = require('electron-store'); const defaultPreferences = { request: { - sslVerification: true + sslVerification: true, + timeout: 0 }, font: { codeFont: 'default' @@ -12,7 +13,8 @@ const defaultPreferences = { const preferencesSchema = Yup.object().shape({ request: Yup.object().shape({ - sslVerification: Yup.boolean() + sslVerification: Yup.boolean(), + timeout: Yup.number() }), font: Yup.object().shape({ codeFont: Yup.string().nullable() diff --git a/packages/bruno-js/src/bruno-request.js b/packages/bruno-js/src/bruno-request.js index 099d35111..afbf97873 100644 --- a/packages/bruno-js/src/bruno-request.js +++ b/packages/bruno-js/src/bruno-request.js @@ -5,6 +5,7 @@ class BrunoRequest { this.method = req.method; this.headers = req.headers; this.body = req.data; + this.timeout = req.timeout; } getUrl() { @@ -50,6 +51,14 @@ class BrunoRequest { setMaxRedirects(maxRedirects) { this.req.maxRedirects = maxRedirects; } + + getTimeout() { + return this.req.timeout; + } + + setTimeout(timeout) { + this.req.timeout = timeout; + } } module.exports = BrunoRequest;