(ns dev.fe-helpers) | |
Returns the root Redux state, the JS object holding the complete state of the app. This is hacky - it reaches deep into the internals of Redux, and may break in the future. That seems acceptable for a dev time helper. | (defn redux-state [] (let [root (js/document.querySelector "#root") store (.. root -_reactRootContainer -_internalRoot -current -child -memoizedProps -store)] (.getState store))) |
Retrieves the current query's card from the Redux state. Undefined behavior if there is not currently a single question loaded in the UI. | (defn current-card [] (.. (redux-state) -qb -card)) |
Gets the legacy query for the currently loaded question. | (defn current-legacy-query-js [] (.-dataset_query (current-card))) |
Gets the MLv2 query for the currently loaded question. Hack: This relies on a dev-mode-only global property that's set whenever a Question object is converted to MLv2. | (defn current-query [] (.-__MLv2_query js/window)) |