Gitea labels are now passed with both names and IDs to more easily support services that use one or the other.

This commit is contained in:
Jamie Greunbaum
2024-05-31 23:40:15 -04:00
parent d4d59c957c
commit d763eb48fe
3 changed files with 45 additions and 29 deletions
+20 -13
View File
@@ -94,12 +94,16 @@ func _on_submit_button_pressed() -> void:
__description_label.remove_theme_color_override("font_color")
__description_text.remove_theme_color_override("font_color")
var labels_to_be_added : Array
var version_error : bool = !__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.VERSION, __version_label, __version_button)
var hardware_error : bool = !__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.HARDWARE, __hardware_label, __hardware_button)
var os_error : bool = !__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.OS, __os_label, __os_button)
var component_error : bool = !__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.COMPONENT, __component_label, __component_button)
var severity_error : bool = !__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.SEVERITY, __severity_label, __severity_button)
var version_tags : Array = []
var hardware_tags : Array = []
var os_tags : Array = []
var component_tags : Array = []
var severity_tags : Array = []
var version_error : bool = !__get_label_ids_for_submission_data(version_tags, BugbotServerAPI.BugbotTagArray.VERSION, __version_label, __version_button)
var hardware_error : bool = !__get_label_ids_for_submission_data(hardware_tags, BugbotServerAPI.BugbotTagArray.HARDWARE, __hardware_label, __hardware_button)
var os_error : bool = !__get_label_ids_for_submission_data(os_tags, BugbotServerAPI.BugbotTagArray.OS, __os_label, __os_button)
var component_error : bool = !__get_label_ids_for_submission_data(component_tags, BugbotServerAPI.BugbotTagArray.COMPONENT, __component_label, __component_button)
var severity_error : bool = !__get_label_ids_for_submission_data(severity_tags, BugbotServerAPI.BugbotTagArray.SEVERITY, __severity_label, __severity_button)
if summary_error or description_error or version_error or hardware_error or os_error or component_error or severity_error:
__submit_button.disabled = false
@@ -108,25 +112,28 @@ func _on_submit_button_pressed() -> void:
var bug_report_form_data : Dictionary = {
"title": summary_text,
"body": description_text,
"labels": labels_to_be_added,
"labels": {},
}
if not version_tags.is_empty(): bug_report_form_data["labels"]["version"] = version_tags[0]
if not hardware_tags.is_empty(): bug_report_form_data["labels"]["hardware"] = hardware_tags[0]
if not os_tags.is_empty(): bug_report_form_data["labels"]["os"] = os_tags[0]
if not component_tags.is_empty(): bug_report_form_data["labels"]["component"] = component_tags[0]
if not severity_tags.is_empty(): bug_report_form_data["labels"]["severity"] = severity_tags[0]
__server_api._send_form_data(bug_report_form_data, map_name, bug_location, bug_rotation, __submission_response)
func __get_label_ids_for_submission_data(label_array:Array, label_group_id:int, label:Label, button:MenuButton) -> bool:
var labels : Array
func __get_label_ids_for_submission_data(tag:Array, label_group_id:int, label:Label, button:MenuButton) -> bool:
for applied_label in __label_groups[label_group_id]:
if applied_label["name"] == __severity_button.text:
labels.append(applied_label["id"])
if applied_label["name"] == button.text:
tag.append({ "name": applied_label["name"], "id": applied_label["id"] })
break
if labels.is_empty() and not (__label_groups[label_group_id] as Array).is_empty():
if tag.is_empty() and not (__label_groups[label_group_id] as Array).is_empty():
printerr("You must select a label for \"%s\"" % [label.text])
label.add_theme_color_override("font_color", __ERROR_TEXT_COLOUR)
button.add_theme_color_override("font_color", __ERROR_TEXT_COLOUR)
return false
label_array.append_array(labels)
label.remove_theme_color_override("font_color")
button.remove_theme_color_override("font_color")
return true