New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add clickable links for Table #1321
Conversation
It would be good to also think about supporting links that will be able to also open external pages in new tabs (#567) and allow download as well. Also use TableCellType instead of data_type as this is a specific type of cell, not a type of data, it's a string after all. |
23bd075
to
03ff30f
Compare
New APIexport interface URLTableCellType {
/** An identifying name for this component. */
name: S
/** Whether it should open a new tab. */
new_tab?: B
} In Actionq.page['example'] = ui.form_card(box='1 1 3 3', items=[
ui.table(
name='table',
columns=[
ui.table_column(name='link', label='Link', cell_type=ui.url_table_cell_type(name='urls', new_tab=True))
],
rows=[
ui.table_row(name='row1', cells=['[Wave](https://wave.h2o.ai/)'])
ui.table_row(name='row2', cells=['https://wave.h2o.ai/'])
]
)
]) QuestionsShould it default to always open in a new tab?
I thought that maybe it could be used for routing to different apps in the same domain, so the user wouldn't have to pass the full domain. Just an idea. |
This is a good direction. Let's do the following changes:
No, the default should be the same as
Can you provide a link? I was not able to find the string you quoted in
It should work like a common web routing (relative links). I see your point, but that would prevent people who want to just append to the current URL (for some reason). Specifying a full domain for routing to a different app on the same server is fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @aalencar! Looks good overall, need a few minor changes.
60b59c9
to
e4033de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one more nit. Will merge it after the 0.21
release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not clear about why this feature is required. We already support the ability for a row to be linked. If there is a need to provide row-specific actions, there's already the other PR with the contextual menu. If the need is to support links on each row that open in new windows, then the request is too specific, and the implementation/API seem hacky (regex, markdown-subset, etc.)
Is there a link to the specific feature request or issue?
That PR implementation has every row with the same actions. We can discuss further improvements there.
I couldn't find any issue or discussion opened by @vopani. @mturoci by any chance, do you remember what was the usecase?
@lo5 It seems hacky indeed. What do you suggest as an alternative? |
Hard to say, since I'm not sure about the origin of this requirement. One option is to have a The decision on whether to open links in I'm not sure if the table already supports markdown formatting. |
The original issue is #428 (found via the branch name) and the requirement is to be able to open the links right from the table. I am fine with MarkdownCell, but make sure the spacing is correct and does not interfere with the rest of the table. |
I meant where this request came from. If I see "via " I assume it comes from somewhere else, GH discussion, another GH issue, or a private conversation. #428 doesn't describe a use case. Like @lo5 said, maybe we already support the use case since it's an old feature request.
Ok |
Markdown doesn't support setting the Another option is to just use Markdown and include an example that uses plain HTML to open in new tab. Should we also document other uses of Markdown or just point to some online reference? |
Convert markdown to html, insert into DOM, use |
I'd prefer not to encourage using HTML.
Not sure what you mean by this. The markdown used in a table cell should be no different from that used elsewhere. |
This could also work but I wonder if there is any benefit over using regex and
Ok.
Open in a new tab when it's an absolute path is a behavior not present in the Markdown specification, so my question was whether we need to document only this behavior and also point the user to some online reference in case they are not familiar with Markdown in general. |
5239696
to
d5fc4cc
Compare
d5fc4cc
to
5cdd356
Compare
The main benefit is that the technique I suggested would support arbitrary markdown, not just links.
Add an attribute to |
Could you please clarify this point? Don't we want to only extend the markdown link feature to support opening in a new tab? Maybe I'm missing something.
I'm a little confused, should we open links in a new tab if the path is absolute and we specify that links can be opened in a new tab? Or should all links open in a new tab if that is specified on |
The goal is to support arbitrary links in table cells. Links can be opened in the same tab or in a new tab. Agreed? You're suggesting using regex and The way I see it, there's not much of a difference between supporting hyperlinks, and supporting arbitrary Markdown inside cells. If we're only going to support hyperlinks, it raises more questions:
So I don't see a good reason to support only hyperlinks. Might as well support Markdown, since Markdown already supports hyperlinks. Hence, That leaves one question open: do we open links in the current tab or a new tab? To which I suggested that we leave that decision to the user by adding an attribute (flag) to Hope this makes it clear. If not, call me. |
Now it's more clear, I was more confused about your suggestion to open absolute links on new tabs. Thanks a lot for clarifying. Note on implementation: I dynamically added the Regarding spacing, it will not wrap by default in case the text exceeds the cell. Should we wrap |
3bbc4b8
to
eee81bb
Compare
* add optional parameter "target" to specify whether it should open in a new tab
eee81bb
to
9b36906
Compare
Good idea.
Yes
There might be, but should be enough to handle the |
Co-authored-by: mturoci <64769322+mturoci@users.noreply.github.com>
Co-authored-by: mturoci <64769322+mturoci@users.noreply.github.com>
Co-authored-by: mturoci <64769322+mturoci@users.noreply.github.com>
Co-authored-by: mturoci <64769322+mturoci@users.noreply.github.com>
* add example with more markdown content * rename table_markdown to avoid misunderstanding * update tour.conf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, good work @aalencar!
Proposed API
Set
data_type
to'link'
and use Markdown notation[label](url)
I tried to use
ui.link
as suggested by @mturoci but I didn't find a way to passlabel
to it becausecells
only accept strings. I wish I could do something likecells=[ui.link(label='my label', path='https://website.com')]
.