Skip to content

Commit b6b36f2

Browse files
committed
Add support for links in table actions, as well as improved rendering of links in markdown
1 parent 31044c1 commit b6b36f2

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

public/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,7 @@
253253
display: none;
254254
}
255255
/* End Gantt chart workaround */
256+
257+
.markdown-widget a {
258+
text-decoration: underline;
259+
}

src/chart/ChartUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export function replaceDashboardParameters(str, parameters) {
219219
let param = _.replace(`$`, '').trim();
220220
let val = parameters?.[param] || null;
221221
let type = getRecordType(val);
222-
let valueRender = type === 'string' ? val : RenderSubValue(val);
222+
let valueRender = type === 'string' || type == 'link' ? val : RenderSubValue(val);
223223
return valueRender;
224224
};
225225

src/chart/markdown/MarkdownChart.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ const NeoMarkdownChart = (props: ChartProps) => {
1919
const modifiedMarkdown = replaceGlobalParameters ? replaceDashboardParameters(markdown, parameters) : markdown;
2020
// TODO: we should check if the gfm plugin has an impact on the standard security provided by ReactMarkdown
2121
return (
22-
<div style={{ marginTop: '0px', marginLeft: '15px', marginRight: '15px', marginBottom: '0px' }}>
22+
<div
23+
className='markdown-widget'
24+
style={{ marginTop: '0px', marginLeft: '15px', marginRight: '15px', marginBottom: '0px' }}
25+
>
2326
<base target='_blank' /> <ReactMarkdown remarkPLugins={[gfm]} children={modifiedMarkdown} />
2427
</div>
2528
);

src/chart/table/TableChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function renderAsButtonWrapper(renderer) {
4545
style={{ width: '100%', marginLeft: '5px', marginRight: '5px' }}
4646
variant='contained'
4747
color='primary'
48-
>{`${renderer(value)}`}</Button>
48+
>{`${renderer(value, true)}`}</Button>
4949
);
5050
};
5151
}

src/report/ReportRecordProcessing.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,12 @@ function RenderString(value) {
269269
return str;
270270
}
271271

272-
function RenderLink(value) {
272+
function RenderLink(value, disabled = false) {
273+
// If the link is embedded in a button (disabled), it's not a hyperlink, so we just return the string.
274+
if (disabled) {
275+
return value;
276+
}
277+
// Else, it's a 'real' link, and return a React object
273278
return (
274279
<TextLink key={value} externalLink target='_blank' href={value}>
275280
{value}
@@ -389,7 +394,7 @@ export const rendererForType: any = {
389394
},
390395
link: {
391396
type: 'link',
392-
renderValue: (c) => RenderLink(c.value),
397+
renderValue: (c, disabled = false) => RenderLink(c.value, disabled),
393398
},
394399
};
395400

0 commit comments

Comments
 (0)