diff --git a/packages/bruno-app/src/components/RequestPane/WSRequestPane/StyledWrapper.js b/packages/bruno-app/src/components/RequestPane/WSRequestPane/StyledWrapper.js index b39bc94dc..b3731fc87 100644 --- a/packages/bruno-app/src/components/RequestPane/WSRequestPane/StyledWrapper.js +++ b/packages/bruno-app/src/components/RequestPane/WSRequestPane/StyledWrapper.js @@ -1,34 +1,7 @@ import styled from 'styled-components'; const StyledWrapper = styled.div` - div.tabs { - div.tab { - padding: 6px 0px; - border: none; - border-bottom: solid 2px transparent; - margin-right: ${(props) => props.theme.tabs.marginRight}; - color: ${(props) => props.theme.colors.text.subtext0}; - cursor: pointer; - &:focus, - &:active, - &:focus-within, - &:focus-visible, - &:target { - outline: none !important; - box-shadow: none !important; - } - - &.active { - color: ${(props) => props.theme.tabs.active.color} !important; - border-bottom: solid 2px ${(props) => props.theme.tabs.active.border} !important; - } - - .content-indicator { - color: ${(props) => props.theme.text} - } - } - } `; export default StyledWrapper; diff --git a/packages/bruno-app/src/components/RequestPane/WSRequestPane/WSAuth/index.js b/packages/bruno-app/src/components/RequestPane/WSRequestPane/WSAuth/index.js index 8283ae40c..187df08fd 100644 --- a/packages/bruno-app/src/components/RequestPane/WSRequestPane/WSAuth/index.js +++ b/packages/bruno-app/src/components/RequestPane/WSRequestPane/WSAuth/index.js @@ -1,7 +1,6 @@ import React, { useEffect } from 'react'; import get from 'lodash/get'; import { useDispatch } from 'react-redux'; -import WSAuthMode from './WSAuthMode'; import BearerAuth from '../../Auth/BearerAuth'; import BasicAuth from '../../Auth/BasicAuth'; import ApiKeyAuth from '../../Auth/ApiKeyAuth'; @@ -68,6 +67,9 @@ const WSAuth = ({ item, collection }) => { const getAuthView = () => { switch (authMode) { + case 'none': { + return
No Auth
; + } case 'basic': { return ; } @@ -80,7 +82,7 @@ const WSAuth = ({ item, collection }) => { case 'oauth2': { return ( <> -
+
OAuth 2 not yet supported by WebSockets. Using no auth instead.
@@ -95,7 +97,7 @@ const WSAuth = ({ item, collection }) => { if (source && supportedAuthModes.includes(source.auth?.mode)) { return ( <> -
+
Auth inherited from {source.name}:
{humanizeRequestAuthMode(source.auth?.mode)}
@@ -104,7 +106,7 @@ const WSAuth = ({ item, collection }) => { } else { return ( <> -
+
Inherited auth not supported by WebSockets. Using no auth instead.
@@ -119,9 +121,6 @@ const WSAuth = ({ item, collection }) => { return ( -
- -
{getAuthView()}
); diff --git a/packages/bruno-app/src/components/RequestPane/WSRequestPane/index.js b/packages/bruno-app/src/components/RequestPane/WSRequestPane/index.js index 6f32d3e41..66825181a 100644 --- a/packages/bruno-app/src/components/RequestPane/WSRequestPane/index.js +++ b/packages/bruno-app/src/components/RequestPane/WSRequestPane/index.js @@ -1,16 +1,17 @@ -import classnames from 'classnames'; +import React, { useMemo, useCallback, useRef } from 'react'; import Documentation from 'components/Documentation/index'; import RequestHeaders from 'components/RequestPane/RequestHeaders'; import StatusDot from 'components/StatusDot/index'; import { find } from 'lodash'; import { updateRequestPaneTab } from 'providers/ReduxStore/slices/tabs'; -import React, { useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import HeightBoundContainer from 'ui/HeightBoundContainer'; +import ResponsiveTabs from 'ui/ResponsiveTabs'; import { getPropertyFromDraftOrRequest } from 'utils/collections/index'; import WsBody from '../WsBody/index'; import StyledWrapper from './StyledWrapper'; import WSAuth from './WSAuth'; +import WSAuthMode from './WSAuth/WSAuthMode'; import WSSettingsPane from '../WSSettingsPane/index'; const WSRequestPane = ({ item, collection, handleRun }) => { @@ -18,15 +19,59 @@ const WSRequestPane = ({ item, collection, handleRun }) => { const tabs = useSelector((state) => state.tabs.tabs); const activeTabUid = useSelector((state) => state.tabs.activeTabUid); - const selectTab = (tab) => { - dispatch(updateRequestPaneTab({ - uid: item.uid, - requestPaneTab: tab - })); - }; + const rightContentRef = useRef(null); - const getTabPanel = (tab) => { - switch (tab) { + const focusedTab = find(tabs, (t) => t.uid === activeTabUid); + const requestPaneTab = focusedTab?.requestPaneTab; + + const selectTab = useCallback( + (tab) => { + dispatch(updateRequestPaneTab({ + uid: item.uid, + requestPaneTab: tab + })); + }, + [dispatch, item.uid] + ); + + const headers = getPropertyFromDraftOrRequest(item, 'request.headers'); + const docs = getPropertyFromDraftOrRequest(item, 'request.docs'); + const auth = getPropertyFromDraftOrRequest(item, 'request.auth'); + + const activeHeadersLength = headers.filter((header) => header.enabled).length; + + const allTabs = useMemo(() => { + return [ + { + key: 'body', + label: 'Message', + indicator: null + }, + { + key: 'headers', + label: 'Headers', + indicator: activeHeadersLength > 0 ? {activeHeadersLength} : null + }, + { + key: 'auth', + label: 'Auth', + indicator: auth.mode !== 'none' ? : null + }, + { + key: 'settings', + label: 'Settings', + indicator: null + }, + { + key: 'docs', + label: 'Docs', + indicator: docs && docs.length > 0 ? : null + } + ]; + }, [activeHeadersLength, auth.mode, docs]); + + const tabPanel = useMemo(() => { + switch (requestPaneTab) { case 'body': { return ( { return
404 | Not found
; } } - }; + }, [requestPaneTab, item, collection, handleRun]); - if (!activeTabUid) { - return
Something went wrong
; - } - - const focusedTab = find(tabs, (t) => t.uid === activeTabUid); - if (!focusedTab || !focusedTab.uid || !focusedTab.requestPaneTab) { + if (!activeTabUid || !focusedTab?.uid || !requestPaneTab) { return
An error occurred!
; } - const getTabClassname = (tabName) => { - return classnames(`tab select-none ${tabName}`, { - active: tabName === focusedTab.requestPaneTab - }); - }; - - const headers = getPropertyFromDraftOrRequest(item, 'request.headers'); - const docs = getPropertyFromDraftOrRequest(item, 'request.docs'); - const auth = getPropertyFromDraftOrRequest(item, 'request.auth'); - - const activeHeadersLength = headers.filter((header) => header.enabled).length; - - useEffect(() => { - if (!focusedTab?.requestPaneTab) { - selectTab('body'); - } - }, []); + const rightContent = requestPaneTab === 'auth' ? ( +
+ +
+ ) : null; return ( -
-
selectTab('body')}> - Message -
-
selectTab('headers')}> - Headers - {activeHeadersLength > 0 && {activeHeadersLength}} -
-
selectTab('auth')}> - Auth - {auth.mode !== 'none' && } -
-
selectTab('settings')}> - Settings -
-
selectTab('docs')}> - Docs - {docs && docs.length > 0 && } -
-
-
- {getTabPanel(focusedTab.requestPaneTab)} + + +
+ {tabPanel}
); diff --git a/packages/bruno-app/src/components/ResponsePane/WsResponsePane/index.js b/packages/bruno-app/src/components/ResponsePane/WsResponsePane/index.js index d9b9f8835..28cc50efc 100644 --- a/packages/bruno-app/src/components/ResponsePane/WsResponsePane/index.js +++ b/packages/bruno-app/src/components/ResponsePane/WsResponsePane/index.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo, useRef } from 'react'; import find from 'lodash/find'; import { useDispatch, useSelector } from 'react-redux'; import { updateResponsePaneTab } from 'providers/ReduxStore/slices/tabs'; @@ -11,7 +11,7 @@ import ClearTimeline from '../ClearTimeline'; import ResponseClear from '../ResponseClear'; import StyledWrapper from './StyledWrapper'; import ResponseLayoutToggle from '../ResponseLayoutToggle'; -import Tab from 'components/Tab'; +import ResponsiveTabs from 'ui/ResponsiveTabs'; import WSMessagesList from './WSMessagesList'; import WSResponseSortOrder from './WSResponseSortOrder'; import WSResponseHeaders from './WSResponseHeaders'; @@ -25,6 +25,7 @@ const WSResponsePane = ({ item, collection }) => { const tabs = useSelector((state) => state.tabs.tabs); const activeTabUid = useSelector((state) => state.tabs.activeTabUid); const isLoading = ['queued', 'sending'].includes(item.requestState); + const rightContentRef = useRef(null); const requestTimeline = [...(collection?.timeline || [])].filter((obj) => { if (obj.itemUid === item.uid) return true; @@ -39,6 +40,29 @@ const WSResponsePane = ({ item, collection }) => { const response = item.response || {}; + const messagesCount = Array.isArray(response.responses) ? response.responses.length : 0; + const headersCount = response.headers ? Object.keys(response.headers).length : 0; + + const allTabs = useMemo(() => { + return [ + { + key: 'response', + label: 'Messages', + indicator: messagesCount > 0 ? {messagesCount} : null + }, + { + key: 'headers', + label: 'Headers', + indicator: headersCount > 0 ? {headersCount} : null + }, + { + key: 'timeline', + label: 'Timeline', + indicator: null + } + ]; + }, [messagesCount, headersCount]); + const getTabPanel = (tab) => { switch (tab) { case 'response': { @@ -81,62 +105,41 @@ const WSResponsePane = ({ item, collection }) => { return
An error occurred!
; } - const tabConfig = [ - { - name: 'response', - label: 'Messages', - count: Array.isArray(response.responses) ? response.responses.length : 0 - }, - { - name: 'headers', - label: 'Headers', - count: response.headers ? Object.keys(response.headers).length : 0 - }, - { - name: 'timeline', - label: 'Timeline' - } - ]; + const rightContent = !isLoading ? ( +
+ {focusedTab?.responsePaneTab === 'timeline' ? ( + <> + + + + ) : item?.response ? ( + <> + + + + + + + ) : null} +
+ ) : null; return ( -
- {tabConfig.map((tab) => ( - - ))} - {!isLoading ? ( -
- {focusedTab?.responsePaneTab === 'timeline' ? ( - <> - - - - ) : item?.response ? ( - <> - - - - - - - ) : null} -
- ) : null} +
+
-
+
{isLoading ? : null} {!item?.response ? ( focusedTab?.responsePaneTab === 'timeline' && requestTimeline?.length ? (