diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..1dec4b93c1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*.{cljs,cljc,clj,js,css,scss,html,yml,yaml,json,mustache}] +charset = utf-8 + +indent_size = 2 +indent_style = space + +end_of_line = lf + +insert_final_newline = true + +trim_trailing_whitespace = true diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..6cef7d76f2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "files.exclude": { + "**/.clj-kondo": true, + "**/.cpcache": true, + "**/.lsp": true, + "**/.shadow-cljs": true, + "**/node_modules": true + } +} diff --git a/backend/src/app/rpc/commands/files.clj b/backend/src/app/rpc/commands/files.clj index bc34c69b71..e3b88a8bcb 100644 --- a/backend/src/app/rpc/commands/files.clj +++ b/backend/src/app/rpc/commands/files.clj @@ -355,8 +355,8 @@ (db/get pool :file {:id id} {:columns [:id :modified-at :revn]})) (defn get-file-etag - [{:keys [modified-at revn]}] - (str (dt/format-instant modified-at :iso) "-" revn)) + [{:keys [::rpc/profile-id]} {:keys [modified-at revn]}] + (str profile-id (dt/format-instant modified-at :iso) revn)) (sv/defmethod ::get-file "Retrieve a file by its ID. Only authenticated users." @@ -371,7 +371,7 @@ (check-read-permissions! perms) (let [file (-> (get-file conn id features project-id) (assoc :permissions perms))] - (vary-meta file assoc ::cond/key (get-file-etag file)))))) + (vary-meta file assoc ::cond/key (get-file-etag params file)))))) ;; --- COMMAND QUERY: get-file-fragment (by id) diff --git a/backend/src/app/rpc/cond.clj b/backend/src/app/rpc/cond.clj index 3cee44e3f5..b683ded138 100644 --- a/backend/src/app/rpc/cond.clj +++ b/backend/src/app/rpc/cond.clj @@ -27,6 +27,8 @@ [app.common.logging :as l] [app.rpc.helpers :as rph] [app.util.services :as-alias sv] + [buddy.core.codecs :as bc] + [buddy.core.hash :as bh] [yetti.response :as yrs])) (def @@ -34,9 +36,16 @@ :doc "Runtime flag for enable/disable conditional processing of RPC methods."} *enabled* false) +(defn- encode + [s] + (-> s + bh/blake2b-256 + bc/bytes->b64u + bc/bytes->str)) + (defn- fmt-key [s] - (str "W/\"" s "\"")) + (str "W/\"" (encode s) "\"")) (defn wrap [_ f {:keys [::get-object ::key-fn ::reuse-key?] :as mdata}] @@ -46,9 +55,8 @@ (fn [cfg {:keys [::key] :as params}] (if *enabled* (let [key' (when (or key reuse-key?) - (some-> (get-object cfg params) key-fn fmt-key))] - (if (and (some? key) - (= key key')) + (some->> (get-object cfg params) (key-fn params) (fmt-key)))] + (if (and (some? key) (= key key')) (fn [_] {::yrs/status 304}) (let [result (f cfg params) etag (or (and reuse-key? key') diff --git a/common/src/app/common/types/components_list.cljc b/common/src/app/common/types/components_list.cljc index d5d37267ed..1dd2917709 100644 --- a/common/src/app/common/types/components_list.cljc +++ b/common/src/app/common/types/components_list.cljc @@ -115,3 +115,9 @@ [] [[(:id shape) (:component-id shape) :component]])) [])) + +(defn get-component-annotation + [shape libraries] + (let [library (dm/get-in libraries [(:component-file shape) :data]) + component (get-component library (:component-id shape) true)] + (:annotation component))) diff --git a/frontend/resources/styles/main/partials/dashboard-grid.scss b/frontend/resources/styles/main/partials/dashboard-grid.scss index 8f97470562..09bf2efc3d 100644 --- a/frontend/resources/styles/main/partials/dashboard-grid.scss +++ b/frontend/resources/styles/main/partials/dashboard-grid.scss @@ -363,7 +363,7 @@ // LIBRARY VIEW .grid-item { .library { - height: 556px; + height: 580px; } &.project-th.library { diff --git a/frontend/resources/styles/main/partials/sidebar-element-options.scss b/frontend/resources/styles/main/partials/sidebar-element-options.scss index 36c098ca64..7febf9415a 100644 --- a/frontend/resources/styles/main/partials/sidebar-element-options.scss +++ b/frontend/resources/styles/main/partials/sidebar-element-options.scss @@ -2414,6 +2414,16 @@ .title .icon { display: flex; } + + textarea { + min-height: 250px; + } + } + + &.creating { + textarea { + min-height: 250px; + } } .hidden { @@ -2445,7 +2455,6 @@ textarea { background-color: $color-gray-60; color: $color-white; - min-height: 250px; padding: 10px; border: none; diff --git a/frontend/src/app/main/data/workspace/annotation_helpers.cljs b/frontend/src/app/main/data/workspace/annotation_helpers.cljs deleted file mode 100644 index a0b00956a6..0000000000 --- a/frontend/src/app/main/data/workspace/annotation_helpers.cljs +++ /dev/null @@ -1,28 +0,0 @@ -;; This Source Code Form is subject to the terms of the Mozilla Public -;; License, v. 2.0. If a copy of the MPL was not distributed with this -;; file, You can obtain one at http://mozilla.org/MPL/2.0/. -;; -;; Copyright (c) KALEIDOS INC - -(ns app.main.data.workspace.annotation-helpers - (:require - [app.common.data.macros :as dm] - [app.common.logging :as log] - [app.common.types.components-list :as ctkl] - [app.main.refs :as refs])) - -;; Change this to :info :debug or :trace to debug this module, or :warn to reset to default -(log/set-level! :warn) - - -(defn get-main-annotation - [shape libraries] - (let [library (dm/get-in libraries [(:component-file shape) :data]) - component (ctkl/get-component library (:component-id shape) true)] - (:annotation component))) - -(defn get-main-annotation-viewer - [shape libraries] - (let [objects (deref (refs/get-viewer-objects)) - parent (get objects (:parent-id shape))] - (get-main-annotation parent libraries))) diff --git a/frontend/src/app/main/ui/dashboard/grid.cljs b/frontend/src/app/main/ui/dashboard/grid.cljs index 2ef1937d61..05d852b304 100644 --- a/frontend/src/app/main/ui/dashboard/grid.cljs +++ b/frontend/src/app/main/ui/dashboard/grid.cljs @@ -113,6 +113,22 @@ typographies (:typographies summary)] [:* + (when (and (zero? (:count components)) (zero? (:count colors)) (zero? (:count typographies))) + [:* + [:div.asset-section + [:div.asset-title + [:span (tr "workspace.assets.components")] + [:span.num-assets (str "\u00A0(") 0 ")"]]] ;; Unicode 00A0 is non-breaking space + [:div.asset-section + [:div.asset-title + [:span (tr "workspace.assets.colors")] + [:span.num-assets (str "\u00A0(") 0 ")"]]] ;; Unicode 00A0 is non-breaking space + [:div.asset-section + [:div.asset-title + [:span (tr "workspace.assets.typography")] + [:span.num-assets (str "\u00A0(") 0 ")"]]]]) ;; Unicode 00A0 is non-breaking space + + (when (pos? (:count components)) [:div.asset-section [:div.asset-title diff --git a/frontend/src/app/main/ui/viewer/inspect/attributes.cljs b/frontend/src/app/main/ui/viewer/inspect/attributes.cljs index 50b2e1b092..997b83a6c0 100644 --- a/frontend/src/app/main/ui/viewer/inspect/attributes.cljs +++ b/frontend/src/app/main/ui/viewer/inspect/attributes.cljs @@ -7,7 +7,7 @@ (ns app.main.ui.viewer.inspect.attributes (:require [app.common.geom.shapes :as gsh] - [app.main.data.workspace.annotation-helpers :as dwah] + [app.common.types.components-list :as ctkl] [app.main.ui.hooks :as hooks] [app.main.ui.viewer.inspect.annotation :refer [annotation]] [app.main.ui.viewer.inspect.attributes.blur :refer [blur-panel]] @@ -41,9 +41,7 @@ type (if (= (count shapes) 1) (-> shapes first :type) :multiple) options (type->options type) content (when (= (count shapes) 1) - (if (= from :workspace) - (dwah/get-main-annotation (first shapes) libraries) - (dwah/get-main-annotation-viewer (first shapes) libraries)))] + (ctkl/get-component-annotation (first shapes) libraries))] [:div.element-options (for [[idx option] (map-indexed vector options)] diff --git a/frontend/src/app/main/ui/workspace/context_menu.cljs b/frontend/src/app/main/ui/workspace/context_menu.cljs index 1557f0abed..c2d8995453 100644 --- a/frontend/src/app/main/ui/workspace/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/context_menu.cljs @@ -447,7 +447,6 @@ first-shape (first shapes) {:keys [id component-id component-file main-instance?]} first-shape - lacks-annotation? (nil? (:annotation first-shape)) component-shapes (filter #(contains? % :component-id) shapes) @@ -458,9 +457,11 @@ workspace-data (deref refs/workspace-data) workspace-libraries (deref refs/workspace-libraries) - is-dangling? (nil? (if local-component? - (ctkl/get-component workspace-data component-id) - (ctf/get-component workspace-libraries component-file component-id))) + component (if local-component? + (ctkl/get-component workspace-data component-id) + (ctf/get-component workspace-libraries component-file component-id)) + is-dangling? (nil? component) + lacks-annotation? (nil? (:annotation component)) lib-exists? (and (not local-component?) (some? (get workspace-libraries component-file))) @@ -535,7 +536,7 @@ [:* [:& menu-entry {:title (tr "workspace.shape.menu.show-in-assets") :on-click do-show-in-assets}] - (when (and components-v2 lacks-annotation?) + (when (and components-v2 local-component? lacks-annotation?) [:& menu-entry {:title (tr "workspace.shape.menu.create-annotation") :on-click create-annotation}])] (if local-component? diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs index 593f3b9504..339aa0bf6e 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs @@ -733,7 +733,7 @@ on-group (mf/use-fn - (mf/deps components selected) + (mf/deps components selected create-group) (fn [event] (dom/stop-propagation event) (modal/show! :name-group-dialog {:accept create-group}))) @@ -1110,7 +1110,7 @@ create-group (mf/use-fn - (mf/deps objects selected on-clear-selection) + (mf/deps objects selected on-clear-selection (:object-id @state)) (fn [group-name] (on-clear-selection) (let [undo-id (js/Symbol)] @@ -1138,7 +1138,7 @@ on-group (mf/use-fn - (mf/deps objects selected) + (mf/deps objects selected create-group) (fn [event] (dom/stop-propagation event) (modal/show! :name-group-dialog {:accept create-group}))) @@ -1868,7 +1868,7 @@ (seq (:colors selected))) open-groups-ref (mf/with-memo [open-status-ref] - (-> (l/in [:groups :components]) + (-> (l/in [:groups :typographies]) (l/derived open-status-ref))) open-groups (mf/deref open-groups-ref) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs index 9e86e786f5..8ff2ebdb3a 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs @@ -99,7 +99,7 @@ (fn [] (st/emit! (dw/set-annotations-id-for-create nil))))) ;; cleanup set-annotationsid-for-create on unload (when (or creating? annotation) - [:div.component-annotation {:class (dom/classnames :editing @editing?)} + [:div.component-annotation {:class (dom/classnames :editing @editing? :creating creating?)} [:div.title {:class (dom/classnames :expandeable (not (or @editing? creating?))) :on-click #(expand (not annotations-expanded?))} [:div (if (or @editing? creating?) @@ -163,7 +163,6 @@ (:main-instance? values) true) main-component? (:main-instance? values) - lacks-annotation? (nil? (:annotation values)) local-component? (= library-id current-file-id) workspace-data (deref refs/workspace-data) workspace-libraries (deref refs/workspace-libraries) @@ -171,6 +170,7 @@ (ctkl/get-component workspace-data component-id) (ctf/get-component workspace-libraries library-id component-id)) is-dangling? (nil? component) + lacks-annotation? (nil? (:annotation component)) lib-exists? (and (not local-component?) (some? (get workspace-libraries library-id))) @@ -237,7 +237,7 @@ :options (if main-component? [[(tr "workspace.shape.menu.show-in-assets") do-show-in-assets] - (when (and components-v2 lacks-annotation?) + (when (and components-v2 local-component? lacks-annotation?) [(tr "workspace.shape.menu.create-annotation") do-create-annotation])] (if local-component? (if is-dangling?