-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into julong/zoom-in-out
* main: fix: update l10n file (#4247) fix: fix loading of extensions by removing sample-ui-plugin (#4251) fix: split qna resource to another template (#4212) feat: UI Schema - Recognizer (#4135) fix: Change http to https for petstore.swagger.io calls (#4238) feat: install remote extensions from npm (#4224) fix: refactored select skill ui-plugin (#4207) feat: Added fieldSets to UIOptions (#4231) fix: New LG template not sync to other locale files (#4230)
- Loading branch information
Showing
149 changed files
with
2,350 additions
and
1,495 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
19 changes: 19 additions & 0 deletions
19
Composer/packages/adaptive-form/src/components/fields/CustomRecognizerField.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,19 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import React from 'react'; | ||
import { FieldProps } from '@bfc/extension-client'; | ||
import { JsonEditor } from '@bfc/code-editor'; | ||
|
||
export const CustomRecognizerField: React.FC<FieldProps> = (props) => { | ||
const { value, onChange } = props; | ||
return ( | ||
<JsonEditor | ||
key="customRecognizerField" | ||
height={200} | ||
id="customRecognizerField" | ||
value={value as object} | ||
onChange={onChange} | ||
/> | ||
); | ||
}; |
29 changes: 29 additions & 0 deletions
29
Composer/packages/adaptive-form/src/components/fields/FieldSets.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,29 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import React from 'react'; | ||
import { FieldProps } from '@bfc/extension-client'; | ||
|
||
import { CollapseField } from '../CollapseField'; | ||
import { getFieldSets } from '../../utils'; | ||
|
||
import { ObjectField } from './ObjectField'; | ||
|
||
export const FieldSets: React.FC<FieldProps<object>> = (props) => { | ||
const { schema, uiOptions: baseUiOptions, value } = props; | ||
const { fieldSets: _, ...uiOptions } = baseUiOptions; | ||
|
||
const fieldSets = getFieldSets(schema, baseUiOptions, value); | ||
|
||
return ( | ||
<React.Fragment> | ||
{fieldSets.map(({ fields, schema, ...rest }, key) => ( | ||
<CollapseField key={key} {...rest}> | ||
<ObjectField {...props} schema={schema} uiOptions={uiOptions} /> | ||
</CollapseField> | ||
))} | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default FieldSets; |
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
129 changes: 0 additions & 129 deletions
129
Composer/packages/adaptive-form/src/components/fields/RecognizerField.tsx
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
Composer/packages/adaptive-form/src/components/fields/RecognizerField/RecognizerField.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,55 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
/** @jsx jsx */ | ||
import { jsx } from '@emotion/core'; | ||
import React, { useMemo } from 'react'; | ||
import { FieldProps, useShellApi, useRecognizerConfig } from '@bfc/extension-client'; | ||
import { MicrosoftIRecognizer } from '@bfc/shared'; | ||
import { Dropdown, ResponsiveMode, IDropdownOption } from 'office-ui-fabric-react/lib/Dropdown'; | ||
import formatMessage from 'format-message'; | ||
|
||
import { FieldLabel } from '../../FieldLabel'; | ||
|
||
import { useMigrationEffect } from './useMigrationEffect'; | ||
import { mapDropdownOptionToRecognizerSchema } from './mappers'; | ||
import { getDropdownOptions } from './getDropdownOptions'; | ||
|
||
export const RecognizerField: React.FC<FieldProps<MicrosoftIRecognizer>> = (props) => { | ||
const { value, id, label, description, uiOptions, required, onChange } = props; | ||
const { shellApi, ...shellData } = useShellApi(); | ||
|
||
useMigrationEffect(value, onChange); | ||
const { recognizers: recognizerConfigs, currentRecognizer } = useRecognizerConfig(); | ||
const dropdownOptions = useMemo(() => getDropdownOptions(recognizerConfigs), [recognizerConfigs]); | ||
|
||
const RecognizerEditor = currentRecognizer?.recognizerEditor; | ||
const widget = RecognizerEditor ? <RecognizerEditor {...props} /> : null; | ||
|
||
const submit = (_, option?: IDropdownOption): void => { | ||
if (!option) return; | ||
|
||
const recognizerDefinition = mapDropdownOptionToRecognizerSchema(option, recognizerConfigs); | ||
|
||
const seedNewRecognizer = recognizerDefinition?.seedNewRecognizer; | ||
const recognizerInstance = | ||
typeof seedNewRecognizer === 'function' | ||
? seedNewRecognizer(shellData, shellApi) | ||
: { $kind: option.key as string, intents: [] }; // fallback to default Recognizer instance; | ||
onChange(recognizerInstance); | ||
}; | ||
|
||
return ( | ||
<React.Fragment> | ||
<FieldLabel description={description} helpLink={uiOptions?.helpLink} id={id} label={label} required={required} /> | ||
<Dropdown | ||
data-testid="recognizerTypeDropdown" | ||
label={formatMessage('Recognizer Type')} | ||
options={dropdownOptions} | ||
responsiveMode={ResponsiveMode.large} | ||
selectedKey={currentRecognizer?.id} | ||
onChange={submit} | ||
/> | ||
{widget} | ||
</React.Fragment> | ||
); | ||
}; |
11 changes: 11 additions & 0 deletions
11
...er/packages/adaptive-form/src/components/fields/RecognizerField/defaultRecognizerOrder.ts
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,11 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { SDKKinds } from '@bfc/shared'; | ||
|
||
export const defaultRecognizerOrder = [SDKKinds.CrossTrainedRecognizerSet, SDKKinds.RegexRecognizer]; | ||
|
||
export const recognizerOrderMap: { [$kind: string]: number } = defaultRecognizerOrder.reduce((result, $kind, index) => { | ||
result[$kind] = index; | ||
return result; | ||
}, {}); |
26 changes: 26 additions & 0 deletions
26
Composer/packages/adaptive-form/src/components/fields/RecognizerField/getDropdownOptions.ts
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,26 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { RecognizerSchema, FallbackRecognizerKey } from '@bfc/extension-client'; | ||
|
||
import { recognizerOrderMap } from './defaultRecognizerOrder'; | ||
import { mapRecognizerSchemaToDropdownOption } from './mappers'; | ||
|
||
const getRankScore = (r: RecognizerSchema) => { | ||
// Always put disabled recognizer behind. Handle 'disabled' before 'default'. | ||
if (r.disabled) return Number.MAX_VALUE; | ||
// Always put default recognzier ahead. | ||
if (r.default) return -1; | ||
// Put fallback recognizer behind. | ||
if (r.id === FallbackRecognizerKey) return Number.MAX_VALUE - 1; | ||
return recognizerOrderMap[r.id] ?? Number.MAX_VALUE - 1; | ||
}; | ||
|
||
export const getDropdownOptions = (recognizerConfigs: RecognizerSchema[]) => { | ||
return recognizerConfigs | ||
.filter((r) => !r.disabled) | ||
.sort((r1, r2) => { | ||
return getRankScore(r1) - getRankScore(r2); | ||
}) | ||
.map(mapRecognizerSchemaToDropdownOption); | ||
}; |
Oops, something went wrong.