From 3c8d3de8af287479305fe500278adac943b2b5b8 Mon Sep 17 00:00:00 2001 From: Long Jun Date: Mon, 16 Dec 2019 18:05:40 +0800 Subject: [PATCH 1/2] update ui for new schema --- .../obiformeditor/demo/src/editorschema.json | 6 + .../src/Form/fields/PromptField/UserInput.tsx | 3 +- .../obiformeditor/src/schema/uischema.ts | 20 +-- Composer/packages/lib/shared/src/appschema.ts | 139 +++++++++++++++++- Composer/packages/lib/shared/src/labelMap.ts | 6 + .../packages/lib/shared/src/types/schema.ts | 2 + Composer/packages/lib/shared/src/viewUtils.ts | 9 +- .../packages/server/schemas/editor.schema | 10 ++ 8 files changed, 175 insertions(+), 20 deletions(-) diff --git a/Composer/packages/extensions/obiformeditor/demo/src/editorschema.json b/Composer/packages/extensions/obiformeditor/demo/src/editorschema.json index 73819db9c2..da056af4f1 100644 --- a/Composer/packages/extensions/obiformeditor/demo/src/editorschema.json +++ b/Composer/packages/extensions/obiformeditor/demo/src/editorschema.json @@ -36,6 +36,9 @@ "Microsoft.DeleteProperty": { "title": "Delete a Property" }, + "Microsoft.DeleteProperties": { + "title": "Delete Properties" + }, "Microsoft.EditArray": { "title": "Edit an Array Property" }, @@ -128,6 +131,9 @@ "Microsoft.SetProperty": { "title": "Set a Property" }, + "Microsoft.setProperties": { + "title": "Set Properties" + }, "Microsoft.SwitchCondition": { "title": "Branch: Switch" }, diff --git a/Composer/packages/extensions/obiformeditor/src/Form/fields/PromptField/UserInput.tsx b/Composer/packages/extensions/obiformeditor/src/Form/fields/PromptField/UserInput.tsx index 2f6e01d125..44aac5ef1f 100644 --- a/Composer/packages/extensions/obiformeditor/src/Form/fields/PromptField/UserInput.tsx +++ b/Composer/packages/extensions/obiformeditor/src/Form/fields/PromptField/UserInput.tsx @@ -47,7 +47,7 @@ export const UserInput: React.FC = props => { {getSchema('outputFormat') && (
- = props => { label={formatMessage('Output Format')} formContext={props.formContext} rawErrors={errorSchema.outputFormat && errorSchema.outputFormat.__errors} - options={{ enumOptions: getOptions(getSchema('outputFormat')) }} />
)} diff --git a/Composer/packages/extensions/obiformeditor/src/schema/uischema.ts b/Composer/packages/extensions/obiformeditor/src/schema/uischema.ts index d3825e4fd1..58b9b3ae36 100644 --- a/Composer/packages/extensions/obiformeditor/src/schema/uischema.ts +++ b/Composer/packages/extensions/obiformeditor/src/schema/uischema.ts @@ -56,7 +56,7 @@ export const uiSchema: { [key in SDKTypes]?: UiSchema } = { options: { 'ui:field': 'CustomObjectField', }, - 'ui:order': ['dialog', 'property', '*'], + 'ui:order': ['dialog', 'options', 'resultProperty', 'includeActivity', '*'], }, [SDKTypes.CancelAllDialogs]: { eventValue: { @@ -78,11 +78,6 @@ export const uiSchema: { [key in SDKTypes]?: UiSchema } = { 'ui:field': 'StepsField', }, }, - [SDKTypes.EmitEvent]: { - eventValue: { - 'ui:field': 'CustomObjectField', - }, - }, [SDKTypes.Foreach]: { 'ui:order': ['itemsProperty', 'actions', '*'], 'ui:hidden': ['actions'], @@ -103,6 +98,9 @@ export const uiSchema: { [key in SDKTypes]?: UiSchema } = { [SDKTypes.IfCondition]: { 'ui:hidden': ['actions', 'elseActions', ...globalHidden], }, + [SDKTypes.SetProperties]: { + 'ui:hidden': [...globalHidden], + }, [SDKTypes.OnActivity]: { ...triggerUiSchema, }, @@ -176,9 +174,6 @@ export const uiSchema: { [key in SDKTypes]?: UiSchema } = { }, 'ui:order': ['connectionName', '*'], }, - [SDKTypes.QnAMakerDialog]: { - 'ui:hidden': ['strictFilters'], - }, [SDKTypes.ReplaceDialog]: { dialog: { 'ui:widget': 'DialogSelectWidget', @@ -187,6 +182,13 @@ export const uiSchema: { [key in SDKTypes]?: UiSchema } = { 'ui:field': 'CustomObjectField', }, 'ui:hidden': [...globalHidden], + 'ui:order': ['dialog', 'options', 'includeActivity', '*'], + }, + [SDKTypes.RepeatDialog]: { + options: { + 'ui:field': 'CustomObjectField', + }, + 'ui:order': ['options', 'includeActivity', '*'], }, [SDKTypes.SwitchCondition]: { cases: { diff --git a/Composer/packages/lib/shared/src/appschema.ts b/Composer/packages/lib/shared/src/appschema.ts index cca5ccfc88..acd6bff589 100644 --- a/Composer/packages/lib/shared/src/appschema.ts +++ b/Composer/packages/lib/shared/src/appschema.ts @@ -258,6 +258,13 @@ export const appschema: OBISchema = { description: 'One or more options that are passed to the dialog that is called.', additionalProperties: true, }, + includeActivity: { + type: 'boolean', + title: 'Include Activity', + description: 'When set to true, dialog that is called can process the current activity.', + default: 'false', + examples: ['false'], + }, resultProperty: { $role: 'expression', title: 'Property', @@ -610,6 +617,12 @@ export const appschema: OBISchema = { default: 'true', examples: ['true'], }, + outputFormat: { + $role: 'expression', + type: 'string', + title: 'Output format', + description: 'confirm output format.', + }, defaultLocale: { type: 'string', title: 'Default Locale', @@ -806,6 +819,12 @@ export const appschema: OBISchema = { default: 'true', examples: ['true'], }, + outputFormat: { + $role: 'expression', + type: 'string', + title: 'Output format', + description: 'Date time output format.', + }, defaultLocale: { type: 'string', title: 'Default locale', @@ -838,6 +857,26 @@ export const appschema: OBISchema = { }, }, }, + 'Microsoft.DeleteProperties': { + $role: 'unionType(Microsoft.IDialog)', + title: 'Delete Properties', + description: 'Delete multiple properties and any value it holds.', + type: 'object', + properties: { + ...$properties(SDKTypes.SetProperties), + properties: { + type: 'array', + title: 'Properties', + description: 'Properties to delete.', + items: { + $role: 'expression', + title: 'Property', + description: 'Property to delete.', + type: 'string', + }, + }, + }, + }, 'Microsoft.DimensionEntityRecognizer': { $role: 'unionType(Microsoft.EntityRecognizers)', title: 'Dimension Entity Recognizer', @@ -949,10 +988,10 @@ export const appschema: OBISchema = { // ], }, eventValue: { - type: 'object', + $role: 'expression', + type: 'string', title: 'Event value', description: 'Value to emit with the event (optional).', - additionalProperties: true, }, bubbleEvent: { type: 'boolean', @@ -1291,6 +1330,16 @@ export const appschema: OBISchema = { description: 'Delete a property and any value it holds.', $ref: '#/definitions/Microsoft.DeleteProperty', }, + { + title: 'Microsoft.DeleteProperty', + description: 'Delete a property and any value it holds.', + $ref: '#/definitions/Microsoft.DeleteProperty', + }, + { + title: 'Microsoft.DeleteProperties', + description: 'Delete multiple properties and any value it holds.', + $ref: '#/definitions/Microsoft.DeleteProperties', + }, { title: 'Microsoft.EditActions', description: 'Edit the current list of actions.', @@ -1382,6 +1431,11 @@ export const appschema: OBISchema = { description: 'Set property to a value.', $ref: '#/definitions/Microsoft.SetProperty', }, + { + title: 'Microsoft.SetProperties', + description: 'Set one or more property values.', + $ref: '#/definitions/Microsoft.SetProperties', + }, { title: 'Microsoft.SwitchCondition', description: 'Execute different actions based on the value of a property.', @@ -1865,11 +1919,10 @@ export const appschema: OBISchema = { examples: ['true'], }, outputFormat: { + $role: 'expression', type: 'string', - enum: ['float', 'integer'], title: 'Output format', description: 'Number output format.', - default: 'float', }, defaultLocale: { type: 'string', @@ -2543,12 +2596,30 @@ export const appschema: OBISchema = { }, strictFilters: { type: 'array', - title: 'Strict Filter Property', - description: 'Memory property that holds strict filters to use when calling the QnA Maker KB.', + title: 'Strict Filters', + description: 'Metadata filters to use when calling the QnA Maker KB.', items: { type: 'object', + properties: { + name: { + type: 'string', + title: 'Name', + maximum: 100, + }, + value: { + type: 'string', + title: 'Value', + maximum: 100, + }, + }, }, }, + top: { + type: 'number', + title: 'Top', + description: 'The number of answers you want to retrieve.', + default: 3, + }, }, }, 'Microsoft.RandomSelector': { @@ -2627,6 +2698,19 @@ export const appschema: OBISchema = { description: 'Repeat current dialog.', properties: { ...$properties(SDKTypes.RepeatDialog), + options: { + type: 'object', + title: 'Options', + description: 'One or more options that are passed to the dialog that is called.', + additionalProperties: true, + }, + includeActivity: { + type: 'boolean', + title: 'Include Activity', + description: 'When set to true, dialog that is called can process the current activity.', + default: 'false', + examples: ['false'], + }, }, }, 'Microsoft.ReplaceDialog': { @@ -2648,6 +2732,13 @@ export const appschema: OBISchema = { description: 'One or more options that are passed to the dialog that is called.', additionalProperties: true, }, + includeActivity: { + type: 'boolean', + title: 'Include Activity', + description: 'When set to true, dialog that is called can process the current activity.', + default: 'false', + examples: ['false'], + }, }, }, 'Microsoft.SendActivity': { @@ -2688,6 +2779,39 @@ export const appschema: OBISchema = { }, }, }, + 'Microsoft.SetProperties': { + $role: 'unionType(Microsoft.IDialog)', + title: 'Set properties', + description: 'Set one or more property values.', + type: 'object', + properties: { + ...$properties(SDKTypes.SetProperties), + assignments: { + type: 'array', + title: 'Assignments', + description: 'Property value assignments to set.', + items: { + type: 'object', + properties: { + property: { + $role: 'expression', + title: 'Property', + description: 'Property (named location to store information).', + examples: ['user.age'], + type: 'string', + }, + value: { + $role: 'expression', + title: 'Value', + description: 'New value or expression.', + examples: ['"milk"', 'dialog.favColor', 'dialog.favColor == "red"'], + type: 'string', + }, + }, + }, + }, + }, + }, 'Microsoft.StaticActivityTemplate': { $role: 'unionType(Microsoft.IActivityTemplate)', title: 'Microsoft Static Activity Template', @@ -2864,11 +2988,10 @@ export const appschema: OBISchema = { examples: ['true'], }, outputFormat: { + $role: 'expression', type: 'string', - enum: ['none', 'trim', 'lowercase', 'uppercase'], title: 'Output format', description: 'Format of output.', - default: 'none', }, }, }, diff --git a/Composer/packages/lib/shared/src/labelMap.ts b/Composer/packages/lib/shared/src/labelMap.ts index d57c715f97..48712512cd 100644 --- a/Composer/packages/lib/shared/src/labelMap.ts +++ b/Composer/packages/lib/shared/src/labelMap.ts @@ -58,6 +58,9 @@ export const ConceptLabels: { [key in ConceptLabelKey]?: LabelOverride } = { [SDKTypes.DeleteProperty]: { title: formatMessage('Delete a property'), }, + [SDKTypes.DeleteProperties]: { + title: formatMessage('Delete properties'), + }, [SDKTypes.EditActions]: { title: formatMessage('Modify this dialog'), }, @@ -221,6 +224,9 @@ export const ConceptLabels: { [key in ConceptLabelKey]?: LabelOverride } = { [SDKTypes.SetProperty]: { title: formatMessage('Set a property'), }, + [SDKTypes.SetProperties]: { + title: formatMessage('Set properties'), + }, [SDKTypes.SwitchCondition]: { title: formatMessage('Branch: switch (multiple options)'), }, diff --git a/Composer/packages/lib/shared/src/types/schema.ts b/Composer/packages/lib/shared/src/types/schema.ts index 6398d5e2d7..37221d09c8 100644 --- a/Composer/packages/lib/shared/src/types/schema.ts +++ b/Composer/packages/lib/shared/src/types/schema.ts @@ -34,6 +34,7 @@ export enum SDKTypes { DateTimeInput = 'Microsoft.DateTimeInput', DebugBreak = 'Microsoft.DebugBreak', DeleteProperty = 'Microsoft.DeleteProperty', + DeleteProperties = 'Microsoft.DeleteProperties', DimensionEntityRecognizer = 'Microsoft.DimensionEntityRecognizer', EditActions = 'Microsoft.EditActions', EditArray = 'Microsoft.EditArray', @@ -91,6 +92,7 @@ export enum SDKTypes { ReplaceDialog = 'Microsoft.ReplaceDialog', SendActivity = 'Microsoft.SendActivity', SetProperty = 'Microsoft.SetProperty', + SetProperties = 'Microsoft.SetProperties', StaticActivityTemplate = 'Microsoft.StaticActivityTemplate', SwitchCondition = 'Microsoft.SwitchCondition', TemperatureEntityRecognizer = 'Microsoft.TemperatureEntityRecognizer', diff --git a/Composer/packages/lib/shared/src/viewUtils.ts b/Composer/packages/lib/shared/src/viewUtils.ts index 5a59ce4c15..402ae904b7 100644 --- a/Composer/packages/lib/shared/src/viewUtils.ts +++ b/Composer/packages/lib/shared/src/viewUtils.ts @@ -65,7 +65,14 @@ export const dialogGroups: DialogGroupsMap = { }, [DialogGroup.MEMORY]: { label: 'Manage properties', - types: [SDKTypes.SetProperty, SDKTypes.InitProperty, SDKTypes.DeleteProperty, SDKTypes.EditArray], + types: [ + SDKTypes.SetProperty, + SDKTypes.SetProperties, + SDKTypes.InitProperty, + SDKTypes.DeleteProperty, + SDKTypes.DeleteProperties, + SDKTypes.EditArray, + ], }, [DialogGroup.STEP]: { label: 'Dialog management', diff --git a/Composer/packages/server/schemas/editor.schema b/Composer/packages/server/schemas/editor.schema index cd539e9cf5..73fe98a25a 100644 --- a/Composer/packages/server/schemas/editor.schema +++ b/Composer/packages/server/schemas/editor.schema @@ -64,6 +64,11 @@ "helpLink": "https://aka.ms/bfc-using-memory", "helpLinkText": "Learn more" }, + "Microsoft.DeleteProperties": { + "title": "Delete Properties", + "helpLink": "https://aka.ms/bfc-using-memory", + "helpLinkText": "Learn more" + }, "Microsoft.EditActions": { "title": "Modify active dialog" }, @@ -264,6 +269,11 @@ "helpLink": "https://aka.ms/bfc-using-memory", "helpLinkText": "Learn more" }, + "Microsoft.SetProperties": { + "title": "Delete Properties", + "helpLink": "https://aka.ms/bfc-using-memory", + "helpLinkText": "Learn more" + }, "Microsoft.SwitchCondition": { "title": "Branch: Switch", "helpLink": "https://aka.ms/bfc-controlling-conversation-flow", From 18c1e5bb8de666ed8492f53b23cad1cb312193d4 Mon Sep 17 00:00:00 2001 From: Long Alan Date: Tue, 17 Dec 2019 11:57:24 +0800 Subject: [PATCH 2/2] Fixed includeActivity default value wrong type & use original component replace customObjectArrayField --- .../obiformeditor/src/schema/uischema.ts | 50 ++++++++++++++++++- Composer/packages/lib/shared/src/appschema.ts | 12 ++--- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/Composer/packages/extensions/obiformeditor/src/schema/uischema.ts b/Composer/packages/extensions/obiformeditor/src/schema/uischema.ts index 58b9b3ae36..c4150ed868 100644 --- a/Composer/packages/extensions/obiformeditor/src/schema/uischema.ts +++ b/Composer/packages/extensions/obiformeditor/src/schema/uischema.ts @@ -99,7 +99,29 @@ export const uiSchema: { [key in SDKTypes]?: UiSchema } = { 'ui:hidden': ['actions', 'elseActions', ...globalHidden], }, [SDKTypes.SetProperties]: { - 'ui:hidden': [...globalHidden], + assignments: { + 'ui:options': { + object: true, + }, + items: { + 'ui:options': { + hideDescription: true, + inline: true, + }, + property: { + 'ui:options': { + hideLabel: true, + transparentBorder: true, + }, + }, + value: { + 'ui:options': { + hideLabel: true, + transparentBorder: true, + }, + }, + }, + }, }, [SDKTypes.OnActivity]: { ...triggerUiSchema, @@ -174,6 +196,31 @@ export const uiSchema: { [key in SDKTypes]?: UiSchema } = { }, 'ui:order': ['connectionName', '*'], }, + [SDKTypes.QnAMakerDialog]: { + strictFilters: { + 'ui:options': { + object: true, + }, + items: { + 'ui:options': { + hideDescription: true, + inline: true, + }, + name: { + 'ui:options': { + hideLabel: true, + transparentBorder: true, + }, + }, + value: { + 'ui:options': { + hideLabel: true, + transparentBorder: true, + }, + }, + }, + }, + }, [SDKTypes.ReplaceDialog]: { dialog: { 'ui:widget': 'DialogSelectWidget', @@ -188,6 +235,7 @@ export const uiSchema: { [key in SDKTypes]?: UiSchema } = { options: { 'ui:field': 'CustomObjectField', }, + 'ui:hidden': [...globalHidden], 'ui:order': ['options', 'includeActivity', '*'], }, [SDKTypes.SwitchCondition]: { diff --git a/Composer/packages/lib/shared/src/appschema.ts b/Composer/packages/lib/shared/src/appschema.ts index acd6bff589..10637cd6ea 100644 --- a/Composer/packages/lib/shared/src/appschema.ts +++ b/Composer/packages/lib/shared/src/appschema.ts @@ -262,8 +262,8 @@ export const appschema: OBISchema = { type: 'boolean', title: 'Include Activity', description: 'When set to true, dialog that is called can process the current activity.', - default: 'false', - examples: ['false'], + default: false, + examples: [false], }, resultProperty: { $role: 'expression', @@ -2708,8 +2708,8 @@ export const appschema: OBISchema = { type: 'boolean', title: 'Include Activity', description: 'When set to true, dialog that is called can process the current activity.', - default: 'false', - examples: ['false'], + default: false, + examples: [false], }, }, }, @@ -2736,8 +2736,8 @@ export const appschema: OBISchema = { type: 'boolean', title: 'Include Activity', description: 'When set to true, dialog that is called can process the current activity.', - default: 'false', - examples: ['false'], + default: false, + examples: [false], }, }, },