From 9c1b55b9fbff0e8e9e22937c448ab72f7aa1559c Mon Sep 17 00:00:00 2001 From: hunteraraujo Date: Wed, 27 Sep 2023 15:11:27 -0700 Subject: [PATCH] Integrate UriUtility in LeaderboardSubmissionDialog for URL Validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit integrates the newly created UriUtility class into the LeaderboardSubmissionDialog. The isURL method from UriUtility is used to add an additional layer of validation for the GitHub repository URL input field. It ensures that users enter a valid URL format before submitting their leaderboard entries. Changes made: - Integrated UriUtility’s isURL method in the _validateAndSubmit function of the LeaderboardSubmissionDialog. - Added a specific error message "Invalid URL format" to inform users when the entered URL does not meet the validation criteria. - Updated the state management to reflect the URL validation status and re-render the dialog with appropriate error messages when necessary. With this integration, the application now provides real-time feedback on the validity of the entered URL, enhancing user experience and data integrity by ensuring that only valid URLs are submitted to the leaderboard. --- .../lib/views/task_queue/leaderboard_submission_dialog.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/lib/views/task_queue/leaderboard_submission_dialog.dart b/frontend/lib/views/task_queue/leaderboard_submission_dialog.dart index 5f2ab71a..14c938db 100644 --- a/frontend/lib/views/task_queue/leaderboard_submission_dialog.dart +++ b/frontend/lib/views/task_queue/leaderboard_submission_dialog.dart @@ -1,4 +1,5 @@ import 'package:auto_gpt_flutter_client/constants/app_colors.dart'; +import 'package:auto_gpt_flutter_client/utils/uri_utility.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -56,6 +57,9 @@ class _LeaderboardSubmissionDialogState if (_repoUrlController.text.isEmpty) { isValid = false; _repoUrlError = 'Repo URL is required'; + } else if (!UriUtility.isURL(_repoUrlController.text)) { + isValid = false; + _repoUrlError = 'Invalid URL format'; } else { _repoUrlError = null; }