From a4d6524cb6c4056028c5080b4aadc563ab4f1571 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 28 Sep 2020 11:39:01 +0200 Subject: [PATCH] :sparkles: Fix review issues. --- backend/src/app/services/mutations/projects.clj | 5 +++-- backend/src/app/services/queries/projects.clj | 2 +- frontend/src/app/main/data/dashboard.cljs | 10 +++++++--- frontend/src/app/main/ui/dashboard/files.cljs | 3 +-- frontend/src/app/main/ui/dashboard/grid.cljs | 11 +++-------- frontend/src/app/main/ui/dashboard/libraries.cljs | 2 +- frontend/src/app/main/ui/dashboard/sidebar.cljs | 1 + 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/backend/src/app/services/mutations/projects.clj b/backend/src/app/services/mutations/projects.clj index 74f648e70..2375721e5 100644 --- a/backend/src/app/services/mutations/projects.clj +++ b/backend/src/app/services/mutations/projects.clj @@ -108,10 +108,10 @@ ;; --- Mutation: Toggle Project Pin (s/def ::is-pinned ::us/boolean) -(s/def ::toggle-project-pin +(s/def ::update-project-pin (s/keys :req-un [::profile-id ::id ::team-id ::is-pinned])) -(sm/defmutation ::toggle-project-pin +(sm/defmutation ::update-project-pin [{:keys [id profile-id team-id is-pinned] :as params}] (db/with-atomic [conn db/pool] (db/update! conn :team-project-profile-rel @@ -121,6 +121,7 @@ :team-id team-id}) nil)) + ;; --- Mutation: Rename Project (declare rename-project) diff --git a/backend/src/app/services/queries/projects.clj b/backend/src/app/services/queries/projects.clj index 2391746a7..09ca44b3a 100644 --- a/backend/src/app/services/queries/projects.clj +++ b/backend/src/app/services/queries/projects.clj @@ -71,7 +71,7 @@ (def sql:projects "select p.*, - tpp.is_pinned, + coalesce(tpp.is_pinned, false) as is_pinned, (select count(*) from file as f where f.project_id = p.id and deleted_at is null) as count diff --git a/frontend/src/app/main/data/dashboard.cljs b/frontend/src/app/main/data/dashboard.cljs index 81fdbf19e..e580cd203 100644 --- a/frontend/src/app/main/data/dashboard.cljs +++ b/frontend/src/app/main/data/dashboard.cljs @@ -28,6 +28,7 @@ (s/def ::project-id ::us/uuid) (s/def ::created-at ::us/inst) (s/def ::modified-at ::us/inst) +(s/def ::is-pinned ::us/boolean) (s/def ::team (s/keys :req-un [::id @@ -41,7 +42,8 @@ ::team-id ::profile-id ::created-at - ::modified-at])) + ::modified-at + ::is-pinned])) (s/def ::file (s/keys :req-un [::id @@ -204,6 +206,7 @@ (update [_ state] (assoc-in state [:dashboard-local :project-for-edit] nil)))) + (defn toggle-project-pin [{:keys [id is-pinned team-id] :as params}] (us/assert ::project params) @@ -214,8 +217,9 @@ ptk/WatchEvent (watch [_ state stream] - (let [params (select-keys params [:id :is-pinned :team-id])] - (->> (rp/mutation :toggle-project-pin params) + (let [project (get-in state [:projects team-id id]) + params (select-keys project [:id :is-pinned :team-id])] + (->> (rp/mutation :update-project-pin params) (rx/ignore)))))) ;; --- Rename Project diff --git a/frontend/src/app/main/ui/dashboard/files.cljs b/frontend/src/app/main/ui/dashboard/files.cljs index 18b659332..51e0e09c3 100644 --- a/frontend/src/app/main/ui/dashboard/files.cljs +++ b/frontend/src/app/main/ui/dashboard/files.cljs @@ -121,6 +121,5 @@ [:& header {:team team :project project}] [:section.dashboard-grid-container [:& grid {:id (:id project) - :files files - :hide-new? true}]]])) + :files files}]]])) diff --git a/frontend/src/app/main/ui/dashboard/grid.cljs b/frontend/src/app/main/ui/dashboard/grid.cljs index 136bd1bde..37fc89a60 100644 --- a/frontend/src/app/main/ui/dashboard/grid.cljs +++ b/frontend/src/app/main/ui/dashboard/grid.cljs @@ -174,16 +174,11 @@ [:div.text (t locale "dashboard.grid.empty-files")]])) (mf/defc grid - [{:keys [id opts files hide-new?] :as props}] - (let [locale (mf/deref i18n/locale) - click #(st/emit! (dd/create-file id))] + [{:keys [id opts files] :as props}] + (let [locale (mf/deref i18n/locale)] [:section.dashboard-grid (if (pos? (count files)) - [:div.dashboard-grid-row - (when (not hide-new?) - [:div.grid-item.add-file {:on-click click} - [:span (t locale "dashboard.new-file")]]) - + [:div.grid-row (for [item files] [:& grid-item {:id (:id item) diff --git a/frontend/src/app/main/ui/dashboard/libraries.cljs b/frontend/src/app/main/ui/dashboard/libraries.cljs index e9a19a975..ef7c13145 100644 --- a/frontend/src/app/main/ui/dashboard/libraries.cljs +++ b/frontend/src/app/main/ui/dashboard/libraries.cljs @@ -38,5 +38,5 @@ [:header.dashboard-header [:h1.dashboard-title (tr "dashboard.header.libraries")]] [:section.dashboard-grid-container - [:& grid {:files files :hide-new? true}]]])) + [:& grid {:files files}]]])) diff --git a/frontend/src/app/main/ui/dashboard/sidebar.cljs b/frontend/src/app/main/ui/dashboard/sidebar.cljs index 5affb40d1..0c2968331 100644 --- a/frontend/src/app/main/ui/dashboard/sidebar.cljs +++ b/frontend/src/app/main/ui/dashboard/sidebar.cljs @@ -332,6 +332,7 @@ (for [item pinned-projects] [:& sidebar-project {:item item + :key (:id item) :id (:id item) :selected? (= (:id item) (:id project))}])] [:div.sidebar-empty-placeholder