Skip to content

Commit

Permalink
Add username to page headings
Browse files Browse the repository at this point in the history
This makes it clearer that a user is logged in, and who they are logged
in as.
  • Loading branch information
tobias committed Feb 1, 2024
1 parent 25a2479 commit bb01ae6
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 215 deletions.
74 changes: 38 additions & 36 deletions src/clojars/web/dashboard.clj
Original file line number Diff line number Diff line change
Expand Up @@ -77,39 +77,41 @@
"Recently pushed projects"]]
[:ul.recent-jars-list.row (map #(recent-jar stats %) (recent-jars db))]))

(defn dashboard [db account]
(html-doc
"Dashboard"
{:account account}
[:div.light-article.col-xs-12
[:h1 (str "Dashboard (" account ")")]
[:div.col-xs-12.col-sm-4
[:div.dash-palette
[:h2 "Your Projects"]
(let [jars (db/jars-by-username db account)]
(if (seq jars)
(unordered-list (map jar-link jars))
[:p "You don't have any projects, would you like to "
(link-to "https://github.com/clojars/clojars-web/wiki/Pushing" "add one")
"?"]))]]
[:div.col-xs-12.col-sm-4
[:div.dash-palette
[:h2 "Your Groups"]
(unordered-list
(map (fn [group-name]
(let [verified-group? (db/find-group-verification db group-name)]
(list [:span (group-link group-name)]
(when verified-group?
verified-group-badge-small))))
(db/find-groupnames db account)))]]
[:div.col-xs-12.col-sm-4
[:div.dash-palette
[:h2 "FAQ"]
[:ul
[:li (link-to "https://github.com/clojars/clojars-web/wiki/Tutorial" "How I create a new project?")]
[:li (link-to "https://github.com/clojars/clojars-web/wiki/Pushing" "How do I deploy to clojars?")]
[:li (link-to "https://github.com/clojars/clojars-web/wiki/Data" "How can I access clojars data programatically?")]
[:li (link-to "https://github.com/clojars/clojars-web/wiki/Groups" "What are groups?")]
[:li (link-to "https://github.com/clojars/clojars-web/wiki/Verified-Group-Names" "How do I verify a group name?")]
[:li (link-to "https://github.com/clojars/clojars-web/wiki/" "More...")]]]]]
(audit-table db account {:username account})))
(defn dashboard
[db account]
(let [heading (format "Dashboard (%s)" account)]
(html-doc
heading
{:account account}
[:div.light-article.col-xs-12
[:h1 heading]
[:div.col-xs-12.col-sm-4
[:div.dash-palette
[:h2 "Your Projects"]
(let [jars (db/jars-by-username db account)]
(if (seq jars)
(unordered-list (map jar-link jars))
[:p "You don't have any projects, would you like to "
(link-to "https://github.com/clojars/clojars-web/wiki/Pushing" "add one")
"?"]))]]
[:div.col-xs-12.col-sm-4
[:div.dash-palette
[:h2 "Your Groups"]
(unordered-list
(map (fn [group-name]
(let [verified-group? (db/find-group-verification db group-name)]
(list [:span (group-link group-name)]
(when verified-group?
verified-group-badge-small))))
(db/find-groupnames db account)))]]
[:div.col-xs-12.col-sm-4
[:div.dash-palette
[:h2 "FAQ"]
[:ul
[:li (link-to "https://github.com/clojars/clojars-web/wiki/Tutorial" "How I create a new project?")]
[:li (link-to "https://github.com/clojars/clojars-web/wiki/Pushing" "How do I deploy to clojars?")]
[:li (link-to "https://github.com/clojars/clojars-web/wiki/Data" "How can I access clojars data programatically?")]
[:li (link-to "https://github.com/clojars/clojars-web/wiki/Groups" "What are groups?")]
[:li (link-to "https://github.com/clojars/clojars-web/wiki/Verified-Group-Names" "How do I verify a group name?")]
[:li (link-to "https://github.com/clojars/clojars-web/wiki/" "More...")]]]]]
(audit-table db account {:username account}))))
89 changes: 45 additions & 44 deletions src/clojars/web/group_verification.clj
Original file line number Diff line number Diff line change
Expand Up @@ -108,47 +108,48 @@

(defn index
[account flash-data]
(html-doc
"Group Verification"
{:account account}
[:div.col-xs-6
[:h1 "Group Verification"]
(format-flash flash-data)
[:div.via-txt
[:h2 "Verification by TXT Record"]
[:details.help
[:summary "Help"]
(TXT-help account)]
(form-to [:post "/verify/group/txt"]
(label :group "Group name")
(text-field {:required true
:placeholder "com.example"}
:group)
(label :domain "Domain with TXT record")
(text-field {:required true
:placeholder "example.com"}
:domain)
(submit-button "Verify Group"))]
[:div.via-vcs
[:h2 "Verification of GitHub/Gitlab Repo Groups"]
[:details.help
[:summary "Help"]
(vcs-help account)]
(form-to [:post "/verify/group/vcs"]
(label :url "Verification Repository URL")
(text-field {:required true
:placeholder (format "https://github.com/example/clojars-%s"
account)}
:url)
(submit-button "Verify Groups"))]
[:div.via-parent
[:h2 "Verification by Parent Group"]
[:details.help
[:summary "Help"]
parent-help]
(form-to [:post "/verify/group/parent"]
(label :group "Group name")
(text-field {:required true
:placeholder "com.example.ham"}
:group)
(submit-button "Verify Group"))]]))
(let [heading (format "Group Verification (%s)" account)]
(html-doc
heading
{:account account}
[:div.col-xs-6
[:h1 heading]
(format-flash flash-data)
[:div.via-txt
[:h2 "Verification by TXT Record"]
[:details.help
[:summary "Help"]
(TXT-help account)]
(form-to [:post "/verify/group/txt"]
(label :group "Group name")
(text-field {:required true
:placeholder "com.example"}
:group)
(label :domain "Domain with TXT record")
(text-field {:required true
:placeholder "example.com"}
:domain)
(submit-button "Verify Group"))]
[:div.via-vcs
[:h2 "Verification of GitHub/Gitlab Repo Groups"]
[:details.help
[:summary "Help"]
(vcs-help account)]
(form-to [:post "/verify/group/vcs"]
(label :url "Verification Repository URL")
(text-field {:required true
:placeholder (format "https://github.com/example/clojars-%s"
account)}
:url)
(submit-button "Verify Groups"))]
[:div.via-parent
[:h2 "Verification by Parent Group"]
[:details.help
[:summary "Help"]
parent-help]
(form-to [:post "/verify/group/parent"]
(label :group "Group name")
(text-field {:required true
:placeholder "com.example.ham"}
:group)
(submit-button "Verify Group"))]])))
153 changes: 77 additions & 76 deletions src/clojars/web/token.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,79 +49,80 @@
([account tokens jars groups]
(show-tokens account tokens jars groups nil))
([account tokens jars groups {:keys [error message new-token]}]
(html-doc
"Deploy Tokens"
{:account account
:description "Clojars deploy tokens"
:extra-js ["/js/tokens.js"]}
[:div
[:h1 "Deploy Tokens"]
(error-list (when error [error]))
(flash message)
(flash (new-token-message new-token))]
[:div.col-xs-12.col-sm-12
[:div.help
[:p "A deploy token is used in place of a password when deploying, and cannot be used to log in. "
"Tokens can be scoped to:"]
[:ul
[:li "any artifact you have access to ('*')"]
[:li "any artifact within a group you have access to ('group-name/*')"]
[:li "a particular artifact you have access to ('group-name/artifact-name')"]]]]
[:div.add-token.col-xs-12.col-sm-12
[:h2 "Create Deploy Token"]
[:p [:strong "Note:"]
" the token value will only be shown once after it is created, so be sure to copy it."]
(form-table
[:post "/tokens/"]
[[(label :name "Token name")
(text-field {:placeholder "Laptop deploy token"
:required true}
:name)]
[(label :scope "Token scope")
(drop-down :scope (scope-options jars groups))]
[(label :single_use "Single use?")
(check-box :single_use)]
[(label :expires_in "Expires in")
(drop-down :expires_in expiry-options)]]
(submit-button "Create Token"))]
[:div.token-table.col-xs-12.col-sm-12
[:h2 "Existing Deploy Tokens"]
[:div
[:span "Show: "]
[:span "disabled tokens?" (check-box :show-disabled)]
[:span "expired tokens?" (check-box :show-expired)]
[:span "used single-use tokens?" (check-box :show-used)]]
[:table.table.deploy-tokens
[:thead
[:tr
[:th "Token Name"]
[:th "Scope"]
[:th "Single Use?"]
[:th "Expires"]
[:th "Created"]
[:th "Disabled"]
[:th "Last Used"]
[:th "Actions"]]]
[:tbody
(for [token tokens
:let [disabled? (:disabled token)
expired? (auth/token-expired? token)
used? (= "used" (:single_use token))
classes (str/join " "
(remove nil?
[(when disabled? "token-disabled")
(when expired? "token-expired")
(when used? "token-used")]))]]
[:tr {:class classes}
[:td.name (:name token)]
[:td.scope (scope token)]
[:td.single-use (:single_use token)]
[:td.expires (format-timestamp (:expires_at token))]
[:td.created (format-timestamp (:created token))]
[:td.updated (when disabled? (format-timestamp (:updated token)))]
[:td.last-used (format-timestamp (:last_used token))]
[:td.actions (when-not (or disabled?
expired?
used?)
(form-to [:delete (str "/tokens/" (:id token))]
[:input.button {:type "submit" :value "Disable Token"}]))]])]]])))
(let [heading (format "Deploy Tokens (%s)" account)]
(html-doc
heading
{:account account
:description "Clojars deploy tokens"
:extra-js ["/js/tokens.js"]}
[:div
[:h1 heading]
(error-list (when error [error]))
(flash message)
(flash (new-token-message new-token))]
[:div.col-xs-12.col-sm-12
[:div.help
[:p "A deploy token is used in place of a password when deploying, and cannot be used to log in. "
"Tokens can be scoped to:"]
[:ul
[:li "any artifact you have access to ('*')"]
[:li "any artifact within a group you have access to ('group-name/*')"]
[:li "a particular artifact you have access to ('group-name/artifact-name')"]]]]
[:div.add-token.col-xs-12.col-sm-12
[:h2 "Create Deploy Token"]
[:p [:strong "Note:"]
" the token value will only be shown once after it is created, so be sure to copy it."]
(form-table
[:post "/tokens/"]
[[(label :name "Token name")
(text-field {:placeholder "Laptop deploy token"
:required true}
:name)]
[(label :scope "Token scope")
(drop-down :scope (scope-options jars groups))]
[(label :single_use "Single use?")
(check-box :single_use)]
[(label :expires_in "Expires in")
(drop-down :expires_in expiry-options)]]
(submit-button "Create Token"))]
[:div.token-table.col-xs-12.col-sm-12
[:h2 "Existing Deploy Tokens"]
[:div
[:span "Show: "]
[:span "disabled tokens?" (check-box :show-disabled)]
[:span "expired tokens?" (check-box :show-expired)]
[:span "used single-use tokens?" (check-box :show-used)]]
[:table.table.deploy-tokens
[:thead
[:tr
[:th "Token Name"]
[:th "Scope"]
[:th "Single Use?"]
[:th "Expires"]
[:th "Created"]
[:th "Disabled"]
[:th "Last Used"]
[:th "Actions"]]]
[:tbody
(for [token tokens
:let [disabled? (:disabled token)
expired? (auth/token-expired? token)
used? (= "used" (:single_use token))
classes (str/join " "
(remove nil?
[(when disabled? "token-disabled")
(when expired? "token-expired")
(when used? "token-used")]))]]
[:tr {:class classes}
[:td.name (:name token)]
[:td.scope (scope token)]
[:td.single-use (:single_use token)]
[:td.expires (format-timestamp (:expires_at token))]
[:td.created (format-timestamp (:created token))]
[:td.updated (when disabled? (format-timestamp (:updated token)))]
[:td.last-used (format-timestamp (:last_used token))]
[:td.actions (when-not (or disabled?
expired?
used?)
(form-to [:delete (str "/tokens/" (:id token))]
[:input.button {:type "submit" :value "Disable Token"}]))]])]]]))))
Loading

0 comments on commit bb01ae6

Please sign in to comment.