Skip to content

Commit 6e3441f

Browse files
authored
Merge branch 'main' into Dashbot_v2
2 parents 9c1fad2 + cff39c1 commit 6e3441f

File tree

22 files changed

+179
-90
lines changed

22 files changed

+179
-90
lines changed

doc/dev_guide/api_endpoints_for_testing.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ A List of API endpoints that can be used for testing API Dash
1111

1212
#### For Testing HTTP PUT, PATCH, DELETE
1313
- https://reqres.in/
14-
14+
15+
#### For Testing HTTP OPTIONS
16+
- https://reqbin.com/echo/options
17+
1518
#### For Testing sites with Bad Certificate
1619
- https://badssl.com/
1720
- https://www.ssl.com/sample-valid-revoked-and-expired-ssl-tls-certificates/

lib/dashbot/features/explain.dart

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'dart:convert';
21
import '../services/dashbot_service.dart';
32
import 'package:apidash/models/request_model.dart';
43

@@ -19,20 +18,14 @@ class ExplainFeature {
1918
return "Error: Invalid API request (missing endpoint).";
2019
}
2120

22-
final method = requestModel.httpRequestModel?.method
23-
.toString()
24-
.split('.')
25-
.last
26-
.toUpperCase() ??
27-
"GET";
28-
final endpoint = requestModel.httpRequestModel!.url;
21+
final method =
22+
requestModel.httpRequestModel?.method.name.toUpperCase() ?? "GET";
23+
final url = requestModel.httpRequestModel!.url;
2924
final headers = requestModel.httpRequestModel?.enabledHeadersMap ?? {};
3025
final parameters = requestModel.httpRequestModel?.enabledParamsMap ?? {};
31-
final body = requestModel.httpRequestModel?.body;
32-
final rawResponse = responseModel.body;
33-
final responseBody =
34-
rawResponse is String ? rawResponse : jsonEncode(rawResponse);
35-
final statusCode = responseModel.statusCode ?? 0;
26+
final body = requestModel.httpRequestModel?.body ?? '';
27+
final responseBody = responseModel.body;
28+
final statusCode = responseModel.statusCode;
3629

3730
final prompt = '''
3831
FOCUSED API INTERACTION BREAKDOWN
@@ -41,10 +34,16 @@ FOCUSED API INTERACTION BREAKDOWN
4134
- Endpoint Purpose: What is this API endpoint designed to do?
4235
- Interaction Type: Describe the core purpose of this specific request
4336
44-
**Request Mechanics:**
45-
- Exact Endpoint: $endpoint
37+
**Request Details:**
38+
- Endpoint: $url
4639
- HTTP Method: $method
47-
- Key Parameters: ${parameters.isNotEmpty ? 'Specific inputs driving the request' : 'No custom parameters'}
40+
- Request Headers: ${headers.isEmpty ? "None" : headers}
41+
- URL Parameters: ${parameters.isEmpty ? "None" : parameters}
42+
- Request Body: ${body.isEmpty ? "None" : body}
43+
44+
**Response Details**
45+
- Status Code: $statusCode
46+
- Content: $responseBody
4847
4948
**Response CORE Insights:**
5049
- Status: Success or Failure?

lib/models/history_meta_model.g.dart

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/settings_model.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class SettingsModel {
1717
this.historyRetentionPeriod = HistoryRetentionPeriod.oneWeek,
1818
this.workspaceFolderPath,
1919
this.isSSLDisabled = false,
20+
this.isDashBotEnabled = true,
2021
});
2122

2223
final bool isDark;
@@ -31,6 +32,7 @@ class SettingsModel {
3132
final HistoryRetentionPeriod historyRetentionPeriod;
3233
final String? workspaceFolderPath;
3334
final bool isSSLDisabled;
35+
final bool isDashBotEnabled;
3436

3537
SettingsModel copyWith({
3638
bool? isDark,
@@ -45,6 +47,7 @@ class SettingsModel {
4547
HistoryRetentionPeriod? historyRetentionPeriod,
4648
String? workspaceFolderPath,
4749
bool? isSSLDisabled,
50+
bool? isDashBotEnabled,
4851
}) {
4952
return SettingsModel(
5053
isDark: isDark ?? this.isDark,
@@ -61,6 +64,7 @@ class SettingsModel {
6164
historyRetentionPeriod ?? this.historyRetentionPeriod,
6265
workspaceFolderPath: workspaceFolderPath ?? this.workspaceFolderPath,
6366
isSSLDisabled: isSSLDisabled ?? this.isSSLDisabled,
67+
isDashBotEnabled: isDashBotEnabled ?? this.isDashBotEnabled,
6468
);
6569
}
6670

@@ -80,6 +84,7 @@ class SettingsModel {
8084
historyRetentionPeriod: historyRetentionPeriod,
8185
workspaceFolderPath: workspaceFolderPath,
8286
isSSLDisabled: isSSLDisabled,
87+
isDashBotEnabled: isDashBotEnabled,
8388
);
8489
}
8590

@@ -134,6 +139,7 @@ class SettingsModel {
134139
}
135140
final workspaceFolderPath = data["workspaceFolderPath"] as String?;
136141
final isSSLDisabled = data["isSSLDisabled"] as bool?;
142+
final isDashBotEnabled = data["isDashBotEnabled"] as bool?;
137143

138144
const sm = SettingsModel();
139145

@@ -151,6 +157,7 @@ class SettingsModel {
151157
historyRetentionPeriod ?? HistoryRetentionPeriod.oneWeek,
152158
workspaceFolderPath: workspaceFolderPath,
153159
isSSLDisabled: isSSLDisabled,
160+
isDashBotEnabled: isDashBotEnabled,
154161
);
155162
}
156163

@@ -170,6 +177,7 @@ class SettingsModel {
170177
"historyRetentionPeriod": historyRetentionPeriod.name,
171178
"workspaceFolderPath": workspaceFolderPath,
172179
"isSSLDisabled": isSSLDisabled,
180+
"isDashBotEnabled": isDashBotEnabled,
173181
};
174182
}
175183

@@ -194,7 +202,8 @@ class SettingsModel {
194202
other.activeEnvironmentId == activeEnvironmentId &&
195203
other.historyRetentionPeriod == historyRetentionPeriod &&
196204
other.workspaceFolderPath == workspaceFolderPath &&
197-
other.isSSLDisabled == isSSLDisabled;
205+
other.isSSLDisabled == isSSLDisabled &&
206+
other.isDashBotEnabled == isDashBotEnabled;
198207
}
199208

200209
@override
@@ -213,6 +222,7 @@ class SettingsModel {
213222
historyRetentionPeriod,
214223
workspaceFolderPath,
215224
isSSLDisabled,
225+
isDashBotEnabled,
216226
);
217227
}
218228
}

lib/providers/settings_providers.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class ThemeStateNotifier extends StateNotifier<SettingsModel> {
3333
HistoryRetentionPeriod? historyRetentionPeriod,
3434
String? workspaceFolderPath,
3535
bool? isSSLDisabled,
36+
bool? isDashBotEnabled,
3637
}) async {
3738
state = state.copyWith(
3839
isDark: isDark,
@@ -47,6 +48,7 @@ class ThemeStateNotifier extends StateNotifier<SettingsModel> {
4748
historyRetentionPeriod: historyRetentionPeriod,
4849
workspaceFolderPath: workspaceFolderPath,
4950
isSSLDisabled: isSSLDisabled,
51+
isDashBotEnabled: isDashBotEnabled,
5052
);
5153
await setSettingsToSharedPrefs(state);
5254
}

lib/screens/common_widgets/envfield_cell.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:apidash/consts.dart';
12
import 'package:apidash_design_system/apidash_design_system.dart';
23
import 'package:flutter/material.dart';
34
import 'package:multi_trigger_autocomplete_plus/multi_trigger_autocomplete_plus.dart';
@@ -37,6 +38,8 @@ class EnvCellField extends StatelessWidget {
3738
decoration: getTextFieldInputDecoration(
3839
clrScheme,
3940
hintText: hintText,
41+
isDense: true,
42+
contentPadding: kIsMobile ? kPh6b12 : null,
4043
),
4144
autocompleteNoTrigger: autocompleteNoTrigger,
4245
onChanged: onChanged,

lib/screens/dashboard.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Dashboard extends ConsumerWidget {
1717
@override
1818
Widget build(BuildContext context, WidgetRef ref) {
1919
final railIdx = ref.watch(navRailIndexStateProvider);
20-
final isDashBotVisible = ref.watch(dashBotVisibilityProvider);
20+
final settings = ref.watch(settingsProvider);
2121
return Scaffold(
2222
body: SafeArea(
2323
child: Stack(
@@ -138,8 +138,9 @@ class Dashboard extends ConsumerWidget {
138138
],
139139
),
140140
),
141-
// TODO: Release DashBot
142-
floatingActionButton: !isDashBotVisible ? const DashBotFAB() : null,
141+
floatingActionButton: settings.isDashBotEnabled
142+
? const DashBotFAB()
143+
: null,
143144
);
144145
}
145146
}

lib/screens/envvar/editor_pane/variables_pane.dart

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class EditEnvironmentVariablesState
182182
color: Theme.of(context).colorScheme.surface,
183183
borderRadius: kBorderRadius12,
184184
),
185-
margin: kP10,
185+
margin: kPh10t10,
186186
child: Column(
187187
crossAxisAlignment: CrossAxisAlignment.stretch,
188188
children: [
@@ -203,27 +203,28 @@ class EditEnvironmentVariablesState
203203
),
204204
),
205205
),
206-
kVSpacer40,
206+
if (!kIsMobile) kVSpacer40,
207207
],
208208
),
209209
),
210-
Align(
211-
alignment: Alignment.bottomCenter,
212-
child: Padding(
213-
padding: kPb15,
214-
child: ElevatedButton.icon(
215-
onPressed: () {
216-
variableRows.add(kEnvironmentVariableEmptyModel);
217-
_onFieldChange(selectedId!);
218-
},
219-
icon: const Icon(Icons.add),
220-
label: const Text(
221-
kLabelAddVariable,
222-
style: kTextStyleButton,
210+
if (!kIsMobile)
211+
Align(
212+
alignment: Alignment.bottomCenter,
213+
child: Padding(
214+
padding: kPb15,
215+
child: ElevatedButton.icon(
216+
onPressed: () {
217+
variableRows.add(kEnvironmentVariableEmptyModel);
218+
_onFieldChange(selectedId!);
219+
},
220+
icon: const Icon(Icons.add),
221+
label: const Text(
222+
kLabelAddVariable,
223+
style: kTextStyleButton,
224+
),
223225
),
224226
),
225227
),
226-
),
227228
],
228229
);
229230
}

lib/screens/home_page/editor_pane/details_card/request_pane/request_form_data.dart

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
185185
return Stack(
186186
children: [
187187
Container(
188-
margin: kP10,
188+
margin: kPh10t10,
189189
child: Column(
190190
children: [
191191
Expanded(
@@ -205,27 +205,28 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
205205
),
206206
),
207207
),
208-
kVSpacer40,
208+
if (!kIsMobile) kVSpacer40,
209209
],
210210
),
211211
),
212-
Align(
213-
alignment: Alignment.bottomCenter,
214-
child: Padding(
215-
padding: kPb15,
216-
child: ElevatedButton.icon(
217-
onPressed: () {
218-
formRows.add(kFormDataEmptyModel);
219-
_onFieldChange();
220-
},
221-
icon: const Icon(Icons.add),
222-
label: const Text(
223-
kLabelAddFormField,
224-
style: kTextStyleButton,
212+
if (!kIsMobile)
213+
Align(
214+
alignment: Alignment.bottomCenter,
215+
child: Padding(
216+
padding: kPb15,
217+
child: ElevatedButton.icon(
218+
onPressed: () {
219+
formRows.add(kFormDataEmptyModel);
220+
_onFieldChange();
221+
},
222+
icon: const Icon(Icons.add),
223+
label: const Text(
224+
kLabelAddFormField,
225+
style: kTextStyleButton,
226+
),
225227
),
226228
),
227229
),
228-
),
229230
],
230231
);
231232
}

lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
178178
return Stack(
179179
children: [
180180
Container(
181-
margin: kP10,
181+
margin: kPh10t10,
182182
child: Column(
183183
children: [
184184
Expanded(
@@ -198,28 +198,29 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
198198
),
199199
),
200200
),
201-
kVSpacer40,
201+
if (!kIsMobile) kVSpacer40,
202202
],
203203
),
204204
),
205-
Align(
206-
alignment: Alignment.bottomCenter,
207-
child: Padding(
208-
padding: kPb15,
209-
child: ElevatedButton.icon(
210-
onPressed: () {
211-
headerRows.add(kNameValueEmptyModel);
212-
isRowEnabledList.add(false);
213-
_onFieldChange();
214-
},
215-
icon: const Icon(Icons.add),
216-
label: const Text(
217-
kLabelAddHeader,
218-
style: kTextStyleButton,
205+
if (!kIsMobile)
206+
Align(
207+
alignment: Alignment.bottomCenter,
208+
child: Padding(
209+
padding: kPb15,
210+
child: ElevatedButton.icon(
211+
onPressed: () {
212+
headerRows.add(kNameValueEmptyModel);
213+
isRowEnabledList.add(false);
214+
_onFieldChange();
215+
},
216+
icon: const Icon(Icons.add),
217+
label: const Text(
218+
kLabelAddHeader,
219+
style: kTextStyleButton,
220+
),
219221
),
220222
),
221223
),
222-
),
223224
],
224225
);
225226
}

0 commit comments

Comments
 (0)