Pass workspace id to import

This commit is contained in:
Gregory Schier
2024-03-20 07:30:59 -07:00
parent 09a23ce357
commit 6096199174
2 changed files with 9 additions and 2 deletions

View File

@@ -722,7 +722,11 @@ async fn cmd_filter_response(w: Window, response_id: &str, filter: &str) -> Resu
}
#[tauri::command]
async fn cmd_import_data(w: Window, file_path: &str) -> Result<WorkspaceExportResources, String> {
async fn cmd_import_data(
w: Window,
file_path: &str,
_workspace_id: &str,
) -> Result<WorkspaceExportResources, String> {
let mut result: Option<ImportResult> = None;
let plugins = vec!["importer-yaak", "importer-insomnia", "importer-postman"];
for plugin_name in plugins {
@@ -745,7 +749,7 @@ async fn cmd_import_data(w: Window, file_path: &str) -> Result<WorkspaceExportRe
let mut imported_resources = WorkspaceExportResources::default();
info!("Importing resources");
for v in r.resources.workspaces {
for mut v in r.resources.workspaces {
let x = upsert_workspace(&w, v).await.map_err(|e| e.to_string())?;
imported_resources.workspaces.push(x.clone());
info!("Imported workspace: {}", x.name);

View File

@@ -7,6 +7,7 @@ import { VStack } from '../components/core/Stacks';
import { useDialog } from '../components/DialogContext';
import type { Environment, Folder, GrpcRequest, HttpRequest, Workspace } from '../lib/models';
import { count } from '../lib/pluralize';
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
import { useAlert } from './useAlert';
import { useAppRoutes } from './useAppRoutes';
@@ -19,6 +20,7 @@ export function useImportData() {
const routes = useAppRoutes();
const dialog = useDialog();
const alert = useAlert();
const activeWorkspaceId = useActiveWorkspaceId();
const importData = async () => {
const selected = await open(openArgs);
@@ -34,6 +36,7 @@ export function useImportData() {
grpcRequests: GrpcRequest[];
} = await invoke('cmd_import_data', {
filePath: Array.isArray(selected) ? selected[0] : selected,
workspaceId: activeWorkspaceId,
});
const importedWorkspace = imported.workspaces[0];