Bug report form can now send summary, description, and labels to the Gitea server when submitting a bug.
This commit is contained in:
+72
-12
@@ -1,19 +1,20 @@
|
||||
class_name BugReportForm
|
||||
extends ColorRect
|
||||
|
||||
signal closed
|
||||
|
||||
@onready var __version_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/VersionButton
|
||||
@onready var __hardware_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/HardwareButton
|
||||
@onready var __os_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/OSButton
|
||||
@onready var __component_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/ComponentButton
|
||||
@onready var __severity_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/SeverityButton
|
||||
|
||||
var __version_items : Array
|
||||
var __hardware_items : Array
|
||||
var __os_items : Array
|
||||
var __component_items : Array
|
||||
var __severity_items : Array
|
||||
@onready var __summary_text : LineEdit = $Form/VBoxContainerRight/GridContainer/SummaryText
|
||||
@onready var __description_text : TextEdit = $Form/VBoxContainerRight/GridContainer/DescriptionText
|
||||
|
||||
var __label_groups : Array
|
||||
var __stored_mouse_mode : int
|
||||
var __server_api : BugbotServerAPI
|
||||
|
||||
const __button_disabled_message : StringName = &"Not available"
|
||||
|
||||
@@ -21,19 +22,25 @@ const __button_disabled_message : StringName = &"Not available"
|
||||
func _enter_tree():
|
||||
__stored_mouse_mode = Input.mouse_mode
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
__server_api = BugbotServerAPI._create_new_server_api()
|
||||
|
||||
func _exit_tree():
|
||||
Input.mouse_mode = __stored_mouse_mode
|
||||
|
||||
|
||||
func fill_tags(tag_list:Array):
|
||||
__fill_item_list(__version_button, __version_items, tag_list[BugbotServerAPI.BugbotTagArray.VERSION])
|
||||
__fill_item_list(__hardware_button, __hardware_items, tag_list[BugbotServerAPI.BugbotTagArray.HARDWARE])
|
||||
__fill_item_list(__os_button, __os_items, tag_list[BugbotServerAPI.BugbotTagArray.OS])
|
||||
__fill_item_list(__component_button, __component_items, tag_list[BugbotServerAPI.BugbotTagArray.COMPONENT])
|
||||
__fill_item_list(__severity_button, __severity_items, tag_list[BugbotServerAPI.BugbotTagArray.SEVERITY])
|
||||
func __fill_item_list(menu_button:MenuButton, menu_options:Array, tag_list:Array):
|
||||
menu_options = tag_list
|
||||
__label_groups.resize(BugbotServerAPI.BugbotTagArray.MAX)
|
||||
__label_groups = tag_list
|
||||
|
||||
__fill_item_list(__version_button, BugbotServerAPI.BugbotTagArray.VERSION)
|
||||
__fill_item_list(__hardware_button, BugbotServerAPI.BugbotTagArray.HARDWARE)
|
||||
__fill_item_list(__os_button, BugbotServerAPI.BugbotTagArray.OS)
|
||||
__fill_item_list(__component_button, BugbotServerAPI.BugbotTagArray.COMPONENT)
|
||||
__fill_item_list(__severity_button, BugbotServerAPI.BugbotTagArray.SEVERITY)
|
||||
|
||||
func __fill_item_list(menu_button:MenuButton, label_group:int):
|
||||
var menu_options : Array = __label_groups[label_group]
|
||||
if menu_options.is_empty():
|
||||
menu_button.text = __button_disabled_message
|
||||
menu_button.disabled = true
|
||||
@@ -42,3 +49,56 @@ func __fill_item_list(menu_button:MenuButton, menu_options:Array, tag_list:Array
|
||||
for i in menu_options.size():
|
||||
menu.add_item(menu_options[i]["name"], i)
|
||||
menu.id_pressed.connect(func(id:int): menu_button.text = menu_options[id]["name"])
|
||||
|
||||
|
||||
func _on_submit_button_pressed() -> void:
|
||||
var error_detected : bool = false
|
||||
|
||||
var summary_text : String = __summary_text.text
|
||||
var description_text : String = __description_text.text
|
||||
if summary_text.is_empty():
|
||||
printerr("You must fill in a summary.")
|
||||
error_detected = true
|
||||
if description_text.is_empty():
|
||||
printerr("You must fill in a description.")
|
||||
error_detected = true
|
||||
|
||||
var labels_to_be_added : Array
|
||||
# Check severity first, since this is a requirement.
|
||||
__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.SEVERITY)
|
||||
if labels_to_be_added.is_empty():
|
||||
printerr("You must select a severity level.")
|
||||
error_detected = true
|
||||
|
||||
if error_detected: return
|
||||
|
||||
__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.VERSION)
|
||||
__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.HARDWARE)
|
||||
__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.OS)
|
||||
__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.COMPONENT)
|
||||
|
||||
var bug_report_form_data : Dictionary = {
|
||||
"title": summary_text,
|
||||
"body": description_text,
|
||||
"labels": labels_to_be_added,
|
||||
}
|
||||
|
||||
__server_api._send_form_data(bug_report_form_data, __form_data_response)
|
||||
|
||||
func __form_data_response(response:Variant):
|
||||
print(response)
|
||||
|
||||
func __get_label_ids_for_submission_data(label_array:Array, label_group_id:int):
|
||||
for label in __label_groups[label_group_id]:
|
||||
if label["name"] == __severity_button.text:
|
||||
label_array.append(label["id"])
|
||||
break
|
||||
|
||||
func __submission_response(response:Array):
|
||||
print(response)
|
||||
queue_free()
|
||||
closed.emit()
|
||||
|
||||
func _on_cancel_button_pressed() -> void:
|
||||
queue_free()
|
||||
closed.emit()
|
||||
|
||||
@@ -151,3 +151,6 @@ wrap_mode = 1
|
||||
[node name="SubmitButton" type="Button" parent="Form/VBoxContainerRight"]
|
||||
layout_mode = 2
|
||||
text = "Submit"
|
||||
|
||||
[connection signal="pressed" from="Form/VBoxContainerLeft/CancelButton" to="." method="_on_cancel_button_pressed"]
|
||||
[connection signal="pressed" from="Form/VBoxContainerRight/SubmitButton" to="." method="_on_submit_button_pressed"]
|
||||
|
||||
Reference in New Issue
Block a user