mirror of
https://github.com/foss42/apidash.git
synced 2025-12-01 18:28:25 +08:00
feat: remove unused openapi action button
This commit is contained in:
@@ -34,7 +34,10 @@ class DashbotActionWidgetFactory {
|
||||
case ChatActionType.applyCurl:
|
||||
return DashbotApplyCurlButton(action: action);
|
||||
case ChatActionType.applyOpenApi:
|
||||
return DashbotApplyOpenApiButton(action: action);
|
||||
if (action.action == 'import_now_openapi') {
|
||||
return DashbotImportNowButton(action: action);
|
||||
}
|
||||
return null;
|
||||
case ChatActionType.downloadDoc:
|
||||
return DashbotDownloadDocButton(action: action);
|
||||
case ChatActionType.noAction:
|
||||
@@ -70,9 +73,6 @@ class DashbotActionWidgetFactory {
|
||||
if (action.action == 'apply_curl') {
|
||||
return DashbotApplyCurlButton(action: action);
|
||||
}
|
||||
if (action.action == 'apply_openapi') {
|
||||
return DashbotApplyOpenApiButton(action: action);
|
||||
}
|
||||
if (action.action.contains('update') ||
|
||||
action.action.contains('add') ||
|
||||
action.action.contains('delete')) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
export 'dashbot_add_test_button.dart';
|
||||
export 'dashbot_apply_curl_button.dart';
|
||||
export 'dashbot_apply_openapi_button.dart';
|
||||
export 'dashbot_auto_fix_button.dart';
|
||||
export 'dashbot_download_doc_button.dart';
|
||||
export 'dashbot_generate_codeblock.dart';
|
||||
|
||||
@@ -233,34 +233,6 @@ class OpenApiImportService {
|
||||
op: op,
|
||||
);
|
||||
|
||||
/// Build an action message asking whether to apply to selected/new
|
||||
/// for a single chosen operation.
|
||||
static Map<String, dynamic> buildActionMessageFromPayload(
|
||||
Map<String, dynamic> actionPayload,
|
||||
{String? title}) {
|
||||
final buf = StringBuffer(
|
||||
title ?? 'Parsed the OpenAPI operation. Where should I apply it?');
|
||||
return {
|
||||
'explnation': buf.toString(),
|
||||
'actions': [
|
||||
{
|
||||
'action': 'apply_openapi',
|
||||
'target': 'httpRequestModel',
|
||||
'field': 'apply_to_new',
|
||||
'path': null,
|
||||
'value': actionPayload,
|
||||
},
|
||||
{
|
||||
'action': 'apply_openapi',
|
||||
'target': 'httpRequestModel',
|
||||
'field': 'apply_to_selected',
|
||||
'path': null,
|
||||
'value': actionPayload,
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
static Map<String, dynamic> buildOperationPicker(OpenApi spec,
|
||||
{String? insights}) {
|
||||
final servers = spec.servers ?? const [];
|
||||
|
||||
@@ -445,27 +445,6 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
collection.addRequestModel(model, name: displayName);
|
||||
_appendSystem('Created a new request from the OpenAPI operation.',
|
||||
ChatMessageType.importOpenApi);
|
||||
} else if (action.field == 'select_operation') {
|
||||
// Present apply options for the selected operation
|
||||
final applyMsg = OpenApiImportService.buildActionMessageFromPayload(
|
||||
payload,
|
||||
title: 'Selected ${action.path}. Where should I apply it?',
|
||||
);
|
||||
final rqId = _currentRequest?.id ?? 'global';
|
||||
_addMessage(
|
||||
rqId,
|
||||
ChatMessage(
|
||||
id: getNewUuid(),
|
||||
content: jsonEncode(applyMsg),
|
||||
role: MessageRole.system,
|
||||
timestamp: DateTime.now(),
|
||||
messageType: ChatMessageType.importOpenApi,
|
||||
actions: (applyMsg['actions'] as List)
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map(ChatAction.fromJson)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user