Skip to content

Commit

Permalink
Disable the state button instead of hidding it
Browse files Browse the repository at this point in the history
for non-admin users
  • Loading branch information
egli committed Oct 4, 2024
1 parent 68787a8 commit a5b150a
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/cljs/daisyproducer2/documents/state.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@
[document]
(let [admin? @(rf/subscribe [::auth/is-admin?])
state @(rf/subscribe [::current-state])]
(when admin?
(if (= state "open")
[:button.button.is-success
{:on-click (fn [e] (rf/dispatch [::update-state document "closed"]))}
[:span.icon {:aria-hidden true}
[:i.mi.mi-verified]]
[:span (tr [:close])]]
[:button.button.is-success.is-light
{:on-click (fn [e] (rf/dispatch [::update-state document "open"]))}
[:span.icon {:aria-hidden true}
[:i.mi.mi-refresh]]
[:span (tr [:reopen])]]))))
(if (= state "open")
[:button.button.is-success
{:on-click (fn [e] (rf/dispatch [::update-state document "closed"]))
:disabled (not admin?)}
[:span.icon {:aria-hidden true}
[:i.mi.mi-verified]]
[:span (tr [:close])]]
[:button.button.is-success.is-light
{:on-click (fn [e] (rf/dispatch [::update-state document "open"]))
:disabled (not admin?)}
[:span.icon {:aria-hidden true}
[:i.mi.mi-refresh]]
[:span (tr [:reopen])]])))

0 comments on commit a5b150a

Please sign in to comment.