This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-28
Channels
- # asami (1)
- # aws (9)
- # babashka (16)
- # beginners (32)
- # calva (2)
- # clj-kondo (20)
- # cljdoc (6)
- # clojure (35)
- # clojure-dev (25)
- # clojure-europe (11)
- # clojure-india (1)
- # clojure-norway (2)
- # clojure-spec (26)
- # clojure-uk (1)
- # clojurescript (41)
- # conjure (3)
- # css (9)
- # cursive (18)
- # data-oriented-programming (6)
- # data-science (2)
- # emacs (47)
- # events (1)
- # fulcro (15)
- # graalvm (30)
- # gratitude (7)
- # honeysql (27)
- # inf-clojure (4)
- # introduce-yourself (2)
- # lsp (129)
- # malli (7)
- # missionary (21)
- # nbb (17)
- # off-topic (18)
- # re-frame (6)
- # releases (1)
- # shadow-cljs (120)
- # vim (7)
- # xtdb (15)
ANN: https://github.com/holyjak/fulcro-rad-asami, the Asami backend for RAD, has reached Alpha status and is ready for a test drive. So please try it out and let me know how it works (or not) for you! You can see it used in https://github.com/fulcrologic/fulcro-rad-demo/pull/37/files
I am still wresting with reports, I tried many cases but in my case :default-value is always ignored. Is it just me again, or default-value must be false, nil or empty string? 🙂 There is initailize-paramters in report.cljc but I think it there a simple way to call it from the repl? Could be a problem that I have reports inside a component, and the component is route target?
ro/controls {:company {:type :picker
po/query-key :search/companies
po/query-component Company
po/options-xform (fn [normalized-result raw-result]
(for [{:company/keys [id name]} raw-result] {:value id :text name}))
:default-value "1"
:label "Company"}
:ps { :label "pos"
:default-value "z"
:type :string}
:locker { :label "locker"
:default-value true
:type :boolean}
:xxx { :type :picker
:options [{:text "a" :value "100"} {:text "b" :value "101"}]
:default-value "100"
:label "xxx"
}}
if you look at source, default value is used by initialize-parameters function which is called when report is initialized and when :event/set-ui-parameters
is triggered
the actual value used will be first non-nil of:
• from event params
• from url params
• from fulcro state (if retain?
isn’t false)
• default-value
at least that’s my reading of the source
a smart thing to do when developing with fulcro rad, is to checkout the repository and then change your deps to point to your local copy of fulcro-rad
then you can modify rad code (such as adding console log statements) and it will reload and work in real-time
and you can see which values you get in these nested components
I have found that report controls are visible, but state machine (:com.fulcrologic.fulcro.ui-state-machines/asm-id) is not there yet, so it is logical, that default-values are not set.
• run-on-mount? true
• but picker-data in loaded in db by the report !!!! there are values in picker
• at start of app there is route set directly to the report (rr/route-to! app lst/StationReport {})
after the first run-report! the state machine is finally there in :state/gathering-parameters
There are two warnings:
• WARN [com.fulcrologic.rad.picker-options:141] - No options cache found in props for app.ui.listing/StationReport . This could mean options have not been loaded, or that you forgot to put [::picker-options/options-cache '_]
on your query. NOTE: This warning can be a false alarm if the application just started and no picker options have yet been loaded.
• WARN [com.fulcrologic.fulcro.ui-state-machines:?] - cljs$core$ExceptionInfo {message: '', data: {…}, cause: null, name: 'Error', description: undefined, …} Attempt to get an ASM path {meta: null, cnt: 2, shift: 5, root: {…}, tail: Array(2), …} for a state machine that is not in Fulcro state. ASM ID: {ns: 'app.ui.root', name: 'MainRouter', fqn: 'app.ui.root/MainRouter', hash: 730525377, cljs$lang$protocolmask$partition0$: 2153775105, …} See https://book.fulcrologic.com/#warn-uism-sm-not-in-state
I am not a computer but you broke something
I found the solution.
I put report directly into the router, outside of parent component. And state machine is started. So I it works.
I used to add report to app like ordinary component. (def ui-station-report (comp/factory StationReport))
Now I have to find a way to initialize report, when parent got :will-enter.
Just call the start function to start the SM. See what the default will enter does.
How are people handling authorization in RAD these days? I came up with two solutions but haven't figured out which way to go yet.
1. Outside of Pathom, look at the incoming query and remove parts the current user shouldn't see (probably using edn-query-language.core/mask-query
)
2. Add the user's permissions onto the pathom environment and have each resolver handle it individually
I'm leaning towards #1 becuase attributes are disabled by default. Is there anything better? Any gotchas I should be aware of?
I have my apps behind https://github.com/oauth2-proxy/oauth2-proxy and resolvers are checking :groups in jwt token. Frontend is aware of jwt groups.