forked from microsoft/BotFramework-Composer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: implement new ProjectTree design with popout menus (microsof…
…t#4361) * Update en-US.json * bring in stuff from the draft branch * make deletion work * add error/warning icons * read notification map for state * fix type-checking and start on unit tests * add sampleDialog and fix more tests * add showAll * rename to onAllSelected because it's a callback * update unit tests * fix onSelect handling in ProjectTree * Update qna.test.tsx * Update design.test.tsx * add unit test * fixes from PR comments Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
- Loading branch information
Showing
23 changed files
with
753 additions
and
270 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
// This is a copy of the JSON that defines the EchoBot sample plus some | ||
// additional dialogs and triggers, including a trigger with a syntax | ||
// error for use with testing error messages. | ||
|
||
export const SAMPLE_DIALOG = { | ||
isRoot: true, | ||
displayName: 'EchoBot-1', | ||
id: 'echobot-1', | ||
content: { | ||
$kind: 'Microsoft.AdaptiveDialog', | ||
$designer: { id: '433224', description: '', name: 'EchoBot-1' }, | ||
autoEndDialog: true, | ||
defaultResultProperty: 'dialog.result', | ||
triggers: [ | ||
{ | ||
$kind: 'Microsoft.OnUnknownIntent', | ||
$designer: { id: '821845' }, | ||
actions: [ | ||
{ $kind: 'Microsoft.SendActivity', $designer: { id: '003038' }, activity: '${SendActivity_003038()}' }, | ||
], | ||
}, | ||
{ | ||
$kind: 'Microsoft.OnConversationUpdateActivity', | ||
$designer: { id: '376720' }, | ||
actions: [ | ||
{ | ||
$kind: 'Microsoft.Foreach', | ||
$designer: { id: '518944', name: 'Loop: for each item' }, | ||
itemsProperty: 'turn.Activity.membersAdded', | ||
actions: [ | ||
{ | ||
$kind: 'Microsoft.IfCondition', | ||
$designer: { id: '641773', name: 'Branch: if/else' }, | ||
condition: 'string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)', | ||
actions: [ | ||
{ | ||
$kind: 'Microsoft.SendActivity', | ||
$designer: { id: '859266', name: 'Send a response' }, | ||
activity: '${SendActivity_Welcome()}', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ $kind: 'Microsoft.OnError', $designer: { id: 'XVSGCI' } }, | ||
{ | ||
$kind: 'Microsoft.OnIntent', | ||
$designer: { id: 'QIgTMy', name: 'more errors' }, | ||
intent: 'test', | ||
actions: [{ $kind: 'Microsoft.SetProperty', $designer: { id: 'VyWC7G' }, value: '=[' }], | ||
}, | ||
], | ||
generator: 'echobot-1.lg', | ||
$schema: | ||
'https://raw.githubusercontent.com/microsoft/BotFramework-Composer/stable/Composer/packages/server/schemas/sdk.schema', | ||
id: 'EchoBot-1', | ||
recognizer: 'echobot-1.lu.qna', | ||
}, | ||
diagnostics: [ | ||
{ | ||
message: | ||
"must be an expression: syntax error at line 1:1 mismatched input '<EOF>' expecting {STRING_INTERPOLATION_START, '+', '-', '!', '(', '[', ']', '{', NUMBER, IDENTIFIER, STRING}", | ||
source: 'echobot-1', | ||
severity: 0, | ||
path: 'echobot-1.triggers[3].actions[0]#Microsoft.SetProperty#value', | ||
}, | ||
], | ||
referredDialogs: [], | ||
lgTemplates: [ | ||
{ name: 'SendActivity_003038', path: 'echobot-1.triggers[0].actions[0]' }, | ||
{ name: 'SendActivity_Welcome', path: 'echobot-1.triggers[1].actions[0].actions[0].actions[0]' }, | ||
], | ||
referredLuIntents: [{ name: 'test', path: 'echobot-1.triggers[3]#Microsoft.OnIntent' }], | ||
luFile: 'echobot-1', | ||
qnaFile: 'echobot-1', | ||
lgFile: 'echobot-1', | ||
triggers: [ | ||
{ id: 'triggers[0]', displayName: '', type: 'Microsoft.OnUnknownIntent', isIntent: false }, | ||
{ id: 'triggers[1]', displayName: '', type: 'Microsoft.OnConversationUpdateActivity', isIntent: false }, | ||
{ id: 'triggers[2]', displayName: '', type: 'Microsoft.OnError', isIntent: false }, | ||
{ id: 'triggers[3]', displayName: 'more errors', type: 'Microsoft.OnIntent', isIntent: true }, | ||
], | ||
intentTriggers: [ | ||
{ intent: 'test', dialogs: [] }, | ||
{ intent: 'test', dialogs: [] }, | ||
], | ||
skills: [], | ||
}; |
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
51 changes: 51 additions & 0 deletions
51
Composer/packages/client/src/components/ProjectTree/ExpandableNode.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,51 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
/** @jsx jsx */ | ||
import { jsx, css } from '@emotion/core'; | ||
import { useState, MouseEvent, KeyboardEvent } from 'react'; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
summary: React.ReactNode; | ||
depth?: number; | ||
detailsRef?: (el: HTMLElement | null) => void; | ||
}; | ||
|
||
const summaryStyle = css` | ||
label: summary; | ||
display: flex; | ||
padding-left: 12px; | ||
padding-top: 6px; | ||
`; | ||
|
||
const nodeStyle = (depth: number) => css` | ||
margin-left: ${depth * 16}px; | ||
`; | ||
|
||
export const ExpandableNode = ({ children, summary, detailsRef, depth = 0 }: Props) => { | ||
const [isExpanded, setExpanded] = useState(true); | ||
|
||
function handleClick(ev: MouseEvent) { | ||
if ((ev.target as Element)?.tagName.toLowerCase() === 'summary') { | ||
setExpanded(!isExpanded); | ||
} | ||
ev.preventDefault(); | ||
} | ||
|
||
function handleKey(ev: KeyboardEvent) { | ||
if (ev.key === 'Enter' || ev.key === 'Space') setExpanded(!isExpanded); | ||
} | ||
|
||
return ( | ||
<div css={nodeStyle(depth)} data-testid="dialog"> | ||
<details ref={detailsRef} open={isExpanded}> | ||
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/no-noninteractive-tabindex */} | ||
<summary css={summaryStyle} role="button" tabIndex={0} onClick={handleClick} onKeyUp={handleKey}> | ||
{summary} | ||
</summary> | ||
{children} | ||
</details> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.