mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 00:58:32 +02:00
Add curl banner to import dialog
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import { VStack } from './core/Stacks';
|
import { VStack } from './core/Stacks';
|
||||||
import { Button } from './core/Button';
|
import { Button } from './core/Button';
|
||||||
import { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import { Banner } from './core/Banner';
|
||||||
|
import { Icon } from './core/Icon';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
importData: () => Promise<void>;
|
importData: () => Promise<void>;
|
||||||
@@ -11,15 +13,17 @@ export function ImportDataDialog({ importData }: Props) {
|
|||||||
return (
|
return (
|
||||||
<VStack space={5} className="pb-4">
|
<VStack space={5} className="pb-4">
|
||||||
<VStack space={1}>
|
<VStack space={1}>
|
||||||
<p>Supported Formats:</p>
|
|
||||||
<ul className="list-disc pl-5">
|
<ul className="list-disc pl-5">
|
||||||
<li>Postman Collection v2+</li>
|
<li>Postman Collection v2+</li>
|
||||||
<li>Insomnia v4+</li>
|
<li>Insomnia v4+</li>
|
||||||
<li>Curl command(s)</li>
|
<li>Curl commands</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<Banner className="mt-3 flex items-center gap-2">
|
||||||
|
<Icon icon="magicWand" />
|
||||||
|
Paste any Curl command into URL bar
|
||||||
|
</Banner>
|
||||||
</VStack>
|
</VStack>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
|
||||||
color="primary"
|
color="primary"
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ export function useImportData() {
|
|||||||
const alert = useAlert();
|
const alert = useAlert();
|
||||||
const activeWorkspaceId = useActiveWorkspaceId();
|
const activeWorkspaceId = useActiveWorkspaceId();
|
||||||
|
|
||||||
const importData = async () => {
|
const importData = async (): Promise<boolean> => {
|
||||||
const selected = await open({
|
const selected = await open({
|
||||||
filters: [{ name: 'Export File', extensions: ['json', 'yaml', 'sh', 'txt'] }],
|
filters: [{ name: 'Export File', extensions: ['json', 'yaml', 'sh', 'txt'] }],
|
||||||
multiple: false,
|
multiple: false,
|
||||||
});
|
});
|
||||||
if (selected == null) {
|
if (selected == null) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const imported: {
|
const imported: {
|
||||||
@@ -71,6 +71,8 @@ export function useImportData() {
|
|||||||
environmentId: imported.environments[0]?.id,
|
environmentId: imported.environments[0]?.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
@@ -86,12 +88,16 @@ export function useImportData() {
|
|||||||
render: ({ hide }) => {
|
render: ({ hide }) => {
|
||||||
const importAndHide = async () => {
|
const importAndHide = async () => {
|
||||||
try {
|
try {
|
||||||
await importData();
|
const didImport = await importData();
|
||||||
|
if (!didImport) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
resolve();
|
resolve();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
}
|
}
|
||||||
hide();
|
|
||||||
};
|
};
|
||||||
return <ImportDataDialog importData={importAndHide} />;
|
return <ImportDataDialog importData={importAndHide} />;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user