mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 09:18:30 +02:00
Methods in recent dropdown
This commit is contained in:
@@ -14,6 +14,7 @@ import type { ButtonProps } from './core/Button';
|
|||||||
import { Button } from './core/Button';
|
import { Button } from './core/Button';
|
||||||
import type { DropdownItem, DropdownRef } from './core/Dropdown';
|
import type { DropdownItem, DropdownRef } from './core/Dropdown';
|
||||||
import { Dropdown } from './core/Dropdown';
|
import { Dropdown } from './core/Dropdown';
|
||||||
|
import { HttpMethodTag } from './core/HttpMethodTag';
|
||||||
|
|
||||||
export function RecentRequestsDropdown({ className }: Pick<ButtonProps, 'className'>) {
|
export function RecentRequestsDropdown({ className }: Pick<ButtonProps, 'className'>) {
|
||||||
const dropdownRef = useRef<DropdownRef>(null);
|
const dropdownRef = useRef<DropdownRef>(null);
|
||||||
@@ -63,6 +64,7 @@ export function RecentRequestsDropdown({ className }: Pick<ButtonProps, 'classNa
|
|||||||
key: request.id,
|
key: request.id,
|
||||||
label: fallbackRequestName(request),
|
label: fallbackRequestName(request),
|
||||||
// leftSlot: <CountBadge className="!ml-0 px-0 w-5" count={recentRequestItems.length} />,
|
// leftSlot: <CountBadge className="!ml-0 px-0 w-5" count={recentRequestItems.length} />,
|
||||||
|
leftSlot: <HttpMethodTag request={request} />,
|
||||||
onSelect: () => {
|
onSelect: () => {
|
||||||
routes.navigate('request', {
|
routes.navigate('request', {
|
||||||
requestId: request.id,
|
requestId: request.id,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import type { ForwardedRef, ReactNode } from 'react';
|
import type { ForwardedRef, ReactNode } from 'react';
|
||||||
import React, { forwardRef, Fragment, useCallback, useMemo, useRef, useState } from 'react';
|
import React, { Fragment, forwardRef, useCallback, useMemo, useRef, useState } from 'react';
|
||||||
import type { XYCoord } from 'react-dnd';
|
import type { XYCoord } from 'react-dnd';
|
||||||
import { useDrag, useDrop } from 'react-dnd';
|
import { useDrag, useDrop } from 'react-dnd';
|
||||||
import { useKey, useKeyPressEvent } from 'react-use';
|
import { useKey, useKeyPressEvent } from 'react-use';
|
||||||
@@ -520,13 +520,9 @@ function SidebarItems({
|
|||||||
}
|
}
|
||||||
itemModel={child.item.model}
|
itemModel={child.item.model}
|
||||||
itemPrefix={
|
itemPrefix={
|
||||||
child.item.model === 'http_request' && child.item.bodyType === 'graphql' ? (
|
(child.item.model === 'http_request' || child.item.model === 'grpc_request') && (
|
||||||
<HttpMethodTag className="opacity-50">GQL</HttpMethodTag>
|
<HttpMethodTag request={child.item} />
|
||||||
) : child.item.model === 'http_request' ? (
|
)
|
||||||
<HttpMethodTag className="opacity-50">{child.item.method}</HttpMethodTag>
|
|
||||||
) : child.item.model === 'grpc_request' ? (
|
|
||||||
<HttpMethodTag className="opacity-50">GRPC</HttpMethodTag>
|
|
||||||
) : null
|
|
||||||
}
|
}
|
||||||
onMove={handleMove}
|
onMove={handleMove}
|
||||||
onEnd={handleEnd}
|
onEnd={handleEnd}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import type { GrpcRequest, HttpRequest } from '../../lib/models';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: string;
|
request: HttpRequest | GrpcRequest;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,10 +17,17 @@ const methodMap: Record<string, string> = {
|
|||||||
grpc: 'GRPC',
|
grpc: 'GRPC',
|
||||||
};
|
};
|
||||||
|
|
||||||
export function HttpMethodTag({ children: method, className }: Props) {
|
export function HttpMethodTag({ request, className }: Props) {
|
||||||
|
const method =
|
||||||
|
request.model === 'http_request' && request.bodyType === 'graphql'
|
||||||
|
? 'GQL'
|
||||||
|
: request.model === 'grpc_request'
|
||||||
|
? 'GRPC'
|
||||||
|
: request.method;
|
||||||
|
|
||||||
const m = method.toLowerCase();
|
const m = method.toLowerCase();
|
||||||
return (
|
return (
|
||||||
<span className={classNames(className, 'text-2xs font-mono')}>
|
<span className={classNames(className, 'text-2xs font-mono opacity-50')}>
|
||||||
{methodMap[m] ?? m.slice(0, 3).toUpperCase()}
|
{methodMap[m] ?? m.slice(0, 3).toUpperCase()}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user