From 6e432ad09e56d2d8445a0f73e5b943bc33b339b3 Mon Sep 17 00:00:00 2001 From: James Gatz Date: Fri, 12 Jul 2024 12:56:13 +0200 Subject: [PATCH] feat(Request pane): Add indicators for body and auth in the request pane tabs (#7697) * Add indicators for body and auth in the request pane tabs * fix auth indicator --- .../ui/components/panes/request-group-pane.tsx | 11 ++++++++++- .../src/ui/components/panes/request-pane.tsx | 15 +++++++++++++++ .../websockets/websocket-request-pane.tsx | 11 +++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/packages/insomnia/src/ui/components/panes/request-group-pane.tsx b/packages/insomnia/src/ui/components/panes/request-group-pane.tsx index 3567cfe36..bc58f8350 100644 --- a/packages/insomnia/src/ui/components/panes/request-group-pane.tsx +++ b/packages/insomnia/src/ui/components/panes/request-group-pane.tsx @@ -3,6 +3,7 @@ import { Tab, TabList, TabPanel, Tabs } from 'react-aria-components'; import { useRouteLoaderData } from 'react-router-dom'; import { Settings } from '../../../models/settings'; +import { getAuthObjectOrNull } from '../../../network/authentication'; import { useRequestGroupPatcher } from '../../hooks/use-request'; import { useActiveRequestSyncVCSVersion, useGitVCSVersion } from '../../hooks/use-vcs-version'; import { RequestGroupLoaderData } from '../../routes/request-group'; @@ -45,6 +46,9 @@ export const RequestGroupPane: FC<{ settings: Settings }> = ({ settings }) => { } }; + const requestGroupAuth = getAuthObjectOrNull(activeRequestGroup.authentication); + const isNoneOrInherited = requestGroupAuth?.type === 'none' || requestGroupAuth === null; + return ( <> @@ -53,7 +57,12 @@ export const RequestGroupPane: FC<{ settings: Settings }> = ({ settings }) => { className='flex-shrink-0 h-full flex items-center justify-between cursor-pointer gap-2 outline-none select-none px-3 py-1 text-[--hl] aria-selected:text-[--color-font] hover:bg-[--hl-sm] hover:text-[--color-font] aria-selected:bg-[--hl-xs] aria-selected:focus:bg-[--hl-sm] aria-selected:hover:bg-[--hl-sm] focus:bg-[--hl-sm] transition-colors duration-300' id='auth' > - Auth + Auth + {!isNoneOrInherited && ( + + + + )} = ({ const contentType = getContentTypeFromHeaders(activeRequest.headers) || activeRequest.body.mimeType; + const isBodyEmpty = Boolean(typeof activeRequest.body.mimeType !== 'string' && !activeRequest.body.text); + const requestAuth = getAuthObjectOrNull(activeRequest.authentication); + const isNoneOrInherited = requestAuth?.type === 'none' || requestAuth === null; return ( @@ -125,12 +129,23 @@ export const RequestPane: FC = ({ id='content-type' > Body + {!isBodyEmpty && ( + + + + )} Auth + + {!isNoneOrInherited && ( + + + + )} = ({ environment }) => { const urlHasQueryParameters = activeRequest.url.indexOf('?') >= 0; // Reset the response pane state when we switch requests, the environment gets modified, or the (Git|Sync)VCS version changes const uniqueKey = `${environment?.modified}::${requestId}::${gitVersion}::${activeRequestSyncVersion}::${activeRequestMeta.activeResponseId}`; + const requestAuth = getAuthObjectOrNull(activeRequest.authentication); + const isNoneOrInherited = requestAuth?.type === 'none' || requestAuth === null; return ( @@ -311,12 +314,20 @@ export const WebSocketRequestPane: FC = ({ environment }) => { id='content-type' > Body + + + Auth + {!isNoneOrInherited && ( + + + + )}