Skip to content

PoC GSOC API Testing Suite - Abhinav Sharma #827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 188 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
6b981b3
chore: implement functions for fake data generation
abhinavs1920 Apr 6, 2025
358019d
chore: create pane for fake data access and guide
abhinavs1920 Apr 6, 2025
94c72ae
chore: edit env utils and ui to implement fake data providers
abhinavs1920 Apr 6, 2025
cdc7391
fix: variable hovering shows random generated value
abhinavs1920 Apr 6, 2025
8ac9cb5
chore: remove additional check for variable hovering
abhinavs1920 Apr 6, 2025
54dc094
Manas Hejmadi's GSoC'25 Application (Initial Version)
synapsecode Apr 1, 2025
f85189f
Added ToolGen, SDUI & Increased Timeline
synapsecode Apr 4, 2025
0bbd09d
Create Application_K_Govind_API_Support.md
Clasherzz Mar 31, 2025
5a561de
Add files via upload
Clasherzz Mar 31, 2025
26da974
Delete doc/proposals/2025/gsoc/images/Screenshot (2).png
Clasherzz Mar 31, 2025
b618449
Delete doc/proposals/2025/gsoc/images/Screenshot (1).png
Clasherzz Mar 31, 2025
6f45243
Add files via upload
Clasherzz Mar 31, 2025
af60b82
Update Application_K_Govind_API_Support.md
Clasherzz Mar 31, 2025
70ea4bf
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
eab65ad
Update Application_K_Govind_API_Support.md with graphql
Clasherzz Apr 1, 2025
ad5a3f3
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
3459e31
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
83b0d3d
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
c83b602
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
5110097
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
e05797f
Rename Screenshot 2025-04-01 031655.png to SSE(1).png
Clasherzz Apr 1, 2025
fdd83aa
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
7addbf8
Rename Screenshot 2025-04-01 031809.png to SSE(2).png
Clasherzz Apr 1, 2025
4a392c2
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
4043a79
Add files via upload
Clasherzz Apr 1, 2025
63c72ed
Rename Screenshot 2025-04-01 095628.png to websocket(1).png
Clasherzz Apr 1, 2025
cdc1758
Rename Screenshot 2025-04-01 095640.png to websocket(2).png
Clasherzz Apr 1, 2025
33fafde
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
0e75a6f
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
866e249
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
62a0cb5
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
4d7e4ea
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
9527052
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
ff9b7bf
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
eb40bbb
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
e5e7a8c
Update Application_K_Govind_API_Support.md
Clasherzz Apr 1, 2025
ed7b35e
Update Application_K_Govind_API_Support.md
Clasherzz Apr 4, 2025
128d243
Update Application_K_Govind_API_Support.md
Clasherzz Apr 4, 2025
bf6f098
Update Application_K_Govind_API_Support.md
Clasherzz Apr 4, 2025
efad455
Update Application_K_Govind_API_Support.md
Clasherzz Apr 4, 2025
eadd008
Update Application_K_Govind_API_Support.md
Clasherzz Apr 4, 2025
aaca77a
Update Application_K_Govind_API_Support.md
Clasherzz Apr 4, 2025
1fad51b
Update Application_K_Govind_API_Support.md
Clasherzz Apr 4, 2025
3a82284
Initial GSoC 2025 Proposal: AI UI Designer by Shree Meher
s-meher Apr 3, 2025
8afc1ec
Update application_ShreeMeher_AI-UI-Designer.md
s-meher Apr 4, 2025
58cfa14
Gsoc Proposal application_AmanGupta_dahbot.md
Aman071106 Apr 4, 2025
80f6c42
Update application_AmanGupta_dahbot.md
animator Apr 4, 2025
b2c833f
Rename application_AmanGupta_dahbot.md to application_AmanGupta_dashb…
animator Apr 4, 2025
1b32a4f
Minor Updates to Proposal
synapsecode Apr 5, 2025
1b106e6
Added Local Images to Proposal + Timeline Changes
synapsecode Apr 5, 2025
e50dbe2
add dashbot application
Udhay-Adithya Mar 28, 2025
77bd54a
add mvvm folder structure
Udhay-Adithya Mar 28, 2025
ccb1a85
improve proposal based on mentor feedback
Udhay-Adithya Mar 29, 2025
b3afe69
fix: correct typos and enhance clarity
Udhay-Adithya Mar 30, 2025
4798954
update title and add more details in weekly timeline
Udhay-Adithya Apr 4, 2025
fcd43fa
dedicate a week for oauth
Udhay-Adithya Apr 5, 2025
5be5c66
Create application_nideesh_bharath_kumar_ai_api_evaluator.md
nb923 Mar 25, 2025
38b245d
Update application_nideesh_bharath_kumar_ai_api_evaluator.md to suppo…
nb923 Mar 25, 2025
f4eb5f1
Add phone number to application
nb923 Mar 30, 2025
347a19a
share response body in Mobile
animator Apr 5, 2025
40ebd3f
Refactor response widgets
animator Apr 5, 2025
52d7220
Copy button for JSON & CSV previewer
animator Apr 5, 2025
7d7b131
Update previewer_json.dart
animator Apr 5, 2025
56a4b09
Update app.dart
animator Apr 5, 2025
fdf21fc
Fix mobile app rebuilding issue
animator Apr 5, 2025
bf61134
Refactor JSON Previewer buttons
animator Apr 5, 2025
1d25c39
Fixes #644
animator Apr 5, 2025
40d27b3
docs: add missing details from previous PR
Udhay-Adithya Apr 6, 2025
6fa2c4b
Added shortcut key "ctrl + s" for saving projects on the go.
Rupamthxt Nov 7, 2024
101566b
update save data
ashitaprasad Nov 10, 2024
9cb1c03
Implemented Save Shortcut.
Rupamthxt Nov 11, 2024
399a0f4
Update
Rupamthxt Nov 12, 2024
bdc67ac
Update dashboard.dart
animator Apr 6, 2025
ace377d
update
animator Apr 6, 2025
4e77af7
Update Application_K_Govind_API_Support.md
Clasherzz Apr 6, 2025
ee202a1
[ADD]: GSOC Proposal
Loghadhith Apr 6, 2025
ef1bbb2
Update application_Loghadhith_Dashbot.md
Loghadhith Apr 6, 2025
529cc93
Update application_Loghadhith_Dashbot.md
Loghadhith Apr 6, 2025
bd1b8fe
feat: add stress test config model
abhinavs1920 Mar 28, 2025
27574f8
feat: add api request result model
abhinavs1920 Mar 28, 2025
530d979
feat: add isolate model for stress test
abhinavs1920 Mar 28, 2025
8f22386
feat: add stress test summer model
abhinavs1920 Mar 28, 2025
4c5dc91
chore: create stress test models file for export
abhinavs1920 Mar 28, 2025
de88a43
chore: create stress test service with isolates and future.wait()
abhinavs1920 Mar 28, 2025
bd1ba64
chore: create input field and result card widget for stress testing
abhinavs1920 Mar 28, 2025
22dcb3c
chore: update stress test service for handling timeout exceptions
abhinavs1920 Mar 29, 2025
7f3f27c
chore: create request details card
abhinavs1920 Mar 29, 2025
9243e37
feat: implement stress testing in the UI
abhinavs1920 Mar 29, 2025
3499341
chore: add label for stress testing in consts.dart
abhinavs1920 Mar 29, 2025
d8e5807
chore: implement the stress test UI in request pane
abhinavs1920 Mar 29, 2025
97ca55c
feat: add stress test config model
abhinavs1920 Mar 28, 2025
df7d747
feat: add api request result model
abhinavs1920 Mar 28, 2025
779e7e9
feat: add isolate model for stress test
abhinavs1920 Mar 28, 2025
d22d5a2
feat: add stress test summer model
abhinavs1920 Mar 28, 2025
8f54f7a
chore: implement the stress test UI in request pane
abhinavs1920 Mar 29, 2025
eba2b0a
feat: add stress test config model
abhinavs1920 Mar 28, 2025
103c73b
feat: add api request result model
abhinavs1920 Mar 28, 2025
18a94ea
feat: add isolate model for stress test
abhinavs1920 Mar 28, 2025
cb2eb56
feat: add stress test summer model
abhinavs1920 Mar 28, 2025
0c2442d
chore: implement the stress test UI in request pane
abhinavs1920 Mar 29, 2025
8e7c98a
feat: add stress test config model
abhinavs1920 Mar 28, 2025
9767d88
feat: add api request result model
abhinavs1920 Mar 28, 2025
a8e4ef9
feat: add isolate model for stress test
abhinavs1920 Mar 28, 2025
6b8c798
feat: add stress test summer model
abhinavs1920 Mar 28, 2025
1eea21a
chore: implement the stress test UI in request pane
abhinavs1920 Mar 29, 2025
60551c2
chore: create and design models workflow model
abhinavs1920 Apr 8, 2025
d985ad7
chore: implement notifier and provider for workflow builder
abhinavs1920 Apr 8, 2025
83599d2
chore: export providers
abhinavs1920 Apr 8, 2025
0104224
chore: export api_testing_suite package implementation
abhinavs1920 Apr 8, 2025
e6d3a63
chore: create widgets for workflow builder (canvas, node, connection,…
abhinavs1920 Apr 8, 2025
8201561
chore: export workflow widgets
abhinavs1920 Apr 8, 2025
3b8202c
refactor: add package in pubspec
abhinavs1920 Apr 8, 2025
e96600e
chore: remove workflow builder components (page, canvas, node, connec…
abhinavs1920 Apr 10, 2025
006b98b
refactor: update WorkflowConnectionModel to include workflowId and po…
abhinavs1920 Apr 10, 2025
17ab7eb
feat: add WorkflowConnection model with connection types and factory …
abhinavs1920 Apr 10, 2025
bca30e7
refactor: update WorkflowModel to require name, nodes, and connection…
abhinavs1920 Apr 10, 2025
c16e056
feat: add WorkflowExecutionState model and WorkflowNodeModel enhancem…
abhinavs1920 Apr 10, 2025
65a82aa
refactor: reorder NodeStatus enum values and update extension for col…
abhinavs1920 Apr 10, 2025
382de99
fix: remove error giving fucntion (TODO: Resolving is required)
abhinavs1920 Apr 10, 2025
5d61efd
refactor: enhance add method in WorkflowsNotifier and comment out rem…
abhinavs1920 Apr 10, 2025
a550dbb
feat: add WorkflowBuilderPage, WorkflowCanvas, WorkflowNodeWidget, an…
abhinavs1920 Apr 10, 2025
c95e061
feat: implement WorkflowsNotifier with methods for managing workflows…
abhinavs1920 Apr 10, 2025
acaf93a
feat: add NodeStatus enum with label and color getters for workflow m…
abhinavs1920 Apr 10, 2025
691374c
feat: add initial tests for WorkflowCanvas and WorkflowNode rendering…
abhinavs1920 Apr 10, 2025
28cebf8
feat: add StressTestConfig and StressTestSummary models for stress te…
abhinavs1920 Apr 10, 2025
a393075
feat: add ApiRequestResult and IsolateMessage models for stress testi…
abhinavs1920 Apr 10, 2025
8cfce62
feat: enhance StressTestSummary with response time metrics and succes…
abhinavs1920 Apr 10, 2025
8f549cb
feat: add stress test models exports for configuration, request resul…
abhinavs1920 Apr 10, 2025
43fd884
feat: implement StressTestService for executing parallel API tests wi…
abhinavs1920 Apr 10, 2025
2123922
feat: add StressTestResultCard widget for displaying stress test resu…
abhinavs1920 Apr 10, 2025
547e287
feat: add FakeDataConfig model for managing fake data configuration
abhinavs1920 Apr 10, 2025
e0ded6e
feat: implement FakeDataProvider for generating various fake data typ…
abhinavs1920 Apr 10, 2025
0809b61
feat: add FakeDataProvidersPane widget for displaying and managing fa…
abhinavs1920 Apr 10, 2025
c70a016
feat: add WorkflowBuilderPage to dashboard and update navigation index
abhinavs1920 Apr 10, 2025
881a571
fix: update export paths for workflow builder widgets and reorganize …
abhinavs1920 Apr 10, 2025
b339f6e
refactor: add all the models inside workflow_builder which were in mo…
abhinavs1920 Apr 11, 2025
922a001
refactor: change WorkflowBuilder to dashboard in place of WorkflowBui…
abhinavs1920 Apr 14, 2025
da20e02
refactor: remove unused import for fake_data_pane in environment_edit…
abhinavs1920 Apr 14, 2025
f905494
feat: add depen's in pubspec.yaml for API Testing Suite
abhinavs1920 Apr 14, 2025
1810d3b
refactor: remove unused import and clean up whitespace in fake_data_p…
abhinavs1920 Apr 14, 2025
88ddf99
refactor: improve code formatting and readability in stress_test_resu…
abhinavs1920 Apr 14, 2025
e453d36
feat: add ConnectionPainter and DagExecutionEngine for workflow visua…
abhinavs1920 Apr 14, 2025
163ac1a
refactor: add workflow providers and notifier for workflow management…
abhinavs1920 Apr 14, 2025
f85e17d
Refactor WorkflowCanvas and related components for improved node mana…
abhinavs1920 Apr 14, 2025
88b8ca4
feat: add LogsViewer and NodeDetailsPanel widgets for enhanced workfl…
abhinavs1920 Apr 14, 2025
67ecba0
feat: enhance workflow execution state management and logging capabil…
abhinavs1920 Apr 14, 2025
7d93e36
feat: reorganize exports and enhance RequestModel with copyWith method
abhinavs1920 Apr 14, 2025
f57299a
fix: remove duplicate import and correct WorkflowBuilder return widget
abhinavs1920 Apr 18, 2025
f76ebff
feat: add reusable widgets for improved UI components including Dragg…
abhinavs1920 Apr 18, 2025
ef27eb4
feat: refactor ConnectionPainter and GridBackgroundPainter for improv…
abhinavs1920 Apr 18, 2025
1ef2cf3
Remove WorkflowBuilderPage and WorkflowCanvas implementations to stre…
abhinavs1920 Apr 18, 2025
a48aa53
feat: add LogEntry and WorkflowLogEntry models with logging functiona…
abhinavs1920 Apr 18, 2025
b7f0899
feat: implement canvas components including connection layer, control…
abhinavs1920 Apr 18, 2025
654997c
refactor: edit components for the new canvas files
abhinavs1920 Apr 18, 2025
8944c0d
feat: implement WorkflowExecutor with execution commands
abhinavs1920 Apr 18, 2025
6ba3d17
refactor: move workflow providers to workflow_builder\providers
abhinavs1920 Apr 18, 2025
ba2147a
refactor: workflow builder components
abhinavs1920 Apr 18, 2025
54edf2b
refactor: update workflows notifier and file structure
abhinavs1920 Apr 18, 2025
e37d9db
refactor: remove direct exports of workflows_notifier and workflow_pr…
abhinavs1920 Apr 18, 2025
54ca85e
refactor: remove unused workflow components and clean up exports
abhinavs1920 Apr 18, 2025
3f3be60
refactor: remove unused stress test models and related widgets and co…
abhinavs1920 Apr 19, 2025
f8ac1ca
refactor: clean up workflow builder exports and remove unused workflo…
abhinavs1920 Apr 19, 2025
f2fdd1a
refactor: add fake data provider and stress test files with exports
abhinavs1920 Apr 19, 2025
b4f6269
refactor: update api_testing_suite.dart
abhinavs1920 Apr 19, 2025
5c9c35d
refactor: remove unused stress test service file
abhinavs1920 Apr 19, 2025
d42ebad
docs: add initial README.md for API Testing Suite documentation
abhinavs1920 Apr 19, 2025
dccc4a9
refactor: streamline processFakeDataTag method using a registry for t…
abhinavs1920 Apr 19, 2025
a1f5ab5
fix: remove opacity(deprecated)
abhinavs1920 Apr 19, 2025
4aacea7
refactor: implement IsolateWorker and RequestExecutor for handling AP…
abhinavs1920 Apr 20, 2025
237c199
refactor: update FakeDataProvidersPane to dynamically fetch fake data…
abhinavs1920 Apr 20, 2025
5a436f2
feat: add result card components for displaying stress test metrics a…
abhinavs1920 Apr 20, 2025
5cc3af5
refactor: clean debug prints
abhinavs1920 Apr 20, 2025
7aef727
refactor: extract method badge styles into CanvasStyles class
abhinavs1920 Apr 20, 2025
223fd10
refactor: streamline error handling in StressTestService by using _ha…
abhinavs1920 Apr 20, 2025
0d50504
refactor: update import statements and use firstWhereOrNull for safer…
abhinavs1920 Apr 20, 2025
7a6de0b
refactor: enhance createdAt getter to handle various date formats in …
abhinavs1920 Apr 20, 2025
a8e3415
refactor: add StressTestConstants for timeout values and add CanvasUI…
abhinavs1920 Apr 20, 2025
b8a5d73
refactor: improve error handling by using StateError for not found wo…
abhinavs1920 Apr 20, 2025
96e955a
refactor: add isolate communication by consolidating receive ports an…
abhinavs1920 Apr 20, 2025
c56f590
refactor: make StressTestConfig to include request-specific fields an…
abhinavs1920 Apr 20, 2025
6b463d3
refactor: update WorkflowModel to initialize createdAt and improve er…
abhinavs1920 Apr 21, 2025
ff5205b
feat: add ApiTestLogger for centralized logging in the API testing suite
abhinavs1920 Apr 21, 2025
82a67b3
refactor: update CanvasStyles and add WorkflowExecutionConstants
abhinavs1920 Apr 21, 2025
4553cc6
feat: add centralized ErrorHandler for consistent error handling in A…
abhinavs1920 Apr 21, 2025
65ba660
refactor: update StressTestService for improved isolate handling and …
abhinavs1920 Apr 21, 2025
6b60744
refactor: update error handling and logging in canvas event handlers …
abhinavs1920 Apr 21, 2025
0c5d0a3
feat: add FakeDataConstants for centralized fake data generation cons…
abhinavs1920 Apr 21, 2025
e46f5a4
refactor: update envvar_utils
abhinavs1920 Apr 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/proposals/2025/gsoc/application_udhay_adithya_dashbot.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ This milestone will involve running benchmark evaluations for all LLM providers

#### **Milestone #4: API Authentication Methods**

This milestone will add a new tab "Authorization" in the home page of API Dash where users can perform various API Authentication Methods such as,
This milestone will a new section in the home page of API Dash "Authorization" where users can perform various API Authentication Methods such as,
- Basic authentication
- API Auth
- API key
- Bearer token
- JWT Bearer
- Digest Auth
- OAuth 1.0
- OAuth 2.0
- OAuth 2.0.

## **[GSOC 2025 TIMELINE](https://developers.google.com/open-source/gsoc/timeline) FOR REFERENCE**

Expand Down
23 changes: 23 additions & 0 deletions lib/api_testing/api_testing_integration.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:api_testing_suite/api_testing_suite.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

final workflowCollectionProvider = Provider<Map<String, dynamic>>((ref) {
//It is usable when collections are implemented in the future.
//For now, we return an empty map to avoid errors.
return {};
});

/// WorkflowBuilderPagePage that uses the implementation from api_testing_suite
class WorkflowBuilder extends StatelessWidget {
const WorkflowBuilder({super.key});

@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: WorkflowBuilderScreen(),
),
);
}
}
1 change: 1 addition & 0 deletions lib/consts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ const kLabelViewCode = "View Code";
const kLabelURLParams = "URL Params";
const kLabelHeaders = "Headers";
const kLabelBody = "Body";
const kLabelStressTest = 'Stress Test';
const kLabelQuery = "Query";
const kNameCheckbox = "Checkbox";
const kNameURLParam = "URL Parameter";
Expand Down
8 changes: 5 additions & 3 deletions lib/screens/common_widgets/envvar_span.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ class EnvVarSpan extends HookConsumerWidget {
final showPopover = useState(false);

final isMissingVariable = suggestion.isUnknown;
final String scope = isMissingVariable
? 'unknown'
: getEnvironmentTitle(environments?[suggestion.environmentId]?.name);
final String scope = suggestion.environmentId == "Random"
? "Random"
: isMissingVariable
? 'unknown'
: getEnvironmentTitle(environments?[suggestion.environmentId]?.name);
final colorScheme = Theme.of(context).colorScheme;

var text = Text(
Expand Down
17 changes: 16 additions & 1 deletion lib/screens/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'envvar/environment_page.dart';
import 'home_page/home_page.dart';
import 'history/history_page.dart';
import 'settings_page.dart';
import 'package:apidash/api_testing/api_testing_integration.dart';

class Dashboard extends ConsumerWidget {
const Dashboard({super.key});
Expand Down Expand Up @@ -68,6 +69,19 @@ class Dashboard extends ConsumerWidget {
'History',
style: Theme.of(context).textTheme.labelSmall,
),
kVSpacer10,
IconButton(
isSelected: railIdx == 3,
onPressed: () {
ref.read(navRailIndexStateProvider.notifier).state = 3;
},
icon: const Icon(Icons.account_tree_outlined),
selectedIcon: const Icon(Icons.account_tree),
),
Text(
'Workflows',
style: Theme.of(context).textTheme.labelSmall,
),
],
),
Expanded(
Expand All @@ -92,7 +106,7 @@ class Dashboard extends ConsumerWidget {
padding: const EdgeInsets.only(bottom: 16.0),
child: NavbarButton(
railIdx: railIdx,
buttonIdx: 3,
buttonIdx: 4,
selectedIcon: Icons.settings,
icon: Icons.settings_outlined,
label: 'Settings',
Expand All @@ -118,6 +132,7 @@ class Dashboard extends ConsumerWidget {
HomePage(),
EnvironmentPage(),
HistoryPage(),
WorkflowBuilder(),
SettingsPage(),
],
),
Expand Down
90 changes: 75 additions & 15 deletions lib/screens/envvar/environment_editor.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:api_testing_suite/api_testing_suite.dart';
import 'package:apidash_design_system/apidash_design_system.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
Expand All @@ -7,9 +8,79 @@ import 'package:apidash/consts.dart';
import '../common_widgets/common_widgets.dart';
import './editor_pane/variables_pane.dart';

final environmentEditorTabProvider = StateProvider<int>((ref) => 0);

class EnvironmentEditor extends ConsumerWidget {
const EnvironmentEditor({super.key});

Widget _buildTabBar(BuildContext context, WidgetRef ref) {
final selectedTab = ref.watch(environmentEditorTabProvider);

return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildTabButton(
context,
'Environment Variables',
0,
selectedTab == 0,
() => ref.read(environmentEditorTabProvider.notifier).state = 0,
),
const SizedBox(width: 16),
_buildTabButton(
context,
'Fake Data Providers',
1,
selectedTab == 1,
() => ref.read(environmentEditorTabProvider.notifier).state = 1,
),
],
);
}

Widget _buildTabButton(BuildContext context, String title, int index, bool isSelected, VoidCallback onPressed) {
return ElevatedButton(
onPressed: onPressed,
style: ElevatedButton.styleFrom(
backgroundColor: isSelected
? Theme.of(context).colorScheme.primaryContainer
: Theme.of(context).colorScheme.surfaceContainerLow,
foregroundColor: isSelected
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.onSurface,
elevation: 0,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
),
child: Text(title),
);
}

Widget _buildTabContent(WidgetRef ref) {
final selectedTab = ref.watch(environmentEditorTabProvider);

if (selectedTab == 0) {
return Column(
children: [
const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(width: 30),
Text("Variable"),
SizedBox(width: 30),
Text("Value"),
SizedBox(width: 40),
],
),
kHSpacer40,
const Divider(),
const Expanded(child: EditEnvironmentVariables()),
],
);
} else {
return const FakeDataProvidersPane();
}
}

@override
Widget build(BuildContext context, WidgetRef ref) {
final id = ref.watch(selectedEnvironmentIdStateProvider);
Expand Down Expand Up @@ -84,24 +155,13 @@ class EnvironmentEditor extends ConsumerWidget {
borderRadius: kBorderRadius12,
),
elevation: 0,
child: const Padding(
child: Padding(
padding: kPv6,
child: Column(
children: [
kHSpacer40,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(width: 30),
Text("Variable"),
SizedBox(width: 30),
Text("Value"),
SizedBox(width: 40),
],
),
kHSpacer40,
Divider(),
Expanded(child: EditEnvironmentVariables())
_buildTabBar(context, ref),
kHSpacer20,
Expanded(child: _buildTabContent(ref))
],
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:apidash/widgets/widgets.dart';
import 'request_headers.dart';
import 'request_params.dart';
import 'request_body.dart';
import 'request_stress_test.dart';

class EditRestRequestPane extends ConsumerWidget {
const EditRestRequestPane({super.key});
Expand Down Expand Up @@ -44,16 +45,19 @@ class EditRestRequestPane extends ConsumerWidget {
paramLength > 0,
headerLength > 0,
hasBody,
false, //default false
],
tabLabels: const [
kLabelURLParams,
kLabelHeaders,
kLabelBody,
kLabelStressTest, // label from consts.dart
],
children: const [
EditRequestURLParams(),
EditRequestHeaders(),
EditRequestBody(),
children: [
const EditRequestURLParams(),
const EditRequestHeaders(),
const EditRequestBody(),
const RequestStressTestPane(),
],
);
}
Expand Down
Loading