📎 Minor code cleaning on workspace header components.

This commit is contained in:
Andrey Antukh 2020-11-23 12:10:34 +01:00 committed by Alonso Torres
parent 45f17f78f3
commit 2dafbeddb0
2 changed files with 22 additions and 26 deletions

View file

@ -41,7 +41,6 @@
[beicon.core :as rx] [beicon.core :as rx]
[cljs.spec.alpha :as s] [cljs.spec.alpha :as s]
[clojure.set :as set] [clojure.set :as set]
[clojure.set :as set]
[cuerdas.core :as str] [cuerdas.core :as str]
;; [cljs.pprint :refer [pprint]] ;; [cljs.pprint :refer [pprint]]
[potok.core :as ptk])) [potok.core :as ptk]))

View file

@ -9,23 +9,21 @@
(ns app.main.ui.workspace.header (ns app.main.ui.workspace.header
(:require (:require
[okulary.core :as l] [app.common.math :as mth]
[rumext.alpha :as mf]
[app.main.ui.icons :as i :include-macros true]
[app.config :as cfg] [app.config :as cfg]
[app.main.data.history :as udh] [app.main.data.modal :as modal]
[app.main.data.workspace :as dw] [app.main.data.workspace :as dw]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.components.dropdown :refer [dropdown]] [app.main.ui.components.dropdown :refer [dropdown]]
[app.main.data.modal :as modal] [app.main.ui.icons :as i]
[app.main.ui.workspace.presence :as presence]
[app.main.ui.keyboard :as kbd] [app.main.ui.keyboard :as kbd]
[app.util.i18n :as i18n :refer [t]] [app.main.ui.workspace.presence :refer [active-sessions]]
[app.util.data :refer [classnames]]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.common.math :as mth] [app.util.i18n :as i18n :refer [tr]]
[app.util.router :as rt])) [app.util.router :as rt]
[okulary.core :as l]
[rumext.alpha :as mf]))
;; --- Zoom Widget ;; --- Zoom Widget
@ -34,28 +32,28 @@
(mf/defc persistence-state-widget (mf/defc persistence-state-widget
{::mf/wrap [mf/memo]} {::mf/wrap [mf/memo]}
[{:keys [locale]}] []
(let [data (mf/deref workspace-persistence-ref)] (let [data (mf/deref workspace-persistence-ref)]
[:div.persistence-status-widget [:div.persistence-status-widget
(cond (cond
(= :pending (:status data)) (= :pending (:status data))
[:div.pending [:div.pending
[:span.label (t locale "workspace.header.unsaved")]] [:span.label (tr "workspace.header.unsaved")]]
(= :saving (:status data)) (= :saving (:status data))
[:div.saving [:div.saving
[:span.icon i/toggle] [:span.icon i/toggle]
[:span.label (t locale "workspace.header.saving")]] [:span.label (tr "workspace.header.saving")]]
(= :saved (:status data)) (= :saved (:status data))
[:div.saved [:div.saved
[:span.icon i/tick] [:span.icon i/tick]
[:span.label (t locale "workspace.header.saved")]] [:span.label (tr "workspace.header.saved")]]
(= :error (:status data)) (= :error (:status data))
[:div.error {:title "There was an error saving the data. Please refresh if this persists."} [:div.error {:title "There was an error saving the data. Please refresh if this persists."}
[:span.icon i/msg-warning] [:span.icon i/msg-warning]
[:span.label (t locale "workspace.header.save-error")]])])) [:span.label (tr "workspace.header.save-error")]])]))
(mf/defc zoom-widget (mf/defc zoom-widget
@ -108,10 +106,10 @@
(st/emitf (modal/show (st/emitf (modal/show
{:type :confirm {:type :confirm
:message "" :message ""
:title (t locale "modals.add-shared-confirm.message" (:name file)) :title (tr "modals.add-shared-confirm.message" (:name file))
:hint (t locale "modals.add-shared-confirm.hint") :hint (tr "modals.add-shared-confirm.hint")
:cancel-label :omit :cancel-label :omit
:accept-label (t locale "modals.add-shared-confirm.accept") :accept-label (tr "modals.add-shared-confirm.accept")
:accept-style :primary :accept-style :primary
:on-accept add-shared-fn}))) :on-accept add-shared-fn})))
@ -121,10 +119,10 @@
(st/emitf (modal/show (st/emitf (modal/show
{:type :confirm {:type :confirm
:message "" :message ""
:title (t locale "modals.remove-shared-confirm.message" (:name file)) :title (tr "modals.remove-shared-confirm.message" (:name file))
:hint (t locale "modals.remove-shared-confirm.hint") :hint (tr "modals.remove-shared-confirm.hint")
:cancel-label :omit :cancel-label :omit
:accept-label (t locale "modals.remove-shared-confirm.accept") :accept-label (tr "modals.remove-shared-confirm.accept")
:on-accept del-shared-fn}))) :on-accept del-shared-fn})))
@ -146,7 +144,7 @@
[:div.menu-section [:div.menu-section
[:div.btn-icon-dark.btn-small {:on-click #(reset! show-menu? true)} i/actions] [:div.btn-icon-dark.btn-small {:on-click #(reset! show-menu? true)} i/actions]
[:div.project-tree {:alt (t locale "workspace.sitemap")} [:div.project-tree {:alt (tr "workspace.sitemap")}
[:span.project-name [:span.project-name
{:on-click #(st/emit! (rt/navigate :dashboard-project {:team-id team-id {:on-click #(st/emit! (rt/navigate :dashboard-project {:team-id team-id
:project-id (:project-id file)}))} :project-id (:project-id file)}))}
@ -254,11 +252,10 @@
:team-id team-id}] :team-id team-id}]
[:div.users-section [:div.users-section
[:& presence/active-sessions]] [:& active-sessions]]
[:div.options-section [:div.options-section
[:& persistence-state-widget [:& persistence-state-widget]
{:locale locale}]
[:& zoom-widget [:& zoom-widget
{:zoom zoom {:zoom zoom