mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-08-25 12:54:09 +02:00
Stage imports before committing
This commit is contained in:
+1
-1
@@ -474,7 +474,7 @@ export type ImportRequest = { content: string, };
|
||||
|
||||
export type ImportResources = { workspaces: Array<Workspace>, environments: Array<Environment>, folders: Array<Folder>, httpRequests: Array<HttpRequest>, grpcRequests: Array<GrpcRequest>, websocketRequests: Array<WebsocketRequest>, };
|
||||
|
||||
export type ImportResponse = { resources: ImportResources, };
|
||||
export type ImportResponse = { importer: string, resources: ImportResources, };
|
||||
|
||||
export type InternalEvent = { id: string, pluginRefId: string, pluginName: string, replyId: string | null, context: PluginContext, payload: InternalEventPayload, };
|
||||
|
||||
|
||||
@@ -247,6 +247,8 @@ pub struct ImportRequest {
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to = "gen_events.ts")]
|
||||
pub struct ImportResponse {
|
||||
/// Display name of the importer that recognized the input.
|
||||
pub importer: String,
|
||||
pub resources: ImportResources,
|
||||
}
|
||||
|
||||
|
||||
@@ -1104,8 +1104,19 @@ impl PluginManager {
|
||||
.await?;
|
||||
|
||||
// TODO: Don't just return the first valid response
|
||||
let result = reply_events.into_iter().find_map(|e| match e.payload {
|
||||
InternalEventPayload::ImportResponse(resp) => Some(resp),
|
||||
let result = reply_events.into_iter().find_map(|e| match e {
|
||||
InternalEvent {
|
||||
plugin_name,
|
||||
payload: InternalEventPayload::ImportResponse(mut resp),
|
||||
..
|
||||
} => {
|
||||
// Older plugin runtimes do not include the importer's display name. The plugin
|
||||
// package name is still enough to identify the detected format in that case.
|
||||
if resp.importer.is_empty() {
|
||||
resp.importer = plugin_name;
|
||||
}
|
||||
Some(resp)
|
||||
}
|
||||
_ => None,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user