Fork me on GitHub
#portal
<
2023-10-27
>
nate18:10:51

I'm working on a custom viewer and I'm hitting an issue.

nate18:10:06

Here's the custom viewer:

(ns data-viewer
  (:require [portal.ui.api :as p]))

(defn data?
  [v]
  (and (map? v)
       (contains? v :duration)))

(defn view-data []
  (fn [data]
    [:<>
     [:h1 "Duration"]
     [:portal.viewer/inspector
      {:portal.viewer/default :portal.viewer/duration-ms}
      (:duration data)]]))

(p/register-viewer!
 {:name ::viewer
  :predicate data?
  :component view-data})

nate18:10:44

When I tap this:

(tap> (with-meta {:duration 39847} {:portal.viewer/default :data-viewer/viewer}))

djblue18:10:21

Ohh, yeah, when migrating hiccup to reagent, the viewers do need to be resolved manually.

djblue18:10:28

You can pull in [portal.ui.inspector :as ins] and wrap the value with the ins/inspector component.

nate18:10:32

heh, you beat me to the screen shot

nate18:10:42

for the record, it shows up like this

awesome 1
nate18:10:00

that did it!

djblue18:10:00

Ohh, wait, it's still not wrapping the value with the duration-ms viewer?

nate18:10:08

that was the before

👌 1
nate18:10:30

now it does the right thing:

💯 1
nate18:10:01

related issue, I tried to require portal.viewer in my custom viewer and it threw Could not resolve symbol: implements? when I ran (p/eval-str (slurp "data_viewer.cljs"))

djblue18:10:19

Ohh, I might need to expose it in sci 👌

nate18:10:28

I'm using HEAD on master, not the released version

nate18:10:32

if that helps

nate18:10:42

oh, right

nate18:10:47

I forgot that sci was the runtime

nate18:10:17

trying that

nate18:10:19

diff --git a/src/portal/ui/sci/libs.cljs b/src/portal/ui/sci/libs.cljs
index a4c7e77..12d2bf3 100644
--- a/src/portal/ui/sci/libs.cljs
+++ b/src/portal/ui/sci/libs.cljs
@@ -96,6 +96,7 @@ (def namespaces
     portal.ui.viewer.vega-lite)
    (sci-import/import
     cljs.core/random-uuid
+    cljs.core/implements?
     cljs.core/tap>
     cljs.reader/read-string)
    {'reagent.core
hm, didn't seem to like that:
❯ clojure -X:build prep
=> Generating docs
=> clojure -M:cljs:shadow -m shadow.cljs.devtools.cli release client
[:client] Compiling ...
------ ERROR -------------------------------------------------------------------                                                                                                    File: /home/nate/projects/portal/src/portal/ui/sci/libs.cljs:98:4
--------------------------------------------------------------------------------
  95 |     portal.ui.viewer.tree
  96 |     portal.ui.viewer.vega
  97 |     portal.ui.viewer.vega-lite)
  98 |    (sci-import/import
----------^---------------------------------------------------------------------
null
Unable to resolve var: implements? in this context at line 98 portal/ui/sci/libs.cljs
--------------------------------------------------------------------------------
  99 |     cljs.core/random-uuid
 100 |     cljs.core/implements?
 101 |     cljs.core/tap>
 102 |     cljs.reader/read-string)
--------------------------------------------------------------------------------

-> 17.783 seconds (exit: 1)
Execution error (ExceptionInfo) at tasks.tools/sh* (tools.clj:58).
Non-zero exit code: clojure -M:cljs:shadow -m shadow.cljs.devtools.cli release client

Full report at:
/tmp/clojure-17926749571961529956.edn
perhaps because it's a macro?

nate18:10:16

macro too

😂 1
nate18:10:04

if I add another function (like update-keys), the prep works

nate18:10:09

something about it being a macro

nate18:10:58

tried a (:require-macros cljs.core) at the top too, no work

Jason Whitlark20:10:06

When working with portal and devcontainers, I keep running into issues with the config file missing. (vs-code.edn file). But it seems to be complicated by the difference between normal operation and working in a devcontainer, and it seems to be intermittent. Has anyone else run into this?

seancorfield20:10:03

Yes, and Chris showed me how to solve it... just a sec...

seancorfield20:10:08

https://github.com/seancorfield/vscode-calva-setup/blob/develop/joyride/src/remote_repl.cljs -- this is how I connect to QA/production REPLs -- in particular, see https://github.com/seancorfield/vscode-calva-setup/blob/develop/joyride/src/remote_repl.cljs#L33 which takes the current Portal config (host/port etc) and sends it to the server to write out locally so that you can open Portal (in my case, into my local VS Code)

Jason Whitlark13:10:19

Thank you. I'll take another look. This seems to be a slightly different issue, I want to say the container creation process is copying the directory, but not the contents. It is certainly related, though. I think I'll have to set up a controlled experiment to narrow down what's going wrong.

Jason Whitlark14:10:04

Oh, in my repo, someone accidentally merged a change that set portal to an old version. That'll probably be it. Sorry for the confusion.