Initial commit

This commit is contained in:
Stephan Bisser 2019-09-04 09:31:28 +02:00
parent 8290b239fc
commit 33482de7c5
14 changed files with 2036 additions and 144 deletions

View File

@ -1,6 +1,6 @@
{ {
"@microsoft/generator-sharepoint": { "@microsoft/generator-sharepoint": {
"isCreatingSolution": true, "isCreatingSolution": false,
"environment": "spo", "environment": "spo",
"version": "1.7.0", "version": "1.7.0",
"libraryName": "react-bot-framework", "libraryName": "react-bot-framework",

View File

@ -9,10 +9,19 @@
"manifest": "./src/webparts/botFrameworkChat/BotFrameworkChatWebPart.manifest.json" "manifest": "./src/webparts/botFrameworkChat/BotFrameworkChatWebPart.manifest.json"
} }
] ]
},
"bot-framework-chatv-4-web-part": {
"components": [
{
"entrypoint": "./lib/webparts/botFrameworkChatv4/BotFrameworkChatv4WebPart.js",
"manifest": "./src/webparts/botFrameworkChatv4/BotFrameworkChatv4WebPart.manifest.json"
}
]
} }
}, },
"externals": {}, "externals": {},
"localizedResources": { "localizedResources": {
"BotFrameworkChatWebPartStrings": "lib/webparts/botFrameworkChat/loc/{locale}.js" "BotFrameworkChatWebPartStrings": "lib/webparts/botFrameworkChat/loc/{locale}.js",
"BotFrameworkChatv4WebPartStrings": "lib/webparts/botFrameworkChatv4/loc/{locale}.js"
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,8 @@
"@types/react": "16.4.2", "@types/react": "16.4.2",
"@types/react-dom": "16.0.5", "@types/react-dom": "16.0.5",
"@types/webpack-env": "1.13.1", "@types/webpack-env": "1.13.1",
"botframework-directlinejs": "^0.11.4",
"botframework-webchat": "^4.5.2",
"react": "16.3.2", "react": "16.3.2",
"react-dom": "16.3.2", "react-dom": "16.3.2",
"swagger-client": "^2.1.23" "swagger-client": "^2.1.23"

View File

@ -0,0 +1,26 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
"id": "7aa6d70f-2a9f-4e92-ad01-a45c582e82be",
"alias": "BotFrameworkChatv4WebPart",
"componentType": "WebPart",
// The "*" signifies that the version should be taken from the package.json
"version": "*",
"manifestVersion": 2,
// If true, the component can only be installed on sites where Custom Script is allowed.
// Components that allow authors to embed arbitrary script code should set this to true.
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
"requiresCustomScript": false,
"preconfiguredEntries": [{
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
"group": { "default": "Other" },
"title": { "default": "BotFrameworkChatv4" },
"description": { "default": "Use the botframework-webchat v4 React component to render the webchat with the new v4 UI" },
"officeFabricIconFontName": "Page",
"properties": {
"description": "BotFrameworkChatv4"
}
}]
}

View File

@ -0,0 +1,164 @@
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { Version } from '@microsoft/sp-core-library';
import {
BaseClientSideWebPart,
IPropertyPaneConfiguration,
PropertyPaneTextField,
PropertyPaneToggle
} from '@microsoft/sp-webpart-base';
import * as strings from 'BotFrameworkChatv4WebPartStrings';
import BotFrameworkChatv4 from './components/BotFrameworkChatv4';
import { IBotFrameworkChatv4Props } from './components/IBotFrameworkChatv4Props';
export interface IBotFrameworkChatv4WebPartProps {
description: string;
directLineSecret: string;
bubbleBackground: string;
bubbleTextColor: string;
bubbleFromUserBackground: string;
bubbleFromUserTextColor: string;
backgroundColor: string;
botAvatarImage: string;
botAvatarInitials: string;
userAvatarImage: string;
userAvatarInitials: string;
hideUploadButton: boolean;
sendBoxBackground: string;
sendBoxTextColor: string;
}
export default class BotFrameworkChatv4WebPart extends BaseClientSideWebPart<IBotFrameworkChatv4WebPartProps> {
public render(): void {
const element: React.ReactElement<IBotFrameworkChatv4Props > = React.createElement(
BotFrameworkChatv4,
{
description: this.properties.description,
directLineSecret: this.properties.directLineSecret,
bubbleBackground: this.properties.bubbleBackground,
bubbleTextColor: this.properties.bubbleTextColor,
bubbleFromUserBackground: this.properties.bubbleFromUserBackground,
bubbleFromUserTextColor: this.properties.bubbleFromUserTextColor,
backgroundColor: this.properties.backgroundColor,
botAvatarImage: this.properties.botAvatarImage,
botAvatarInitials: this.properties.botAvatarInitials,
userAvatarImage: this.properties.userAvatarImage,
userAvatarInitials: this.properties.userAvatarInitials,
hideUploadButton: this.properties.hideUploadButton,
sendBoxBackground: this.properties.sendBoxBackground,
sendBoxTextColor: this.properties.sendBoxTextColor,
context: this.context
}
);
ReactDom.render(element, this.domElement);
}
protected onDispose(): void {
ReactDom.unmountComponentAtNode(this.domElement);
}
protected get dataVersion(): Version {
return Version.parse('1.0');
}
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
pages: [
{
header: {
description: 'Here you can set various properties and settings regarding how your bot chat web part will look visually and functionally work'
},
groups: [
{
groupName: 'Bot Connection',
groupFields: [
PropertyPaneTextField('directLineSecret', {
label: 'Direct Line Secret'
})
]
},
{
groupName: 'Appearance - Colors',
groupFields: [
PropertyPaneTextField('backgroundColor', {
label: 'Background color of webchat'
}),
PropertyPaneTextField('bubbleBackground', {
label: 'Bot messages background color',
onGetErrorMessage: this._validateColorPropertyAsync.bind(this), // validation function
deferredValidationTime: 500 // delay after which to run the validation function
}),
PropertyPaneTextField('bubbleTextColor', {
label: 'Bot messages foreground color',
onGetErrorMessage: this._validateColorPropertyAsync.bind(this), // validation function
deferredValidationTime: 500 // delay after which to run the validation function
}),
PropertyPaneTextField('bubbleFromUserBackground', {
label: 'User messages background color',
onGetErrorMessage: this._validateColorPropertyAsync.bind(this), // validation function
deferredValidationTime: 500 // delay after which to run the validation function
}),
PropertyPaneTextField('bubbleFromUserTextColor', {
label: 'User messages foreground color',
onGetErrorMessage: this._validateColorPropertyAsync.bind(this), // validation function
deferredValidationTime: 500 // delay after which to run the validation function
}),
PropertyPaneTextField('sendBoxBackground', {
label: 'Sendbox background color',
onGetErrorMessage: this._validateColorPropertyAsync.bind(this), // validation function
deferredValidationTime: 500, // delay after which to run the validation function
}),
PropertyPaneTextField('sendBoxTextColor', {
label: 'Sendbox text color',
onGetErrorMessage: this._validateColorPropertyAsync.bind(this), // validation function
deferredValidationTime: 500 // delay after which to run the validation function
})
]
}
]
},
{
header: {
description: 'Here you can set various properties and settings regarding how your bot chat web part will look visually and functionally work'
},
groups: [
{
groupName: 'Appearance - Visuals',
groupFields: [
PropertyPaneTextField('botAvatarImage', {
label: 'Avatar image used for bot'
}),
PropertyPaneTextField('botAvatarInitials', {
label: 'Avatar initials used for bot'
}),
PropertyPaneTextField('userAvatarImage', {
label: 'Avatar image used for user'
}),
PropertyPaneTextField('userAvatarInitials', {
label: 'Avatar initials used for user'
}),
PropertyPaneToggle('hideUploadButton', {
label: 'Diable upload button'
})
]
}
]
}
]
};
}
private _validateColorPropertyAsync(value: string): string {
var colorRegex = /^#([a-zA-Z0-9]){6}$/;
if (!value || colorRegex.test(value) == false) {
return "Please enter a valid 6 character hex color value";
}
return "";
}
}

View File

@ -0,0 +1,74 @@
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
.botFrameworkChatv4 {
.container {
max-width: 700px;
margin: 0px auto;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
}
.row {
@include ms-Grid-row;
@include ms-fontColor-white;
background-color: $ms-color-themeDark;
padding: 20px;
}
.column {
@include ms-Grid-col;
@include ms-lg10;
@include ms-xl8;
@include ms-xlPush2;
@include ms-lgPush1;
}
.title {
@include ms-font-xl;
@include ms-fontColor-white;
}
.subTitle {
@include ms-font-l;
@include ms-fontColor-white;
}
.description {
@include ms-font-l;
@include ms-fontColor-white;
}
.button {
// Our button
text-decoration: none;
height: 32px;
// Primary Button
min-width: 80px;
background-color: $ms-color-themePrimary;
border-color: $ms-color-themePrimary;
color: $ms-color-white;
// Basic Button
outline: transparent;
position: relative;
font-family: "Segoe UI WestEuropean","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,"Helvetica Neue",sans-serif;
-webkit-font-smoothing: antialiased;
font-size: $ms-font-size-m;
font-weight: $ms-font-weight-regular;
border-width: 0;
text-align: center;
cursor: pointer;
display: inline-block;
padding: 0 16px;
.label {
font-weight: $ms-font-weight-semibold;
font-size: $ms-font-size-m;
height: 32px;
line-height: 32px;
margin: 0 4px;
vertical-align: top;
display: inline-block;
}
}
}

View File

@ -0,0 +1,49 @@
import * as React from 'react';
import styles from './BotFrameworkChatv4.module.scss';
import { IBotFrameworkChatv4Props } from './IBotFrameworkChatv4Props';
import { escape } from '@microsoft/sp-lodash-subset';
import ReactWebChat from 'botframework-webchat';
import styleSetOptions from 'botframework-webchat';
import { DirectLine } from 'botframework-directlinejs';
export interface IBotFrameworkChatv4State {
directLine: any;
styleSetOptions: any;
}
export default class BotFrameworkChatv4 extends React.Component<IBotFrameworkChatv4Props, IBotFrameworkChatv4State> {
constructor(props) {
super(props);
const styleOptions = {
backgroundColor: this.props.backgroundColor,
botAvatarImage: this.props.botAvatarImage,
userAvatarImage: this.props.userAvatarImage,
hideUploadButton: this.props.hideUploadButton,
sendBoxBackground: this.props.sendBoxBackground,
sendBoxTextColor: this.props.sendBoxTextColor,
bubbleBackground: this.props.bubbleBackground,
bubbleTextColor: this.props.bubbleTextColor,
bubbleFromUserTextColor: this.props.bubbleFromUserTextColor,
bubbleFromUserBackground: this.props.bubbleFromUserBackground,
userAvatarInitials: this.props.userAvatarInitials,
botAvatarInitials: this.props.botAvatarInitials
};
this.state = {
directLine: new DirectLine({
secret: this.props.directLineSecret
}),
styleSetOptions: styleOptions
};
}
public render(): React.ReactElement<IBotFrameworkChatv4Props> {
// <ReactWebChat directLine={this.state.directLine} styleOptions={this.state.styleSetOptions} />
return (
<div className={styles.botFrameworkChatv4} style={{ height: 700 }}>
<ReactWebChat directLine={this.state.directLine} styleOptions={this.state.styleSetOptions} />
</div>
);
}
}

View File

@ -0,0 +1,19 @@
import { IWebPartContext } from '@microsoft/sp-webpart-base';
export interface IBotFrameworkChatv4Props {
description: string;
directLineSecret: string;
bubbleBackground: string;
bubbleTextColor: string;
bubbleFromUserBackground: string;
bubbleFromUserTextColor: string;
backgroundColor: string;
botAvatarImage: string;
botAvatarInitials: string;
userAvatarImage: string;
userAvatarInitials: string;
hideUploadButton: boolean;
sendBoxBackground: string;
sendBoxTextColor: string;
context: IWebPartContext;
}

View File

@ -0,0 +1,7 @@
define([], function() {
return {
"PropertyPaneDescription": "Description",
"BasicGroupName": "Group Name",
"DescriptionFieldLabel": "Description Field"
}
});

View File

@ -0,0 +1,10 @@
declare interface IBotFrameworkChatv4WebPartStrings {
PropertyPaneDescription: string;
BasicGroupName: string;
DescriptionFieldLabel: string;
}
declare module 'BotFrameworkChatv4WebPartStrings' {
const strings: IBotFrameworkChatv4WebPartStrings;
export = strings;
}

View File

@ -0,0 +1,47 @@
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.2/MicrosoftTeams.schema.json",
"manifestVersion": "1.2",
"packageName": "BotFrameworkChatv4",
"id": "7aa6d70f-2a9f-4e92-ad01-a45c582e82be",
"version": "0.1",
"developer": {
"name": "SPFx + Teams Dev",
"websiteUrl": "https://products.office.com/en-us/sharepoint/collaboration",
"privacyUrl": "https://privacy.microsoft.com/en-us/privacystatement",
"termsOfUseUrl": "https://www.microsoft.com/en-us/servicesagreement"
},
"name": {
"short": "BotFrameworkChatv4"
},
"description": {
"short": "Use the botframework-webchat v4 React component to render the webchat with the new v4 UI",
"full": "Use the botframework-webchat v4 React component to render the webchat with the new v4 UI"
},
"icons": {
"outline": "tab20x20.png",
"color": "tab96x96.png"
},
"accentColor": "#004578",
"configurableTabs": [
{
"configurationUrl": "https://{teamSiteDomain}{teamSitePath}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest={teamSitePath}/_layouts/15/teamshostedapp.aspx%3FopenPropertyPane=true%26teams%26componentId=7aa6d70f-2a9f-4e92-ad01-a45c582e82be",
"canUpdateConfiguration": false,
"scopes": [
"team"
]
}
],
"validDomains": [
"*.login.microsoftonline.com",
"*.sharepoint.com",
"*.sharepoint-df.com",
"spoppe-a.akamaihd.net",
"spoprod-a.akamaihd.net",
"resourceseng.blob.core.windows.net",
"msft.spoppe.com"
],
"webApplicationInfo": {
"resource": "https://{teamSiteDomain}",
"id": "00000003-0000-0ff1-ce00-000000000000"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB