diff --git a/Scenes/bug_marker.gd b/Scenes/bug_marker.gd index a95412b..308260c 100644 --- a/Scenes/bug_marker.gd +++ b/Scenes/bug_marker.gd @@ -13,12 +13,16 @@ enum BugStatus { NEUTRAL, UNRESOLVED, IN_PROGRESS, RESOLVED } @export_group("") @export var enable_info : bool = true : set = set_info_enabled -@onready var __arrow : MeshInstance3D = $Arrow as MeshInstance3D -@onready var __billboard : MeshInstance3D = $Billboard as MeshInstance3D -@onready var __info_collider : Area3D = $Billboard/Info as Area3D +var __arrow : MeshInstance3D +var __billboard : MeshInstance3D +var __info_collider : Area3D -func _ready() -> void: +func _enter_tree() -> void: + __arrow = $Arrow as MeshInstance3D + __billboard = $Billboard as MeshInstance3D + __info_collider = $Billboard/Info as Area3D + set_info_enabled(enable_info) __set_marker_status(marker_status) diff --git a/Scripts/BugDataStructs/bug_data.gd b/Scripts/BugDataStructs/bug_data.gd index 06c4247..0d02432 100644 --- a/Scripts/BugDataStructs/bug_data.gd +++ b/Scripts/BugDataStructs/bug_data.gd @@ -4,13 +4,13 @@ extends Resource var id : int = -1 var title : String var body : String -var component : String -var map_name : String -var marker_location : String -var platform : String -var operating_system : String +var component : StringName +var map_name : StringName +var marker_location : StringName +var platform : StringName +var operating_system : StringName var is_open : bool -var severity : String -var status : String -var resolution : String +var severity : StringName +var status : StringName +var resolution : StringName var duplicate_of : int = -1 diff --git a/Scripts/server_gitea_api.gd b/Scripts/server_gitea_api.gd index 8dc6930..d8ef349 100644 --- a/Scripts/server_gitea_api.gd +++ b/Scripts/server_gitea_api.gd @@ -2,13 +2,17 @@ class_name BugbotServerGiteaAPI extends "res://addons/Bugbot/Scripts/server_api.gd" #region Consts -const DEFAULT_SERVER : String = "https://gitea.example.com" -const DEFAULT_BASE_URL : String = "api/v1/" -const DEFAULT_OWNER_NAME : String = "ProjectOwner" -const DEFAULT_REPO_NAME : String = "ProjectName" -const DEFAULT_API_KEY : String = "0123456789abcdef0123456789abcdef01234567" -const DEFAULT_LABEL : String = "Kind/Bug" -const DEFAULT_STATUS : String = "Status/Need More Info" +const DEFAULT_SERVER : StringName = &"https://gitea.example.com" +const DEFAULT_BASE_URL : StringName = &"api/v1/" +const DEFAULT_OWNER_NAME : StringName = &"ProjectOwner" +const DEFAULT_REPO_NAME : StringName = &"ProjectName" +const DEFAULT_API_KEY : StringName = &"0123456789abcdef0123456789abcdef01234567" +const DEFAULT_LABEL : StringName = &"Kind/Bug" +const DEFAULT_STATUS : StringName = &"Status/Need More Info" + +const UNRESOLVED_TAG : String = &"Status/Unresolved" +const IN_PROGRESS_TAG : String = &"Status/In Progress" +const RESOLVED_TAG : String = &"Status/Resolved" #endregion @@ -41,6 +45,7 @@ func __return_list_of_bugs_thread(callback:Callable) -> void: assert(http_client.get_status() == HTTPClient.STATUS_CONNECTED) var api_url : String = _build_url_string() + api_url += "?state=all&labels=" + ProjectSettings.get_setting("bugbot/reporting/gitea/default_label", DEFAULT_LABEL).uri_encode() var header_data : Array = _create_header_data("application/json", ProjectSettings.get_setting("bugbot/reporting/gitea/API_key", DEFAULT_API_KEY)) error = http_client.request(HTTPClient.METHOD_GET, api_url, header_data) assert(error == Error.OK) @@ -64,6 +69,9 @@ func __return_list_of_bugs_thread(callback:Callable) -> void: if response_data is Array: # If the response is an array, we can make the assumption that this is # a list of returned bugs. + var resolved_labels : Array = ProjectSettings.get_setting("bugbot/markers/resolved/resolved_statuses") + var in_progress_labels : Array = ProjectSettings.get_setting("bugbot/markers/in_progress/in_progress_statuses") + var unresolved_labels : Array = ProjectSettings.get_setting("bugbot/markers/unresolved/unresolved_statuses") for bug_in:Dictionary in response_data: var bug : BugbotBugData = BugbotBugData.new() bug.id = bug_in["id"] @@ -74,13 +82,26 @@ func __return_list_of_bugs_thread(callback:Callable) -> void: bug.operating_system = &"Unused" bug.is_open = (bug_in["state"] == "open") bug.severity = "Severity will go here." - bug.status = "Status will go here." - bug.resolution = "Resolution will go here." + bug.status = bug_in["state"] bug.duplicate_of = -1 - bug.map_name = "Map name will go here." bug.marker_location = "Marker location will go here." + if not bug.is_open: + bug.resolution = RESOLVED_TAG + else: + for resolution_label:Dictionary in bug_in["labels"]: + var label_name : String = resolution_label["name"] + if resolved_labels.has(label_name): + bug.resolution = RESOLVED_TAG + break + elif in_progress_labels.has(label_name): + bug.resolution = IN_PROGRESS_TAG + break + elif unresolved_labels.has(label_name): + bug.resolution = UNRESOLVED_TAG + break + response_array.append(bug) elif response_data is Dictionary: # If the response is a dictionary and not an array, make the assumption diff --git a/bugbot.gd b/bugbot.gd index ccbf1aa..c58ed49 100644 --- a/bugbot.gd +++ b/bugbot.gd @@ -104,27 +104,33 @@ func __on_bugbot_menu_item_pressed(id:int): var markers : Array = marker_container.get_children() for marker:Node3D in markers: marker.queue_free() -func __show_bug_markers_response(bug_list:Array): - var scene_path : String = EditorInterface.get_edited_scene_root().scene_file_path - var marker_container : Node3D = __fill_marker_container(EditorInterface.get_edited_scene_root(), bug_list) - __bugbot_marker_containers[scene_path] = marker_container -func __fill_marker_container(scene_root:Node, response_resources:Array) -> Node3D: +func __show_bug_markers_response(bug_list:Array) -> void: var marker_container : Node3D = Node3D.new() - for bugbot_data:Resource in response_resources: + var scene_root : Node = EditorInterface.get_edited_scene_root() + scene_root.add_child(marker_container) + for bugbot_data:Resource in bug_list: if bugbot_data is BugbotBugData: var bug_status : BugMarker.BugStatus = BugMarker.BugStatus.NEUTRAL - var data_resource : BugbotBugData = bugbot_data as BugbotBugData - if data_resource.is_open: - bug_status = BugMarker.BugStatus.UNRESOLVED + var bug_data : BugbotBugData = bugbot_data as BugbotBugData + var show_resolved : bool = ProjectSettings.get_setting("bugbot/markers/resolved/show_resolved_bugs") + var show_in_progress : bool = ProjectSettings.get_setting("bugbot/markers/in_progress/show_in_progress_bugs") + var show_unresolved : bool = ProjectSettings.get_setting("bugbot/markers/unresolved/show_unresolved_bugs") + + if not bug_data.is_open and show_resolved: + bug_status = BugMarker.BugStatus.RESOLVED else: - if ProjectSettings.get_setting("bugbot/markers/resolved/show_resolved_bugs"): + if bug_data.resolution == BugbotServerGiteaAPI.RESOLVED_TAG and show_resolved: bug_status = BugMarker.BugStatus.RESOLVED - if bug_status == BugMarker.BugStatus.NEUTRAL: + elif bug_data.resolution == BugbotServerGiteaAPI.IN_PROGRESS_TAG and show_in_progress: + bug_status = BugMarker.BugStatus.IN_PROGRESS + elif bug_data.resolution == BugbotServerGiteaAPI.UNRESOLVED_TAG and show_unresolved: + bug_status = BugMarker.BugStatus.UNRESOLVED + + if bug_status != BugMarker.BugStatus.NEUTRAL: var bug_marker : BugMarker = load("res://addons/Bugbot/Scenes/bug_marker.tscn").instantiate() marker_container.add_child(bug_marker) bug_marker.marker_status = bug_status - scene_root.add_child(marker_container) - return marker_container + __bugbot_marker_containers[scene_root.scene_file_path] = marker_container func __add_project_setting(_setting:String, _type:int, _default_value:Variant, _hint:int = PropertyHint.PROPERTY_HINT_NONE, _hint_string:String = ""):