🚸 SWU: Add a display indication when the Github access token is set (#4540)

* Add github set flag in software update plugin

* Improve github token presence check

* Remove "github_set" from default settings.
Improve credentials presence check.
Revert restricted_paths edit.
This commit is contained in:
Federico Nembrini authored and GitHub committed 2022-08-02 10:18:05 +02:00
1 parent 6fe358eb68
commit 8d2d06eeee
3 files changed
+17

No files matched your search

@@ -712,6 +712,13 @@ class SoftwareUpdatePlugin(
def on_settings_load(self):
# ensure we don't persist check configs we receive on the API
data = dict(octoprint.plugin.SettingsPlugin.on_settings_load(self))
# set credentials flag
credentials = self._settings.get(["credentials"])
data["credentials"] = {}
for key, value in credentials.items():
data["credentials"][f"{key}_set"] = bool(value)
if "checks" in data:
del data["checks"]
@@ -65,6 +65,7 @@ $(function () {
self.config_pipEnableCheck = ko.observable();
self.config_minimumFreeStorage = ko.observable();
self.config_githubToken = ko.observable();
self.config_githubTokenSet = ko.observable(false);
self.error_checkoutFolder = ko.pureComputed(function () {
return (
@@ -334,6 +335,10 @@ $(function () {
self.config_minimumFreeStorage(
self.settings.settings.plugins.softwareupdate.minimum_free_storage()
);
self.config_githubTokenSet(
self.settings.settings.plugins.softwareupdate.credentials.github_set()
);
};
self._copyConfigBack = function () {
@@ -1,7 +1,12 @@
<div class="control-group">
<label class="control-label">{{ _('GitHub Access Token') }}</label>
<div class="controls">
<!-- ko if : config_githubTokenSet -->
<input type="text" class="input-block-level" data-bind="value: config_githubToken" placeholder="{{ _('Token entered but hidden for privacy reasons')|edq }}">
<!-- /ko -->
<!-- ko ifnot : config_githubTokenSet -->
<input type="text" class="input-block-level" data-bind="value: config_githubToken" placeholder="{{ _('Enter a new token...')|edq }}">
<!-- /ko -->
<span class="help-block">{{ _('Set this if you keep running into rate limiting issues. <a href="%(url)s" target="_blank" rel="noopener noreferer">See here for how to obtain a token</a>.', url="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token") }}</span>
</div>
</div>