From 8c4846f76b064920ba587a4483971bc9835dca71 Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Wed, 5 Feb 2025 10:40:54 -0500 Subject: [PATCH 01/11] Refactor API key row view --- .../views/credentials/api_key.cljs | 249 ++++++++++-------- 1 file changed, 137 insertions(+), 112 deletions(-) diff --git a/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs b/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs index a94ebca4..46ff0967 100644 --- a/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs +++ b/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs @@ -6,121 +6,146 @@ [com.yetanalytics.lrs-admin-ui.functions.scopes :refer [scope-list has-scope? toggle-scope]] [com.yetanalytics.lrs-admin-ui.functions :refer [ps-event]])) +(defn- scope-list-text + "Convert scopes into a comma-separated list, e.g. \"all, all-read\"." + [scopes] + (map-indexed (fn [idx scope] + [:span {:key (str "scope-display-" scope)} + (str (when (> idx 0) + ", ") + scope)]) + scopes)) + +(defn- api-key-row + [{:keys [api-key scopes] :as _credential} expanded] + [:div {:class "api-key-row" + :aria-label @(subscribe [:lang/get :notification.key.aria]) + :on-click #(swap! expanded not)} + [:div {:class "api-key-col"} + [:span {:class (str "collapse-sign" + (when @expanded " expanded"))} + [:input {:value api-key + :class "key-display" + :read-only true}] + [copy-text + {:text api-key + :on-copy #(dispatch [:notification/notify false + @(subscribe [:lang/get :notification.credentials.key-copied])])} + [:a {:class "icon-copy" + :on-click #(ps-event %)}]]]] + [:div {:class "api-key-col"} + @(subscribe [:lang/get :credentials.key.permissions]) + (scope-list-text scopes)]]) + +(defn- api-key-expand-edit + [idx {:keys [scopes] :as credential} edit] + [:div {:class "action-row"} + [:ul {:class "role-select"} + (map (fn [scope] + [:li {:class "role-checkbox" + :key (str "permission-check-" + idx "-" scope)} + [:input {:type "checkbox", + :name "scopes", + :value scope + :checked (has-scope? scopes scope) + :on-change #(dispatch [:credentials/update-credential + idx + (assoc credential :scopes + (toggle-scope scopes scope))])}] + [:label {:for "scopes"} (str " " scope)]]) + scope-list)] + [:ul {:class "action-icon-list"} + [:li + [:a {:href "#!", + :on-click (fn [] + (swap! edit not) + (dispatch [:credentials/save-credential credential])) + :class "icon-save"} @(subscribe [:lang/get :credentials.key.permissions.save])]] + [:li + [:a {:href "#!", + :on-click (fn [] + (swap! edit not) + (dispatch [:credentials/load-credentials])) + :class "icon-close"} @(subscribe [:lang/get :credentials.key.permissions.cancel])]]]]) + +(defn- api-key-expand-view + [{:keys [scopes] :as credential} edit] + (let [delete-confirm (r/atom false)] + (fn [_credential _edit] + [:div {:class "action-row"} + [:div {:class "action-label"} + (scope-list-text scopes)] + [:ul {:class "action-icon-list"} + [:li + [:a {:href "#!", + :on-click #(swap! edit not) + :class "icon-edit"} @(subscribe [:lang/get :credentials.key.edit])]] + (if @delete-confirm + [:li + [:span @(subscribe [:lang/get :credentials.key.delete.confirm])] + [:a {:href "#!", + :on-click #(do (dispatch [:credentials/delete-credential credential]) + (swap! delete-confirm not)) + :class "confirm-delete"} + "Yes"] + [:a {:href "#!" + :on-click #(swap! delete-confirm not) + :class "confirm-delete"} + "No"]] + [:li + [:a {:href "#!" + :on-click #(swap! delete-confirm not) + :class "icon-delete"} + @(subscribe [:lang/get :credentials.key.delete])]])]]))) + +(defn- api-key-expand-secret-key + [{:keys [secret-key] :as _credential}] + [:div {:class "action-label-wide"} + [:span + [:input {:value secret-key + :class "key-display" + :read-only true}] + [copy-text + {:text secret-key + :on-copy #(dispatch [:notification/notify false + @(subscribe [:lang/get :notification.credentials.secret-copied])])} + [:a {:class "icon-copy pointer"}]]]]) + +(defn- api-key-expand + [idx credential] + (let [edit (r/atom false) + show-secret (r/atom false)] + (fn [_idx _credential _delete-confirm] + [:div {:class "api-key-expand"} + [:div {:class "api-key-col"} + [:p {:class "api-key-col-header"} + @(subscribe [:lang/get :credentials.key.secret])] + [:div {:class "action-row"} + (when @show-secret + [api-key-expand-secret-key credential]) + [:ul {:class "action-icon-list"} + [:li + [:a {:href "#!", + :class "icon-secret" + :on-click #(swap! show-secret not)} + (str (cond + @show-secret @(subscribe [:lang/get :credentials.key.hide]) + :else @(subscribe [:lang/get :credentials.key.show])))]]]]] + [:div {:class "api-key-col"} + [:p {:class "api-key-col-header"} + @(subscribe [:lang/get :credentials.key.permissions])] + (if @edit + [api-key-expand-edit idx credential edit] + [api-key-expand-view credential edit])]]))) + (defn api-key [{:keys [idx]}] - (let [expanded (r/atom false) - show-secret (r/atom false) - edit (r/atom false) - delete-confirm (r/atom false)] + (let [expanded (r/atom false)] (fn [] - (let [credential @(subscribe [:credentials/get-credential idx]) - scopes (:scopes credential) - scope-display (map-indexed (fn [idx scope] - [:span {:key (str "scope-display-" idx)} - (str (when (> idx 0) - ", ") - scope)]) - scopes)] + (let [credential @(subscribe [:credentials/get-credential idx])] [:li {:class "mb-2"} [:div {:class "accordion-container"} - [:div {:class "api-key-row" - :aria-label @(subscribe [:lang/get :notification.key.aria]) - :on-click #(swap! expanded not)} - [:div {:class "api-key-col"} - [:span {:class (str "collapse-sign" - (when @expanded " expanded"))} - [:input {:value (:api-key credential) - :class "key-display" - :read-only true}] - [copy-text - {:text (:api-key credential) - :on-copy #(dispatch [:notification/notify false - @(subscribe [:lang/get :notification.credentials.key-copied])])} - [:a {:class "icon-copy" - :on-click #(ps-event %)}]]]] - [:div {:class "api-key-col"} @(subscribe [:lang/get :credentials.key.permissions]) scope-display]] + [api-key-row credential expanded] (when @expanded - [:div {:class "api-key-expand"} - [:div {:class "api-key-col"} - [:p {:class "api-key-col-header"} - @(subscribe [:lang/get :credentials.key.secret])] - [:div {:class "action-row"} - (when @show-secret - [:div {:class "action-label-wide"} - [:span - [:input {:value (:secret-key credential) - :class "key-display" - :read-only true}] - [copy-text - {:text (:secret-key credential) - :on-copy #(dispatch [:notification/notify false - @(subscribe [:lang/get :notification.credentials.secret-copied])])} - [:a {:class "icon-copy pointer"}]]]]) - [:ul {:class "action-icon-list"} - [:li - [:a {:href "#!", - :class "icon-secret" - :on-click #(swap! show-secret not)} - (str (cond - @show-secret @(subscribe [:lang/get :credentials.key.hide]) - :else @(subscribe [:lang/get :credentials.key.show])))]]]]] - [:div {:class "api-key-col"} - [:p {:class "api-key-col-header"} - @(subscribe [:lang/get :credentials.key.permissions])] - (cond - @edit - [:div {:class "action-row"} - [:ul {:class "role-select"} - (map (fn [scope] - [:li {:class "role-checkbox" - :key (str "permission-check-" - idx "-" scope)} - [:input {:type "checkbox", - :name "scopes", - :value scope - :checked (has-scope? scopes scope) - :on-change #(dispatch [:credentials/update-credential - idx - (assoc credential :scopes - (toggle-scope scopes scope))])}] - [:label {:for "scopes"} (str " " scope)]]) - scope-list)] - [:ul {:class "action-icon-list"} - [:li - [:a {:href "#!", - :on-click (fn [] - (swap! edit not) - (dispatch [:credentials/save-credential credential])) - :class "icon-save"} @(subscribe [:lang/get :credentials.key.permissions.save])]] - [:li - [:a {:href "#!", - :on-click (fn [] - (swap! edit not) - (dispatch [:credentials/load-credentials])) - :class "icon-close"} @(subscribe [:lang/get :credentials.key.permissions.cancel])]]]] - :else - [:div {:class "action-row"} - [:div {:class "action-label"} - scope-display] - [:ul {:class "action-icon-list"} - [:li - [:a {:href "#!", - :on-click #(swap! edit not) - :class "icon-edit"} @(subscribe [:lang/get :credentials.key.edit])]] - (if @delete-confirm - [:li - [:span @(subscribe [:lang/get :credentials.key.delete.confirm])] - [:a {:href "#!", - :on-click #(do (dispatch [:credentials/delete-credential credential]) - (swap! delete-confirm not)) - :class "confirm-delete"} - "Yes"] - [:a {:href "#!" - :on-click #(swap! delete-confirm not) - :class "confirm-delete"} - "No"]] - [:li - [:a {:href "#!" - :on-click #(swap! delete-confirm not) - :class "icon-delete"} - @(subscribe [:lang/get :credentials.key.delete])]])]])]])]])))) + [api-key-expand idx credential])]])))) From 58171382b89d8c74ff5aecac85c1f36361715e1d Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Wed, 5 Feb 2025 11:45:05 -0500 Subject: [PATCH 02/11] Add label to api-key-row view --- .../lrs_admin_ui/views/credentials/api_key.cljs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs b/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs index 46ff0967..282667e5 100644 --- a/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs +++ b/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs @@ -17,10 +17,11 @@ scopes)) (defn- api-key-row - [{:keys [api-key scopes] :as _credential} expanded] + [{:keys [api-key label scopes] :as _credential} expanded] [:div {:class "api-key-row" :aria-label @(subscribe [:lang/get :notification.key.aria]) :on-click #(swap! expanded not)} + ;; API Key View [:div {:class "api-key-col"} [:span {:class (str "collapse-sign" (when @expanded " expanded"))} @@ -33,6 +34,10 @@ @(subscribe [:lang/get :notification.credentials.key-copied])])} [:a {:class "icon-copy" :on-click #(ps-event %)}]]]] + ;; Label + [:div {:class "api-key-col"} + "Label: " [:span (or label "(None)")]] + ;; Permissions [:div {:class "api-key-col"} @(subscribe [:lang/get :credentials.key.permissions]) (scope-list-text scopes)]]) From 7dd6a87cd2bd88917969d4dc46d0c94decb06c09 Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Wed, 5 Feb 2025 11:46:38 -0500 Subject: [PATCH 03/11] Change CSS to accomodate third column in API row header --- resources/sass/global.scss | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/sass/global.scss b/resources/sass/global.scss index b5d28eab..cef0c626 100644 --- a/resources/sass/global.scss +++ b/resources/sass/global.scss @@ -905,15 +905,15 @@ span.close-alert img { } @media only screen and (max-width: 1124px) { - .accordion .accordion-container .accordion-header > div:nth-child(2) { + .accordion .accordion-container > div:nth-child(2) { padding-left: 20px; } } - /************************************************** # Action Icon List **************************************************/ + .action-row { display: table; width: 100%; @@ -1075,7 +1075,7 @@ a.icon-copy:hover { } .api-key-col { - @extend .col-sm-12, .col-lg-6; + @extend .col-sm-8, .col-lg-4; } .api-key-col-header { @@ -1125,7 +1125,7 @@ input.key-display { } .account-col { - @extend .api-key-col; + @extend .col-sm-12, .col-lg-6; } .account-col-header { From a20fda41c2574001a618e799006e0a8d7c40b5c3 Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Wed, 5 Feb 2025 11:58:40 -0500 Subject: [PATCH 04/11] Credential needs to be inner fn param --- .../lrs_admin_ui/views/credentials/api_key.cljs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs b/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs index 282667e5..3360358d 100644 --- a/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs +++ b/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs @@ -75,9 +75,9 @@ :class "icon-close"} @(subscribe [:lang/get :credentials.key.permissions.cancel])]]]]) (defn- api-key-expand-view - [{:keys [scopes] :as credential} edit] + [_credential edit] (let [delete-confirm (r/atom false)] - (fn [_credential _edit] + (fn [{:keys [scopes] :as credential} _edit] [:div {:class "action-row"} [:div {:class "action-label"} (scope-list-text scopes)] @@ -118,10 +118,10 @@ [:a {:class "icon-copy pointer"}]]]]) (defn- api-key-expand - [idx credential] + [_idx _credential] (let [edit (r/atom false) show-secret (r/atom false)] - (fn [_idx _credential _delete-confirm] + (fn [idx credential] [:div {:class "api-key-expand"} [:div {:class "api-key-col"} [:p {:class "api-key-col-header"} @@ -145,9 +145,9 @@ [api-key-expand-view credential edit])]]))) (defn api-key - [{:keys [idx]}] + [_props] (let [expanded (r/atom false)] - (fn [] + (fn [{:keys [idx]}] (let [credential @(subscribe [:credentials/get-credential idx])] [:li {:class "mb-2"} [:div {:class "accordion-container"} From a95b7afc967eb5120f827dfaea7d5ca3550359a5 Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Thu, 6 Feb 2025 15:49:20 -0500 Subject: [PATCH 05/11] Change edit view to add label input --- .../views/credentials/api_key.cljs | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs b/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs index 3360358d..9a4fd470 100644 --- a/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs +++ b/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs @@ -4,7 +4,7 @@ [re-frame.core :as re-frame :refer [dispatch subscribe]] [com.yetanalytics.lrs-admin-ui.functions.copy :refer [copy-text]] [com.yetanalytics.lrs-admin-ui.functions.scopes :refer [scope-list has-scope? toggle-scope]] - [com.yetanalytics.lrs-admin-ui.functions :refer [ps-event]])) + [com.yetanalytics.lrs-admin-ui.functions :refer [ps-event ps-event-val]])) (defn- scope-list-text "Convert scopes into a comma-separated list, e.g. \"all, all-read\"." @@ -43,8 +43,18 @@ (scope-list-text scopes)]]) (defn- api-key-expand-edit - [idx {:keys [scopes] :as credential} edit] + [idx {:keys [label scopes] :as credential} edit] [:div {:class "action-row"} + ;; Label editor + [:input + {:class "label-editor round" + :value label + :placeholder "Add Label" + :on-change (fn [e] + (let [new-label (not-empty (ps-event-val e)) + new-cred (assoc credential :label new-label)] + (dispatch [:credentials/update-credential idx new-cred])))}] + ;; Scope selector [:ul {:class "role-select"} (map (fn [scope] [:li {:class "role-checkbox" @@ -61,26 +71,28 @@ [:label {:for "scopes"} (str " " scope)]]) scope-list)] [:ul {:class "action-icon-list"} + ;; Save button [:li [:a {:href "#!", :on-click (fn [] (swap! edit not) (dispatch [:credentials/save-credential credential])) - :class "icon-save"} @(subscribe [:lang/get :credentials.key.permissions.save])]] + :class "icon-save"} + @(subscribe [:lang/get :credentials.key.permissions.save])]] + ;; Cancel button [:li [:a {:href "#!", :on-click (fn [] (swap! edit not) (dispatch [:credentials/load-credentials])) - :class "icon-close"} @(subscribe [:lang/get :credentials.key.permissions.cancel])]]]]) + :class "icon-close"} + @(subscribe [:lang/get :credentials.key.permissions.cancel])]]]]) (defn- api-key-expand-view [_credential edit] (let [delete-confirm (r/atom false)] - (fn [{:keys [scopes] :as credential} _edit] + (fn [credential _edit] [:div {:class "action-row"} - [:div {:class "action-label"} - (scope-list-text scopes)] [:ul {:class "action-icon-list"} [:li [:a {:href "#!", @@ -139,7 +151,10 @@ :else @(subscribe [:lang/get :credentials.key.show])))]]]]] [:div {:class "api-key-col"} [:p {:class "api-key-col-header"} - @(subscribe [:lang/get :credentials.key.permissions])] + (if @edit + "Edit Credential" + "Actions") + #_@(subscribe [:lang/get :credentials.key.permissions])] (if @edit [api-key-expand-edit idx credential edit] [api-key-expand-view credential edit])]]))) From b110eba56257381dcc1c84a100f8f122cee4524a Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Thu, 6 Feb 2025 15:49:31 -0500 Subject: [PATCH 06/11] Update CSS for label and scope editors --- resources/sass/global.scss | 47 ++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/resources/sass/global.scss b/resources/sass/global.scss index cef0c626..3a7ba398 100644 --- a/resources/sass/global.scss +++ b/resources/sass/global.scss @@ -939,7 +939,7 @@ span.close-alert img { .action-icon-list li { display: inline-block; vertical-align: top; - margin: 0 0 18px 24px; + margin: 0 12px 18px 0; padding: 0; } @@ -1108,6 +1108,30 @@ input.key-display { vertical-align: top; } +// Credential Label Editor + +input.label-editor { + margin-bottom: 8px; +} + +// Credential Roles Editor + +ul.role-select { + padding-left: 0; + margin-bottom: 8px; +} + +ul.role-select li.role-checkbox { + vertical-align: top; + margin: 0px; + padding: 0px; + list-style-type: none; +} + +.role-checkbox label { + padding-left: 4px; +} + /************************************************** # Accounts ***************************************************/ @@ -1251,27 +1275,6 @@ div.browser-filters { white-space: nowrap; } -/************************************************** -# Roles -**************************************************/ - -ul.role-select { - margin: 0px; - padding: 0px; -} - -ul.role-select li.role-checkbox { - vertical-align: top; - margin: 0px; - padding: 0px; - list-style-type: none; -} - -.role-checkbox label { - padding-left: 4px; -} - - /************************************************** # Tooltip **************************************************/ From 581aef7c7c60d4e0743dbb9ec846ca0e8e1c8fdd Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Thu, 6 Feb 2025 15:54:06 -0500 Subject: [PATCH 07/11] Add new entries for lang/get --- src/com/yetanalytics/lrs_admin_ui/language.cljs | 5 ++++- .../yetanalytics/lrs_admin_ui/views/accounts.cljs | 4 ++-- .../lrs_admin_ui/views/credentials/api_key.cljs | 12 ++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/com/yetanalytics/lrs_admin_ui/language.cljs b/src/com/yetanalytics/lrs_admin_ui/language.cljs index 6224ff3c..d411c25c 100644 --- a/src/com/yetanalytics/lrs_admin_ui/language.cljs +++ b/src/com/yetanalytics/lrs_admin_ui/language.cljs @@ -32,12 +32,15 @@ :credentials.tenant.number {:en-US "Number of Credentials: "} :credentials.tenant.key {:en-US "Api Key"} :credentials.key.aria {:en-US "Show/Hide Api Key Details"} - :credentials.key.permissions {:en-US "Permissions "} + :credentials.key.label {:en-US "Label: "} + :credentials.key.permissions {:en-US "Permissions: "} :credentials.key.secret {:en-US "API Key Secret"} :credentials.key.hide {:en-US "Hide"} :credentials.key.show {:en-US "Show Secret Key"} :credentials.key.permissions.save {:en-US "Save"} :credentials.key.permissions.cancel {:en-US "Cancel"} + :credentials.key.actions {:en-US "Actions"} + :credentials.key.edit-credential {:en-US "Edit Credential"} :credentials.key.edit {:en-US "Edit"} :credentials.key.delete {:en-US "Delete"} :credentials.key.delete.confirm {:en-US "Are you sure?"} diff --git a/src/com/yetanalytics/lrs_admin_ui/views/accounts.cljs b/src/com/yetanalytics/lrs_admin_ui/views/accounts.cljs index c4092d1f..25849143 100644 --- a/src/com/yetanalytics/lrs_admin_ui/views/accounts.cljs +++ b/src/com/yetanalytics/lrs_admin_ui/views/accounts.cljs @@ -27,11 +27,11 @@ :on-click #(do (dispatch [:accounts/delete-account account]) (swap! delete-confirm not)) :class "confirm-delete"} - "Yes"] + "Yes"] ; TODO: :lang/get [:a {:href "#!" :on-click #(swap! delete-confirm not) :class "confirm-delete"} - "No"]] + "No"]] ; TODO: :lang/get [:li [:a {:href "#!" :on-click #(swap! delete-confirm not) diff --git a/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs b/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs index 9a4fd470..8c76734a 100644 --- a/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs +++ b/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs @@ -36,7 +36,8 @@ :on-click #(ps-event %)}]]]] ;; Label [:div {:class "api-key-col"} - "Label: " [:span (or label "(None)")]] + @(subscribe [:lang/get :credentials.key.label]) + [:span (or label "(None)")]] ;; Permissions [:div {:class "api-key-col"} @(subscribe [:lang/get :credentials.key.permissions]) @@ -105,11 +106,11 @@ :on-click #(do (dispatch [:credentials/delete-credential credential]) (swap! delete-confirm not)) :class "confirm-delete"} - "Yes"] + "Yes"] ; TODO: :lang/get [:a {:href "#!" :on-click #(swap! delete-confirm not) :class "confirm-delete"} - "No"]] + "No"]] ; TODO: :lang/get [:li [:a {:href "#!" :on-click #(swap! delete-confirm not) @@ -152,9 +153,8 @@ [:div {:class "api-key-col"} [:p {:class "api-key-col-header"} (if @edit - "Edit Credential" - "Actions") - #_@(subscribe [:lang/get :credentials.key.permissions])] + @(subscribe [:lang/get :credentials.key.edit-credential]) + @(subscribe [:lang/get :credentials.key.actions]))] (if @edit [api-key-expand-edit idx credential edit] [api-key-expand-view credential edit])]]))) From fc5ade7c5bcf36c8d14a58d29276ef79c3c0de5e Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Thu, 6 Feb 2025 16:03:14 -0500 Subject: [PATCH 08/11] Add spec for cred label --- src/com/yetanalytics/lrs_admin_ui/db.cljs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/com/yetanalytics/lrs_admin_ui/db.cljs b/src/com/yetanalytics/lrs_admin_ui/db.cljs index d6246bc1..6f970093 100644 --- a/src/com/yetanalytics/lrs_admin_ui/db.cljs +++ b/src/com/yetanalytics/lrs_admin_ui/db.cljs @@ -26,6 +26,7 @@ (s/def :credential/api-key string?) (s/def :credential/secret-key string?) +(s/def :credential/label (s/nilable (s/and string? not-empty))) (s/def :credential/scope string?) (s/def :credential/scopes (s/every :credential/scope)) @@ -33,6 +34,7 @@ (s/def ::credential (s/keys :req-un [:credential/api-key :credential/secret-key + :credential/label :credential/scopes])) (s/def ::credentials From 9bf0111e588694defb6a2bc9a7e5bca2e11d45b6 Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Thu, 6 Feb 2025 16:07:08 -0500 Subject: [PATCH 09/11] Refactor label and scope text display --- .../yetanalytics/lrs_admin_ui/language.cljs | 4 ++-- .../views/credentials/api_key.cljs | 23 ++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/com/yetanalytics/lrs_admin_ui/language.cljs b/src/com/yetanalytics/lrs_admin_ui/language.cljs index d411c25c..5636b00f 100644 --- a/src/com/yetanalytics/lrs_admin_ui/language.cljs +++ b/src/com/yetanalytics/lrs_admin_ui/language.cljs @@ -32,8 +32,8 @@ :credentials.tenant.number {:en-US "Number of Credentials: "} :credentials.tenant.key {:en-US "Api Key"} :credentials.key.aria {:en-US "Show/Hide Api Key Details"} - :credentials.key.label {:en-US "Label: "} - :credentials.key.permissions {:en-US "Permissions: "} + :credentials.key.label {:en-US "Label:"} + :credentials.key.permissions {:en-US "Permissions:"} :credentials.key.secret {:en-US "API Key Secret"} :credentials.key.hide {:en-US "Hide"} :credentials.key.show {:en-US "Show Secret Key"} diff --git a/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs b/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs index 8c76734a..a15d376c 100644 --- a/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs +++ b/src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs @@ -1,21 +1,12 @@ (ns com.yetanalytics.lrs-admin-ui.views.credentials.api-key (:require + [clojure.string :as cstr] [reagent.core :as r] [re-frame.core :as re-frame :refer [dispatch subscribe]] [com.yetanalytics.lrs-admin-ui.functions.copy :refer [copy-text]] [com.yetanalytics.lrs-admin-ui.functions.scopes :refer [scope-list has-scope? toggle-scope]] [com.yetanalytics.lrs-admin-ui.functions :refer [ps-event ps-event-val]])) -(defn- scope-list-text - "Convert scopes into a comma-separated list, e.g. \"all, all-read\"." - [scopes] - (map-indexed (fn [idx scope] - [:span {:key (str "scope-display-" scope)} - (str (when (> idx 0) - ", ") - scope)]) - scopes)) - (defn- api-key-row [{:keys [api-key label scopes] :as _credential} expanded] [:div {:class "api-key-row" @@ -36,12 +27,16 @@ :on-click #(ps-event %)}]]]] ;; Label [:div {:class "api-key-col"} - @(subscribe [:lang/get :credentials.key.label]) - [:span (or label "(None)")]] + (str + @(subscribe [:lang/get :credentials.key.label]) + " " + (or label "(None)"))] ;; Permissions [:div {:class "api-key-col"} - @(subscribe [:lang/get :credentials.key.permissions]) - (scope-list-text scopes)]]) + (str + @(subscribe [:lang/get :credentials.key.permissions]) + " " + (cstr/join ", " scopes))]]) (defn- api-key-expand-edit [idx {:keys [label scopes] :as credential} edit] From bf12fc2075edfc01a600daa1f4ffeac173019462 Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Fri, 7 Feb 2025 17:13:06 -0500 Subject: [PATCH 10/11] Try installing chromium to fix failing test --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 540a8306..a6473afa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,9 @@ jobs: - name: Setup CI Environment uses: yetanalytics/action-setup-env@v2 + - name: Install Chromium + uses: browser-actions/setup-chrome + - name: Cache Deps uses: actions/cache@v4 with: From 7b35c4266bf9fb05c1efd037c7f6b2951a2ef03b Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Fri, 7 Feb 2025 17:13:22 -0500 Subject: [PATCH 11/11] Add version tag --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6473afa..423b5af2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: uses: yetanalytics/action-setup-env@v2 - name: Install Chromium - uses: browser-actions/setup-chrome + uses: browser-actions/setup-chrome@v1 - name: Cache Deps uses: actions/cache@v4