[ENHANCEMENT]: Add dashboard-level links support#67
[ENHANCEMENT]: Add dashboard-level links support#67prakhar29jain wants to merge 1 commit intoperses:mainfrom
Conversation
73a717c to
5c0ea97
Compare
|
Only checked screenshot, please use the same layout as others drawers / editors |
| ); | ||
| } | ||
|
|
||
| function DashboardLinkMenuItem({ link }: { link: Link }): ReactElement { |
There was a problem hiding this comment.
Same remark as above
| ); | ||
| } | ||
|
|
||
| function useLink(link: Link): Link { |
There was a problem hiding this comment.
same remark as above
5c0ea97 to
b8b4d6b
Compare
|
I became more ambitious and went forward create a single component for Displaying Links... |
b8b4d6b to
8b97c01
Compare
8b97c01 to
907b536
Compare
| sx={{ backgroundColor: (theme) => theme.palette.primary.main + (isEditMode ? '30' : '0') }} | ||
| > | ||
| {dashboardTitle} | ||
| {dashboardLinks.length > 0 && ( |
There was a problem hiding this comment.
We need to check if isLinksEnabled is enabled here too
There was a problem hiding this comment.
Well agreed I missed this :)
| // Default: show dropdown menu for multiple links | ||
| return ( | ||
| <> | ||
| <InfoTooltip description={`${links.length} links`} enterDelay={100}> |
There was a problem hiding this comment.
IMO, if there is only one link, it should not display a menu on the dashboard, the link could be directly clickable. Can be improved later in another PR, if others are fine with that
There was a problem hiding this comment.
We already have that check just above the default return that you mentioned with proper comments.
// Dashboard variant: 1-3 links show as chips
// Max character limit for the name and url to prevent overflow
// in the dashboard title area, but if either the name or url is too long,
// we will fall back to showing the links in a dropdown menu
if (variant === 'dashboard' && links.length <= 3) {
const canRenderAsChips = links.every((link) => {
if (link.name) {
return link.name.length < 30;
}
if (link.url) {
return link.url.length < 70;
}
return false;
});
if (canRenderAsChips) {
return (
<Stack direction="row" spacing={1}>
{links.map((link: Link) => (
<LinkChip key={link.url} link={link} />
))}
</Stack>
);
}
}There was a problem hiding this comment.
Ok, mb, I only tried with long name
| <TableContainer> | ||
| <Table size="small" sx={{ tableLayout: 'fixed', width: '100%' }} aria-label="table of dashboard links"> | ||
| <TableHead> | ||
| <TableRow> |
There was a problem hiding this comment.
Let's use all the place available
<TableRow>
<TableCell>Name</TableCell>
<TableCell>URL</TableCell>
<TableCell width={80}>New Tab</TableCell>
<TableCell align="right" width={180}>
Actions
</TableCell>
</TableRow>There was a problem hiding this comment.
Well I think it is better to enforce css here as they waste a lot of space, since title is explaining the most what the URL. But even so wasting the space just does not makes sense to me.
Your suggestion:
with this:
<TableCell sx={{ width: 180 }}>Name</TableCell>
<TableCell>URL</TableCell>
<TableCell sx={{ width: 40 }}>New Tab</TableCell>
<TableCell align="right" sx={{ width: 180 }}>
There was a problem hiding this comment.
On wide screen, 180px is too small. That why I don't want hardcoded values for these fields
| <TableCell component="th" scope="row" sx={{ fontWeight: 'bold', overflow: 'hidden', textOverflow: 'ellipsis' }}> | ||
| {displayName} | ||
| </TableCell> | ||
| <TableCell |
There was a problem hiding this comment.
URL is wrap, title will help to see all url on hover, we could use tooltip, but I think title is enough
<TableCell
title={link.url || '(no URL)'}
...There was a problem hiding this comment.
I do not understand said by we could use tooltip... it is already there right ? :)
There was a problem hiding this comment.
There is currently no tooltip on hover of the url. If url is too long, user will not be able to know to end of it because of ellipsis
| display?: Display; | ||
| datasources?: Record<string, DatasourceSpec>; | ||
| links?: Link[]; | ||
| setLinks: (links: Link[]) => void; |
There was a problem hiding this comment.
In readonly mode with embedded usage, it not useful to useful to define this method. Make it optional
setLinks?: (links: Link[]) => void;
I wonder if we should not use Slice instead too 🤔
There was a problem hiding this comment.
Well I made it optional but do you really think we need a new file for the links-slice as I do not see much gain in that making the code more complex.
But If you insist I can refactor the code required.
There was a problem hiding this comment.
Not a big fan of slices myself, but everything touching dashboard props is using slice, so let's continue to use it
907b536 to
400af9d
Compare
…iagtion Signed-off-by: Prakhar JAIN <prakhar29jain@gmail.com>
400af9d to
2ed82a6
Compare










Description
Adds support for dashboard-level links, allowing users to navigate between dashboards or external resources while preserving variable context.
Merge Panel level and Dashboard level Links support for scalability.
perses/perses#3905
Screenshots
UX-1:

UX-2:
Working after Variables rendering -
Checklist
[<catalog_entry>] <commit message>naming convention using one of thefollowing
catalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.UI Changes
See e2e docs for more details. Common issues include: