Merge pull request #1460 from pnp/react-adaptivecards-hooks-patch1
Upgraded two Adaptive Cards samples to SPFx 1.11
This commit is contained in:
commit
24dbcaa057
|
@ -2,11 +2,11 @@
|
|||
"@microsoft/generator-sharepoint": {
|
||||
"isCreatingSolution": true,
|
||||
"environment": "spo",
|
||||
"version": "1.10.0",
|
||||
"version": "1.11.0",
|
||||
"libraryName": "react-adaptivecards-hooks",
|
||||
"libraryId": "9b520d32-ce30-4ffa-bf38-5d888e65c782",
|
||||
"packageManager": "npm",
|
||||
"isDomainIsolated": false,
|
||||
"componentType": "webpart"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ A version of [react-adaptivecards](https://github.com/SharePoint/sp-dev-fx-webpa
|
|||
|
||||
## Used SharePoint Framework Version
|
||||
|
||||
![1.10.0](https://img.shields.io/badge/version-1.10.0-green.svg)
|
||||
![1.11.0](https://img.shields.io/badge/version-1.11.0-green.svg)
|
||||
|
||||
## Applies to
|
||||
|
||||
|
@ -20,12 +20,14 @@ A version of [react-adaptivecards](https://github.com/SharePoint/sp-dev-fx-webpa
|
|||
Solution|Author(s)
|
||||
--------|---------
|
||||
react-adaptivecards-hooks | Paul Schaeflein (http://www.schaeflein.net)
|
||||
react-adaptivecards-hooks | Hugo Bernier ([Tahoe Ninjas](https://tahoeninjas.blog), [@bernier](https://twitter.com/bernierh))
|
||||
|
||||
## Version history
|
||||
|
||||
Version|Date|Comments
|
||||
-------|----|--------
|
||||
1.0|April 27, 2020|Initial release
|
||||
2.0|August 25, 2020|Upgraded to SPFx 1.11 and added support for May 2020 changes to Adaptive Cards
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"title": "Adaptive Card Viewer",
|
||||
"iconPath": "assets/adaptive-cards.png",
|
||||
"id": "9b520d32-ce30-4ffa-bf38-5d888e65c782",
|
||||
"version": "1.0.0.0",
|
||||
"version": "2.0.0.0",
|
||||
"includeClientSideAssets": true,
|
||||
"isDomainIsolated": false
|
||||
},
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "react-adaptivecards-hooks",
|
||||
"version": "0.0.1",
|
||||
"version": "2.0.0",
|
||||
"private": true,
|
||||
"main": "lib/index.js",
|
||||
"engines": {
|
||||
|
@ -12,23 +12,19 @@
|
|||
"test": "gulp test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/sp-core-library": "1.10.0",
|
||||
"@microsoft/sp-lodash-subset": "1.10.0",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.10.0",
|
||||
"@microsoft/sp-property-pane": "1.10.0",
|
||||
"@microsoft/sp-webpart-base": "1.10.0",
|
||||
"@microsoft/sp-core-library": "1.11.0",
|
||||
"@microsoft/sp-lodash-subset": "1.11.0",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.11.0",
|
||||
"@microsoft/sp-property-pane": "1.11.0",
|
||||
"@microsoft/sp-webpart-base": "1.11.0",
|
||||
"@pnp/sp": "^2.0.4",
|
||||
"@pnp/spfx-controls-react": "^1.17.0",
|
||||
"@pnp/spfx-property-controls": "^1.17.0",
|
||||
"@types/es6-promise": "0.0.33",
|
||||
"@types/react": "16.8.8",
|
||||
"@types/react-dom": "16.8.3",
|
||||
"@types/webpack-env": "1.13.1",
|
||||
"adaptivecards": "^1.2.5",
|
||||
"adaptivecards": "^1.2.6",
|
||||
"adaptivecards-fabric": "^1.0.4",
|
||||
"adaptivecards-templating": "^0.1.1-alpha.1",
|
||||
"adaptivecards-templating": "1.1.0",
|
||||
"markdown-it": "^10.0.0",
|
||||
"office-ui-fabric-react": "6.189.2",
|
||||
"office-ui-fabric-react": "6.214.0",
|
||||
"react": "16.8.5",
|
||||
"react-dom": "16.8.5"
|
||||
},
|
||||
|
@ -36,14 +32,18 @@
|
|||
"@types/react": "16.8.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/sp-build-web": "1.10.0",
|
||||
"@microsoft/sp-tslint-rules": "1.10.0",
|
||||
"@microsoft/sp-module-interfaces": "1.10.0",
|
||||
"@microsoft/sp-webpart-workbench": "1.10.0",
|
||||
"@microsoft/rush-stack-compiler-3.3": "0.3.5",
|
||||
"gulp": "~3.9.1",
|
||||
"@microsoft/sp-build-web": "1.11.0",
|
||||
"@microsoft/sp-module-interfaces": "1.11.0",
|
||||
"@microsoft/sp-tslint-rules": "1.11.0",
|
||||
"@microsoft/sp-webpart-workbench": "1.11.0",
|
||||
"@types/chai": "3.4.34",
|
||||
"@types/es6-promise": "0.0.33",
|
||||
"@types/mocha": "2.2.38",
|
||||
"ajv": "~5.2.2"
|
||||
"@types/react": "16.8.8",
|
||||
"@types/react-dom": "16.8.3",
|
||||
"@types/webpack-env": "1.13.1",
|
||||
"ajv": "~5.2.2",
|
||||
"gulp": "~3.9.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ export class AdaptiveCard extends React.Component<IAdaptiveCardProps, IAdaptiveC
|
|||
}
|
||||
|
||||
let errors: Array<IValidationError> = [];
|
||||
let card: {};
|
||||
let card: any;
|
||||
|
||||
if (this.props.data && this.props.useTemplating) {
|
||||
// Define a template payload
|
||||
|
@ -77,16 +77,18 @@ export class AdaptiveCard extends React.Component<IAdaptiveCardProps, IAdaptiveC
|
|||
try {
|
||||
templatePayload = JSON.parse(this.props.template);
|
||||
} catch (error) {
|
||||
this._errorHandler(strings.TemplateJsonError + error);
|
||||
console.error("Something went wrong with the template", error);
|
||||
this._errorHandler(strings.TemplatingJsonError + error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a Template instance from the template payload
|
||||
var template = new ACData.Template(templatePayload);
|
||||
|
||||
// Create a data binding context, and set its $root property to the
|
||||
// data object to bind the template to
|
||||
var context = new ACData.EvaluationContext();
|
||||
var context: any = {
|
||||
"$root":{}
|
||||
};
|
||||
|
||||
try {
|
||||
context.$root = JSON.parse(this.props.data);
|
||||
} catch (error) {
|
||||
|
|
|
@ -68,10 +68,6 @@ export default class AdaptiveCardViewerWebPart extends BaseClientSideWebPart <IA
|
|||
return Version.parse('1.0');
|
||||
}
|
||||
|
||||
protected get disableReactivePropertyChanges(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instead of always loading the property field code editor every time the web part is loaded,
|
||||
* we load it dynamically only when we need to display the property pane.
|
||||
|
|
|
@ -36,6 +36,7 @@ declare interface IAdaptiveCardViewerWebPartStrings {
|
|||
AdaptiveTemplatingEnd: string;
|
||||
TemplateJsonError: string;
|
||||
DataJsonError: string;
|
||||
TemplatingJsonError: string;
|
||||
}
|
||||
|
||||
declare module 'AdaptiveCardViewerWebPartStrings' {
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts", "src/webparts/adaptiveCardViewer/components/RootComponent.tsx"
|
||||
"src/**/*.ts", "src/webparts/adaptiveCardViewer/components/RootComponent.tsx",
|
||||
"src/**/*.tsx"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
"environment": "spo",
|
||||
"framework": "react",
|
||||
"isCreatingSolution": false,
|
||||
"version": "1.10.0",
|
||||
"version": "1.11.0",
|
||||
"libraryName": "adaptive-card-host",
|
||||
"libraryId": "ce1e3712-fb7a-4564-b2d3-c81e45936afd",
|
||||
"packageManager": "npm",
|
||||
"isDomainIsolated": false,
|
||||
"componentType": "webpart"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ This sample creates an Adaptive Cards Host web part that you can use to display
|
|||
|
||||
## Used SharePoint Framework Version
|
||||
|
||||
![1.10.0](https://img.shields.io/badge/version-1.10.0-green.svg)
|
||||
![1.11.0](https://img.shields.io/badge/version-1.11.0-green.svg)
|
||||
|
||||
## Applies to
|
||||
|
||||
|
@ -37,6 +37,7 @@ Version|Date|Comments
|
|||
1.0|March 24, 2020|Initial release
|
||||
2.0|April 06, 2020|Added data and template URLs
|
||||
2.1|June 11, 2020|Fixed breaking changes introduced with Adaptive Card Templating in May update
|
||||
2.2|August 25, 2020|Upgraded to SPFx 1.11
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"solution": {
|
||||
"name": "adaptive-cards",
|
||||
"id": "ce1e3712-fb7a-4564-b2d3-c81e45936afd",
|
||||
"version": "2.1.0.0",
|
||||
"version": "2.2.0.0",
|
||||
"includeClientSideAssets": true,
|
||||
"isDomainIsolated": false
|
||||
},
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "adaptive-card-host",
|
||||
"version": "2.1.0",
|
||||
"version": "2.2.0",
|
||||
"private": true,
|
||||
"main": "lib/index.js",
|
||||
"engines": {
|
||||
|
@ -14,23 +14,19 @@
|
|||
"postversion": "gulp dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/sp-core-library": "1.10.0",
|
||||
"@microsoft/sp-lodash-subset": "1.10.0",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.10.0",
|
||||
"@microsoft/sp-property-pane": "1.10.0",
|
||||
"@microsoft/sp-webpart-base": "1.10.0",
|
||||
"@microsoft/sp-core-library": "1.11.0",
|
||||
"@microsoft/sp-lodash-subset": "1.11.0",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.11.0",
|
||||
"@microsoft/sp-property-pane": "1.11.0",
|
||||
"@microsoft/sp-webpart-base": "1.11.0",
|
||||
"@pnp/sp": "^2.0.3",
|
||||
"@pnp/spfx-controls-react": "1.16.0",
|
||||
"@pnp/spfx-property-controls": "^1.18.0",
|
||||
"@types/es6-promise": "0.0.33",
|
||||
"@types/react": "16.8.8",
|
||||
"@types/react-dom": "16.8.3",
|
||||
"@types/webpack-env": "1.13.1",
|
||||
"adaptivecards": "^1.2.6",
|
||||
"adaptivecards-fabric": "^1.0.4",
|
||||
"adaptivecards-templating": "^1.0.0-rc.0",
|
||||
"adaptivecards-templating": "1.1.0",
|
||||
"markdown-it": "^10.0.0",
|
||||
"office-ui-fabric-react": "6.189.2",
|
||||
"office-ui-fabric-react": "6.214.0",
|
||||
"react": "16.8.5",
|
||||
"react-dom": "16.8.5",
|
||||
"save": "^2.4.0"
|
||||
|
@ -40,12 +36,16 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/rush-stack-compiler-3.3": "0.3.5",
|
||||
"@microsoft/sp-build-web": "1.10.0",
|
||||
"@microsoft/sp-module-interfaces": "1.10.0",
|
||||
"@microsoft/sp-tslint-rules": "1.10.0",
|
||||
"@microsoft/sp-webpart-workbench": "1.10.0",
|
||||
"@microsoft/sp-build-web": "1.11.0",
|
||||
"@microsoft/sp-module-interfaces": "1.11.0",
|
||||
"@microsoft/sp-tslint-rules": "1.11.0",
|
||||
"@microsoft/sp-webpart-workbench": "1.11.0",
|
||||
"@types/chai": "3.4.34",
|
||||
"@types/es6-promise": "0.0.33",
|
||||
"@types/mocha": "2.2.38",
|
||||
"@types/react": "16.8.8",
|
||||
"@types/react-dom": "16.8.3",
|
||||
"@types/webpack-env": "1.13.1",
|
||||
"ajv": "~5.2.2",
|
||||
"gulp": "~3.9.1",
|
||||
"gulp-sequence": "1.0.0",
|
||||
|
|
|
@ -92,16 +92,24 @@ export class AdaptiveCard extends React.Component<IAdaptiveCardProps, IAdaptiveC
|
|||
try {
|
||||
context.$root = JSON.parse(this.props.data);
|
||||
} catch (error) {
|
||||
console.error("Error parsing the data JSON", error);
|
||||
this._errorHandler(strings.DataJsonError + error);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Expand the card by combining the template and data
|
||||
card = template.expand(context);
|
||||
} catch (error) {
|
||||
console.error("Error combining template and data", error);
|
||||
this._errorHandler(strings.DataJsonError + error);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
card = JSON.parse(this.props.template);
|
||||
} catch (error) {
|
||||
console.error("Error parsing template", error);
|
||||
this._errorHandler(strings.TemplateJsonError + error);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
"esModuleInterop": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts", "src/controls/AdaptiveCard/AdaptiveCard.tsx"
|
||||
"src/**/*.ts", "src/controls/AdaptiveCard/AdaptiveCard.tsx",
|
||||
"src/**/*.tsx"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
|
|
Loading…
Reference in New Issue