From c6fed81d28f32dd727211683c401cd59823f3fd3 Mon Sep 17 00:00:00 2001 From: Robert Barrow Date: Wed, 12 Jun 2019 21:57:38 +0100 Subject: [PATCH] updated some ember actions to closure actions to remove deprecation warnings, fixed issue where you could not remove last auth parameter as key would never be cleared --- .../discourse/templates/admin-wizards-api.hbs | 16 ++++++++-------- lib/api/authorization.rb | 7 +++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/assets/javascripts/discourse/templates/admin-wizards-api.hbs b/assets/javascripts/discourse/templates/admin-wizards-api.hbs index 32618101..6a0a8067 100644 --- a/assets/javascripts/discourse/templates/admin-wizards-api.hbs +++ b/assets/javascripts/discourse/templates/admin-wizards-api.hbs @@ -8,10 +8,10 @@ {{/if}} {{/if}} - {{d-button label="admin.wizard.api.save" action="save" class="btn-primary" disabled=saveDisabled}} + {{d-button label="admin.wizard.api.save" action=(action "save") class="btn-primary" disabled=saveDisabled}} {{#if showRemove}} - {{d-button action="remove" label="admin.wizard.api.remove"}} + {{d-button action=(action "remove") label="admin.wizard.api.remove"}} {{/if}} {{#if error}} @@ -57,7 +57,7 @@ {{/if}} {{/if}} {{d-button label="admin.wizard.api.auth.btn" - action="authorize" + action=(action "authorize") disabled=authDisabled class="btn-primary"}} {{/if}} @@ -131,10 +131,10 @@
{{input value=param.key placeholder=(i18n 'admin.wizard.api.auth.params.key')}} {{input value=param.value placeholder=(i18n 'admin.wizard.api.auth.params.value')}} - {{d-button action='removeParam' actionParam=param icon='times'}} + {{d-button action=(action "removeParam") actionParam=param icon='times'}}
{{/each}} - {{d-button label='admin.wizard.api.auth.params.new' icon='plus' action='addParam'}} + {{d-button label='admin.wizard.api.auth.params.new' icon='plus' action=(action "addParam")}} {{/if}} @@ -219,7 +219,7 @@
- {{d-button action='addEndpoint' label='admin.wizard.api.endpoint.add' icon='plus'}} + {{d-button action=(action "addEndpoint") label='admin.wizard.api.endpoint.add' icon='plus'}} {{#if api.endpoints}}
@@ -236,7 +236,7 @@ {{input value=endpoint.url placeholder=(i18n 'admin.wizard.api.endpoint.url') class='endpoint-url'}} - {{d-button action='removeEndpoint' + {{d-button action=(action "removeEndpoint") actionParam=endpoint icon='times' class='remove-endpoint'}} @@ -251,7 +251,7 @@
{{i18n 'admin.wizard.api.log.label'}} - {{d-button action='clearLogs' + {{d-button action=(action "clearLogs") icon='trash-alt' class='clear-logs'}}
diff --git a/lib/api/authorization.rb b/lib/api/authorization.rb index 3c57a955..9dd51d50 100644 --- a/lib/api/authorization.rb +++ b/lib/api/authorization.rb @@ -32,6 +32,7 @@ class CustomWizard::Api::Authorization end def self.set(api_name, new_data = {}) + api_name = api_name.underscore data = self.get(api_name, data_only: true) || {} @@ -40,6 +41,12 @@ class CustomWizard::Api::Authorization data[k.to_sym] = v end + data.each do |k, v| + unless new_data.key?(k.to_s) + data.delete(k) + end + end + PluginStore.set("custom_wizard_api_#{api_name}", 'authorization', data) self.get(api_name)