✨ SWU: Add button to clear the Github Access Token (#4609)

* Add github token clear checkbox in software update plugin

* Replace checkbox with action button for github access token removal in software update plugin

* Fix action button title
This commit is contained in:
Federico Nembrini authored and GitHub committed 2022-09-28 14:51:59 +02:00
1 parent 4c86459c1b
commit e74f87b07c
2 files changed
+33 -6

No files matched your search

@@ -241,6 +241,29 @@ $(function () {
self.configurationDialog.modal();
};
self.deleteGithubTokenApiKey = function () {
var data = {
plugins: {
softwareupdate: {
credentials: {
github: undefined
}
}
}
};
self.settings.saveData(data, {
success: function () {
self.performCheck();
},
complete: function () {
self.config_githubToken("");
self.config_githubTokenSet(false);
},
sending: true
});
};
self.savePluginSettings = function (viewModel, event) {
var target = $(event.target);
target.prepend('<i class="fa fa-spinner fa-spin"></i> ');
@@ -1,12 +1,16 @@
<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 -->
<div class="input-append input-block-level ">
<!-- 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 -->
<a class="btn add-on btn-danger" title="Delete GitHub Access Token" data-bind="click: function() { $root.deleteGithubTokenApiKey(); }, css: {'disabled': !$root.config_githubTokenSet()}"><i class="far fa-trash-alt"></i></a>
</div>
<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>
<span class="help-block">{{ _('Please note that the deletion of the access token is applied immediately, without having to "Confirm" first.') }}</span>
</div>
</div>