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
This commit is contained in:
James Gatz 2024-07-12 12:56:13 +02:00 committed by GitHub
parent 5a370a7174
commit 6e432ad09e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 36 additions and 1 deletions

View File

@ -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 (
<>
<Tabs aria-label='Request group tabs' className="flex-1 w-full h-full flex flex-col">
@ -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
<span>Auth</span>
{!isNoneOrInherited && (
<span className='p-1 min-w-6 h-6 flex items-center justify-center text-xs rounded-lg border border-solid border-[--hl]'>
<span className='w-2 h-2 bg-green-500 rounded-full' />
</span>
)}
</Tab>
<Tab
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'

View File

@ -8,6 +8,7 @@ import * as models from '../../../models';
import { queryAllWorkspaceUrls } from '../../../models/helpers/query-all-workspace-urls';
import { getCombinedPathParametersFromUrl, RequestParameter } from '../../../models/request';
import type { Settings } from '../../../models/settings';
import { getAuthObjectOrNull } from '../../../network/authentication';
import { deconstructQueryStringToParams, extractQueryStringFromUrl } from '../../../utils/url/querystring';
import { useRequestPatcher, useSettingsPatcher } from '../../hooks/use-request';
import { useActiveRequestSyncVCSVersion, useGitVCSVersion } from '../../hooks/use-vcs-version';
@ -93,6 +94,9 @@ export const RequestPane: FC<Props> = ({
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 (
<Pane type="request">
@ -125,12 +129,23 @@ export const RequestPane: FC<Props> = ({
id='content-type'
>
<span>Body</span>
{!isBodyEmpty && (
<span className='p-1 min-w-6 h-6 flex items-center justify-center text-xs rounded-lg border border-solid border-[--hl]'>
<span className='w-2 h-2 bg-green-500 rounded-full' />
</span>
)}
</Tab>
<Tab
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'
>
<span>Auth</span>
{!isNoneOrInherited && (
<span className='p-1 min-w-6 h-6 flex items-center justify-center text-xs rounded-lg border border-solid border-[--hl]'>
<span className='w-2 h-2 bg-green-500 rounded-full' />
</span>
)}
</Tab>
<Tab
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'

View File

@ -9,6 +9,7 @@ import * as models from '../../../models';
import { Environment } from '../../../models/environment';
import { AuthTypes, getCombinedPathParametersFromUrl, RequestPathParameter } from '../../../models/request';
import { WebSocketRequest } from '../../../models/websocket-request';
import { getAuthObjectOrNull } from '../../../network/authentication';
import { tryToInterpolateRequestOrShowRenderErrorModal } from '../../../utils/try-interpolate';
import { buildQueryStringFromParams, deconstructQueryStringToParams, extractQueryStringFromUrl, joinUrlAndQueryString } from '../../../utils/url/querystring';
import { useReadyState } from '../../hooks/use-ready-state';
@ -280,6 +281,8 @@ export const WebSocketRequestPane: FC<Props> = ({ 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 (
<Pane type="request">
@ -311,12 +314,20 @@ export const WebSocketRequestPane: FC<Props> = ({ environment }) => {
id='content-type'
>
<span>Body</span>
<span className='p-1 min-w-6 h-6 flex items-center justify-center text-xs rounded-lg border border-solid border-[--hl]'>
<span className='w-2 h-2 bg-green-500 rounded-full' />
</span>
</Tab>
<Tab
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'
>
<span>Auth</span>
{!isNoneOrInherited && (
<span className='p-1 min-w-6 h-6 flex items-center justify-center text-xs rounded-lg border border-solid border-[--hl]'>
<span className='w-2 h-2 bg-green-500 rounded-full' />
</span>
)}
</Tab>
<Tab
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'