Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Composer/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
'@typescript-eslint/ban-ts-ignore': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-use-before-define': 'warn',

// eslint rules
Expand Down
9 changes: 8 additions & 1 deletion Composer/packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"lodash.findindex": "^4.6.0",
"lodash.findlastindex": "^4.6.0",
"lodash.get": "^4.4.2",
"lodash.isequal": "^4.5.0",
"lodash.once": "^4.1.1",
"lodash.set": "^4.3.2",
"lodash.startcase": "^4.4.0",
Expand Down Expand Up @@ -94,7 +95,13 @@
"@emotion/babel-preset-css-prop": "^10.0.14",
"@types/jest": "^24.0.16",
"@types/jwt-decode": "^2.2.1",
"@types/lodash.clonedeep": "^4.5.6",
"@types/lodash.find": "^4.6.6",
"@types/lodash.findindex": "^4.6.6",
"@types/lodash.get": "^4.4.6",
"@types/lodash.isequal": "^4.5.5",
"@types/lodash.once": "^4.1.6",
"@types/lodash.set": "^4.3.6",
"@types/reach__router": "^1.2.4",
"@types/react": "16.9.0",
"@types/react-dom": "16.9.0",
Expand All @@ -104,4 +111,4 @@
"jest-dom": "^3.2.2",
"react-testing-library": "^6.0.1"
}
}
}
10 changes: 4 additions & 6 deletions Composer/packages/client/src/CreationFlow/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React, { useState, useEffect, useContext } from 'react';
import { toLower } from 'lodash';

import { CreationFlowStatus } from '../constants';
import { CreationFlowStatus, DialogCreationCopy, Steps } from '../constants';

import { CreateOptions } from './CreateOptions/index';
import { DefineConversation } from './DefineConversation/index';
import { Steps } from './../constants/index';
import { OpenProject } from './OpenProject';
import { StoreContext } from './../store';
import { DialogInfo } from './../constants/index';
import { StepWizard } from './StepWizard/StepWizard';
import { navigateTo } from './../utils/navigation';

Expand Down Expand Up @@ -120,15 +118,15 @@ export function CreationFlow(props) {

const steps = {
[Steps.CREATE]: {
...DialogInfo.CREATE_NEW_BOT,
...DialogCreationCopy.CREATE_NEW_BOT,
children: <CreateOptions templates={templateProjects} onDismiss={handleDismiss} onNext={handleCreateNext} />,
},
[Steps.LOCATION]: {
...DialogInfo.SELECT_LOCATION,
...DialogCreationCopy.SELECT_LOCATION,
children: <OpenProject onOpen={openBot} onDismiss={handleDismiss} />,
},
[Steps.DEFINE]: {
...DialogInfo.DEFINE_CONVERSATION_OBJECTIVE,
...DialogCreationCopy.DEFINE_CONVERSATION_OBJECTIVE,
children: (
<DefineConversation
onSubmit={handleSubmit}
Expand Down
30 changes: 10 additions & 20 deletions Composer/packages/client/src/ShellApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useEffect, useContext, useRef, useMemo, useState } from 'react';
import { debounce, isEqual, get } from 'lodash';
import React, { useEffect, useContext, useMemo, useState } from 'react';
import { ShellData } from 'shared';
import isEqual from 'lodash.isequal';
import get from 'lodash.get';

import { parseLgTemplate, checkLgContent, updateTemplateInContent } from '../src/store/action/lg';

Expand All @@ -10,27 +12,12 @@ import ApiClient from './messenger/ApiClient';
import { getDialogData, setDialogData, sanitizeDialogData } from './utils';
import { OpenAlertModal, DialogStyle } from './components/Modal';
import { getFocusPath, navigateTo } from './utils/navigation';
import { DialogInfo, LgFile, LuFile, BotSchemas } from './store/types';

// this is the api interface provided by shell to extensions this is the single
// place handles all incoming request from extensions, VisualDesigner or
// FormEditor this is where all side effects (like directly calling api of
// extensions) happened

export interface ShellData {
data: any;
dialogs: DialogInfo[];
focusPath: string;
schemas: BotSchemas;
lgFiles: LgFile[];
luFiles: LuFile[];
currentDialog?: DialogInfo;
dialogId: string;
focusedEvent: string;
focusedSteps: string[];
focusedTab?: string;
}

const apiClient = new ApiClient();

const VISUAL_EDITOR = 'VisualEditor';
Expand All @@ -41,8 +28,6 @@ const isEventSourceValid = event => {
return [VISUAL_EDITOR, FORM_EDITOR].includes(sourceWindowName);
};

const useDebouncedFunc = (fn, delay = 750) => useRef(debounce(fn, delay)).current;

const FileChangeTypes = {
CREATE: 'create',
UPDATE: 'update',
Expand Down Expand Up @@ -71,7 +56,7 @@ export const ShellApi: React.FC = () => {
const [, forceUpdate] = useState();

const { state, actions } = useContext(StoreContext);
const { dialogs, schemas, lgFiles, luFiles, designPageLocation, focusPath, breadcrumb } = state;
const { dialogs, schemas, lgFiles, luFiles, designPageLocation, focusPath, breadcrumb, botName } = state;
const updateDialog = actions.updateDialog;
const updateLuFile = actions.updateLuFile; //if debounced, error can't pass to form
const updateLgFile = actions.updateLgFile;
Expand Down Expand Up @@ -169,8 +154,13 @@ export const ShellApi: React.FC = () => {
function getState(sourceWindow?: string): ShellData {
const currentDialog = dialogs.find(d => d.id === dialogId);

if (!currentDialog) {
return {} as ShellData;
}

return {
data: getData(sourceWindow),
botName,
dialogs,
focusPath,
schemas,
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/TestController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Stack,
} from 'office-ui-fabric-react';
import formatMessage from 'format-message';
import { DialogInfo } from 'shared';

import settingsStorage from './utils/dialogSettingStorage';
import { StoreContext } from './store';
Expand All @@ -17,7 +18,6 @@ import { BotStatus, LuisConfig, Text } from './constants';
import { PublishLuisDialog } from './publishDialog';
import { OpenAlertModal, DialogStyle } from './components/Modal';
import { getReferredFiles } from './utils/luUtil';
import { DialogInfo } from './store/types';

const openInEmulator = (url, authSettings: { MicrosoftAppId: string; MicrosoftAppPassword: string }) => {
// this creates a temporary hidden iframe to fire off the bfemulator protocol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import formatMessage from 'format-message';
import { DialogFooter, PrimaryButton, DefaultButton, Stack, IDropdownOption } from 'office-ui-fabric-react';
import { Dropdown } from 'office-ui-fabric-react/lib/Dropdown';
import { get } from 'lodash';
import { DialogInfo } from 'shared';

import {
addNewTrigger,
Expand All @@ -17,7 +18,6 @@ import {
getActivityTypes,
} from '../../utils/dialogUtil';
import { StoreContext } from '../../store';
import { DialogInfo } from '../../store/types';

import { styles, dropdownStyles, dialogWindow } from './styles';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
import React, { useMemo, useRef, useState } from 'react';
import { cloneDeep } from 'lodash';
import formatMessage from 'format-message';
import { DialogInfo, ITrigger } from 'shared';

import { DialogInfo, ITrigger } from '../../store/types';
import { createSelectedPath, getFriendlyName } from '../../utils';

import { addButton, groupListStyle, root, searchBox } from './styles';
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export const Steps = {
NONE: 'NONE',
};

export const DialogInfo = {
export const DialogCreationCopy = {
CREATE_NEW_BOT: {
title: formatMessage('Create from scratch?'),
subText: formatMessage('You can create a new bot from scratch with Designer, or start with a template.'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useState, useEffect } from 'react';
import { initializeIcons } from 'office-ui-fabric-react';
import { LuFile, ShellData } from 'shared';

import ApiClient from '../messenger/ApiClient';
import { ShellData } from '../ShellApi';
import { LuFile } from '../store/types';

import getEditor from './EditorMap';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';

import { DialogInfo } from '../../constants';
import { DialogCreationCopy } from '../../constants';
import { DefineConversation } from '../../CreationFlow/DefineConversation/index';
import { DialogWrapper } from '../../components/DialogWrapper/index';

export default function NewDialogModal(props) {
const { isOpen, onDismiss, onSubmit, onGetErrorMessage } = props;

return (
<DialogWrapper isOpen={isOpen} onDismiss={onDismiss} {...DialogInfo.DEFINE_CONVERSATION_OBJECTIVE}>
<DialogWrapper isOpen={isOpen} onDismiss={onDismiss} {...DialogCreationCopy.DEFINE_CONVERSATION_OBJECTIVE}>
<DefineConversation
onSubmit={onSubmit}
onDismiss={onDismiss}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export default function TableView(props) {
// build usedIn map
templates.forEach(template => {
templateUsedInDialogMap[template.Name] = dialogs.reduce((result, dialog) => {
if (dialog.lgTemplates.indexOf(template.Name) !== -1) {
if (dialog.lgTemplates.includes(template.Name)) {
result.push(dialog.id);
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function TableView(props) {
name,
phrases: [utterance.text],
fileId: luFile.id,
used: luDialog.luIntents.indexOf(name) !== -1, // used by it's dialog or not
used: luDialog.luIntents.includes(name), // used by it's dialog or not
state,
});
}
Expand Down
3 changes: 2 additions & 1 deletion Composer/packages/client/src/store/action/dialog.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import axios from 'axios';
import clonedeep from 'lodash.clonedeep';
import { remove } from 'lodash';
import { DialogInfo } from 'shared';

import { ActionCreator, State, DialogInfo } from '../types';
import { ActionCreator, State } from '../types';
import { undoable, Pick } from '../middlewares/undo';

import { BASEURL, ActionTypes } from './../../constants/index';
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/store/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const initialState: State = {
templateId: '',
storageFileLoadingStatus: 'success',
lgFiles: [],
schemas: {},
schemas: { editor: {} },
luFiles: [],
designPageLocation: {
dialogId: '',
Expand Down
63 changes: 1 addition & 62 deletions Composer/packages/client/src/store/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// TODO: Extract some common types to be shared across packages (e.g. DialogInfo, LgFile, etc)
// TODO: remove this once we can expand the types
/* eslint-disable @typescript-eslint/no-explicit-any */
import React from 'react';
import { PromptTab } from 'shared';
import { PromptTab, DialogInfo, BotSchemas, LgFile, LuFile } from 'shared';

import { CreationFlowStatus, BotStatus } from '../constants';

Expand All @@ -29,12 +28,6 @@ export interface BreadcrumbItem {
focused: string;
}

export interface BotSchemas {
editor?: any;
sdk?: any;
diagnostics?: any[];
}

export interface State {
dialogs: DialogInfo[];
botName: string;
Expand Down Expand Up @@ -84,60 +77,6 @@ export interface MiddlewareApi {

export type MiddlewareFunc = (middlewareApi: MiddlewareApi) => (next: any) => React.Dispatch<ActionType>;

export interface ITrigger {
id: string;
displayName: string;
type: string;
isIntent: boolean;
}

export interface DialogInfo {
id: string;
displayName: string;
isRoot: boolean;
content: any;
diagnostics: string[];
luFile: string;
triggers: ITrigger[];
}

export interface Intent {
name: string;
}

export interface Utterance {
intent: string;
text: string;
}

export interface LuDiagnostic {
text: string;
}

export interface LuFile {
id: string;
relativePath: string;
content: string;
parsedContent: {
LUISJsonStructure: {
intents: Intent[];
utterances: Utterance[];
};
};
diagnostics: LuDiagnostic[];
}

export interface LgFile {
id: string;
relativePath: string;
content: string;
}

export interface LgTemplate {
Name: string;
Body: string;
}

export interface ILuisConfig {
name: string;
authoringKey: string;
Expand Down
3 changes: 1 addition & 2 deletions Composer/packages/client/src/utils/dialogUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { ConceptLabels, DialogGroup, SDKTypes, dialogGroups, seedNewDialog } fro
import { cloneDeep, get, set } from 'lodash';
import { ExpressionEngine } from 'botbuilder-expression-parser';
import { IDropdownOption } from 'office-ui-fabric-react';

import { DialogInfo } from '../store/types';
import { DialogInfo } from 'shared';

import { getFocusPath } from './navigation';
import { upperCaseName } from './fileUtil';
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/utils/luUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LuFile, DialogInfo, LuDiagnostic } from '../store/types';
import { LuFile, DialogInfo, LuDiagnostic } from 'shared';

export function getReferredFiles(luFiles: LuFile[], dialogs: DialogInfo[]) {
return luFiles.filter(file => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { IContextualMenuItem, ContextualMenuItemType, IconButton } from 'office-
import formatMessage from 'format-message';
import { NeutralColors, FontSizes } from '@uifabric/fluent-theme';
import classnames from 'classnames';
import { JSONSchema6 } from 'json-schema';
import { FIELDS_TO_HIDE } from 'shared';
import { FIELDS_TO_HIDE, OBISchema } from 'shared';

import './styles.css';

Expand All @@ -14,7 +13,7 @@ interface ObjectItemProps {
onDropPropertyClick: (name: string) => (e) => void;
onEdit: (e) => void;
onAdd: (e) => void;
schema: JSONSchema6;
schema: OBISchema;
}

export default function ObjectItem(props: ObjectItemProps) {
Expand Down
Loading