Skip to content

Commit

Permalink
Refactor label and scope text display
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinqian00 committed Feb 6, 2025
1 parent fc5ade7 commit 9bf0111
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/com/yetanalytics/lrs_admin_ui/language.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
23 changes: 9 additions & 14 deletions src/com/yetanalytics/lrs_admin_ui/views/credentials/api_key.cljs
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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]
Expand Down

0 comments on commit 9bf0111

Please sign in to comment.