Skip to content

Commit 718a782

Browse files
committed
NodeHandler
1 parent 37c348c commit 718a782

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/card/view/CardViewHeader.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import ImageIcon from '@material-ui/icons/Image';
1515
import CloseIcon from '@material-ui/icons/Close';
1616
import ReactMarkdown from 'react-markdown';
1717
import gfm from 'remark-gfm';
18+
import { replaceDashboardParameters } from '../../chart/ChartUtils';
1819

1920
const NeoCardViewHeader = ({
2021
title,
@@ -37,13 +38,8 @@ const NeoCardViewHeader = ({
3738
const [descriptionModalOpen, setDescriptionModalOpen] = React.useState(false);
3839

3940
function replaceParamsOnString(s, p) {
40-
let parsed = `${s} `;
41-
for (const [key, value] of Object.entries(p)) {
42-
// TODO: make this a regex.
43-
parsed = parsed.replace(`$${key} `, `${value} `);
44-
parsed = parsed.replace(`$${key},`, `${value},`);
45-
parsed = parsed.replace(`$${key}.`, `${value}.`);
46-
}
41+
let parsed: string;
42+
parsed = replaceDashboardParameters(s, p);
4743
return parsed;
4844
}
4945

src/chart/ChartUtils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ export function replaceDashboardParameters(str, parameters) {
208208
let newString = str.replace(rx, parameterElementReplacer);
209209

210210
Object.keys(parameters).forEach((key) => {
211-
newString = newString.replaceAll(`$${key}`, parameters[key] !== null ? parameters[key] : '');
211+
let valueRender = RenderSubValue(parameters[key]);
212+
newString = newString.replaceAll(`$${key}`, `${valueRender} `);
213+
newString = newString.replaceAll(`$${key},`, `${valueRender},`);
214+
newString = newString.replaceAll(`$${key}.`, `${valueRender}.`);
215+
newString = newString.replaceAll(`$${key})`, `${valueRender})`);
212216
});
213217

214218
return newString;

src/settings/SettingsThunks.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { setSessionParameters } from '../application/ApplicationActions';
22
import { hardResetCardSettings } from '../card/CardActions';
3-
import { castToNeo4jDate, isCastableToNeo4jDate } from '../chart/ChartUtils';
3+
import { castToNeo4jDate, isCastableToNeo4jDate, valueIsNode } from '../chart/ChartUtils';
44
import { createNotificationThunk } from '../page/PageThunks';
55
import { updateDashboardSetting } from './SettingsActions';
66

@@ -29,7 +29,8 @@ export const updateGlobalParameterThunk = (key, value) => (dispatch: any, getSta
2929
const { settings } = getState().dashboard;
3030
const parameters = settings.parameters ? settings.parameters : {};
3131
if (value !== undefined) {
32-
parameters[key] = value;
32+
let valueFinal = valueIsNode(value) ? Object.assign({}, value) : value;
33+
parameters[key] = valueFinal;
3334
} else {
3435
delete parameters[key];
3536
}

0 commit comments

Comments
 (0)