-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: implement new ProjectTree design with popout menus #4361
Changes from 24 commits
7595021
78c3f7a
e0576b5
e6c088d
49d7ce0
73b657e
9fa39e9
28c4baf
e49078c
bdb21db
28fcadf
ca31c22
34d6415
9cee86c
ea7ced6
7a4fa20
69ddaa3
fa557ef
ebf8450
ad66423
48ab9bf
76bee68
b877aca
762b2b5
463870a
014a094
89caba3
a02da9b
0a20716
d00c42d
90c92d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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: [], | ||
}; |
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: JSX.Element; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: React.ReactNode instead of JSX There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
summary: JSX.Element; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: React.ReactNode instead of JSX |
||
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 [isOpen, setOpen] = useState(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: isExpanded There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see that it makes that much difference, but okay. |
||
|
||
function handleClick(ev: MouseEvent) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't the event type: React.MouseEvent<HTMLElement, MouseEvent> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not according to TypeScript. That's a standard HTML tag, and following the chain of type declarations that VSCode gives me leads to this line in the TS lib:
|
||
if ((ev.target as Element)?.tagName.toLowerCase() === 'summary') { | ||
setOpen(!isOpen); | ||
} | ||
ev.preventDefault(); | ||
} | ||
|
||
function handleKey(ev: KeyboardEvent) { | ||
if (ev.key === 'Enter' || ev.key === 'Space') setOpen(!isOpen); | ||
beyackle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return ( | ||
<div css={nodeStyle(depth)} data-testid="dialog"> | ||
<details ref={detailsRef} open={isOpen}> | ||
{/* 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> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Maybe move this file inside __mocks folder rather than directly inside testUtils
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea.