Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Conversation

@yeze322
Copy link
Contributor

@yeze322 yeze322 commented Aug 19, 2020

Description

closes #2955

Convert Flow Editor's schema to pure JSON format. (builtinSchema.ts)

Tasks

  • Integrate with adaptive-expressions
  • convert flow schema from TSX to pure JSON format
  • inject Flow Actions schema from uischema

Following tasks on other repos

  • Update the JSON schema of uischema.
  • Move 'flow' uischema from 'ui-plugins/composer' to SDK component schema.

Schema Preview
IfCondition
image

[SDKKinds.IfCondition]: {
  widget: 'IfConditionWidget',
  nowrap: true,
  judgement: {
    widget: 'ActionCard',
    body: '=coalesce(action.condition, "<condition>")',
  },
}

BeginDialog
image

[SDKKinds.BeginDialog]: {
  widget: 'ActionCard',
  body: {
    widget: 'DialogRef',
    dialog: '=action.dialog',
  },
  footer: {
    widget: 'PropertyDescription',
    property: '=action.resultProperty',
    description: '= Return value',
  },
  hideFooter: '=!action.resultProperty',
}

SetProperties
image

[SDKKinds.SetProperties]: {
  widget: 'ActionCard',
  body: {
    widget: 'ListOverview',
    items: '=foreach(action.assignments, x => concat(x.property, " : ", x.value))',
  },
}

SetProperty (string interpolation in LG format)
image

[SDKKinds.SetProperty]: {
  widget: 'ActionCard',
  body: '${coalesce(action.property, "?")} : ${coalesce(action.value, "?")}',
},

Task Item

Screenshots

Use sdk.override.uischema to demo the scenario.

  • Original EditArray node:
    image
  • Define the overrided Flow schema in sdk.override.uischema:
{
  "$schema": "https://schemas.botframework.com/schemas/ui/v1.0/ui.schema",
  "Microsoft.EditArray": {
    "flow": {
      "widget": "ActionCard",
      "header": {
        "widget": "ActionHeader",
        "title": "Overrided Edit Array",
        "icon": "Edit",
        "colors": {
          "theme": "#168686",
          "color": "white",
          "icon": "white"
        }
      },
      "body": "=concat('Change Type: ', action.changeType, '\nItems Property: ', action.itemsProperty)",
      "footer": "=string(action.value)",
      "hideFooter": "=!action.resultProperty"
    }
  }
}
  • With the overrided Flow schema, EditArray will look like this:
    image

@coveralls
Copy link

coveralls commented Aug 19, 2020

Coverage Status

Coverage increased (+0.2%) to 55.925% when pulling 589e4d2 on yeze322:visual/flow-schema into b0f2fd8 on microsoft:main.

@yeze322 yeze322 changed the title draft: try to define flow schema of Actions draft: define uischema for Flow Editor actions Aug 20, 2020
@cwhitten
Copy link
Member

@yeze322 as we discussed last night. I agree that we should allow basic data binding into the uischema, however I don't think we shouldn't promote users to inline HTML like that.

Can you come up with a few example expressions that you need to render the widgets currently so we can think on how to model the expressiveness you are looking for?

@yeze322

This comment has been minimized.

@yeze322
Copy link
Contributor Author

yeze322 commented Aug 24, 2020

@cwhitten Chris I updated the description with newest example schema

@yeze322
Copy link
Contributor Author

yeze322 commented Sep 3, 2020

As I tested in both LG/Expression, we have multiple approaches to write a string interpolation

// 1. LG
'Hello ${user.name}.'

// 2. Expression
'=concat("Hello ", user.name)'

// 3. Expression - with string interpolation
'=`Hello ${user.name}`'

A restriction in Expression is that string interpolation needs to be wrapped in ``.

// Can be evaluated by Expression -> Expression class
'`Hello ${user.name}`'

// Can be evaluated by Expression -> ValueExpression class
'=`Hello ${user.name}`'

// Can be evaluated by LG
'Hello ${user.name}'

@a-b-r-o-w-n Which one would you prefer? I have no strong opinions. We can support both but the default Flow uischema as a sample needs to be in a uniform format.

@yeze322 yeze322 requested a review from a-b-r-o-w-n September 8, 2020 02:10
@a-b-r-o-w-n
Copy link
Contributor

@yeze322 I think matching the sdk properties as closely as possible would be best. So to me that looks like we should use the LG parser for string interpolation.

@yeze322
Copy link
Contributor Author

yeze322 commented Sep 9, 2020

@yeze322 I think matching the sdk properties as closely as possible would be best. So to me that looks like we should use the LG parser for string interpolation.

I updated the schema, the Action ‘SetProperty' is an example on how string interpolation be written LG format.

One thing to note is writting string interpolation in LG format can simplify the schema in some case but not all the cases. Expression engine is still required regarding sometimes we want to take the raw value instead of getting a string.

For example, in BeginDialog, dialog field could be a string or a IDialog object. We have to write =action.dialog instead of ${action.dialog} because of the latter one will return a string. This is LG parser's default behavior.

@a-b-r-o-w-n
Copy link
Contributor

That sounds reasonable and is the same as when authoring bots, so hopefully the learning curve will be small.

I think we should consider adding this functionality to the form properties in the ui schema as well.

@a-b-r-o-w-n
Copy link
Contributor

@yeze322 sorry for all the conflicts. I removed the extensions directory 😕

@yeze322
Copy link
Contributor Author

yeze322 commented Sep 17, 2020

@a-b-r-o-w-n that's fine Andy, it's just some import conflicts

@cwhitten cwhitten merged commit 854e9e5 into microsoft:main Sep 28, 2020
@cwhitten cwhitten mentioned this pull request Nov 13, 2020
lei9444 pushed a commit to lei9444/BotFramework-Composer-1 that referenced this pull request Jun 15, 2021
* draft: uischema flow part

* draft: try define flow schema

* lint: blank line at EOF

* schema: add rest actions

* schema: unify the schema of yml files

* schema: migrate schema to LG

* feat: evaluate LG in widgetRenderer

* fix: capture LG eval error

* schema: migrate schema to LG; TODO: migrate to Exp

* feat: mixed evaluation with LG + Exp

* refactor: rename variables

* schema: migrate some actions to pure exp

* fix: wrong result key in BeginDialog

* feat: add 'hideFooter' option to widgets/ActionCard

* feat: new widget 'PropertyDescription'

* schema: migrate to PropertyDescription

* schema: migrate prev change to expression

* schema: migrat 3 kinds to PropertyDescription in exp

* schema: migrate DeleteActivity

* feat: new widget 'ResourceOperation'

* schema: migrate to 'ResourceOperation' widget

* refactor: adjust schema reorder

* fix: more restrict regex for value access

* schema: migrate SetProperty to lg

* refactor: rename ListOverview prop 'itemInterval'

* refactor: optimize ListOverview interface desgin

* schema: migrate SetProps, DelProps to Exp engine

* refactor: suffix builtin config files with '.ts'

* clean: remove yml drafts

* remove debug code

* schema: expand *Input kinds definitions

* refactor: move evaluator to Expression domain

* test: UT for widgetExpEvaluator

* refactor: write inline color value in flow schema

* refactor: hoists Flow widget types to @bfc/extension

* schema: move flow schema to extension pkg

* feat: merge 'flow' part to uischema

* fix: render ActionCard safely

* fix: move looping schema as Flow's builtin schema

* feat: use pure expression way in Flow schema

* fix: handle evaluator corner case

* schema: migrate whole schema to expression format

* typo: space in schema

* fix: respect null undfined value in ActionCard

* refactor: more robust safeRender

* add a comment

* schema: Oauth wording

* fix: escape those constant strings begin with '='

* feat: only evaluate Action with specific key

* schema: update '= Result' usages

* feat: be compatible with string interpolation pattern

* manually fix some '@bfc/extension-client' imports

* fix ForeachPage prop binding

Co-authored-by: Chris Whitten <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Needs review R11 Release 11 - November 15th, 2020

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Customize the appearance of custom action nodes in Visual Editor

5 participants