Skip to content

Commit

Permalink
Merge branch 'master' into qika/deployupdate2
Browse files Browse the repository at this point in the history
  • Loading branch information
luhan2017 authored Mar 6, 2020
2 parents 7e1c7b0 + 964b8d6 commit 3bd704b
Show file tree
Hide file tree
Showing 34 changed files with 492 additions and 352 deletions.
7 changes: 2 additions & 5 deletions Composer/cypress/integration/LUPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ context('LU Page', () => {
cy.contains('ToDoBotWithLuisSample.Main');
cy.contains('All');

cy.get('.toggleEditMode button').as('switchButton');

// all multiple file, edit mode button is disabled.
cy.get('@switchButton').should('be.disabled');
cy.get('.toggleEditMode button').should('not.exist');

// by default is table view
cy.findByTestId('LUEditor')
Expand All @@ -28,7 +25,7 @@ context('LU Page', () => {
cy.findByTestId('LUEditor').within(() => {
cy.findByText('__TestToDoBotWithLuisSample.Main').click();
});

cy.get('.toggleEditMode button').as('switchButton');
// goto edit-mode
cy.get('@switchButton').click();
cy.findByTestId('LUEditor')
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@bfc/extensions": "*",
"@bfc/indexers": "*",
"@bfc/shared": "*",
"@bfcomposer/bf-lu": "^1.2.5",
"@bfcomposer/bf-lu": "^1.2.9",
"@emotion/core": "^10.0.7",
"@reach/router": "^1.2.1",
"axios": "^0.18.0",
Expand Down
21 changes: 11 additions & 10 deletions Composer/packages/client/src/pages/language-understanding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,17 @@ const LUPage: React.FC<LUPageProps> = props => {
<div css={ContentHeaderStyle}>
<div css={HeaderText}>{formatMessage('User Input')}</div>
<div css={flexContent}>
<Toggle
className={'toggleEditMode'}
css={actionButton}
onText={formatMessage('Edit mode')}
offText={formatMessage('Edit mode')}
defaultChecked={false}
checked={!!edit}
disabled={isRoot && edit === false}
onChange={onToggleEditMode}
/>
{(!isRoot || edit) && (
<Toggle
className={'toggleEditMode'}
css={actionButton}
onText={formatMessage('Edit mode')}
offText={formatMessage('Edit mode')}
defaultChecked={false}
checked={!!edit}
onChange={onToggleEditMode}
/>
)}
</div>
</div>
<div css={ContentStyle} data-testid="LUEditor">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FieldProps } from '@bfcomposer/react-jsonschema-form';
import formatMessage from 'format-message';
import { JSONSchema6 } from 'json-schema';
import { SDKTypes, MicrosoftInputDialog, ChoiceInput, ConfirmInput } from '@bfc/shared';
import { DialogInfo } from '@bfc/indexers/lib/type';

import { TextWidget, SelectWidget } from '../../widgets';
import { LuEditorWidget } from '../../widgets/LuEditorWidget';
Expand All @@ -16,7 +17,6 @@ import { field } from './styles';
import { GetSchema, PromptFieldChangeHandler } from './types';
import { ChoiceInputSettings } from './ChoiceInput';
import { ConfirmInputSettings } from './ConfirmInput';
import { DialogInfo } from '@bfc/indexers/lib/type';

const getOptions = (enumSchema: JSONSchema6) => {
if (!enumSchema || !enumSchema.enum || !Array.isArray(enumSchema.enum)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { LuFile, filterSectionDiagnostics } from '@bfc/indexers';
import { LuIntentSection } from '@bfc/shared';

import { FormContext } from '../types';

import { WidgetLabel } from './WidgetLabel';

interface LuEditorWidgetProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,14 @@ export const drawSVGEdge = (
const [p1, p2] = calculateArrowPoints(endPoint, direction);
const points = [p1, endPoint, p2].map(p => `${p.x},${p.y}`).join(' ');
const arrow = (
<polyline key={`edge-${id}__arrow`} points={points} {...strokeProps} fill="none" strokeDasharray="none" />
<polyline
key={`edge-${id}__arrow`}
name={id}
points={points}
{...strokeProps}
fill="none"
strokeDasharray="none"
/>
);
elements.push(arrow);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const declareElementAttributes = (id: string) => {
[AttrNames.SelectedId]: `${id}${MenuTypes.NodeMenu}`,
};
};
export const NodeMenu = ({ id, onEvent }): JSX.Element => {
export const NodeMenu = ({ id, onEvent }) => {
const menuItems = [
{
key: 'delete',
Expand All @@ -35,6 +35,7 @@ export const NodeMenu = ({ id, onEvent }): JSX.Element => {

return (
<div
data-name="nodeMenu"
css={{
marginRight: '1px',
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
titleStyle,
subtitleStyle,
triggerIconStyle,
titleContentStyle,
} from './triggerStyles';

function getLabel(data: any): string {
Expand All @@ -39,9 +40,11 @@ export const Trigger = ({ data, onClick = () => {} }): JSX.Element => {
<div css={triggerContentStyle}>
<div css={titleStyle}>
<Icon iconName="Flow" style={triggerIconStyle} />
<span>{name}</span>
<h4 css={titleContentStyle}>{name}</h4>
</div>
<div css={subtitleStyle} className="trigger__content-label">
{label}
</div>
<div css={subtitleStyle}>{label}</div>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ export const titleStyle: any = {
fontSize: '18px',
lineHeight: '24px',
fontWeight: 600,
display: 'flex',
};

export const titleContentStyle = {
fontWeight: 600,
margin: '0px',
};
export const subtitleStyle: any = {
whiteSpace: 'nowrap',
color: ObiColors.LightGray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const ObiEditor: FC<ObiEditorProps> = ({
}): JSX.Element | null => {
let divRef;

const { focusedId, focusedEvent, clipboardActions, copyLgTemplate, removeLgTemplates } = useContext(
const { focusedId, focusedEvent, clipboardActions, copyLgTemplate, removeLgTemplates, removeLuIntent } = useContext(
NodeRendererContext
);

Expand All @@ -59,6 +59,10 @@ export const ObiEditor: FC<ObiEditorProps> = ({
return removeLgTemplates(lgFileId, normalizedLgTemplates);
};

const deleteLuIntents = (luIntents: string[]) => {
return Promise.all(luIntents.map(intent => removeLuIntent(path, intent)));
};

const dispatchEvent = (eventName: NodeEventTypes, eventData: any): any => {
let handler;
switch (eventName) {
Expand All @@ -80,7 +84,7 @@ export const ObiEditor: FC<ObiEditorProps> = ({
break;
case NodeEventTypes.Delete:
handler = e => {
onChange(deleteNode(data, e.id, node => deleteAction(node, deleteLgTemplates)));
onChange(deleteNode(data, e.id, node => deleteAction(node, deleteLgTemplates, deleteLuIntents)));
onFocusSteps([]);
};
break;
Expand Down Expand Up @@ -138,7 +142,9 @@ export const ObiEditor: FC<ObiEditorProps> = ({
break;
case NodeEventTypes.DeleteSelection:
handler = e => {
const dialog = deleteNodes(data, e.actionIds, nodes => deleteActions(nodes, deleteLgTemplates));
const dialog = deleteNodes(data, e.actionIds, nodes =>
deleteActions(nodes, deleteLgTemplates, deleteLuIntents)
);
onChange(dialog);
onFocusSteps([]);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const StepEditor = ({ id, data, onEvent, trigger, addCoachMarkRef }): JSX
{ directed: true }
)}
<circle
name="editor__end"
r={TerminatorSize.height / 2 - 1}
cx={editorAxisX}
cy={contentBoundary.height + HeadSize.height + ElementInterval.y / 2 + TerminatorSize.height / 2}
Expand Down
2 changes: 2 additions & 0 deletions Composer/packages/extensions/visual-designer/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const VisualDesigner: React.FC<VisualDesignerProps> = ({
copyLgTemplate,
removeLgTemplate,
removeLgTemplates,
removeLuIntent,
undo,
redo,
} = shellApi;
Expand All @@ -78,6 +79,7 @@ const VisualDesigner: React.FC<VisualDesignerProps> = ({
copyLgTemplate,
removeLgTemplate,
removeLgTemplates,
removeLuIntent,
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ type ShellApiFuncs =
| 'copyLgTemplate'
| 'removeLgTemplate'
| 'removeLgTemplates'
| 'updateLgTemplate';
| 'updateLgTemplate'
| 'removeLuIntent';

interface NodeRendererContextValue extends Pick<ShellApi, ShellApiFuncs> {
focusedId?: string;
Expand All @@ -28,4 +29,5 @@ export const NodeRendererContext = React.createContext<NodeRendererContextValue>
removeLgTemplate: () => Promise.resolve(),
removeLgTemplates: () => Promise.resolve(),
updateLgTemplate: () => Promise.resolve(),
removeLuIntent: () => Promise.resolve(),
});
2 changes: 1 addition & 1 deletion Composer/packages/lib/indexers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@bfc/shared": "*",
"@bfcomposer/bf-lu": "^1.2.5",
"@bfcomposer/bf-lu": "^1.2.9",
"botbuilder-lg": "^4.8.0-preview.106823",
"botframework-expressions": "^4.8.0-preview.106476",
"lodash": "^4.17.15"
Expand Down
9 changes: 5 additions & 4 deletions Composer/packages/lib/indexers/src/dialogIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { JsonWalk, VisitorFunc } from './utils/jsonWalk';
import { getBaseName } from './utils/help';
import { Diagnostic } from './diagnostic';
import ExtractMemoryPaths from './dialogUtils/extractMemoryPaths';

import ExtractIntentTriggers from './dialogUtils/extractIntentTriggers';
// find out all lg templates given dialog
function ExtractLgTemplates(id, dialog): LgTemplateJsonPath[] {
const templates: LgTemplateJsonPath[] = [];
Expand Down Expand Up @@ -95,7 +95,7 @@ function ExtractLuIntents(dialog, id: string): ReferredLuIntents[] {

// find out all triggers given dialog
function ExtractTriggers(dialog): ITrigger[] {
const trigers: ITrigger[] = [];
const triggers: ITrigger[] = [];
/** *
* @param path , jsonPath string
* @param value , current node value *
Expand All @@ -118,15 +118,15 @@ function ExtractTriggers(dialog): ITrigger[] {
} else if (trigger.isIntent && has(rule, 'intent')) {
trigger.displayName = rule.intent;
}
trigers.push(trigger);
triggers.push(trigger);
}
});
return true;
}
return false;
};
JsonWalk('$', dialog, visitor);
return trigers;
return triggers;
}

// find out all referred dialog
Expand Down Expand Up @@ -204,6 +204,7 @@ function parse(id: string, content: any, schema: any) {
luFile: getBaseName(luFile, '.lu'),
lgFile: getBaseName(lgFile, '.lg'),
triggers: ExtractTriggers(content),
intentTriggers: ExtractIntentTriggers(content),
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { SDKTypes } from '@bfc/shared';

import { VisitorFunc, JsonWalk } from '../utils/jsonWalk';

import { IIntentTrigger } from './types';

// find out all properties from given dialog
function ExtractIntentTriggers(value: any): IIntentTrigger[] {
const triggers: IIntentTrigger[] = [];

const visitor: VisitorFunc = (path: string, value: any): boolean => {
if (value?.$type === SDKTypes.OnIntent) {
if (value.intent) {
const dialogs: string[] = [];

const visitor: VisitorFunc = (path: string, value: any): boolean => {
if (value?.$type === SDKTypes.BeginDialog) {
if (value.dialog) {
dialogs.push(value.dialog);
}
return true;
}
return false;
};
JsonWalk('$', value, visitor);
if (dialogs.length) {
triggers.push({
intent: value.intent,
dialogs,
});
}
}
return true;
}
return false;
};
JsonWalk('$', value, visitor);

return triggers;
}

export default ExtractIntentTriggers;
5 changes: 5 additions & 0 deletions Composer/packages/lib/indexers/src/dialogUtils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ export interface IExpressionProperties {
};
}

export interface IIntentTrigger {
intent: string;
dialogs: string[];
}

export type CheckerFunc = (path: string, value: any, type: string, schema: any) => Diagnostic[] | null; // error msg
2 changes: 1 addition & 1 deletion Composer/packages/lib/indexers/src/luIndexer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { sectionHandler } from '@bfcomposer/bf-lu/lib/parser';
import { sectionHandler } from '@bfcomposer/bf-lu/lib/parser/composerindex';
import get from 'lodash/get';
import { LuIntentSection } from '@bfc/shared';

Expand Down
2 changes: 2 additions & 0 deletions Composer/packages/lib/indexers/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { LuIntentSection } from '@bfc/shared';

import { Diagnostic } from './diagnostic';
import { IIntentTrigger } from './dialogUtils/types';

export interface FileInfo {
name: string;
Expand Down Expand Up @@ -38,6 +39,7 @@ export interface DialogInfo {
relativePath: string;
userDefinedVariables: string[];
triggers: ITrigger[];
intentTriggers: IIntentTrigger[];
}

export interface LgTemplateJsonPath {
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/lib/indexers/src/types/bf-lu.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

declare module '@bfcomposer/bf-lu/lib/parser' {
declare module '@bfcomposer/bf-lu/lib/parser/composerindex' {
namespace parser {
function parseFile(fileContent: any, log: any, locale: any): any;
function validateLUISBlob(LUISJSONBlob: any): any;
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/lib/indexers/src/utils/luUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* for more usage detail, please check client/__tests__/utils/luUtil.test.ts
*/

import { sectionHandler } from '@bfcomposer/bf-lu/lib/parser';
import { sectionHandler } from '@bfcomposer/bf-lu/lib/parser/composerindex';
import isEmpty from 'lodash/isEmpty';
import { LuIntentSection } from '@bfc/shared';

Expand Down
7 changes: 3 additions & 4 deletions Composer/packages/lib/shared/src/appschema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,11 @@ export const appschema: OBISchema = {
additionalProperties: true,
},
activityProcessed: {
$role: 'expression',
type: 'string',
type: 'boolean',
title: 'Activity Processed',
description: 'When set to false, the dialog that is called can process the current activity.',
default: 'true',
examples: ['true'],
default: true,
examples: [true],
},
resultProperty: {
$role: 'expression',
Expand Down
Loading

0 comments on commit 3bd704b

Please sign in to comment.