BugMarkers are now loaded with their status intact.

This commit is contained in:
Jamie Greunbaum 2024-05-19 19:57:08 -04:00
parent 39d5834eb9
commit be16db4d76
4 changed files with 66 additions and 35 deletions

View File

@ -13,12 +13,16 @@ enum BugStatus { NEUTRAL, UNRESOLVED, IN_PROGRESS, RESOLVED }
@export_group("") @export_group("")
@export var enable_info : bool = true : set = set_info_enabled @export var enable_info : bool = true : set = set_info_enabled
@onready var __arrow : MeshInstance3D = $Arrow as MeshInstance3D var __arrow : MeshInstance3D
@onready var __billboard : MeshInstance3D = $Billboard as MeshInstance3D var __billboard : MeshInstance3D
@onready var __info_collider : Area3D = $Billboard/Info as Area3D 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_info_enabled(enable_info)
__set_marker_status(marker_status) __set_marker_status(marker_status)

View File

@ -4,13 +4,13 @@ extends Resource
var id : int = -1 var id : int = -1
var title : String var title : String
var body : String var body : String
var component : String var component : StringName
var map_name : String var map_name : StringName
var marker_location : String var marker_location : StringName
var platform : String var platform : StringName
var operating_system : String var operating_system : StringName
var is_open : bool var is_open : bool
var severity : String var severity : StringName
var status : String var status : StringName
var resolution : String var resolution : StringName
var duplicate_of : int = -1 var duplicate_of : int = -1

View File

@ -2,13 +2,17 @@ class_name BugbotServerGiteaAPI
extends "res://addons/Bugbot/Scripts/server_api.gd" extends "res://addons/Bugbot/Scripts/server_api.gd"
#region Consts #region Consts
const DEFAULT_SERVER : String = "https://gitea.example.com" const DEFAULT_SERVER : StringName = &"https://gitea.example.com"
const DEFAULT_BASE_URL : String = "api/v1/" const DEFAULT_BASE_URL : StringName = &"api/v1/"
const DEFAULT_OWNER_NAME : String = "ProjectOwner" const DEFAULT_OWNER_NAME : StringName = &"ProjectOwner"
const DEFAULT_REPO_NAME : String = "ProjectName" const DEFAULT_REPO_NAME : StringName = &"ProjectName"
const DEFAULT_API_KEY : String = "0123456789abcdef0123456789abcdef01234567" const DEFAULT_API_KEY : StringName = &"0123456789abcdef0123456789abcdef01234567"
const DEFAULT_LABEL : String = "Kind/Bug" const DEFAULT_LABEL : StringName = &"Kind/Bug"
const DEFAULT_STATUS : String = "Status/Need More Info" 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 #endregion
@ -41,6 +45,7 @@ func __return_list_of_bugs_thread(callback:Callable) -> void:
assert(http_client.get_status() == HTTPClient.STATUS_CONNECTED) assert(http_client.get_status() == HTTPClient.STATUS_CONNECTED)
var api_url : String = _build_url_string() 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)) 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) error = http_client.request(HTTPClient.METHOD_GET, api_url, header_data)
assert(error == Error.OK) assert(error == Error.OK)
@ -64,6 +69,9 @@ func __return_list_of_bugs_thread(callback:Callable) -> void:
if response_data is Array: if response_data is Array:
# If the response is an array, we can make the assumption that this is # If the response is an array, we can make the assumption that this is
# a list of returned bugs. # 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: for bug_in:Dictionary in response_data:
var bug : BugbotBugData = BugbotBugData.new() var bug : BugbotBugData = BugbotBugData.new()
bug.id = bug_in["id"] bug.id = bug_in["id"]
@ -74,13 +82,26 @@ func __return_list_of_bugs_thread(callback:Callable) -> void:
bug.operating_system = &"Unused" bug.operating_system = &"Unused"
bug.is_open = (bug_in["state"] == "open") bug.is_open = (bug_in["state"] == "open")
bug.severity = "Severity will go here." bug.severity = "Severity will go here."
bug.status = "Status will go here." bug.status = bug_in["state"]
bug.resolution = "Resolution will go here."
bug.duplicate_of = -1 bug.duplicate_of = -1
bug.map_name = "Map name will go here." bug.map_name = "Map name will go here."
bug.marker_location = "Marker location 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) response_array.append(bug)
elif response_data is Dictionary: elif response_data is Dictionary:
# If the response is a dictionary and not an array, make the assumption # If the response is a dictionary and not an array, make the assumption

View File

@ -104,27 +104,33 @@ func __on_bugbot_menu_item_pressed(id:int):
var markers : Array = marker_container.get_children() var markers : Array = marker_container.get_children()
for marker:Node3D in markers: for marker:Node3D in markers:
marker.queue_free() marker.queue_free()
func __show_bug_markers_response(bug_list:Array): func __show_bug_markers_response(bug_list:Array) -> void:
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:
var marker_container : Node3D = Node3D.new() 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: if bugbot_data is BugbotBugData:
var bug_status : BugMarker.BugStatus = BugMarker.BugStatus.NEUTRAL var bug_status : BugMarker.BugStatus = BugMarker.BugStatus.NEUTRAL
var data_resource : BugbotBugData = bugbot_data as BugbotBugData var bug_data : BugbotBugData = bugbot_data as BugbotBugData
if data_resource.is_open: var show_resolved : bool = ProjectSettings.get_setting("bugbot/markers/resolved/show_resolved_bugs")
bug_status = BugMarker.BugStatus.UNRESOLVED var show_in_progress : bool = ProjectSettings.get_setting("bugbot/markers/in_progress/show_in_progress_bugs")
else: var show_unresolved : bool = ProjectSettings.get_setting("bugbot/markers/unresolved/show_unresolved_bugs")
if ProjectSettings.get_setting("bugbot/markers/resolved/show_resolved_bugs"):
if not bug_data.is_open and show_resolved:
bug_status = BugMarker.BugStatus.RESOLVED bug_status = BugMarker.BugStatus.RESOLVED
if bug_status == BugMarker.BugStatus.NEUTRAL: else:
if bug_data.resolution == BugbotServerGiteaAPI.RESOLVED_TAG and show_resolved:
bug_status = BugMarker.BugStatus.RESOLVED
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() var bug_marker : BugMarker = load("res://addons/Bugbot/Scenes/bug_marker.tscn").instantiate()
marker_container.add_child(bug_marker) marker_container.add_child(bug_marker)
bug_marker.marker_status = bug_status bug_marker.marker_status = bug_status
scene_root.add_child(marker_container) __bugbot_marker_containers[scene_root.scene_file_path] = marker_container
return marker_container
func __add_project_setting(_setting:String, _type:int, _default_value:Variant, _hint:int = PropertyHint.PROPERTY_HINT_NONE, _hint_string:String = ""): func __add_project_setting(_setting:String, _type:int, _default_value:Variant, _hint:int = PropertyHint.PROPERTY_HINT_NONE, _hint_string:String = ""):