diff --git a/superset-frontend/package-lock.json b/superset-frontend/package-lock.json index e8a280306ef72..80591d8c921a0 100644 --- a/superset-frontend/package-lock.json +++ b/superset-frontend/package-lock.json @@ -23028,6 +23028,12 @@ "version": "2.6.9", "license": "MIT" }, + "node_modules/currencyformatter.js": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/currencyformatter.js/-/currencyformatter.js-1.0.5.tgz", + "integrity": "sha1-+MbZRdzmtn70j0dRaGEajZXJx14=", + "peer": true + }, "node_modules/cyclist": { "version": "1.0.1", "license": "MIT" @@ -51571,7 +51577,8 @@ "version": "0.0.0", "license": "Apache-2.0", "dependencies": { - "handlebars": "^4.7.7" + "handlebars": "^4.7.7", + "just-handlebars-helpers": "^1.0.19" }, "devDependencies": { "@types/jest": "^26.0.0", @@ -51589,6 +51596,23 @@ "react-dom": "^16.13.1" } }, + "plugins/plugin-chart-handlebars/node_modules/just-handlebars-helpers": { + "version": "1.0.19", + "resolved": "https://registry.npmjs.org/just-handlebars-helpers/-/just-handlebars-helpers-1.0.19.tgz", + "integrity": "sha512-E+0eUn5xKfBAoU6mF3QbGZ939PZDw7RYI6AMTpRQtesRH2lZXjXaOqHzJ2nbHnDVmxNQM453sXFnMpd/uaLkKg==", + "peerDependencies": { + "currencyformatter.js": ">= 1.0.4 < 2", + "handlebars": ">= 3.*", + "moment": ">= 2.22.0 < 3", + "sprintf-js": ">= 1.1.1 < 2" + } + }, + "plugins/plugin-chart-handlebars/node_modules/sprintf-js": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", + "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==", + "peer": true + }, "plugins/plugin-chart-pivot-table": { "name": "@superset-ui/plugin-chart-pivot-table", "version": "0.18.25", @@ -62007,7 +62031,22 @@ "@types/jest": "^26.0.0", "@types/lodash": "^4.14.149", "handlebars": "^4.7.7", - "jest": "^26.0.1" + "jest": "^26.0.1", + "just-handlebars-helpers": "*" + }, + "dependencies": { + "just-handlebars-helpers": { + "version": "1.0.19", + "resolved": "https://registry.npmjs.org/just-handlebars-helpers/-/just-handlebars-helpers-1.0.19.tgz", + "integrity": "sha512-E+0eUn5xKfBAoU6mF3QbGZ939PZDw7RYI6AMTpRQtesRH2lZXjXaOqHzJ2nbHnDVmxNQM453sXFnMpd/uaLkKg==", + "requires": {} + }, + "sprintf-js": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", + "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==", + "peer": true + } } }, "@superset-ui/plugin-chart-pivot-table": { @@ -67444,6 +67483,12 @@ "csstype": { "version": "2.6.9" }, + "currencyformatter.js": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/currencyformatter.js/-/currencyformatter.js-1.0.5.tgz", + "integrity": "sha1-+MbZRdzmtn70j0dRaGEajZXJx14=", + "peer": true + }, "cyclist": { "version": "1.0.1" }, diff --git a/superset-frontend/plugins/plugin-chart-handlebars/package.json b/superset-frontend/plugins/plugin-chart-handlebars/package.json index da88ada90bae1..dd887865692d9 100644 --- a/superset-frontend/plugins/plugin-chart-handlebars/package.json +++ b/superset-frontend/plugins/plugin-chart-handlebars/package.json @@ -26,7 +26,8 @@ "access": "public" }, "dependencies": { - "handlebars": "^4.7.7" + "handlebars": "^4.7.7", + "just-handlebars-helpers": "^1.0.19" }, "peerDependencies": { "@superset-ui/chart-controls": "*", @@ -39,8 +40,8 @@ "react-dom": "^16.13.1" }, "devDependencies": { - "@types/lodash": "^4.14.149", "@types/jest": "^26.0.0", + "@types/lodash": "^4.14.149", "jest": "^26.0.1" } } diff --git a/superset-frontend/plugins/plugin-chart-handlebars/src/components/Handlebars/HandlebarsViewer.tsx b/superset-frontend/plugins/plugin-chart-handlebars/src/components/Handlebars/HandlebarsViewer.tsx index b1ec9597ac26f..479da8ac91b65 100644 --- a/superset-frontend/plugins/plugin-chart-handlebars/src/components/Handlebars/HandlebarsViewer.tsx +++ b/superset-frontend/plugins/plugin-chart-handlebars/src/components/Handlebars/HandlebarsViewer.tsx @@ -21,6 +21,7 @@ import Handlebars from 'handlebars'; import moment from 'moment'; import React, { useMemo, useState } from 'react'; import { isPlainObject } from 'lodash'; +import Helpers from 'just-handlebars-helpers'; export interface HandlebarsViewerProps { templateSource: string; @@ -86,3 +87,5 @@ Handlebars.registerHelper('stringify', (obj: any, obj2: any) => { throw Error('Please call with an object. Example: `stringify myObj`'); return isPlainObject(obj) ? JSON.stringify(obj) : String(obj); }); + +Helpers.registerHelpers(Handlebars); diff --git a/superset-frontend/plugins/plugin-chart-handlebars/types/external.d.ts b/superset-frontend/plugins/plugin-chart-handlebars/types/external.d.ts index 8f7985ceaf135..a07e4dd267159 100644 --- a/superset-frontend/plugins/plugin-chart-handlebars/types/external.d.ts +++ b/superset-frontend/plugins/plugin-chart-handlebars/types/external.d.ts @@ -20,3 +20,5 @@ declare module '*.png' { const value: any; export default value; } + +declare module 'just-handlebars-helpers';