diff --git a/src-web/components/RequestPane.tsx b/src-web/components/RequestPane.tsx
index 71284de1..8654b0eb 100644
--- a/src-web/components/RequestPane.tsx
+++ b/src-web/components/RequestPane.tsx
@@ -1,6 +1,6 @@
import classNames from 'classnames';
import type { CSSProperties } from 'react';
-import { memo, useCallback, useMemo, useState } from 'react';
+import React, { memo, useCallback, useMemo, useState } from 'react';
import { createGlobalState } from 'react-use';
import { useCancelHttpResponse } from '../hooks/useCancelHttpResponse';
import { useIsResponseLoading } from '../hooks/useIsResponseLoading';
@@ -39,7 +39,8 @@ import { HeadersEditor } from './HeadersEditor';
import { UrlBar } from './UrlBar';
import { UrlParametersEditor } from './UrlParameterEditor';
import { useCurlToRequest } from '../hooks/useCurlToRequest';
-import { useConfirm } from '../hooks/useConfirm';
+import { useToast } from './ToastContext';
+import { Icon } from './core/Icon';
interface Props {
style: CSSProperties;
@@ -230,7 +231,7 @@ export const RequestPane = memo(function RequestPane({
);
const importCurl = useCurlToRequest();
- const confirm = useConfirm();
+ const toast = useToast();
const isLoading = useIsResponseLoading(activeRequestId ?? null);
const { updateKey } = useRequestUpdateKey(activeRequestId ?? null);
@@ -250,15 +251,15 @@ export const RequestPane = memo(function RequestPane({
if (!command.startsWith('curl ')) {
return;
}
- const confirmed = await confirm({
- id: 'paste-curl',
- title: 'Import from Curl?',
- description: 'Do you want to overwrite the current request with the Curl command?',
- confirmText: 'Overwrite',
+ importCurl.mutate({ requestId: activeRequestId, command });
+ toast.show({
+ render: () => [
+ <>
+
+ Curl command imported
+ >,
+ ],
});
- if (confirmed) {
- importCurl.mutate({ requestId: activeRequestId, command });
- }
}}
onSend={handleSend}
onCancel={handleCancel}
diff --git a/src-web/components/Workspace.tsx b/src-web/components/Workspace.tsx
index 6a150af2..41d67611 100644
--- a/src-web/components/Workspace.tsx
+++ b/src-web/components/Workspace.tsx
@@ -6,7 +6,7 @@ import type {
MouseEvent as ReactMouseEvent,
ReactNode,
} from 'react';
-import { useCallback, useMemo, useRef, useState } from 'react';
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useWindowSize } from 'react-use';
import { useActiveRequest } from '../hooks/useActiveRequest';
import { useActiveWorkspace } from '../hooks/useActiveWorkspace';
@@ -34,7 +34,7 @@ import { Sidebar } from './Sidebar';
import { SidebarActions } from './SidebarActions';
import { WorkspaceHeader } from './WorkspaceHeader';
import { useClipboardText } from '../hooks/useClipboardText';
-import { Portal } from './Portal';
+import { useToast } from './ToastContext';
const side = { gridArea: 'side' };
const head = { gridArea: 'head' };
@@ -56,7 +56,24 @@ export default function Workspace() {
const moveState = useRef<{ move: (e: MouseEvent) => void; up: (e: MouseEvent) => void } | null>(
null,
);
- const isCurlInClipboard = !!useClipboardText()?.startsWith('curl ');
+ const clipboardText = useClipboardText();
+ const toast = useToast();
+
+ useEffect(() => {
+ const isCurlInClipboard = clipboardText?.startsWith('curl ');
+ if (!isCurlInClipboard) {
+ return;
+ }
+
+ toast.show({
+ render: () => (
+
+
Curl command detected?
+
Import
+
+ ),
+ });
+ }, [clipboardText, toast]);
const unsub = () => {
if (moveState.current !== null) {
@@ -127,88 +144,83 @@ export default function Workspace() {
}
return (
- <>
-
- {isCurlInClipboard && Import
}
-
-
- {floating ? (
-
setFloatingSidebarHidden(true)}
+
+ {floating ? (
+
setFloatingSidebarHidden(true)}
+ >
+
-
-
-
-
-
-
-
- ) : (
- <>
-
-
-
-
- >
- )}
-
-
-
- {activeWorkspace == null ? (
-
-
- The active workspace{' '}
- {activeWorkspaceId} was not
- found. Select a workspace from the header menu or report this bug to
-
+
+
+
+
+
+
+ ) : (
+ <>
+
+
- ) : activeRequest == null ? (
-
- importData.mutate()}>
- Import
-
-
-
- New Request
-
-
-
- }
+
- ) : activeRequest.model === 'grpc_request' ? (
-
- ) : (
-
- )}
-
- >
+ >
+ )}
+
+
+
+ {activeWorkspace == null ? (
+
+
+ The active workspace{' '}
+ {activeWorkspaceId} was not found.
+ Select a workspace from the header menu or report this bug to
+
+
+ ) : activeRequest == null ? (
+
+ importData.mutate()}>
+ Import
+
+
+
+ New Request
+
+
+
+ }
+ />
+ ) : activeRequest.model === 'grpc_request' ? (
+
+ ) : (
+
+ )}
+
);
}
diff --git a/src-web/hooks/useClipboardText.ts b/src-web/hooks/useClipboardText.ts
index 0a5f8926..d5e2a04a 100644
--- a/src-web/hooks/useClipboardText.ts
+++ b/src-web/hooks/useClipboardText.ts
@@ -4,10 +4,6 @@ import { readText } from '@tauri-apps/plugin-clipboard-manager';
export function useClipboardText() {
return useQuery({
queryKey: [],
- queryFn: async () => {
- const text = await readText();
- console.log('READ CLIPBOARD', text);
- return text;
- },
+ queryFn: () => readText(),
}).data;
}