diff --git a/app/lib/pages/apps/providers/add_app_provider.dart b/app/lib/pages/apps/providers/add_app_provider.dart index 0b76b1591..50a07efb2 100644 --- a/app/lib/pages/apps/providers/add_app_provider.dart +++ b/app/lib/pages/apps/providers/add_app_provider.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; @@ -29,6 +30,7 @@ class AddAppProvider extends ChangeNotifier { TextEditingController webhookUrlController = TextEditingController(); TextEditingController setupCompletedController = TextEditingController(); TextEditingController instructionsController = TextEditingController(); + TextEditingController authUrlController = TextEditingController(); bool termsAgreed = false; @@ -124,6 +126,7 @@ class AddAppProvider extends ChangeNotifier { webhookUrlController.clear(); setupCompletedController.clear(); instructionsController.clear(); + authUrlController.clear(); termsAgreed = false; makeAppPublic = false; appCategory = null; @@ -271,7 +274,15 @@ class AddAppProvider extends ChangeNotifier { 'webhook_url': webhookUrlController.text, 'setup_completed_url': setupCompletedController.text, 'setup_instructions_file_path': instructionsController.text, + 'auth_steps': [], }; + if (authUrlController.text.isNotEmpty) { + data['external_integration']['auth_steps'] = []; + data['external_integration']['auth_steps'].add({ + 'url': authUrlController.text, + 'name': 'Setup ${appNameController.text}', + }); + } } if (capability.id == 'chat') { data['chat_prompt'] = chatPromptController.text; @@ -319,7 +330,15 @@ class AddAppProvider extends ChangeNotifier { 'webhook_url': webhookUrlController.text, 'setup_completed_url': setupCompletedController.text, 'setup_instructions_file_path': instructionsController.text, + 'auth_steps': [], }; + if (authUrlController.text.isNotEmpty) { + data['external_integration']['auth_steps'] = []; + data['external_integration']['auth_steps'].add({ + 'url': authUrlController.text, + 'name': 'Setup ${appNameController.text}', + }); + } } if (capability.id == 'chat') { data['chat_prompt'] = chatPromptController.text; diff --git a/app/lib/pages/apps/widgets/external_trigger_fields_widget.dart b/app/lib/pages/apps/widgets/external_trigger_fields_widget.dart index dae416dda..013364086 100644 --- a/app/lib/pages/apps/widgets/external_trigger_fields_widget.dart +++ b/app/lib/pages/apps/widgets/external_trigger_fields_widget.dart @@ -67,6 +67,50 @@ class ExternalTriggerFieldsWidget extends StatelessWidget { ), TextFormField( controller: provider.webhookUrlController, + validator: (value) { + if (value == null || !isValidUrl(value)) { + return 'Please enter a valid Auth URL'; + } + return null; + }, + decoration: InputDecoration( + border: const OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10)), + ), + focusedBorder: const OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10)), + borderSide: BorderSide( + color: Colors.white, + ), + ), + label: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(Icons.link, + color: WidgetStateColor.resolveWith( + (states) => states.contains(WidgetState.focused) ? Colors.white : Colors.grey)), + const SizedBox( + width: 8, + ), + const Text( + 'Auth URL (if required)', + ), + ], + ), + hintText: 'https://your-auth-url.com/', + labelStyle: const TextStyle( + color: Colors.grey, + ), + floatingLabelStyle: const TextStyle( + color: Colors.white, + ), + ), + ), + const SizedBox( + height: 20, + ), + TextFormField( + controller: provider.authUrlController, validator: (value) { if (value == null || !isValidUrl(value)) { return 'Please enter a valid webhook URL';