@@ -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)}
+
+
+
);
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 ? (