From ef712badbf7e35d16b51e324c3833cd8f006c4ef Mon Sep 17 00:00:00 2001 From: William Wong Date: Fri, 5 Mar 2021 03:54:48 -0800 Subject: [PATCH] Add adaptiveCardsParserMaxVersion style options (#3778) --- ...arser-max-version-style-options-1-snap.png | Bin 0 -> 9691 bytes ...arser-max-version-style-options-2-snap.png | Bin 0 -> 8933 bytes ...arser-max-version-style-options-3-snap.png | Bin 0 -> 9691 bytes .../html/adaptiveCards.parserMaxVersion.html | 96 ++++++++++++++++++ .../html/adaptiveCards.parserMaxVersion.js | 8 ++ .../internal/useParseAdaptiveCardJSON.js | 21 +++- 6 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 __tests__/__image_snapshots__/html/adaptive-cards-parser-max-version-js-adaptive-cards-with-adaptive-cards-parser-max-version-style-options-1-snap.png create mode 100644 __tests__/__image_snapshots__/html/adaptive-cards-parser-max-version-js-adaptive-cards-with-adaptive-cards-parser-max-version-style-options-2-snap.png create mode 100644 __tests__/__image_snapshots__/html/adaptive-cards-parser-max-version-js-adaptive-cards-with-adaptive-cards-parser-max-version-style-options-3-snap.png create mode 100644 __tests__/html/adaptiveCards.parserMaxVersion.html create mode 100644 __tests__/html/adaptiveCards.parserMaxVersion.js diff --git a/__tests__/__image_snapshots__/html/adaptive-cards-parser-max-version-js-adaptive-cards-with-adaptive-cards-parser-max-version-style-options-1-snap.png b/__tests__/__image_snapshots__/html/adaptive-cards-parser-max-version-js-adaptive-cards-with-adaptive-cards-parser-max-version-style-options-1-snap.png new file mode 100644 index 0000000000000000000000000000000000000000..2b4d1521309c960ae3571070c684e89691f70838 GIT binary patch literal 9691 zcmeHNc{G%L-=8AtF5D#w;Vu*kb!W-Glw}gKXD^kp#1zK9RFtyT*dkk5$6DF443&^= z?38Va7-le8COgmfdj5LPd){-NbDs15dC%#b95dH7zu)is{eHH~)2sU0Y=7|nfkL6! z&^nilP^evwDAexzds*N&Z+XXa;lEuTM%o&vV$!i06zVS&`jWbdPs-e=zvp4b*3QD9 zn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XG)3`I+RuY{k+3Y&;ZRSQtCMdyu54sN=oR-XYUDK%d`qa>>Yu zHEbNomiXU|K|BM#(5XM)6p@_}zx5rbZK)t8X!ctvXsnzz$(k#YiMoOTzaEUZd4~n2 zT_~02zy?qx6Tmd*A&C;4K=tgqwz$N^Q)p7hp(3`P3R|+ zTng~`L&|GEV}UXUp) + + + + + + +
+ + + diff --git a/__tests__/html/adaptiveCards.parserMaxVersion.js b/__tests__/html/adaptiveCards.parserMaxVersion.js new file mode 100644 index 0000000000..710d2658b5 --- /dev/null +++ b/__tests__/html/adaptiveCards.parserMaxVersion.js @@ -0,0 +1,8 @@ +/** + * @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js + */ + +describe('Adaptive Cards', () => { + test('with "adaptiveCardsParserMaxVersion" style options', () => + runHTMLTest('adaptiveCards.parserMaxVersion.html')); +}); diff --git a/packages/bundle/src/adaptiveCards/hooks/internal/useParseAdaptiveCardJSON.js b/packages/bundle/src/adaptiveCards/hooks/internal/useParseAdaptiveCardJSON.js index 4627e20c7b..a493baa654 100644 --- a/packages/bundle/src/adaptiveCards/hooks/internal/useParseAdaptiveCardJSON.js +++ b/packages/bundle/src/adaptiveCards/hooks/internal/useParseAdaptiveCardJSON.js @@ -1,9 +1,9 @@ import { hooks } from 'botframework-webchat-component'; -import { useCallback } from 'react'; +import { useCallback, useMemo } from 'react'; import useAdaptiveCardsPackage from '../useAdaptiveCardsPackage'; -const { useDirection } = hooks; +const { useDirection, useStyleOptions } = hooks; function updateRTLInline(element, rtl, adaptiveCardsPackage) { if (element instanceof adaptiveCardsPackage.Container) { @@ -25,8 +25,19 @@ function updateRTLInline(element, rtl, adaptiveCardsPackage) { export default function useParseAdaptiveCardJSON() { const [adaptiveCardsPackage] = useAdaptiveCardsPackage(); const [direction] = useDirection(); + const [{ adaptiveCardsParserMaxVersion }] = useStyleOptions(); - const { AdaptiveCard, SerializationContext } = adaptiveCardsPackage; + const { AdaptiveCard, SerializationContext, Version } = adaptiveCardsPackage; + + const maxVersion = useMemo(() => { + const maxVersion = Version.parse(adaptiveCardsParserMaxVersion, new SerializationContext()); + + if (maxVersion && !maxVersion.isValid) { + return console.warn('botframework-webchat: "adaptiveCardsParserMaxVersion" specified is not a valid version.'); + } + + return maxVersion; + }, [adaptiveCardsParserMaxVersion]); return useCallback( (content, { ignoreErrors = false } = {}) => { @@ -36,7 +47,7 @@ export default function useParseAdaptiveCardJSON() { const card = new AdaptiveCard(); const errors = []; - const serializationContext = new SerializationContext(); + const serializationContext = new SerializationContext(maxVersion); card.parse(content, serializationContext); @@ -56,6 +67,6 @@ export default function useParseAdaptiveCardJSON() { return card; }, - [AdaptiveCard, adaptiveCardsPackage, direction, SerializationContext] + [AdaptiveCard, adaptiveCardsPackage, direction, maxVersion, SerializationContext] ); }