Skip to content
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: show multi-skill project with correct link behavior #4466

Merged
merged 98 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
7595021
Update en-US.json
beyackle Oct 5, 2020
78c3f7a
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 9, 2020
e0576b5
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 12, 2020
e6c088d
bring in stuff from the draft branch
beyackle Oct 13, 2020
49d7ce0
make deletion work
beyackle Oct 13, 2020
73b657e
Merge branch 'main' into beyackle/botProjectTreeOnly
beyackle Oct 13, 2020
9fa39e9
add error/warning icons
beyackle Oct 13, 2020
28c4baf
Merge branch 'main' into beyackle/botProjectTreeOnly
beyackle Oct 14, 2020
e49078c
Merge branch 'beyackle/botProjectTreeOnly' of https://github.com/micr…
beyackle Oct 14, 2020
bdb21db
Merge branch 'main' into beyackle/botProjectTreeOnly
beyackle Oct 14, 2020
28fcadf
read notification map for state
beyackle Oct 14, 2020
ca31c22
Merge branch 'beyackle/botProjectTreeOnly' of https://github.com/micr…
beyackle Oct 14, 2020
34d6415
fix type-checking and start on unit tests
beyackle Oct 14, 2020
9cee86c
add sampleDialog and fix more tests
beyackle Oct 14, 2020
ea7ced6
add showAll
beyackle Oct 15, 2020
7a4fa20
rename to onAllSelected because it's a callback
beyackle Oct 15, 2020
69ddaa3
update unit tests
beyackle Oct 15, 2020
fa557ef
Merge branch 'main' into beyackle/botProjectTreeOnly
beyackle Oct 15, 2020
ebf8450
fix onSelect handling in ProjectTree
beyackle Oct 15, 2020
ad66423
Update qna.test.tsx
beyackle Oct 15, 2020
48ab9bf
Merge branch 'main' into beyackle/botProjectTreeOnly
beyackle Oct 15, 2020
76bee68
Update design.test.tsx
beyackle Oct 15, 2020
b877aca
add unit test
beyackle Oct 15, 2020
762b2b5
Merge branch 'main' into beyackle/botProjectTreeOnly
beyackle Oct 16, 2020
463870a
Merge branch 'main' into beyackle/botProjectTreeOnly
beyackle Oct 16, 2020
014a094
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 16, 2020
89caba3
Merge branch 'main' into beyackle/botProjectTreeOnly
beyackle Oct 19, 2020
a02da9b
fixes from PR comments
beyackle Oct 19, 2020
0a20716
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 19, 2020
d00c42d
Merge branch 'main' into beyackle/botProjectTreeOnly
beyackle Oct 19, 2020
90c92d0
Merge branch 'main' into beyackle/botProjectTreeOnly
cwhitten Oct 20, 2020
83c126d
restore multibots to tree
beyackle Oct 20, 2020
e498a2f
fix links from project tree
beyackle Oct 21, 2020
bf75528
fix wrong IDs in URL
beyackle Oct 21, 2020
a601063
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 21, 2020
74addaf
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 21, 2020
ec31343
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 22, 2020
bd88b7a
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 22, 2020
97266a1
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 22, 2020
b32dfff
yarn.lock rebuild
beyackle Oct 22, 2020
19d196c
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 22, 2020
916a74b
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 22, 2020
0407f62
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 22, 2020
bb61b65
update yarn.lock files
beyackle Oct 22, 2020
72ce95b
fix action card links
beyackle Oct 22, 2020
46237dd
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 23, 2020
4272be6
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 23, 2020
0d13f78
Update DesignPage.tsx
beyackle Oct 23, 2020
03cc029
fix unit test
beyackle Oct 23, 2020
4fa9ccd
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 23, 2020
b3943f3
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 23, 2020
d593043
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 26, 2020
5ba58f2
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 26, 2020
f705b59
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 26, 2020
faaa7ca
add unit test to ExpandableNode
beyackle Oct 26, 2020
bed80ec
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 26, 2020
709b2d0
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 26, 2020
deabda9
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 26, 2020
399479c
update ProjectTree unit tests
beyackle Oct 26, 2020
1d3ab78
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 26, 2020
398988f
Update ExpandableNode.tsx
beyackle Oct 27, 2020
76be81b
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 27, 2020
61f7290
Merge branch 'beyackle/botProjectWithSkills' of https://github.com/mi…
beyackle Oct 27, 2020
48a77e5
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 27, 2020
1afebb7
add rootProjectId to triggerApi
beyackle Oct 27, 2020
f7ee2c6
fix creation and deletion bugs
beyackle Oct 27, 2020
1b7ede9
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 27, 2020
360e98b
change mocks folder name
beyackle Oct 27, 2020
3406a93
Load design page only after skill project is loaded
Oct 27, 2020
8f35732
fixes from CR
beyackle Oct 27, 2020
e3fa82b
fix more tests
beyackle Oct 28, 2020
17ad0c5
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 28, 2020
720dcc4
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 28, 2020
e7b9c75
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 28, 2020
3d32857
fix more unit tests
beyackle Oct 28, 2020
fb0b597
Merge branch 'beyackle/botProjectWithSkills' of https://github.com/mi…
beyackle Oct 28, 2020
3c106df
fix test typol
beyackle Oct 28, 2020
d1d530a
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 28, 2020
7b5338d
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 28, 2020
7b4c93b
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 28, 2020
8c3bcc3
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 28, 2020
33c3cc5
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
beyackle Oct 29, 2020
f429e6d
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 29, 2020
d8aa80b
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 29, 2020
5662dcf
handle clicks on bots as bot/id/skill/id
beyackle Oct 29, 2020
3219bad
Merge branch 'beyackle/botProjectWithSkills' of https://github.com/mi…
beyackle Oct 29, 2020
ead752b
always go to dialog on click (not to a trigger in it)
beyackle Oct 29, 2020
90a0a3f
fix unit tests
beyackle Oct 29, 2020
da75a72
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 29, 2020
a5bd2ee
fix link highlight for dialogs
beyackle Oct 29, 2020
1affb13
attempt to fix breadcrumbs (will finish in separate PR)
beyackle Oct 29, 2020
f24f34f
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 29, 2020
3989f1e
fixes from CR
beyackle Oct 29, 2020
0dcc8e1
Update ProjectTree.tsx
beyackle Oct 29, 2020
502fe70
Update ProjectTree.tsx
beyackle Oct 29, 2020
e178197
Update ProjectTree.tsx
beyackle Oct 30, 2020
70119c1
fix unit tests to add correct multibot Recoil stuff
beyackle Oct 30, 2020
58242b3
Merge branch 'main' into beyackle/botProjectWithSkills
beyackle Oct 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation.
beyackle marked this conversation as resolved.
Show resolved Hide resolved
// Licensed under the MIT License.

import React from 'react';
import { render, fireEvent } from '@botframework-composer/test-utils';

import { ExpandableNode } from '../../src/components/ProjectTree/ExpandableNode';

function isShown(details: HTMLElement) {
if (details == null) return false;
return details.attributes.getNamedItem('open') != null;
}

describe('<ExpandableNode />', () => {
let component;
beforeEach(() => {
component = render(<ExpandableNode summary={'Summary'}>{'details'}</ExpandableNode>);
});

it('closes and opens on click', async () => {
const triangle = await component.findByTestId('summaryTag');
let details = await component.findAllByText('details');
expect(isShown(details[0])).toEqual(true);

fireEvent.click(triangle);
details = await component.findAllByText('details');
expect(isShown(details[0])).toEqual(false);

fireEvent.click(triangle);
details = await component.findAllByText('details');
expect(isShown(details[0])).toEqual(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { fireEvent } from '@botframework-composer/test-utils';

import { ProjectTree } from '../../src/components/ProjectTree/ProjectTree';
import { renderWithRecoil } from '../testUtils';
import { SAMPLE_DIALOG } from '../mocks/sampleDialog';
import { SAMPLE_DIALOG, SAMPLE_DIALOG_2 } from '../mocks/sampleDialog';
import { dialogsSelectorFamily, currentProjectIdState, botProjectIdsState, schemasState } from '../../src/recoilModel';

const projectId = '12345.6789';
const projectId2 = '56789.1234';
const dialogs = [SAMPLE_DIALOG];

const initRecoilState = ({ set }) => {
Expand All @@ -19,6 +20,15 @@ const initRecoilState = ({ set }) => {
set(schemasState(projectId), { sdk: { content: {} } });
};

const initRecoilStateMulti = ({ set }) => {
set(currentProjectIdState, projectId);
set(botProjectIdsState, [projectId, projectId2]);
set(dialogsSelectorFamily(projectId), dialogs);
set(dialogsSelectorFamily(projectId2), [SAMPLE_DIALOG, SAMPLE_DIALOG_2]);
set(schemasState(projectId), { sdk: { content: {} } });
set(schemasState(projectId2), { sdk: { content: {} } });
};

describe('<ProjectTree/>', () => {
it('should render the projecttree', async () => {
const { findByText } = renderWithRecoil(
Expand All @@ -29,6 +39,16 @@ describe('<ProjectTree/>', () => {
await findByText('EchoBot-1');
});

it('should render the projecttree with multiple bots', async () => {
const { findAllByText, findByText } = renderWithRecoil(
<ProjectTree onDeleteDialog={() => {}} onDeleteTrigger={() => {}} onSelect={() => {}} />,
initRecoilStateMulti
);

await findAllByText('EchoBot-1');
await findByText('EchoBot-1b');
});

it('should handle project tree item click', async () => {
const mockFileSelect = jest.fn(() => null);
const component = renderWithRecoil(
Expand Down
54 changes: 54 additions & 0 deletions Composer/packages/client/__tests__/mocks/sampleDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,57 @@ export const SAMPLE_DIALOG = {
],
skills: [],
};

beyackle marked this conversation as resolved.
Show resolved Hide resolved
export const SAMPLE_DIALOG_2 = {
isRoot: false,
displayName: 'EchoBot-1b',
id: 'echobot-1b',
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.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-1b.lg',
$schema:
'https://github.com/microsoft/BotFramework-Composer/stable/Composer/packages/server/schemas/sdk.schema',
id: 'EchoBot-1',
recognizer: 'echobot-1b.lu.qna',
},
diagnostics: [],
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: [],
};
27 changes: 25 additions & 2 deletions Composer/packages/client/__tests__/utils/navigation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ describe('composer url util', () => {
expect(result1).toEqual('?selected=triggers[0]&focused=triggers[0].actions[0]');
});

it('check url', () => {
it('checks a URL without a skill', () => {
const result1 = checkUrl(
`/bot/${projectId}/dialogs/a?selected=triggers[0]&focused=triggers[0].actions[0]#botAsks`,
projectId,
null,
{
dialogId: 'a',
selected: 'triggers[0]',
Expand All @@ -85,7 +86,29 @@ describe('composer url util', () => {
}
);
expect(result1).toEqual(true);
const result2 = checkUrl(`test`, projectId, {
const result2 = checkUrl(`test`, projectId, skillId, {
dialogId: 'a',
selected: 'triggers[0]',
focused: 'triggers[0].actions[0]',
promptTab: PromptTab.BOT_ASKS,
});
expect(result2).toEqual(false);
});

it('checks a URL with a skill', () => {
const result1 = checkUrl(
`/bot/${projectId}/skill/${skillId}/dialogs/a?selected=triggers[0]&focused=triggers[0].actions[0]#botAsks`,
projectId,
skillId,
{
dialogId: 'a',
selected: 'triggers[0]',
focused: 'triggers[0].actions[0]',
promptTab: PromptTab.BOT_ASKS,
}
);
expect(result1).toEqual(true);
const result2 = checkUrl(`test`, projectId, skillId, {
dialogId: 'a',
selected: 'triggers[0]',
focused: 'triggers[0].actions[0]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ const nodeStyle = (depth: number) => css`
margin-left: ${depth * 16}px;
`;

const TRIANGLE_SCALE = 0.6;

const detailsStyle = css`
&:not([open]) > summary::-webkit-details-marker {
transform: scaleX(${TRIANGLE_SCALE});
}

&[open] > summary::-webkit-details-marker {
transform: scaleY(${TRIANGLE_SCALE});
}
`;

export const ExpandableNode = ({ children, summary, detailsRef, depth = 0 }: Props) => {
const [isExpanded, setExpanded] = useState(true);

Expand All @@ -39,9 +51,16 @@ export const ExpandableNode = ({ children, summary, detailsRef, depth = 0 }: Pro

return (
<div css={nodeStyle(depth)} data-testid="dialog">
<details ref={detailsRef} open={isExpanded}>
<details ref={detailsRef} css={detailsStyle} 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
css={summaryStyle}
data-testid={'summaryTag'}
role="button"
tabIndex={0}
onClick={handleClick}
onKeyUp={handleKey}
>
{summary}
</summary>
{children}
Expand Down
Loading