From b4b38133ad3053288a093d99fd4c5cc85d2f7f9c Mon Sep 17 00:00:00 2001 From: NilsRo <51311453+NilsRo@users.noreply.github.com> Date: Mon, 28 Feb 2022 20:24:00 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20swu:=20Allow=20configuring=20Git?= =?UTF-8?q?Hub=20PAT=20via=20GUI=20(#4443)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Demo Github Token Settings * 🚸 swu: explain where and why to get a GitHub PAT * 🐛 swu: Only set GH PAT if it's been provided Co-authored-by: Gina Häußge --- .../plugins/softwareupdate/static/js/softwareupdate.js | 7 +++++++ .../softwareupdate/templates/snippets/githubToken.jinja2 | 7 +++++++ .../templates/softwareupdate_settings.jinja2 | 1 + 3 files changed, 15 insertions(+) create mode 100644 src/octoprint/plugins/softwareupdate/templates/snippets/githubToken.jinja2 diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js index 03bdd30f5..2de85091f 100644 --- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js +++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js @@ -64,6 +64,7 @@ $(function () { self.config_releaseChannel = ko.observable(); self.config_pipEnableCheck = ko.observable(); self.config_minimumFreeStorage = ko.observable(); + self.config_githubToken = ko.observable(); self.error_checkoutFolder = ko.pureComputed(function () { return ( @@ -243,6 +244,8 @@ $(function () { var target = $(event.target); target.prepend(' '); + var githubToken = self.config_githubToken(); + var data = { plugins: { softwareupdate: { @@ -258,6 +261,9 @@ $(function () { } } }; + if (githubToken) { + data.plugins.softwareupdate.credentials = {github: githubToken}; + } self.settings.saveData(data, { success: function () { self.configurationDialog.modal("hide"); @@ -266,6 +272,7 @@ $(function () { }, complete: function () { $("i.fa-spinner", target).remove(); + self.config_githubToken(""); }, sending: true }); diff --git a/src/octoprint/plugins/softwareupdate/templates/snippets/githubToken.jinja2 b/src/octoprint/plugins/softwareupdate/templates/snippets/githubToken.jinja2 new file mode 100644 index 000000000..0a03630d9 --- /dev/null +++ b/src/octoprint/plugins/softwareupdate/templates/snippets/githubToken.jinja2 @@ -0,0 +1,7 @@ +
+ +
+ + {{ _('Set this if you keep running into rate limiting issues. See here for how to obtain a token.', url="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token") }} +
+
diff --git a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 index 2ac61e04b..b8d8df41e 100644 --- a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 +++ b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 @@ -171,6 +171,7 @@ {% include "snippets/checkoutFolder.jinja2" %} {% include "snippets/pipTarget.jinja2" %} {% include "snippets/pipEnableCheck.jinja2" %} + {% include "snippets/githubToken.jinja2" %}