-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: migrate SendActivity, BeginDialog, ReplaceDialog to uischema (#…
…1840) * render fallback node * fix the problem in a more schema-driven way * revert unnecessary changes * extend builtin props: id, data, onEvent * migrate widget ActionCard to new base props * retire DefaultRenderer * make ActivityRenderer a widget * make 'icon' customizable * update sdk demp * register 'SendActivity' in uischema * drive ReplaceDialog, BeginDialog * fix lint * render BeginDialog, ReplaceDialog with UISchemaRenderer * leverage fabric <Link /> as dialog ref
- Loading branch information
1 parent
a255210
commit a8c348e
Showing
10 changed files
with
153 additions
and
166 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
3 changes: 0 additions & 3 deletions
3
Composer/packages/extensions/visual-designer/src/components/nodes/index.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
35 changes: 0 additions & 35 deletions
35
Composer/packages/extensions/visual-designer/src/components/nodes/steps/ActivityRenderer.tsx
This file was deleted.
Oops, something went wrong.
55 changes: 0 additions & 55 deletions
55
Composer/packages/extensions/visual-designer/src/components/nodes/steps/BeginDialog.tsx
This file was deleted.
Oops, something went wrong.
58 changes: 0 additions & 58 deletions
58
Composer/packages/extensions/visual-designer/src/components/nodes/steps/ReplaceDialog.tsx
This file was deleted.
Oops, something went wrong.
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
57 changes: 57 additions & 0 deletions
57
Composer/packages/extensions/visual-designer/src/widgets/ActivityRenderer.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,57 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import React from 'react'; | ||
import { generateSDKTitle } from '@bfc/shared'; | ||
import get from 'lodash/get'; | ||
|
||
import { NodeEventTypes } from '../constants/NodeEventTypes'; | ||
import { ElementIcon } from '../utils/obiPropertyResolver'; | ||
import { NodeMenu } from '../components/menus/NodeMenu'; | ||
import { FormCard } from '../components/nodes/templates/FormCard'; | ||
import { useLgTemplate } from '../utils/hooks'; | ||
import { WidgetContainerProps } from '../schema/uischema.types'; | ||
import { ObiColors } from '../constants/ElementColors'; | ||
|
||
export interface ActivityRenderer extends WidgetContainerProps { | ||
/** indicates which field contains lg activity. ('activity', 'prompt', 'invalidPropmt'...) */ | ||
field: string; | ||
icon: ElementIcon; | ||
colors?: { | ||
theme: string; | ||
icon: string; | ||
}; | ||
} | ||
|
||
const DefaultThemeColor = { | ||
theme: ObiColors.BlueMagenta20, | ||
icon: ObiColors.BlueMagenta30, | ||
}; | ||
|
||
export const ActivityRenderer: React.FC<ActivityRenderer> = ({ | ||
id, | ||
data, | ||
onEvent, | ||
field, | ||
icon = ElementIcon.MessageBot, | ||
colors = DefaultThemeColor, | ||
}) => { | ||
const designerId = get(data, '$designer.id'); | ||
const activityTemplate = get(data, field, ''); | ||
|
||
const templateText = useLgTemplate(activityTemplate, designerId); | ||
const nodeColors = { themeColor: colors.theme, iconColor: colors.icon }; | ||
|
||
return ( | ||
<FormCard | ||
header={generateSDKTitle(data)} | ||
label={templateText} | ||
icon={icon} | ||
corner={<NodeMenu id={id} onEvent={onEvent} />} | ||
nodeColors={nodeColors} | ||
onClick={() => { | ||
onEvent(NodeEventTypes.Focus, { id }); | ||
}} | ||
/> | ||
); | ||
}; |
60 changes: 60 additions & 0 deletions
60
Composer/packages/extensions/visual-designer/src/widgets/DialogRefCard.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,60 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
/** @jsx jsx */ | ||
import { jsx } from '@emotion/core'; | ||
import { generateSDKTitle } from '@bfc/shared'; | ||
import get from 'lodash/get'; | ||
import { Link } from 'office-ui-fabric-react/lib/Link'; | ||
|
||
import { FormCard } from '../components/nodes/templates/FormCard'; | ||
import { WidgetContainerProps, WidgetComponent } from '../schema/uischema.types'; | ||
import { ObiColors } from '../constants/ElementColors'; | ||
import { NodeEventTypes } from '../constants/NodeEventTypes'; | ||
import { NodeMenu } from '../components/menus/NodeMenu'; | ||
|
||
export interface DialogRefCardProps extends WidgetContainerProps { | ||
dialog: string | object; | ||
getRefContent?: (dialogRef: JSX.Element) => JSX.Element; | ||
colors?: { | ||
theme: string; | ||
icon: string; | ||
}; | ||
} | ||
|
||
const DefaultCardColor = { | ||
theme: ObiColors.AzureGray3, | ||
icon: ObiColors.AzureGray2, | ||
}; | ||
|
||
export const DialogRefCard: WidgetComponent<DialogRefCardProps> = ({ | ||
id, | ||
data, | ||
onEvent, | ||
dialog, | ||
getRefContent, | ||
colors = DefaultCardColor, | ||
}) => { | ||
const header = generateSDKTitle(data); | ||
const nodeColors = { themeColor: colors.theme, iconColor: colors.icon }; | ||
const calleeDialog = typeof dialog === 'object' ? get(dialog, '$ref') : dialog; | ||
const dialogRef = ( | ||
<Link | ||
onClick={e => { | ||
e.stopPropagation(); | ||
onEvent(NodeEventTypes.OpenDialog, { caller: id, callee: calleeDialog }); | ||
}} | ||
> | ||
{calleeDialog} | ||
</Link> | ||
); | ||
return ( | ||
<FormCard | ||
header={header} | ||
corner={<NodeMenu id={id} onEvent={onEvent} />} | ||
label={typeof getRefContent === 'function' ? getRefContent(dialogRef) : dialogRef} | ||
nodeColors={nodeColors} | ||
onClick={() => onEvent(NodeEventTypes.Focus, { id })} | ||
/> | ||
); | ||
}; |