This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-07-28
Channels
- # announcements (21)
- # beginners (12)
- # calva (16)
- # cider (3)
- # clj-commons (23)
- # clojure (32)
- # clojure-europe (8)
- # clojure-norway (3)
- # clojure-uk (3)
- # clojurescript (12)
- # conjure (2)
- # cursive (6)
- # data-science (15)
- # datomic (5)
- # dev-tooling (10)
- # emacs (13)
- # events (3)
- # lsp (36)
- # missionary (6)
- # off-topic (22)
- # portal (46)
- # releases (1)
- # shadow-cljs (15)
- # slack-help (7)
- # sql (3)
- # squint (1)
- # timbre (5)
Hello Folks, I hope everyone is doing good. I have a very simple question, is it possible to change the viewer for multiple selected values at the same time in the UI?
No currently, but that should be relatively easy to add. Would you be interested in giving it a shot?
Of course! I'm not that familiar with the project yet but I could give it a try. I think it's just a matter of keeping track of the multiple selections indexes and executing the specific viewer function to which of them, right?
You are correct. The selected contexts are already tracked in state, they just need to be leverage by the code that sets the viewer.
https://github.com/djblue/portal/blob/master/src/portal/ui/app.cljs#L137-L140 is one such location, the other being https://github.com/djblue/portal/blob/master/src/portal/ui/commands.cljs#L732-L739
The first issue is that these functions are ignoring the rest of the selected contexts because they are using these selectors: https://github.com/djblue/portal/blob/master/src/portal/ui/state.cljs#L51-L53
I think the second issue will be finding the intersection of applicable viewer for the currently selected values
Oh nice. And that's true, didn't even thought of the second issue. But you basically need to only show the viewer functions that are applicable for all the selections. So like you said, basically getting the intersection of the result of https://github.com/djblue/portal/blob/a4dd8f1abd631a00ecb56a3917caf7e7d8db4432/src/portal/ui/inspector.cljs#L117 to all the selected indexes, I presume
https://cljdoc.org/d/djblue/portal/0.44.0/doc/dev-guide is some notes for setup and bb dev
to get everything started. You can also do ctrl|cmd
+`shift` +`o` to open a child portal window to checkout the ui state and other useful info.
Started working on it last night and it was pretty easy to get results (the project setup is very easy to understand and use, congrats!). I still haven't done the commands part and it lacks a bunch of proper testing, but here it is an example of it working. There are contributing guidelines for the project or I can just create a new branch and PR after I'm done?
I was wondering, do you think it makes sense to apply the same logic to the next and prev viewer function? The current viewer will be considered the viewer for the first selection as normal, but then if you have multiple selections with different viewers it would cycle the intersection possible viewers.
Hey, just opened the PR: https://github.com/djblue/portal/pull/191 Let me know if you see any problems with it. I'm fairly new to clojure so feedback on my code is always greatly appreciated.
For someone fairly new to Clojure, you seem to fairly comfortable within the Portal code base 💯
Thanks! It has been a lot of fun working on the change, and like I said, the project it's very well setup and the code is easy to understand.
Hey @U1G869VNV, I was not able to find out how to open the embedded portal for calva notebooks in dev mode so I can test my changes. Do you know how could I do that?
You should be able to launch the dev version of the extension by opening vscode in the extension-vscode
directory, then under the Run and Debug
tab you should see a Run Portal
action.
Merged, thanks again for getting this handy feature implemented. I should be doing a release in the next couple of days 🙏
Thanks for being so helpful. It was my first contribution to an open source project and it was a lot of fun. I’ll be following the project a little bit more closely and may be contributing more in the future
I'm glad you enjoyed your first contribution, happy to help! Let me know if you run into any other usability issues or improvements you think of 👌
One thing that I would like for Portal is a way to configure a set of "preferred viewers" in order as the default. So you could ask for sequences of maps to use "table" by default and so on.
I "workaround" that right now by having ctrl+alt+space 0
to cycle through viewers for the most recent tap>
'd values for convenience but it's still "work"...
If the rules are relatively simple and the data supports metadata, I think you might be able to do a lot with a custom submit function.
I think supporting order preference would be a bit tricker so I'd rather not support it unless the existing support is insufficient
Hah! Touche... Yeah, I'm already using a custom submitter so that makes perfect sense. Dammit, you already thought of it.
After you gave me the two-Portal-window hints last time, my workflow is just so sweet!

I don't think so...
With latest portal try shift+space or shift+e a couple of times on a value with a lot of children:ok_hand:
Bear in mind, I almost never have focus on the Portal window -- I like to drive it all from the editor keybindings.
Since expand-inc is available as a command, you should be able to leverage it in the same way you leverage toggle-expand 👍
Link to the docs page with all the keybindings? A quick skim doesn't find it...
Sorry, they aren't currently available outside of the code https://github.com/djblue/portal/blob/master/src/portal/ui/commands.cljs#L271-L272
Oh, interesting... I should add a keybinding to remotely invoke that I suspect...
(ok, need to go do chores -- thank you, as always!)