Skip to content

Commit

Permalink
Fix location of result in db. See #127
Browse files Browse the repository at this point in the history
  • Loading branch information
katauber committed Sep 8, 2023
1 parent fc72b12 commit 691e921
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/cljs/metafacture_playground/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
(let [example-data (find-example-data example-name (:examples db))]
(if example-data
{:db (-> db
(assoc :result nil)
(assoc-in [:editors :result :content] nil)
(assoc-in [:ui :dropdown :active-item] example-name))
:fx (mapv
(fn [editor]
Expand Down Expand Up @@ -422,7 +422,7 @@
:body {:content (str "Response from server: " problem-message)}
:server (server-problem-message status status-text body))]
{:db (-> db
(assoc-in [:result :loading?] false)
(assoc-in [:editors :result :loading?] false)
(assoc :message (merge message-data {:type :error})))}))

(re-frame/reg-event-fx
Expand All @@ -441,7 +441,7 @@
#"application/.*json" :json}
:on-success [::process-response]
:on-failure [::bad-response]}
:db (assoc-in db [:result :loading?] true)})
:db (assoc-in db [:editors :result :loading?] true)})

(re-frame/reg-event-fx
::process
Expand Down
2 changes: 1 addition & 1 deletion src/cljs/metafacture_playground/subs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
(re-frame/reg-sub
::result-loading?
(fn [db _]
(get-in db [:editor :result :loading?])))
(get-in db [:editors :result :loading?])))

(re-frame/reg-sub
::backend-versions
Expand Down
2 changes: 1 addition & 1 deletion src/cljs/metafacture_playground/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@
{:color color
:stackable true}
[title-label @label]
[collapse-label [:result]]]
[collapse-label :result]]
[result]]]))

;;; Main panel
Expand Down
4 changes: 2 additions & 2 deletions test/cljs/metafacture_playground/event_handler_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
(events/load-example [:load-example example-name]))
{:keys [data flux transformation]} (get-in db' [:db :editors])
db'' (events/process db' [:process (:content data) (:content flux) (:content transformation)])]
(is (get-in db'' [:db :result :loading?])))))
(is (get-in db'' [:db :editors :result :loading?])))))

(deftest collapse-panel-test
(testing "Test collapse behaviour"
Expand All @@ -106,7 +106,7 @@
(and (is (get-in db' [:db :editors :flux :collapsed?]))
(is (not (get-in db' [:db :editors :transformation :collapsed?])))
(is (not (get-in db' [:db :editors :data :collapsed?])))
(is (not (get-in db' [:db :result :collapsed?]))))))
(is (not (get-in db' [:db :editors :result :collapsed?]))))))

(testing "Test collapsing and expanding a panel"
(let [db' (-> empty-db
Expand Down

0 comments on commit 691e921

Please sign in to comment.