-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support custom event type in EmitEvent Action (#2435)
* add emit event ui plugin * use emit event plugin in client * make dropdown same width as menu * turn on autoComplete * add adaptive form to emit-event dependencies
- Loading branch information
1 parent
85575f8
commit 736498d
Showing
12 changed files
with
158 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
extends: ['../../../.eslintrc.react.js'], | ||
parserOptions: { | ||
project: './tsconfig.json', | ||
tsconfigRootDir: __dirname, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
|
||
const path = require('path'); | ||
|
||
module.exports = { | ||
displayName: 'ui-plugin/emit-event', | ||
preset: 'ts-jest/presets/js-with-ts', | ||
moduleNameMapper: { | ||
// use commonjs modules for test so they do not need to be compiled | ||
'office-ui-fabric-react/lib/(.*)$': 'office-ui-fabric-react/lib-commonjs/$1', | ||
'@uifabric/fluent-theme/lib/(.*)$': '@uifabric/fluent-theme/lib-commonjs/$1', | ||
}, | ||
globals: { | ||
'ts-jest': { | ||
tsConfig: path.resolve(__dirname, './tsconfig.json'), | ||
diagnostics: false, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "@bfc/ui-plugin-emit-event", | ||
"version": "0.0.0", | ||
"private": true, | ||
"description": "", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"start": "tsc --watch --preserveWatchOutput", | ||
"build": "tsc --build ./tsconfig.build.json", | ||
"lint": "eslint --quiet --ext .ts,.tsx src" | ||
}, | ||
"keywords": [ | ||
"botframework", | ||
"composer" | ||
], | ||
"author": "andy.brown@microsoft.com", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@bfc/adaptive-form": "*", | ||
"@bfc/extension": "*", | ||
"@emotion/core": "^10.0.27", | ||
"@uifabric/fluent-theme": "^7.1.4", | ||
"@uifabric/icons": "^7.3.0", | ||
"@uifabric/styling": "^7.7.4", | ||
"office-ui-fabric-react": "^7.71.0", | ||
"react": "16.13.0", | ||
"react-dom": "16.13.0" | ||
}, | ||
"devDependencies": { | ||
"@bfc/adaptive-form": "*", | ||
"@bfc/extension": "*", | ||
"@emotion/core": "^10.0.27", | ||
"@types/react": "16.9.23", | ||
"@types/react-dom": "16.9.5", | ||
"react": "16.13.0", | ||
"react-dom": "16.13.0" | ||
}, | ||
"dependencies": { | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
Composer/packages/ui-plugins/emit-event/src/EventNameField.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import React from 'react'; | ||
import { FieldProps } from '@bfc/extension'; | ||
import { FieldLabel } from '@bfc/adaptive-form'; | ||
import { ComboBox, IComboBox, IComboBoxOption } from 'office-ui-fabric-react/lib/ComboBox'; | ||
import formatMessage from 'format-message'; | ||
|
||
const EventNameField: React.FC<FieldProps<string>> = props => { | ||
const { enumOptions, value, description, id, label, uiOptions, onChange, error } = props; | ||
|
||
const options: IComboBoxOption[] = (enumOptions ?? []).map(o => ({ | ||
key: o?.toString(), | ||
text: o?.toString(), | ||
})); | ||
|
||
const handleChange = (e: React.FormEvent<IComboBox>, option?: IComboBoxOption, index?: number, value?: string) => { | ||
if (option) { | ||
onChange(option.key as string); | ||
} else if (value) { | ||
onChange(value); | ||
} else { | ||
onChange(undefined); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<FieldLabel description={description} id={id} label={label} helpLink={uiOptions?.helpLink} /> | ||
<ComboBox | ||
id={id} | ||
text={value} | ||
options={options} | ||
placeholder={formatMessage('Select event type or type a custom one')} | ||
allowFreeform | ||
autoComplete="on" | ||
onChange={handleChange} | ||
errorMessage={error as string} | ||
useComboBoxAsMenuWidth | ||
styles={{ | ||
errorMessage: { display: 'none' }, | ||
}} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export { EventNameField }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { PluginConfig } from '@bfc/extension'; | ||
import { SDKTypes } from '@bfc/shared'; | ||
|
||
import { EventNameField } from './EventNameField'; | ||
|
||
const config: PluginConfig = { | ||
uiSchema: { | ||
[SDKTypes.EmitEvent]: { | ||
properties: { | ||
eventName: { | ||
field: EventNameField, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"exclude": ["node_modules", "**/__tests__/**"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "./lib/", | ||
}, | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters