Skip to content

Commit

Permalink
Make links in query result panel clickable (#2428)
Browse files Browse the repository at this point in the history
  • Loading branch information
YannanGao-gs authored Jul 13, 2023
1 parent aaf62ce commit 8a14aca
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changeset/long-feet-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
'@finos/legend-shared': patch
---
5 changes: 5 additions & 0 deletions .changeset/rotten-tigers-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-query-builder': patch
---

Make links in query result panel clickable.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import {
type PlainObject,
prettyDuration,
filterByType,
isValidURL,
} from '@finos/legend-shared';
import { forwardRef, useRef, useState } from 'react';
import {
Expand Down Expand Up @@ -713,7 +714,13 @@ const QueryResultCellRenderer = observer(
onMouseUp={(event) => mouseUp(event)}
onMouseOver={(event) => mouseOver(event)}
>
<span>{cellValue}</span>
{isValidURL(cellValue) ? (
<a href={cellValue} target="_blank" rel="noreferrer">
{cellValue}
</a>
) : (
<span>{cellValue}</span>
)}
</div>
</ContextMenu>
);
Expand Down
8 changes: 8 additions & 0 deletions packages/legend-shared/src/network/NetworkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ const compressData = (data: object | string): Blob =>
new Blob([deflate(isObject(data) ? JSON.stringify(data) : data)]);

export const URL_SEPARATOR = '/';
/**
* Reference: https://uibakery.io/regex-library/url
*/
const URL_REGEX = new RegExp(
'^https?://(?:www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$',
);
export const HttpStatus = StatusCodes;
export const CHARSET = 'charset=utf-8';

Expand Down Expand Up @@ -586,3 +592,5 @@ export const buildUrl = (parts: string[]): string =>
.join(URL_SEPARATOR);

export const sanitizeURL = (val: string): string => sanitizeUrl(val);

export const isValidURL = (val: string): boolean => URL_REGEX.test(val);

0 comments on commit 8a14aca

Please sign in to comment.