    [app.main.data.workspace :as dw]
    [app.main.ui.icons :as i]
    [app.main.ui.modal :as modal]))
+
+(def workspace-file
+  (l/derived :workspace-file st/state))
 
 (mf/defc libraries-tab
   [{:keys [file libraries shared-files] :as props}]


        locale       (mf/deref i18n/locale)
        project      (mf/deref refs/workspace-project)
        file         (mf/deref refs/workspace-file)
        libraries    (mf/deref refs/workspace-libraries)
        shared-files (mf/deref refs/workspace-shared-files)


        (mf/use-callback (mf/deps file) #(st/emit! (dw/unlink-file-from-library (:id file) %)))

        contents-str
        (fn [library]
          (let [graphics-count (count (get-in library [:data :media] []))
                colors-count (count (get-in library [:data :colors] []))]
            ;; Include a &nbsp; so this block has always some content
            (str
             (str/join " · "
                       (cond-> []
                         (< 0 graphics-count)
                         (conj (tr "workspace.libraries.graphics" graphics-count))

                         (< 0 colors-count)
                         (conj (tr "workspace.libraries.colors" colors-count))))
             "\u00A0")))]
    [:*
     [:div.section
      [:div.section-title (tr "workspace.libraries.in-this-file")]
      [:div.section-list
       [:div.section-list-item
        [:div.item-name (tr "workspace.libraries.file-library")]
        [:div.item-contents (contents-str file)]]
       (for [library sorted-libraries]
         [:div.section-list-item {:key (:id library)}
          [:div.item-name (:name library)]
          [:div.item-contents (contents-str library)]
          [:input.item-button {:type "button"
                               :value (tr "workspace.libraries.remove")
                               :on-click #(unlink-library (:id library))}]])
