Truly independent web browser
LibWebView+UI/Qt: Prefill bug reports from the feedback button
Andreas Kling2ebaf6a76893
diff --git a/Libraries/LibWebView/WebCompatReport.cpp b/Libraries/LibWebView/WebCompatReport.cppindex 3c90ee1cb16..3794bcc4264 100644--- a/Libraries/LibWebView/WebCompatReport.cpp+++ b/Libraries/LibWebView/WebCompatReport.cpp@@ -10,6 +10,7 @@#include <LibCore/BrowserVersion.h>#include <LibCore/ImmutableBytes.h>#include <LibCore/Promise.h>+#include <LibURL/Parser.h>#include <LibWebCommon/Loader/UserAgent.h>#include <LibWebCommon/WebView/PageInfo.h>#include <LibWebView/Application.h>@@ -228,4 +229,22 @@ void WebCompatReport::start_submission()submission->start();}+URL::URL new_bug_report_url()+{+ StringBuilder url;+ url.append("https://github.com/LadybirdBrowser/ladybird/issues/new?template=bug_report.yml"sv);+ auto append_field = [&](StringView id, StringView value) {+ url.appendff("&{}={}", id, URL::percent_encode(value, URL::PercentEncodeSet::Component));+ };++ // NB: These are the IDs of the fields in .github/ISSUE_TEMPLATE/bug_report.yml, where the architecture is a choice+ // of these values.+ append_field("os"sv, platform);+ append_field("architecture"sv, architecture == "x86_64"sv || architecture == "AArch64"sv ? architecture : "Other"sv);+ append_field("commit"sv, LADYBIRD_COMMIT);+ append_field("build-flags"sv, ByteString::formatted("Ladybird {}, {}", browser_version, build_configuration));++ return URL::Parser::basic_parse(url.string_view()).release_value();+}+}diff --git a/Libraries/LibWebView/WebCompatReport.h b/Libraries/LibWebView/WebCompatReport.hindex 5153481d9ce..0ac8ded4204 100644--- a/Libraries/LibWebView/WebCompatReport.h+++ b/Libraries/LibWebView/WebCompatReport.h@@ -80,4 +80,7 @@ private:RefPtr<ReportSubmission> m_submission;};+// A new issue on GitHub, with what we know of this build already filled in.+WEBVIEW_API URL::URL new_bug_report_url();+}diff --git a/UI/Qt/WindowToolbar.cpp b/UI/Qt/WindowToolbar.cppindex ca1a6469557..86e850b0af0 100644--- a/UI/Qt/WindowToolbar.cpp+++ b/UI/Qt/WindowToolbar.cpp@@ -8,11 +8,11 @@*/#include <AK/kmalloc.h>-#include <LibURL/Parser.h>#include <LibWebView/Application.h>#include <LibWebView/CrashReportStore.h>#include <LibWebView/DownloadPresentation.h>#include <LibWebView/TabPerformanceMonitor.h>+#include <LibWebView/WebCompatReport.h>#include <UI/Qt/Application.h>#include <UI/Qt/BrowserWindow.h>#include <UI/Qt/ChromeLayout.h>@@ -620,7 +620,6 @@ static constexpr int toolbar_right_margin(bool has_custom_window_controls){return has_custom_window_controls ? 0 : TOOLBAR_HORIZONTAL_MARGIN - TOOLBAR_LOCATION_FOCUS_RING_ROOM;}-static constexpr auto REPORT_BUG_URL = "https://github.com/LadybirdBrowser/ladybird/issues/new?template=bug_report.yml"sv;static constexpr int DOWNLOADS_POPOVER_WIDTH = 380;static constexpr int DOWNLOADS_POPOVER_MAX_HEIGHT = 360;class ElidedLabel final : public QLabel {@@ -1473,7 +1472,7 @@ void WindowToolbar::show_feedback_popover()m_tab->view().report_website_issue();};m_feedback_popover->on_report_bug = [this] {- browser_window().new_tab_from_url(URL::Parser::basic_parse(REPORT_BUG_URL).release_value(), Web::HTML::ActivateTab::Yes, BrowserWindow::TabLocation::after_current_tab());+ browser_window().new_tab_from_url(WebView::new_bug_report_url(), Web::HTML::ActivateTab::Yes, BrowserWindow::TabLocation::after_current_tab());};m_feedback_popover->on_review_crash_reports = [] {auto names = WebView::CrashReportStore::the().pending_report_names();