Minor tweaks

This commit is contained in:
Gregory Schier
2024-02-06 19:32:03 -08:00
parent c6b5e4d5df
commit 1e3d43dbae
4 changed files with 12 additions and 21 deletions

View File

@@ -87,7 +87,6 @@ export function GrpcConnectionLayout({ style }: Props) {
onCommit={grpc.commit.mutate} onCommit={grpc.commit.mutate}
onCancel={grpc.cancel.mutate} onCancel={grpc.cancel.mutate}
onSend={grpc.send.mutate} onSend={grpc.send.mutate}
onReflectRefetch={grpc.reflect.refetch}
services={services ?? null} services={services ?? null}
reflectionError={grpc.reflect.error as string | undefined} reflectionError={grpc.reflect.error as string | undefined}
reflectionLoading={grpc.reflect.isFetching} reflectionLoading={grpc.reflect.isFetching}

View File

@@ -34,7 +34,6 @@ interface Props {
onClientStreaming: () => void; onClientStreaming: () => void;
onServerStreaming: () => void; onServerStreaming: () => void;
onStreaming: () => void; onStreaming: () => void;
onReflectRefetch: () => void;
services: ReflectResponseService[] | null; services: ReflectResponseService[] | null;
} }
@@ -45,7 +44,6 @@ export function GrpcConnectionSetupPane({
activeRequest, activeRequest,
reflectionError, reflectionError,
reflectionLoading, reflectionLoading,
onReflectRefetch,
onStreaming, onStreaming,
onClientStreaming, onClientStreaming,
onServerStreaming, onServerStreaming,
@@ -230,7 +228,6 @@ export function GrpcConnectionSetupPane({
className="bg-gray-50" className="bg-gray-50"
reflectionError={reflectionError} reflectionError={reflectionError}
reflectionLoading={reflectionLoading} reflectionLoading={reflectionLoading}
onReflect={onReflectRefetch}
request={activeRequest} request={activeRequest}
/> />
</VStack> </VStack>

View File

@@ -1,8 +1,8 @@
import { formatDistanceToNow } from 'date-fns'; import { formatDistanceToNowStrict } from 'date-fns';
import { useDeleteGrpcConnection } from '../hooks/useDeleteGrpcConnection'; import { useDeleteGrpcConnection } from '../hooks/useDeleteGrpcConnection';
import { useDeleteGrpcConnections } from '../hooks/useDeleteGrpcConnections'; import { useDeleteGrpcConnections } from '../hooks/useDeleteGrpcConnections';
import type { GrpcConnection } from '../lib/models'; import type { GrpcConnection } from '../lib/models';
import { pluralize } from '../lib/pluralize'; import { count, pluralize } from '../lib/pluralize';
import { Dropdown } from './core/Dropdown'; import { Dropdown } from './core/Dropdown';
import { Icon } from './core/Icon'; import { Icon } from './core/Icon';
import { IconButton } from './core/IconButton'; import { IconButton } from './core/IconButton';
@@ -14,27 +14,23 @@ interface Props {
onPinned: (r: GrpcConnection) => void; onPinned: (r: GrpcConnection) => void;
} }
export const RecentConnectionsDropdown = function ResponsePane({ export function RecentConnectionsDropdown({ activeConnection, connections, onPinned }: Props) {
activeConnection, const deleteConnection = useDeleteGrpcConnection(activeConnection?.id ?? null);
connections, const deleteAllConnections = useDeleteGrpcConnections(activeConnection?.requestId);
onPinned,
}: Props) {
const deleteResponse = useDeleteGrpcConnection(activeConnection?.id ?? null);
const deleteAllResponses = useDeleteGrpcConnections(activeConnection?.requestId);
return ( return (
<Dropdown <Dropdown
items={[ items={[
{ {
key: 'clear-single', key: 'clear-single',
label: 'Clear Response', label: 'Clear Connection',
onSelect: deleteResponse.mutate, onSelect: deleteConnection.mutate,
disabled: connections.length === 0, disabled: connections.length === 0,
}, },
{ {
key: 'clear-all', key: 'clear-all',
label: `Clear ${connections.length} ${pluralize('Response', connections.length)}`, label: `Clear ${count('Connection', connections.length)}`,
onSelect: deleteAllResponses.mutate, onSelect: deleteAllConnections.mutate,
hidden: connections.length <= 1, hidden: connections.length <= 1,
disabled: connections.length === 0, disabled: connections.length === 0,
}, },
@@ -43,7 +39,7 @@ export const RecentConnectionsDropdown = function ResponsePane({
key: c.id, key: c.id,
label: ( label: (
<HStack space={2} alignItems="center"> <HStack space={2} alignItems="center">
{formatDistanceToNow(c.createdAt)} &bull;{' '} {formatDistanceToNowStrict(c.createdAt + 'Z')} ago &bull;{' '}
<span className="font-mono text-xs">{c.elapsed}ms</span> <span className="font-mono text-xs">{c.elapsed}ms</span>
</HStack> </HStack>
), ),
@@ -53,7 +49,7 @@ export const RecentConnectionsDropdown = function ResponsePane({
]} ]}
> >
<IconButton <IconButton
title="Show response history" title="Show connection history"
icon="chevronDown" icon="chevronDown"
className="ml-auto" className="ml-auto"
size="sm" size="sm"
@@ -61,4 +57,4 @@ export const RecentConnectionsDropdown = function ResponsePane({
/> />
</Dropdown> </Dropdown>
); );
}; }

View File

@@ -6,7 +6,6 @@ interface Props {
} }
export function FormattedError({ children }: Props) { export function FormattedError({ children }: Props) {
console.log('ERROR', children);
return ( return (
<pre <pre
className={classNames( className={classNames(