A platform for community discussion. Free, open, simple.
UX: fix the status on pr in github oneboxes (#36488)
Régis Hanol6419056a5d76
diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex af1a309cd5f..de69d7110c0 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -5585,6 +5585,13 @@ en:review_by: "Review by"pr_summary: "%{commits} commits changed %{changed_files} files with %{additions} additions and %{deletions} deletions"no_description: "Contribute to %{repo} development by creating an account on GitHub."+ pr_title:+ default: "Pull Request"+ draft: "Draft Pull Request"+ open: "Open Pull Request"+ approved: "Approved Pull Request"+ merged: "Merged Pull Request"+ closed: "Closed Pull Request"discourse_push_notifications:popup:diff --git a/lib/onebox/engine/github_pull_request_onebox.rb b/lib/onebox/engine/github_pull_request_onebox.rbindex b70263b9a36..5d7a4be21e3 100644--- a/lib/onebox/engine/github_pull_request_onebox.rb+++ b/lib/onebox/engine/github_pull_request_onebox.rb@@ -34,6 +34,7 @@ module Oneboxresult = raw(github_auth_header(match[:org])).cloneresult["link"] = linkresult["pr_status"] = fetch_pr_status(result)+ result["pr_status_title"] = pr_status_title(result["pr_status"])created_at = Time.parse(result["created_at"])result["created_at"] = created_at.strftime("%I:%M%p - %d %b %y %Z")@@ -84,6 +85,11 @@ module Onebox}end+ def pr_status_title(status)+ key = status.presence || "default"+ I18n.t("onebox.github.pr_title.#{key}")+ end+def load_commit(link)if commit_match = link.match(%r{commits/(\h+)})load_json(@@ -125,6 +131,7 @@ module Oneboxreturn "draft" if pr_data["draft"]reviews_data = load_json(url + "/reviews")+return "approved" if reviews_approved?(reviews_data)"open"diff --git a/lib/onebox/templates/githubpullrequest.mustache b/lib/onebox/templates/githubpullrequest.mustacheindex 9383d67ed64..e17eaf2db5e 100644--- a/lib/onebox/templates/githubpullrequest.mustache+++ b/lib/onebox/templates/githubpullrequest.mustache@@ -18,7 +18,7 @@{{/discussion}}{{#pr}}- <div class="github-icon-container" title="Pull Request">+ <div class="github-icon-container" title="{{pr_status_title}}"><svg width="60" height="60" class="github-icon" viewBox="0 0 12 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0 0 10 15a1.993 1.993 0 0 0 1-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v6.56A1.993 1.993 0 0 0 2 15a1.993 1.993 0 0 0 1-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg></div>{{/pr}}diff --git a/plugins/discourse-github/assets/stylesheets/common/github-pr-status.scss b/plugins/discourse-github/assets/stylesheets/common/github-pr-status.scssindex 0f1e9fc4362..3fd673f1896 100644--- a/plugins/discourse-github/assets/stylesheets/common/github-pr-status.scss+++ b/plugins/discourse-github/assets/stylesheets/common/github-pr-status.scss@@ -48,7 +48,7 @@&.--gh-status-open .github-icon-container::before {mask-image: var(--gh-icon-open);- background-color: #3fb950;+ background-color: #8b949e;}&.--gh-status-approved .github-icon-container::before {