From aa8e5c3d034b264f665955754c1c43795c959269 Mon Sep 17 00:00:00 2001 From: Rio Jos <62337699+riojosdev@users.noreply.github.com> Date: Thu, 24 Apr 2025 13:05:00 +0530 Subject: [PATCH 01/17] http method options --- doc/dev_guide/api_endpoints_for_testing.md | 5 ++++- lib/utils/ui_utils.dart | 1 + packages/apidash_core/lib/consts.dart | 3 ++- packages/apidash_core/lib/services/http_service.dart | 11 +++++++++++ packages/apidash_design_system/lib/tokens/colors.dart | 1 + 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/dev_guide/api_endpoints_for_testing.md b/doc/dev_guide/api_endpoints_for_testing.md index 7f2e9556..f1082884 100644 --- a/doc/dev_guide/api_endpoints_for_testing.md +++ b/doc/dev_guide/api_endpoints_for_testing.md @@ -11,7 +11,10 @@ A List of API endpoints that can be used for testing API Dash #### For Testing HTTP PUT, PATCH, DELETE - https://reqres.in/ - + +#### For Testing HTTP OPTIONS, TRACE +- Use localhost servers, as TRACE and OPTIONS HTTP methods are not publicly available (used for diagnostic purposes) + #### For Testing sites with Bad Certificate - https://badssl.com/ - https://www.ssl.com/sample-valid-revoked-and-expired-ssl-tls-certificates/ diff --git a/lib/utils/ui_utils.dart b/lib/utils/ui_utils.dart index 4f72a1a3..68eaa82c 100644 --- a/lib/utils/ui_utils.dart +++ b/lib/utils/ui_utils.dart @@ -51,6 +51,7 @@ Color getHTTPMethodColor(HTTPVerb? method) { HTTPVerb.put => kColorHttpMethodPut, HTTPVerb.patch => kColorHttpMethodPatch, HTTPVerb.delete => kColorHttpMethodDelete, + HTTPVerb.options => kColorHttpMethodOptions, _ => kColorHttpMethodGet, }; return col; diff --git a/packages/apidash_core/lib/consts.dart b/packages/apidash_core/lib/consts.dart index 1d7044c7..c1d45ad4 100644 --- a/packages/apidash_core/lib/consts.dart +++ b/packages/apidash_core/lib/consts.dart @@ -17,7 +17,8 @@ enum HTTPVerb { post("POST"), put("PUT"), patch("PAT"), - delete("DEL"); + delete("DEL"), + options("OPT"); const HTTPVerb(this.abbr); final String abbr; diff --git a/packages/apidash_core/lib/services/http_service.dart b/packages/apidash_core/lib/services/http_service.dart index dbd93086..642ce89d 100644 --- a/packages/apidash_core/lib/services/http_service.dart +++ b/packages/apidash_core/lib/services/http_service.dart @@ -104,6 +104,17 @@ Future<(HttpResponse?, Duration?, String?)> sendHttpRequest( final streamed = await client.send(request); response = await http.Response.fromStream(streamed); break; + case HTTPVerb.options: + final request = prepareHttpRequest( + url: requestUrl, + method: requestModel.method.name.toUpperCase(), + headers: headers, + body: body, + overrideContentType: overrideContentType, + ); + final streamed = await client.send(request); + response = await http.Response.fromStream(streamed); + break; } } if (apiType == APIType.graphql) { diff --git a/packages/apidash_design_system/lib/tokens/colors.dart b/packages/apidash_design_system/lib/tokens/colors.dart index 11943bd3..22b6780c 100644 --- a/packages/apidash_design_system/lib/tokens/colors.dart +++ b/packages/apidash_design_system/lib/tokens/colors.dart @@ -23,6 +23,7 @@ final kColorHttpMethodPost = Colors.blue.shade800; final kColorHttpMethodPut = Colors.amber.shade900; final kColorHttpMethodPatch = kColorHttpMethodPut; final kColorHttpMethodDelete = Colors.red.shade800; +final kColorHttpMethodOptions = Colors.yellow.shade800; final kColorGQL = Colors.pink.shade600; From a19c9ba0938e2aefa979e54ff8b75ce2719e85cd Mon Sep 17 00:00:00 2001 From: Rio Jos <62337699+riojosdev@users.noreply.github.com> Date: Thu, 24 Apr 2025 14:12:59 +0530 Subject: [PATCH 02/17] http options method on history provider --- doc/dev_guide/api_endpoints_for_testing.md | 4 ++-- lib/models/history_meta_model.g.dart | 1 + packages/apidash_core/lib/models/http_request_model.g.dart | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/dev_guide/api_endpoints_for_testing.md b/doc/dev_guide/api_endpoints_for_testing.md index f1082884..5e0c1378 100644 --- a/doc/dev_guide/api_endpoints_for_testing.md +++ b/doc/dev_guide/api_endpoints_for_testing.md @@ -12,8 +12,8 @@ A List of API endpoints that can be used for testing API Dash #### For Testing HTTP PUT, PATCH, DELETE - https://reqres.in/ -#### For Testing HTTP OPTIONS, TRACE -- Use localhost servers, as TRACE and OPTIONS HTTP methods are not publicly available (used for diagnostic purposes) +#### For Testing HTTP OPTIONS +- https://reqbin.com/echo/options #### For Testing sites with Bad Certificate - https://badssl.com/ diff --git a/lib/models/history_meta_model.g.dart b/lib/models/history_meta_model.g.dart index a2b2b7b1..da184793 100644 --- a/lib/models/history_meta_model.g.dart +++ b/lib/models/history_meta_model.g.dart @@ -44,4 +44,5 @@ const _$HTTPVerbEnumMap = { HTTPVerb.put: 'put', HTTPVerb.patch: 'patch', HTTPVerb.delete: 'delete', + HTTPVerb.options: 'options', }; diff --git a/packages/apidash_core/lib/models/http_request_model.g.dart b/packages/apidash_core/lib/models/http_request_model.g.dart index 29005786..13795ded 100644 --- a/packages/apidash_core/lib/models/http_request_model.g.dart +++ b/packages/apidash_core/lib/models/http_request_model.g.dart @@ -58,6 +58,7 @@ const _$HTTPVerbEnumMap = { HTTPVerb.put: 'put', HTTPVerb.patch: 'patch', HTTPVerb.delete: 'delete', + HTTPVerb.options: 'options', }; const _$ContentTypeEnumMap = { From 8177cbeeabec5294b699890e4cd1a17a82b42c12 Mon Sep 17 00:00:00 2001 From: Rio Jos <62337699+riojosdev@users.noreply.github.com> Date: Thu, 24 Apr 2025 15:28:55 +0530 Subject: [PATCH 03/17] tests for http options --- test/models/history_models.dart | 18 ++++++++++++++++++ test/models/history_models_test.dart | 8 ++++++++ test/models/http_request_models.dart | 6 ++++++ test/models/request_models.dart | 6 ++++++ test/models/response_model_test.dart | 17 +++++++++++++++++ 5 files changed, 55 insertions(+) diff --git a/test/models/history_models.dart b/test/models/history_models.dart index e33c2f99..68b2b45f 100644 --- a/test/models/history_models.dart +++ b/test/models/history_models.dart @@ -77,3 +77,21 @@ final Map historyRequestModelJson2 = { "httpRequestModel": httpRequestModelPost10Json, "httpResponseModel": responseModelJson, }; + +/// Basic History Meta model 1 +final historyMetaModel3 = HistoryMetaModel( + historyId: 'historyId3', + requestId: 'requestId3', + apiType: APIType.rest, + url: 'https://reqbin.com/echo/options', + method: HTTPVerb.options, + timeStamp: DateTime(2024, 1, 1), + responseStatus: 200, +); + +final historyRequestModel3 = HistoryRequestModel( + historyId: 'historyId3', + metaData: historyMetaModel3, + httpRequestModel: httpRequestModelOptions1, + httpResponseModel: responseModel, +); diff --git a/test/models/history_models_test.dart b/test/models/history_models_test.dart index 91a085e9..af13a055 100644 --- a/test/models/history_models_test.dart +++ b/test/models/history_models_test.dart @@ -75,5 +75,13 @@ void main() { expect(historyRequestModel.httpRequestModel, httpRequestModelGet4); expect(historyRequestModel.httpResponseModel, responseModel); }); + + test("Testing HistoryRequestModel getters", () { + var historyRequestModel = historyRequestModel3; + expect(historyRequestModel.historyId, 'historyId3'); + expect(historyRequestModel.metaData, historyMetaModel3); + expect(historyRequestModel.httpRequestModel, httpRequestModelOptions1); + expect(historyRequestModel.httpResponseModel, responseModel); + }); }); } diff --git a/test/models/http_request_models.dart b/test/models/http_request_models.dart index 30260983..10b84eda 100644 --- a/test/models/http_request_models.dart +++ b/test/models/http_request_models.dart @@ -466,3 +466,9 @@ const httpRequestModelPost13 = HttpRequestModel( "text": "I LOVE Flutter" }""", ); + +/// Basic OPTIONS request model +const httpRequestModelOptions1 = HttpRequestModel( + method: HTTPVerb.options, + url: 'https://reqbin.com/echo/options', +); diff --git a/test/models/request_models.dart b/test/models/request_models.dart index 9a6a91c7..74d11376 100644 --- a/test/models/request_models.dart +++ b/test/models/request_models.dart @@ -253,3 +253,9 @@ const requestModelPost13 = RequestModel( apiType: APIType.rest, httpRequestModel: httpRequestModelPost13, ); + +const requestModelOptions1 = RequestModel( + id: 'options1', + apiType: APIType.rest, + httpRequestModel: httpRequestModelOptions1, +); diff --git a/test/models/response_model_test.dart b/test/models/response_model_test.dart index 0060b13b..74872cdb 100644 --- a/test/models/response_model_test.dart +++ b/test/models/response_model_test.dart @@ -119,4 +119,21 @@ void main() { test('Testing hashcode', () { expect(responseModel.hashCode, greaterThan(0)); }); + + test('Testing fromResponse for OPTIONS method', () async { + var responseRec = await sendHttpRequest( + requestModelOptions1.id, + requestModelOptions1.apiType, + requestModelOptions1.httpRequestModel!, + defaultUriScheme: kDefaultUriScheme, + noSSL: false, + ); + + final responseData = responseModel.fromResponse(response: responseRec.$1!); + expect(responseData.statusCode, 200); + expect(responseData.headers?['access-control-allow-methods'], 'GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS'); + expect(responseData.headers?['access-control-allow-methods']?.contains("OPTIONS"), true); + expect(responseData.headers?['allow'], 'GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS'); + expect(responseData.headers?['allow']?.contains("OPTIONS"), true); + }); } From 7728d02b30faeedb9a206ccd4f6188a1f20f2301 Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sun, 27 Apr 2025 05:06:31 +0530 Subject: [PATCH 04/17] Update colors.dart --- packages/apidash_design_system/lib/tokens/colors.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/apidash_design_system/lib/tokens/colors.dart b/packages/apidash_design_system/lib/tokens/colors.dart index 22b6780c..7b203212 100644 --- a/packages/apidash_design_system/lib/tokens/colors.dart +++ b/packages/apidash_design_system/lib/tokens/colors.dart @@ -23,7 +23,7 @@ final kColorHttpMethodPost = Colors.blue.shade800; final kColorHttpMethodPut = Colors.amber.shade900; final kColorHttpMethodPatch = kColorHttpMethodPut; final kColorHttpMethodDelete = Colors.red.shade800; -final kColorHttpMethodOptions = Colors.yellow.shade800; +final kColorHttpMethodOptions = Colors.deepPurple.shade800; final kColorGQL = Colors.pink.shade600; From 897436bc70c5e198cfba07bc46e49be8f231f4f7 Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sun, 27 Apr 2025 05:08:39 +0530 Subject: [PATCH 05/17] Update http_service.dart --- packages/apidash_core/lib/services/http_service.dart | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/packages/apidash_core/lib/services/http_service.dart b/packages/apidash_core/lib/services/http_service.dart index 642ce89d..1b05976a 100644 --- a/packages/apidash_core/lib/services/http_service.dart +++ b/packages/apidash_core/lib/services/http_service.dart @@ -94,16 +94,6 @@ Future<(HttpResponse?, Duration?, String?)> sendHttpRequest( case HTTPVerb.put: case HTTPVerb.patch: case HTTPVerb.delete: - final request = prepareHttpRequest( - url: requestUrl, - method: requestModel.method.name.toUpperCase(), - headers: headers, - body: body, - overrideContentType: overrideContentType, - ); - final streamed = await client.send(request); - response = await http.Response.fromStream(streamed); - break; case HTTPVerb.options: final request = prepareHttpRequest( url: requestUrl, From f437b77973e01a3f58aa8129cd77e9d61a8728cc Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sun, 27 Apr 2025 05:13:42 +0530 Subject: [PATCH 06/17] Update history_models.dart --- test/models/history_models.dart | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/test/models/history_models.dart b/test/models/history_models.dart index 68b2b45f..e33c2f99 100644 --- a/test/models/history_models.dart +++ b/test/models/history_models.dart @@ -77,21 +77,3 @@ final Map historyRequestModelJson2 = { "httpRequestModel": httpRequestModelPost10Json, "httpResponseModel": responseModelJson, }; - -/// Basic History Meta model 1 -final historyMetaModel3 = HistoryMetaModel( - historyId: 'historyId3', - requestId: 'requestId3', - apiType: APIType.rest, - url: 'https://reqbin.com/echo/options', - method: HTTPVerb.options, - timeStamp: DateTime(2024, 1, 1), - responseStatus: 200, -); - -final historyRequestModel3 = HistoryRequestModel( - historyId: 'historyId3', - metaData: historyMetaModel3, - httpRequestModel: httpRequestModelOptions1, - httpResponseModel: responseModel, -); From 169d97b16674a9fd282d17d944b48c8b4e8bf6ed Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sun, 27 Apr 2025 05:13:48 +0530 Subject: [PATCH 07/17] Update history_models_test.dart --- test/models/history_models_test.dart | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/models/history_models_test.dart b/test/models/history_models_test.dart index af13a055..91a085e9 100644 --- a/test/models/history_models_test.dart +++ b/test/models/history_models_test.dart @@ -75,13 +75,5 @@ void main() { expect(historyRequestModel.httpRequestModel, httpRequestModelGet4); expect(historyRequestModel.httpResponseModel, responseModel); }); - - test("Testing HistoryRequestModel getters", () { - var historyRequestModel = historyRequestModel3; - expect(historyRequestModel.historyId, 'historyId3'); - expect(historyRequestModel.metaData, historyMetaModel3); - expect(historyRequestModel.httpRequestModel, httpRequestModelOptions1); - expect(historyRequestModel.httpResponseModel, responseModel); - }); }); } From 8d06fc4cd05894968fd0b36c5c8bf3ab39a96ce4 Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sun, 4 May 2025 22:35:21 +0530 Subject: [PATCH 08/17] UI friendly fix for issue #638 --- lib/widgets/previewer_json.dart | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/widgets/previewer_json.dart b/lib/widgets/previewer_json.dart index 3f8e2b19..811cbbc8 100644 --- a/lib/widgets/previewer_json.dart +++ b/lib/widgets/previewer_json.dart @@ -281,8 +281,18 @@ class _JsonPreviewerState extends State { size: 18, ), onPressed: () async { - await _copy( - kJsonEncoder.convert(toJson(node)), sm); + final val = toJson(node); + String toCopy = ''; + if (node.isClass || + node.isArray || + node.isRoot) { + toCopy = kJsonEncoder.convert(val); + } else { + toCopy = (val.values as Iterable) + .first + .toString(); + } + await _copy(toCopy, sm); }, ), ) From ce219ddd423269cd48721e95f5ff29ddb366b5da Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Sat, 10 May 2025 00:42:42 +0530 Subject: [PATCH 09/17] Update measurements.dart --- packages/apidash_design_system/lib/tokens/measurements.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/apidash_design_system/lib/tokens/measurements.dart b/packages/apidash_design_system/lib/tokens/measurements.dart index f760f8f9..4d0e12a2 100644 --- a/packages/apidash_design_system/lib/tokens/measurements.dart +++ b/packages/apidash_design_system/lib/tokens/measurements.dart @@ -53,6 +53,11 @@ const kPh20t40 = EdgeInsets.only( right: 20, top: 40, ); +const kPh10t10 = EdgeInsets.only( + left: 10, + right: 10, + top: 10, +); const kPs0o6 = EdgeInsets.only( left: 0, top: 6, From 17c3c8a793fdb8ef104a9c30a5d720a3c61590bc Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Sat, 10 May 2025 00:43:50 +0530 Subject: [PATCH 10/17] UX Fix: Field addition button removed from mobile --- .../envvar/editor_pane/variables_pane.dart | 33 ++++++++--------- .../request_pane/request_form_data.dart | 33 ++++++++--------- .../request_pane/request_headers.dart | 35 ++++++++++--------- .../request_pane/request_params.dart | 35 ++++++++++--------- 4 files changed, 70 insertions(+), 66 deletions(-) diff --git a/lib/screens/envvar/editor_pane/variables_pane.dart b/lib/screens/envvar/editor_pane/variables_pane.dart index af3a1e39..f6172ec7 100644 --- a/lib/screens/envvar/editor_pane/variables_pane.dart +++ b/lib/screens/envvar/editor_pane/variables_pane.dart @@ -182,7 +182,7 @@ class EditEnvironmentVariablesState color: Theme.of(context).colorScheme.surface, borderRadius: kBorderRadius12, ), - margin: kP10, + margin: kPh10t10, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ @@ -203,27 +203,28 @@ class EditEnvironmentVariablesState ), ), ), - kVSpacer40, + if (!kIsMobile) kVSpacer40, ], ), ), - Align( - alignment: Alignment.bottomCenter, - child: Padding( - padding: kPb15, - child: ElevatedButton.icon( - onPressed: () { - variableRows.add(kEnvironmentVariableEmptyModel); - _onFieldChange(selectedId!); - }, - icon: const Icon(Icons.add), - label: const Text( - kLabelAddVariable, - style: kTextStyleButton, + if (!kIsMobile) + Align( + alignment: Alignment.bottomCenter, + child: Padding( + padding: kPb15, + child: ElevatedButton.icon( + onPressed: () { + variableRows.add(kEnvironmentVariableEmptyModel); + _onFieldChange(selectedId!); + }, + icon: const Icon(Icons.add), + label: const Text( + kLabelAddVariable, + style: kTextStyleButton, + ), ), ), ), - ), ], ); } diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_form_data.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_form_data.dart index 56d3d138..c007cc73 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_form_data.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_form_data.dart @@ -185,7 +185,7 @@ class _FormDataBodyState extends ConsumerState { return Stack( children: [ Container( - margin: kP10, + margin: kPh10t10, child: Column( children: [ Expanded( @@ -205,27 +205,28 @@ class _FormDataBodyState extends ConsumerState { ), ), ), - kVSpacer40, + if (!kIsMobile) kVSpacer40, ], ), ), - Align( - alignment: Alignment.bottomCenter, - child: Padding( - padding: kPb15, - child: ElevatedButton.icon( - onPressed: () { - formRows.add(kFormDataEmptyModel); - _onFieldChange(); - }, - icon: const Icon(Icons.add), - label: const Text( - kLabelAddFormField, - style: kTextStyleButton, + if (!kIsMobile) + Align( + alignment: Alignment.bottomCenter, + child: Padding( + padding: kPb15, + child: ElevatedButton.icon( + onPressed: () { + formRows.add(kFormDataEmptyModel); + _onFieldChange(); + }, + icon: const Icon(Icons.add), + label: const Text( + kLabelAddFormField, + style: kTextStyleButton, + ), ), ), ), - ), ], ); } diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart index 658789a0..435346de 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart @@ -178,7 +178,7 @@ class EditRequestHeadersState extends ConsumerState { return Stack( children: [ Container( - margin: kP10, + margin: kPh10t10, child: Column( children: [ Expanded( @@ -198,28 +198,29 @@ class EditRequestHeadersState extends ConsumerState { ), ), ), - kVSpacer40, + if (!kIsMobile) kVSpacer40, ], ), ), - Align( - alignment: Alignment.bottomCenter, - child: Padding( - padding: kPb15, - child: ElevatedButton.icon( - onPressed: () { - headerRows.add(kNameValueEmptyModel); - isRowEnabledList.add(false); - _onFieldChange(); - }, - icon: const Icon(Icons.add), - label: const Text( - kLabelAddHeader, - style: kTextStyleButton, + if (!kIsMobile) + Align( + alignment: Alignment.bottomCenter, + child: Padding( + padding: kPb15, + child: ElevatedButton.icon( + onPressed: () { + headerRows.add(kNameValueEmptyModel); + isRowEnabledList.add(false); + _onFieldChange(); + }, + icon: const Icon(Icons.add), + label: const Text( + kLabelAddHeader, + style: kTextStyleButton, + ), ), ), ), - ), ], ); } diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_params.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_params.dart index a583b183..be752217 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_params.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_params.dart @@ -178,7 +178,7 @@ class EditRequestURLParamsState extends ConsumerState { return Stack( children: [ Container( - margin: kP10, + margin: kPh10t10, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ @@ -199,28 +199,29 @@ class EditRequestURLParamsState extends ConsumerState { ), ), ), - kVSpacer40, + if (!kIsMobile) kVSpacer40, ], ), ), - Align( - alignment: Alignment.bottomCenter, - child: Padding( - padding: kPb15, - child: ElevatedButton.icon( - onPressed: () { - paramRows.add(kNameValueEmptyModel); - isRowEnabledList.add(false); - _onFieldChange(); - }, - icon: const Icon(Icons.add), - label: const Text( - kLabelAddParam, - style: kTextStyleButton, + if (!kIsMobile) + Align( + alignment: Alignment.bottomCenter, + child: Padding( + padding: kPb15, + child: ElevatedButton.icon( + onPressed: () { + paramRows.add(kNameValueEmptyModel); + isRowEnabledList.add(false); + _onFieldChange(); + }, + icon: const Icon(Icons.add), + label: const Text( + kLabelAddParam, + style: kTextStyleButton, + ), ), ), ), - ), ], ); } From 95ed16c061b969141d1172a73183a82033028c90 Mon Sep 17 00:00:00 2001 From: Arshhasan Date: Fri, 16 May 2025 13:11:09 +0530 Subject: [PATCH 11/17] [Mobile] #842 Headers, Params & Form data text fields get clipped towards bottom for longer texts --- lib/screens/common_widgets/envfield_cell.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/screens/common_widgets/envfield_cell.dart b/lib/screens/common_widgets/envfield_cell.dart index ececb8a2..9c93a44b 100644 --- a/lib/screens/common_widgets/envfield_cell.dart +++ b/lib/screens/common_widgets/envfield_cell.dart @@ -37,7 +37,12 @@ class EnvCellField extends StatelessWidget { decoration: getTextFieldInputDecoration( clrScheme, hintText: hintText, + isDense: true, + // contentPadding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), + contentPadding: const EdgeInsets.symmetric(vertical: 9.0, horizontal: 10.0), + ), + autocompleteNoTrigger: autocompleteNoTrigger, onChanged: onChanged, ); From 89cbf8312b5066402f4f671ec7c5344a975a60a7 Mon Sep 17 00:00:00 2001 From: Arshhasan Date: Fri, 16 May 2025 13:13:07 +0530 Subject: [PATCH 12/17] [Mobile] #842 Headers, Params & Form data text fields get clipped towards bottom for longer texts --- lib/screens/common_widgets/envfield_cell.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/screens/common_widgets/envfield_cell.dart b/lib/screens/common_widgets/envfield_cell.dart index 9c93a44b..524ee4af 100644 --- a/lib/screens/common_widgets/envfield_cell.dart +++ b/lib/screens/common_widgets/envfield_cell.dart @@ -38,7 +38,6 @@ class EnvCellField extends StatelessWidget { clrScheme, hintText: hintText, isDense: true, - // contentPadding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), contentPadding: const EdgeInsets.symmetric(vertical: 9.0, horizontal: 10.0), ), From 6ec2b1d273bf13cef880ba9431edee72b1cee959 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Sat, 17 May 2025 04:13:55 +0530 Subject: [PATCH 13/17] Update padding fix --- lib/screens/common_widgets/envfield_cell.dart | 5 ++--- packages/apidash_design_system/lib/tokens/measurements.dart | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/screens/common_widgets/envfield_cell.dart b/lib/screens/common_widgets/envfield_cell.dart index 524ee4af..ef9e603b 100644 --- a/lib/screens/common_widgets/envfield_cell.dart +++ b/lib/screens/common_widgets/envfield_cell.dart @@ -1,3 +1,4 @@ +import 'package:apidash/consts.dart'; import 'package:apidash_design_system/apidash_design_system.dart'; import 'package:flutter/material.dart'; import 'package:multi_trigger_autocomplete_plus/multi_trigger_autocomplete_plus.dart'; @@ -38,10 +39,8 @@ class EnvCellField extends StatelessWidget { clrScheme, hintText: hintText, isDense: true, - contentPadding: const EdgeInsets.symmetric(vertical: 9.0, horizontal: 10.0), - + contentPadding: kIsMobile ? kPh6b12 : null, ), - autocompleteNoTrigger: autocompleteNoTrigger, onChanged: onChanged, ); diff --git a/packages/apidash_design_system/lib/tokens/measurements.dart b/packages/apidash_design_system/lib/tokens/measurements.dart index 4d0e12a2..b06a9ce9 100644 --- a/packages/apidash_design_system/lib/tokens/measurements.dart +++ b/packages/apidash_design_system/lib/tokens/measurements.dart @@ -64,6 +64,11 @@ const kPs0o6 = EdgeInsets.only( right: 6, bottom: 6, ); +const kPh6b12 = EdgeInsets.only( + left: 6.0, + right: 6.0, + bottom: 12.0, +); const kPh60 = EdgeInsets.symmetric(horizontal: 60); const kPh60v60 = EdgeInsets.symmetric(vertical: 60, horizontal: 60); const kPt24l4 = EdgeInsets.only( From 4473bce00363a69d5c5cc47a15c7ae2b4169bb15 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Sat, 17 May 2025 16:48:25 +0530 Subject: [PATCH 14/17] Update explain.dart --- lib/dashbot/features/explain.dart | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/dashbot/features/explain.dart b/lib/dashbot/features/explain.dart index 4b008e6c..74e30248 100644 --- a/lib/dashbot/features/explain.dart +++ b/lib/dashbot/features/explain.dart @@ -1,4 +1,3 @@ -import 'dart:convert'; import '../services/dashbot_service.dart'; import 'package:apidash/models/request_model.dart'; @@ -19,20 +18,14 @@ class ExplainFeature { return "Error: Invalid API request (missing endpoint)."; } - final method = requestModel.httpRequestModel?.method - .toString() - .split('.') - .last - .toUpperCase() ?? - "GET"; - final endpoint = requestModel.httpRequestModel!.url; + final method = + requestModel.httpRequestModel?.method.name.toUpperCase() ?? "GET"; + final url = requestModel.httpRequestModel!.url; final headers = requestModel.httpRequestModel?.enabledHeadersMap ?? {}; final parameters = requestModel.httpRequestModel?.enabledParamsMap ?? {}; - final body = requestModel.httpRequestModel?.body; - final rawResponse = responseModel.body; - final responseBody = - rawResponse is String ? rawResponse : jsonEncode(rawResponse); - final statusCode = responseModel.statusCode ?? 0; + final body = requestModel.httpRequestModel?.body ?? ''; + final responseBody = responseModel.body; + final statusCode = responseModel.statusCode; final prompt = ''' FOCUSED API INTERACTION BREAKDOWN @@ -41,10 +34,16 @@ FOCUSED API INTERACTION BREAKDOWN - Endpoint Purpose: What is this API endpoint designed to do? - Interaction Type: Describe the core purpose of this specific request -**Request Mechanics:** -- Exact Endpoint: $endpoint +**Request Details:** +- Endpoint: $url - HTTP Method: $method -- Key Parameters: ${parameters.isNotEmpty ? 'Specific inputs driving the request' : 'No custom parameters'} +- Request Headers: ${headers.isEmpty ? "None" : headers} +- URL Parameters: ${parameters.isEmpty ? "None" : parameters} +- Request Body: ${body.isEmpty ? "None" : body} + +**Response Details** +- Status Code: $statusCode +- Content: $responseBody **Response CORE Insights:** - Status: Success or Failure? From b3b3127c55378ebb694d0be541ee65f95090bf5d Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Sat, 17 May 2025 16:56:53 +0530 Subject: [PATCH 15/17] Update settings_model.dart --- lib/models/settings_model.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/models/settings_model.dart b/lib/models/settings_model.dart index 74bc2ff9..a06b1e59 100644 --- a/lib/models/settings_model.dart +++ b/lib/models/settings_model.dart @@ -17,6 +17,7 @@ class SettingsModel { this.historyRetentionPeriod = HistoryRetentionPeriod.oneWeek, this.workspaceFolderPath, this.isSSLDisabled = false, + this.isDashBotEnabled = true, }); final bool isDark; @@ -31,6 +32,7 @@ class SettingsModel { final HistoryRetentionPeriod historyRetentionPeriod; final String? workspaceFolderPath; final bool isSSLDisabled; + final bool isDashBotEnabled; SettingsModel copyWith({ bool? isDark, @@ -45,6 +47,7 @@ class SettingsModel { HistoryRetentionPeriod? historyRetentionPeriod, String? workspaceFolderPath, bool? isSSLDisabled, + bool? isDashBotEnabled, }) { return SettingsModel( isDark: isDark ?? this.isDark, @@ -61,6 +64,7 @@ class SettingsModel { historyRetentionPeriod ?? this.historyRetentionPeriod, workspaceFolderPath: workspaceFolderPath ?? this.workspaceFolderPath, isSSLDisabled: isSSLDisabled ?? this.isSSLDisabled, + isDashBotEnabled: isDashBotEnabled ?? this.isDashBotEnabled, ); } @@ -80,6 +84,7 @@ class SettingsModel { historyRetentionPeriod: historyRetentionPeriod, workspaceFolderPath: workspaceFolderPath, isSSLDisabled: isSSLDisabled, + isDashBotEnabled: isDashBotEnabled, ); } @@ -134,6 +139,7 @@ class SettingsModel { } final workspaceFolderPath = data["workspaceFolderPath"] as String?; final isSSLDisabled = data["isSSLDisabled"] as bool?; + final isDashBotEnabled = data["isDashBotEnabled"] as bool?; const sm = SettingsModel(); @@ -151,6 +157,7 @@ class SettingsModel { historyRetentionPeriod ?? HistoryRetentionPeriod.oneWeek, workspaceFolderPath: workspaceFolderPath, isSSLDisabled: isSSLDisabled, + isDashBotEnabled: isDashBotEnabled, ); } @@ -170,6 +177,7 @@ class SettingsModel { "historyRetentionPeriod": historyRetentionPeriod.name, "workspaceFolderPath": workspaceFolderPath, "isSSLDisabled": isSSLDisabled, + "isDashBotEnabled": isDashBotEnabled, }; } @@ -194,7 +202,8 @@ class SettingsModel { other.activeEnvironmentId == activeEnvironmentId && other.historyRetentionPeriod == historyRetentionPeriod && other.workspaceFolderPath == workspaceFolderPath && - other.isSSLDisabled == isSSLDisabled; + other.isSSLDisabled == isSSLDisabled && + other.isDashBotEnabled == isDashBotEnabled; } @override @@ -213,6 +222,7 @@ class SettingsModel { historyRetentionPeriod, workspaceFolderPath, isSSLDisabled, + isDashBotEnabled, ); } } From 6e638bb3836f122f55519ad77880468b443d7359 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Sat, 17 May 2025 16:57:16 +0530 Subject: [PATCH 16/17] Add DashBot to settings --- lib/providers/settings_providers.dart | 2 ++ lib/screens/settings_page.dart | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/providers/settings_providers.dart b/lib/providers/settings_providers.dart index 6b64343a..d3cb9f2f 100644 --- a/lib/providers/settings_providers.dart +++ b/lib/providers/settings_providers.dart @@ -33,6 +33,7 @@ class ThemeStateNotifier extends StateNotifier { HistoryRetentionPeriod? historyRetentionPeriod, String? workspaceFolderPath, bool? isSSLDisabled, + bool? isDashBotEnabled, }) async { state = state.copyWith( isDark: isDark, @@ -47,6 +48,7 @@ class ThemeStateNotifier extends StateNotifier { historyRetentionPeriod: historyRetentionPeriod, workspaceFolderPath: workspaceFolderPath, isSSLDisabled: isSSLDisabled, + isDashBotEnabled: isDashBotEnabled, ); await setSettingsToSharedPrefs(state); } diff --git a/lib/screens/settings_page.dart b/lib/screens/settings_page.dart index 28305cd0..606ef516 100644 --- a/lib/screens/settings_page.dart +++ b/lib/screens/settings_page.dart @@ -50,6 +50,18 @@ class SettingsPage extends ConsumerWidget { ref.read(settingsProvider.notifier).update(isDark: value); }, ), + ADListTile( + type: ListTileType.switchOnOff, + title: 'DashBot', + subtitle: + 'Current selection: ${settings.isDashBotEnabled ? "Enabled" : "Disabled"}', + value: settings.isDashBotEnabled, + onChanged: (bool? value) { + ref + .read(settingsProvider.notifier) + .update(isDashBotEnabled: value); + }, + ), ADListTile( type: ListTileType.switchOnOff, title: 'Collection Pane Scrollbar Visiblity', From cff39c12e51318d518e75d3de418e0243bbeb63c Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Sat, 17 May 2025 17:02:26 +0530 Subject: [PATCH 17/17] Update dashboard.dart --- lib/screens/dashboard.dart | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index 428ffaeb..29bb7907 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -17,6 +17,7 @@ class Dashboard extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final railIdx = ref.watch(navRailIndexStateProvider); + final settings = ref.watch(settingsProvider); return Scaffold( body: SafeArea( child: Row( @@ -125,18 +126,19 @@ class Dashboard extends ConsumerWidget { ], ), ), - // TODO: Release DashBot - // floatingActionButton: FloatingActionButton( - // onPressed: () => showModalBottomSheet( - // context: context, - // isScrollControlled: true, - // builder: (context) => const Padding( - // padding: EdgeInsets.all(16.0), - // child: DashBotWidget(), - // ), - // ), - // child: const Icon(Icons.help_outline), - // ), + floatingActionButton: settings.isDashBotEnabled + ? FloatingActionButton( + onPressed: () => showModalBottomSheet( + context: context, + isScrollControlled: true, + builder: (context) => const Padding( + padding: EdgeInsets.all(16.0), + child: DashBotWidget(), + ), + ), + child: const Icon(Icons.help_outline), + ) + : null, ); } }