From cf33fb97920c10a13811c988fe40b5c188b50a71 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Thu, 2 Jun 2022 16:45:20 +0200 Subject: [PATCH] Style and other fixes for API features --- .../controllers/admin-wizards-api-show.js.es6 | 5 ++++ .../templates/admin-wizards-api-show.hbs | 30 +++++++++++-------- assets/stylesheets/admin/admin.scss | 10 +++++-- assets/stylesheets/admin/wizard/api.scss | 19 +++++++----- config/locales/client.en.yml | 1 + lib/custom_wizard/api/log_entry.rb | 2 +- 6 files changed, 43 insertions(+), 24 deletions(-) diff --git a/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 b/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 index 7d3c1084..f41c3ada 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 @@ -88,6 +88,11 @@ export default Controller.extend({ twoLeggedOauth: equal("api.authType", "oauth_2"), threeLeggedOauth: equal("api.authType", "oauth_3"), + @discourseComputed("api.isNew") + nameClass(isNew) { + return isNew ? "new" : "saved"; + }, + actions: { addParam() { this.get("api.authParams").pushObject({}); diff --git a/assets/javascripts/discourse/templates/admin-wizards-api-show.hbs b/assets/javascripts/discourse/templates/admin-wizards-api-show.hbs index 4d3def3d..303b3f6d 100644 --- a/assets/javascripts/discourse/templates/admin-wizards-api-show.hbs +++ b/assets/javascripts/discourse/templates/admin-wizards-api-show.hbs @@ -21,11 +21,11 @@ {{/if}} -
+
{{#if api.isNew}} {{i18n "admin.wizard.api.new"}} {{else}} - {{api.title}} + {{api.title}} {{/if}}
@@ -35,12 +35,12 @@ {{input value=api.title placeholder=(i18n "admin.wizard.api.title_placeholder")}}
-
+
{{#if api.isNew}} {{input value=api.name placeholder=(i18n "admin.wizard.api.name_placeholder")}} {{else}} - {{api.name}} + {{api.name}} {{/if}}
@@ -63,7 +63,7 @@ {{/if}} -
+
{{i18n "admin.wizard.api.auth.label"}}
@@ -71,7 +71,7 @@
-
+
{{i18n "admin.wizard.api.auth.settings"}}
@@ -174,7 +174,7 @@ {{/if}}
-
+
{{i18n "admin.wizard.api.status.label"}}
@@ -220,7 +220,7 @@ {{/if}}
-
+
{{i18n "admin.wizard.api.endpoint.label"}}
@@ -277,11 +277,15 @@ {{/if}}
-
+
{{i18n "admin.wizard.api.log.label"}} - {{d-button action=(action "clearLogs") - icon="trash-alt" - class="clear-logs"}} + +
+ {{d-button + action=(action "clearLogs") + class="clear-logs" + label="admin.wizard.api.log.clear"}} +
@@ -300,7 +304,7 @@ {{logentry.time}} {{logentry.status}} diff --git a/assets/stylesheets/admin/admin.scss b/assets/stylesheets/admin/admin.scss index 70d5d539..d0106337 100644 --- a/assets/stylesheets/admin/admin.scss +++ b/assets/stylesheets/admin/admin.scss @@ -79,7 +79,8 @@ $error: #ef1700; } } - & + div { + & + div, + & + div + div { margin-top: 30px; } } @@ -212,6 +213,7 @@ $error: #ef1700; .wizard-header { margin-bottom: 20px; + display: flex; &.large { font-size: 1.5em; @@ -253,11 +255,12 @@ $error: #ef1700; } &.medium { - font-size: 1.3em; + font-size: 1.2em; } &.small { font-size: 1em; + font-weight: 700; margin-bottom: 5px; } @@ -266,8 +269,9 @@ $error: #ef1700; } .controls { + font-size: 1rem; + display: flex; margin-left: auto; - margin-right: 0.5rem; } } diff --git a/assets/stylesheets/admin/wizard/api.scss b/assets/stylesheets/admin/wizard/api.scss index 9d0ad261..29aff22d 100644 --- a/assets/stylesheets/admin/wizard/api.scss +++ b/assets/stylesheets/admin/wizard/api.scss @@ -40,9 +40,18 @@ float: right; } - .wizard-header { - overflow: hidden; - font-size: 1.3em; + .metadata { + display: flex; + + .title { + margin-right: 1em; + } + + .name.saved span { + display: inline-block; + padding: 6px 12px; + background-color: var(--primary-low); + } } } @@ -74,10 +83,6 @@ width: 50%; max-width: 50%; - .wizard-header { - overflow: hidden; - } - .authorization { float: right; } diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 45efabb8..6fe9e5ee 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -447,6 +447,7 @@ en: log: label: "Logs" + clear: clear log: nav_label: "Logs" diff --git a/lib/custom_wizard/api/log_entry.rb b/lib/custom_wizard/api/log_entry.rb index 3fe2969e..31af514e 100644 --- a/lib/custom_wizard/api/log_entry.rb +++ b/lib/custom_wizard/api/log_entry.rb @@ -27,7 +27,7 @@ class CustomWizard::Api::LogEntry log_id = new_data['log_id'] else data = {} - log_id = SecureRandom.hex(3) + log_id = SecureRandom.hex(8) end new_data.each do |k, v|