Markers can now be loaded and unloaded in the editor. Currently not fully implemented, but getting there.

This commit is contained in:
Jamie Greunbaum
2024-05-19 18:12:42 -04:00
parent a5bd6cfd72
commit 2a57cd544d
7 changed files with 141 additions and 36 deletions
+16
View File
@@ -0,0 +1,16 @@
class_name BugbotBugData
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 is_open : bool
var severity : String
var status : String
var resolution : String
var duplicate_of : int = -1
@@ -0,0 +1,6 @@
class_name BugbotErrorData
extends Resource
var code : int = -1
var message : String
var url : String
+6
View File
@@ -0,0 +1,6 @@
class_name BugReportPlatform
enum {
BUGZILLA,
GITEA,
JIRA
}
+8 -1
View File
@@ -1,5 +1,5 @@
class_name BugbotServerAPI
extends Object
extends Resource
enum BugbotServerError { OK, THREAD_NULL, THREAD_BUSY }
@@ -23,6 +23,13 @@ static func _send_form_data() -> int:
return BugbotServerError.OK
static func _create_new_server_api() -> BugbotServerAPI:
match ProjectSettings.get_setting("bugbot/reporting/bug_report_platform", -1):
BugReportPlatform.BUGZILLA: return BugbotServerAPI.new()
BugReportPlatform.GITEA: return BugbotServerGiteaAPI.new()
BugReportPlatform.JIRA: return BugbotServerAPI.new()
return BugbotServerAPI.new()
static func _current_server_api() -> String:
return ""
+58 -13
View File
@@ -1,6 +1,16 @@
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"
#endregion
static func _return_list_of_bugs(callback:Callable) -> int:
if not __bugbot_server_thread:
@@ -13,16 +23,16 @@ static func _return_list_of_bugs(callback:Callable) -> int:
__bugbot_server_thread.start(__return_list_of_bugs_thread.bind(callback))
return BugbotServerError.OK
#func _prepare_form() -> void:
#static func _prepare_form() -> void:
#print("Prepare ", _current_server_api(), " form here.")
#
#func _send_form_data() -> void:
#static func _send_form_data() -> void:
#print("Send ", _current_server_api(), " form data here.")
func __return_list_of_bugs_thread(callback:Callable) -> void:
var http_client : HTTPClient = HTTPClient.new()
var server : String = ProjectSettings.get_setting("bugbot/reporting/gitea/server")
var server : String = ProjectSettings.get_setting("bugbot/reporting/gitea/server", DEFAULT_SERVER)
var error : int = http_client.connect_to_host(server, 443)
assert(error == Error.OK)
@@ -31,7 +41,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()
var header_data : Array = _create_header_data("application/json", ProjectSettings.get_setting("bugbot/reporting/gitea/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)
assert(error == Error.OK)
@@ -49,7 +59,41 @@ func __return_list_of_bugs_thread(callback:Callable) -> void:
response_body = response_body + chunk
response_string = response_body.get_string_from_utf8()
callback.call_deferred(JSON.parse_string(response_string) as Array)
var response_array : Array
var response_data := JSON.parse_string(response_string)
if response_data is Array:
# If the response is an array, we can make the assumption that this is
# a list of returned bugs.
for bug_in:Dictionary in response_data:
var bug : BugbotBugData = BugbotBugData.new()
bug.id = bug_in["id"]
bug.title = bug_in["title"]
bug.body = bug_in["body"]
bug.component = &"Unused"
bug.platform = &"Unused"
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.duplicate_of = -1
bug.map_name = "Map name will go here."
bug.marker_location = "Marker location will go here."
response_array.append(bug)
elif response_data is Dictionary:
# If the response is a dictionary and not an array, make the assumption
# that this is because the response was an error code.
var error_data : BugbotErrorData = BugbotErrorData.new()
error_data.code = 1
error_data.message = response_data["message"]
error_data.url = response_data["url"]
response_array.append(error_data)
printerr(error_data.message)
callback.call_deferred(response_array)
__bugbot_server_thread.call_deferred("wait_to_finish")
@@ -57,18 +101,19 @@ static func _current_server_api() -> String:
return "Gitea"
static func _build_url_string() -> String:
return "/" + \
ProjectSettings.get_setting("bugbot/reporting/gitea/base_URL", "api/v1/") + \
"/repos/" + \
ProjectSettings.get_setting("bugbot/reporting/gitea/owner_name") + \
"/" + \
ProjectSettings.get_setting("bugbot/reporting/gitea/repo_name") + \
return "/" + \
ProjectSettings.get_setting("bugbot/reporting/gitea/base_URL", DEFAULT_BASE_URL) + \
"/repos/" + \
ProjectSettings.get_setting("bugbot/reporting/gitea/owner_name", DEFAULT_OWNER_NAME) + \
"/" + \
ProjectSettings.get_setting("bugbot/reporting/gitea/repo_name", DEFAULT_REPO_NAME) + \
"/issues"
static func _create_header_data(mime_type:String, api_key:String) -> Array:
return [
var header : Array = [
"User-Agent: Pirulo/1.0 (Godot)",
"Accept: " + mime_type,
"Content-Type: " + mime_type,
"Authorization: token " + api_key,
]
if api_key: header.append("Authorization: token " + api_key)
return header