Skip to content

Commit

Permalink
add option auth field
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmohsin7 committed Nov 15, 2024
1 parent 1480b83 commit bfccda6
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/lib/pages/apps/providers/add_app_provider.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -29,6 +30,7 @@ class AddAppProvider extends ChangeNotifier {
TextEditingController webhookUrlController = TextEditingController();
TextEditingController setupCompletedController = TextEditingController();
TextEditingController instructionsController = TextEditingController();
TextEditingController authUrlController = TextEditingController();

bool termsAgreed = false;

Expand Down Expand Up @@ -124,6 +126,7 @@ class AddAppProvider extends ChangeNotifier {
webhookUrlController.clear();
setupCompletedController.clear();
instructionsController.clear();
authUrlController.clear();
termsAgreed = false;
makeAppPublic = false;
appCategory = null;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
44 changes: 44 additions & 0 deletions app/lib/pages/apps/widgets/external_trigger_fields_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit bfccda6

Please sign in to comment.