Fix editor selection/cursor and lint errors

This commit is contained in:
Gregory Schier
2024-02-09 14:32:58 -08:00
parent 16d4f2952d
commit 812e5238ac
26 changed files with 1633 additions and 595 deletions

View File

@@ -15,6 +15,9 @@ export function BasicAuth({ requestId, authentication }: Props) {
<VStack className="my-2" space={2}>
<Input
useTemplating
autocompleteVariables
forceUpdateKey={requestId}
placeholder="username"
label="Username"
name="username"
size="sm"
@@ -28,6 +31,9 @@ export function BasicAuth({ requestId, authentication }: Props) {
/>
<Input
useTemplating
autocompleteVariables
forceUpdateKey={requestId}
placeholder="password"
label="Password"
name="password"
size="sm"

View File

@@ -16,6 +16,7 @@ export function BearerAuth({ requestId, authentication }: Props) {
<Input
useTemplating
autocompleteVariables
placeholder="token"
type="password"
label="Token"
name="token"

View File

@@ -61,6 +61,7 @@ export function CookieDropdown() {
),
name: 'name',
label: 'Name',
placeholder: 'New name',
defaultValue: activeCookieJar?.name,
});
updateCookieJar.mutate({ name });

View File

@@ -161,6 +161,7 @@ const EnvironmentEditor = function ({
),
name: 'name',
label: 'Name',
placeholder: 'New Name',
defaultValue: environment.name,
});
updateEnvironment.mutate({ name });

View File

@@ -2,7 +2,7 @@ import { formatDistanceToNowStrict } from 'date-fns';
import { useDeleteGrpcConnection } from '../hooks/useDeleteGrpcConnection';
import { useDeleteGrpcConnections } from '../hooks/useDeleteGrpcConnections';
import type { GrpcConnection } from '../lib/models';
import { count, pluralize } from '../lib/pluralize';
import { count } from '../lib/pluralize';
import { Dropdown } from './core/Dropdown';
import { Icon } from './core/Icon';
import { IconButton } from './core/IconButton';

View File

@@ -1,12 +1,10 @@
import classNames from 'classnames';
import type { CSSProperties, MouseEvent as ReactMouseEvent } from 'react';
import React from 'react';
import { Separator } from './core/Separator';
interface ResizeBarProps {
style?: CSSProperties;
className?: string;
barClassName?: string;
isResizing: boolean;
onResizeStart: (e: ReactMouseEvent<HTMLDivElement>) => void;
onReset?: () => void;
@@ -18,7 +16,6 @@ export function ResizeHandle({
style,
justify,
className,
barClassName,
onResizeStart,
onReset,
isResizing,

View File

@@ -78,6 +78,7 @@ export const SettingsDialog = () => {
size="sm"
name="requestTimeout"
label="Request Timeout (ms)"
placeholder="0"
labelPosition="left"
labelClassName="w-1/3"
containerClassName="col-span-2"

View File

@@ -660,6 +660,7 @@ const SidebarItem = forwardRef(function SidebarItem(
),
name: 'name',
label: 'Name',
placeholder: 'New Name',
defaultValue: itemName,
});
updateAnyFolder.mutate({ id: itemId, update: (f) => ({ ...f, name }) });

View File

@@ -1,5 +1,4 @@
import { memo } from 'react';
import { Simulate } from 'react-dom/test-utils';
import { useCreateFolder } from '../hooks/useCreateFolder';
import { useCreateGrpcRequest } from '../hooks/useCreateGrpcRequest';
import { useCreateHttpRequest } from '../hooks/useCreateHttpRequest';

View File

@@ -117,6 +117,7 @@ export const WorkspaceActionsDropdown = memo(function WorkspaceActionsDropdown({
),
name: 'name',
label: 'Name',
placeholder: 'New Name',
defaultValue: activeWorkspace?.name,
});
updateWorkspace.mutate({ name });
@@ -142,6 +143,7 @@ export const WorkspaceActionsDropdown = memo(function WorkspaceActionsDropdown({
defaultValue: 'My Workspace',
title: 'New Workspace',
confirmLabel: 'Create',
placeholder: 'My Workspace',
});
createWorkspace.mutate({ name });
},

View File

@@ -31,6 +31,7 @@ import {
} from '@codemirror/view';
import { tags as t } from '@lezer/highlight';
import { graphql, graphqlLanguageSupport } from 'cm6-graphql';
import { EditorView } from 'codemirror';
import { jsonSchema } from 'codemirror-json-schema';
import type { Environment, Workspace } from '../../../lib/models';
import type { EditorProps } from './index';
@@ -60,6 +61,8 @@ export const myHighlightStyle = HighlightStyle.define([
{ tag: [t.keyword, t.meta, t.operator], color: 'hsl(var(--color-red-600))' },
]);
const myTheme = EditorView.theme({}, { dark: true });
// export const defaultHighlightStyle = HighlightStyle.define([
// { tag: t.meta, color: '#404740' },
// { tag: t.link, textDecoration: 'underline' },
@@ -83,7 +86,7 @@ export const myHighlightStyle = HighlightStyle.define([
// ]);
const syntaxExtensions: Record<string, LanguageSupport> = {
'application/grpc': jsonSchema() as any, // TODO: Fix this
'application/grpc': jsonSchema() as unknown as LanguageSupport, // TODO: Fix this
'application/graphql': graphqlLanguageSupport(),
'application/json': json(),
'application/javascript': javascript(),
@@ -131,6 +134,7 @@ export const baseExtensions = [
},
}),
syntaxHighlighting(myHighlightStyle),
myTheme,
EditorState.allowMultipleSelections.of(true),
];

View File

@@ -37,7 +37,7 @@ export type InputProps = Omit<
rightSlot?: ReactNode;
size?: 'xs' | 'sm' | 'md' | 'auto';
className?: string;
placeholder?: string;
placeholder: string;
validate?: (v: string) => boolean;
require?: boolean;
wrapLines?: boolean;

View File

@@ -5,6 +5,7 @@ import { Icon } from './Icon';
interface Props {
depth?: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
attrValue: any;
attrKey?: string | number;
attrKeyJsonPath?: string;
@@ -44,7 +45,8 @@ export const JsonAttributeTree = ({ depth = 0, attrKey, attrValue, attrKeyJsonPa
} else if (jsonType === '[object Array]') {
return {
children: isExpanded
? attrValue.flatMap((v: any, i: number) => (
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
attrValue.flatMap((v: any, i: number) => (
<JsonAttributeTree
depth={depth + 1}
attrValue={v}

View File

@@ -81,7 +81,7 @@ export function SplitLayout({
/ ${1 - width}fr 0 ${width}fr
`,
};
}, [style, vertical, height, minHeightPx, width]);
}, [forceVertical, style, vertical, height, minHeightPx, width]);
const unsub = () => {
if (moveState.current !== null) {
@@ -154,7 +154,6 @@ export function SplitLayout({
<ResizeHandle
style={areaD}
isResizing={isResizing}
barClassName={'bg-red-300'}
className={classNames(vertical ? 'translate-y-0.5' : 'translate-x-0.5')}
onResizeStart={handleResizeStart}
onReset={handleReset}

View File

@@ -10,8 +10,8 @@ export interface PromptProps {
onResult: (value: string) => void;
label: InputProps['label'];
name: InputProps['name'];
defaultValue?: InputProps['defaultValue'];
placeholder?: InputProps['placeholder'];
defaultValue: InputProps['defaultValue'];
placeholder: InputProps['placeholder'];
confirmLabel?: string;
}

View File

@@ -1,4 +1,3 @@
import { r } from 'vitest/dist/types-94cfe4b4';
import type { GrpcRequest, HttpRequest } from '../lib/models';
import { useActiveRequestId } from './useActiveRequestId';
import { useGrpcRequests } from './useGrpcRequests';

View File

@@ -20,6 +20,7 @@ export function useCreateCookieJar() {
id: 'new-cookie-jar',
name: 'name',
title: 'New CookieJar',
placeholder: 'My Jar',
label: 'Name',
defaultValue: 'My Jar',
});

View File

@@ -20,6 +20,7 @@ export function useCreateEnvironment() {
name: 'name',
title: 'New Environment',
label: 'Name',
placeholder: 'My Environment',
defaultValue: 'My Environment',
});
return invoke('cmd_create_environment', { name, variables: [], workspaceId });

View File

@@ -1,13 +1,11 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { invoke } from '@tauri-apps/api';
import { trackEvent } from '../lib/analytics';
import type { GrpcRequest, HttpRequest } from '../lib/models';
import type { GrpcRequest } from '../lib/models';
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
import { useActiveRequest } from './useActiveRequest';
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
import { useAppRoutes } from './useAppRoutes';
import { grpcRequestsQueryKey } from './useGrpcRequests';
import { httpRequestsQueryKey } from './useHttpRequests';
export function useCreateGrpcRequest() {
const workspaceId = useActiveWorkspaceId();

View File

@@ -1,7 +1,6 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { invoke } from '@tauri-apps/api';
import type { GrpcRequest } from '../lib/models';
import { sleep } from '../lib/sleep';
import { getGrpcRequest } from '../lib/store';
import { grpcRequestsQueryKey } from './useGrpcRequests';

View File

@@ -10,10 +10,12 @@ export async function minPromiseMillis<T>(promise: Promise<T>, millis: number) {
result = await promise;
} catch (e) {
err = e;
const delayFor = millis - (Date.now() - start);
await sleep(delayFor);
throw err;
}
const delayFor = millis - (Date.now() - start);
await sleep(delayFor);
if (err) throw err;
else return result;
return result;
}