diff --git a/src-web/components/BinaryFileEditor.tsx b/src-web/components/BinaryFileEditor.tsx index 8e56e9b2..7932b4c4 100644 --- a/src-web/components/BinaryFileEditor.tsx +++ b/src-web/components/BinaryFileEditor.tsx @@ -28,7 +28,7 @@ export function BinaryFileEditor({ fallback: false, }); - const handleChange = async (filePath: string | null) => { + const handleChange = async ({ filePath }: { filePath: string | null }) => { await ignoreContentType.set(false); onChange({ filePath: filePath ?? undefined }); }; diff --git a/src-web/components/ImportDataDialog.tsx b/src-web/components/ImportDataDialog.tsx index de39068a..0c779984 100644 --- a/src-web/components/ImportDataDialog.tsx +++ b/src-web/components/ImportDataDialog.tsx @@ -24,7 +24,7 @@ export function ImportDataDialog({ importData }: Props) { - + setFilePath(filePath)} /> {filePath && ( -
- {/* Special character to insert ltr text in rtl element without making things wonky */} - ‎ - {filePath ?? 'No file selected'} -
+ {!inline && ( + <> + {filePath && ( + + )} +
+ {rtlEscapeChar} + {filePath ?? 'No file selected'} +
+ + )} ); } diff --git a/src-web/components/core/Button.tsx b/src-web/components/core/Button.tsx index c32dfb2a..d5733788 100644 --- a/src-web/components/core/Button.tsx +++ b/src-web/components/core/Button.tsx @@ -5,7 +5,7 @@ import type { HotkeyAction } from '../../hooks/useHotKey'; import { useFormattedHotkey, useHotKey } from '../../hooks/useHotKey'; import { Icon } from './Icon'; -export type ButtonProps = Omit, 'color'> & { +export type ButtonProps = Omit, 'color' | 'onChange'> & { innerClassName?: string; color?: | 'custom' diff --git a/src-web/components/core/PairEditor.tsx b/src-web/components/core/PairEditor.tsx index 705a618c..655aa452 100644 --- a/src-web/components/core/PairEditor.tsx +++ b/src-web/components/core/PairEditor.tsx @@ -1,4 +1,3 @@ -import { open } from '@tauri-apps/plugin-dialog'; import classNames from 'classnames'; import type { EditorView } from 'codemirror'; import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react'; @@ -7,7 +6,7 @@ import { useDrag, useDrop } from 'react-dnd'; import { v4 as uuid } from 'uuid'; import { usePrompt } from '../../hooks/usePrompt'; import { DropMarker } from '../DropMarker'; -import { Button } from './Button'; +import { SelectFile } from '../SelectFile'; import { Checkbox } from './Checkbox'; import { Dropdown } from './Dropdown'; import type { GenericCompletionConfig } from './Editor/genericCompletion'; @@ -286,7 +285,12 @@ function PairEditorRow({ ); const handleChangeValueFile = useMemo( - () => (value: string) => onChange({ id, pair: { ...pairContainer.pair, value, isFile: true } }), + () => + ({ filePath }: { filePath: string | null }) => + onChange({ + id, + pair: { ...pairContainer.pair, value: filePath ?? '', isFile: true }, + }), [onChange, id, pairContainer.pair], ); @@ -386,27 +390,12 @@ function PairEditorRow({ />
{pairContainer.pair.isFile ? ( - + filePath={pairContainer.pair.value} + onChange={handleChangeValueFile} + /> ) : ( { - if (v === 'file') handleChangeValueFile(''); + if (v === 'file') handleChangeValueFile({ filePath: '' }); else handleChangeValueText(''); }} items={[ @@ -444,6 +433,7 @@ function PairEditorRow({ key: 'mime', label: 'Set Content-Type', leftSlot: , + hidden: !pairContainer.pair.isFile, onSelect: async () => { const v = await prompt({ id: 'content-type', @@ -459,6 +449,15 @@ function PairEditorRow({ handleChangeValueContentType(v); }, }, + { + key: 'clear-file', + label: 'Unset File', + leftSlot: , + hidden: !pairContainer.pair.isFile, + onSelect: async () => { + handleChangeValueFile({ filePath: null }); + }, + }, { key: 'delete', label: 'Delete', diff --git a/src-web/components/core/Stacks.tsx b/src-web/components/core/Stacks.tsx index 7ac05299..6aca28bc 100644 --- a/src-web/components/core/Stacks.tsx +++ b/src-web/components/core/Stacks.tsx @@ -60,10 +60,11 @@ type BaseStackProps = HTMLAttributes & { space?: keyof typeof gapClasses; alignItems?: 'start' | 'center' | 'stretch' | 'end'; justifyContent?: 'start' | 'center' | 'end' | 'between'; + wrap?: boolean; }; const BaseStack = forwardRef(function BaseStack( - { className, alignItems, justifyContent, children, as, ...props }: BaseStackProps, + { className, alignItems, justifyContent, wrap, children, as, ...props }: BaseStackProps, // eslint-disable-next-line @typescript-eslint/no-explicit-any ref: ForwardedRef, ) { @@ -74,6 +75,7 @@ const BaseStack = forwardRef(function BaseStack( className={classNames( className, 'flex', + wrap && 'flex-wrap', alignItems === 'center' && 'items-center', alignItems === 'start' && 'items-start', alignItems === 'stretch' && 'items-stretch', diff --git a/src-web/components/responseViewers/TextViewer.tsx b/src-web/components/responseViewers/TextViewer.tsx index 1e7c354f..648bc19b 100644 --- a/src-web/components/responseViewers/TextViewer.tsx +++ b/src-web/components/responseViewers/TextViewer.tsx @@ -127,7 +127,7 @@ export function TextViewer({ response, pretty, className }: Props) { return ; } - if (!showLargeResponse && (response.contentLength ?? 0) > LARGE_RESPONSE_BYTES / 1000) { + if (!showLargeResponse && (response.contentLength ?? 0) > LARGE_RESPONSE_BYTES) { return (

@@ -137,7 +137,7 @@ export function TextViewer({ response, pretty, className }: Props) { {' '} may impact performance

- +