Skip to content

Commit

Permalink
Merge branch 'main' into fix/4616
Browse files Browse the repository at this point in the history
  • Loading branch information
cwhitten committed Nov 4, 2020
2 parents f209ad6 + 41f9bf9 commit dfcc65b
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface ElementMeasurerProps {
export const ElementMeasurer: React.FC<ElementMeasurerProps> = ({ children, style, onResize }) => {
return (
<Measure
bounds
scroll
onResize={({ bounds }) => {
/**
* As a parent node, <Measure /> mounted before children mounted.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { fireEvent } from '@botframework-composer/test-utils';

import { renderWithRecoil } from '../testUtils/renderWithRecoil';
import CreateQnAFromUrlModal from '../../src/components/QnA/CreateQnAFromUrlModal';
import { showCreateQnAFromUrlDialogState, showCreateQnAFromUrlDialogWithScratchState } from '../../src/recoilModel';
import { showCreateQnAFromUrlDialogState } from '../../src/recoilModel';

describe('<CreateQnAFromUrlModal />', () => {
const onDismiss = jest.fn(() => {});
Expand All @@ -24,7 +24,6 @@ describe('<CreateQnAFromUrlModal />', () => {
/>,
({ set }) => {
set(showCreateQnAFromUrlDialogState(projectId), true);
set(showCreateQnAFromUrlDialogWithScratchState(projectId), true);
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

/** @jsx jsx */
import { jsx, css } from '@emotion/core';
import isEmpty from 'lodash/isEmpty';
import { useRecoilValue } from 'recoil';

import { dispatcherState } from '../../recoilModel';
Expand All @@ -22,9 +23,11 @@ const container = css`
// -------------------- NotificationContainer -------------------- //

export const NotificationContainer = () => {
const notifications = useRecoilValue(notificationsSelector);
const notifications = useRecoilValue(notificationsSelector).filter(({ hidden }) => !hidden);
const { deleteNotification, hideNotification } = useRecoilValue(dispatcherState);

if (isEmpty(notifications)) return null;

return (
<div css={container} role="presentation">
{notifications.map((item) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { FocusZone, FocusZoneDirection } from 'office-ui-fabric-react/lib/FocusZ
import cloneDeep from 'lodash/cloneDeep';
import formatMessage from 'format-message';
import { DialogInfo, ITrigger, Diagnostic, DiagnosticSeverity } from '@bfc/shared';
import debounce from 'lodash/debounce';
import throttle from 'lodash/throttle';
import { useRecoilValue } from 'recoil';
import { ISearchBoxStyles } from 'office-ui-fabric-react/lib/SearchBox';
import { extractSchemaProperties, groupTriggersByPropertyReference, NoGroupingTriggerGroupName } from '@bfc/indexers';
Expand Down Expand Up @@ -152,7 +152,7 @@ export const ProjectTree: React.FC<Props> = ({
const [filter, setFilter] = useState('');
const formDialogComposerFeatureEnabled = useFeatureFlag('FORM_DIALOG');
const [selectedLink, setSelectedLink] = useState<Partial<TreeLink> | undefined>(defaultSelected);
const delayedSetFilter = debounce((newValue) => setFilter(newValue), 1000);
const delayedSetFilter = throttle((newValue) => setFilter(newValue), 200);
const addMainDialogRef = useCallback((mainDialog) => onboardingAddCoachMarkRef({ mainDialog }), []);
const projectCollection = useRecoilValue<BotInProject[]>(botProjectSpaceSelector).map((bot) => ({
...bot,
Expand Down Expand Up @@ -305,13 +305,17 @@ export const ProjectTree: React.FC<Props> = ({
isActive={doesLinkMatch(link, selectedLink)}
link={link}
menu={[
{
label: formatMessage('Remove this dialog'),
icon: 'Delete',
onClick: (link) => {
onDeleteDialog(link.dialogId ?? '');
},
},
...(!dialog.isRoot
? [
{
label: formatMessage('Remove this dialog'),
icon: 'Delete',
onClick: (link) => {
onDeleteDialog(link.dialogId ?? '');
},
},
]
: []),
...(showEditSchema
? [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const optionRow = {
export const warningIcon = {
marginLeft: 5,
color: '#BE880A',
fontSize: 5,
fontSize: 8,
};

// -------------------- Validation Helpers -------------------- //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ import { PrimaryButton, DefaultButton } from 'office-ui-fabric-react/lib/Button'
import { Link } from 'office-ui-fabric-react/lib/Link';

import { FieldConfig, useForm } from '../../hooks/useForm';
import {
dispatcherState,
onCreateQnAFromUrlDialogCompleteState,
showCreateQnAFromUrlDialogWithScratchState,
} from '../../recoilModel';
import { dispatcherState, onCreateQnAFromUrlDialogCompleteState } from '../../recoilModel';

import {
knowledgeBaseSourceUrl,
Expand Down Expand Up @@ -67,7 +63,6 @@ export const CreateQnAFromUrlModal: React.FC<CreateQnAFromModalProps> = (props)
const { onDismiss, onSubmit, dialogId, projectId, qnaFiles } = props;
const actions = useRecoilValue(dispatcherState);
const onComplete = useRecoilValue(onCreateQnAFromUrlDialogCompleteState(projectId));
const showWithScratch = useRecoilValue(showCreateQnAFromUrlDialogWithScratchState(projectId));

formConfig.name.validate = validateName(qnaFiles);
const { formData, updateField, hasErrors, formErrors } = useForm(formConfig);
Expand Down Expand Up @@ -123,17 +118,15 @@ export const CreateQnAFromUrlModal: React.FC<CreateQnAFromModalProps> = (props)
</Stack>
</div>
<DialogFooter>
{showWithScratch && (
<DefaultButton
data-testid={'createKnowledgeBaseFromScratch'}
styles={{ root: { float: 'left' } }}
text={formatMessage('Create knowledge base from scratch')}
onClick={() => {
// switch to create from scratch flow, pass onComplete callback.
actions.createQnAFromScratchDialogBegin({ projectId, onComplete: onComplete?.func });
}}
/>
)}
<DefaultButton
data-testid={'createKnowledgeBaseFromScratch'}
styles={{ root: { float: 'left' } }}
text={formatMessage('Create knowledge base from scratch')}
onClick={() => {
// switch to create from scratch flow, pass onComplete callback.
actions.createQnAFromScratchDialogBegin({ projectId, onComplete: onComplete?.func });
}}
/>
<DefaultButton
text={formatMessage('Cancel')}
onClick={() => {
Expand Down
3 changes: 1 addition & 2 deletions Composer/packages/client/src/pages/design/DesignPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ const DesignPage: React.FC<RouteComponentProps<{ dialogId: string; projectId: st
const showDisableBtn = selectedActions.some((x) => get(x, 'disabled') !== true);
const showEnableBtn = selectedActions.some((x) => get(x, 'disabled') === true);
return { actionSelected, showDisableBtn, showEnableBtn };
}, [visualEditorSelection]);
}, [visualEditorSelection, currentDialog?.content]);

const { onFocusFlowEditor, onBlurFlowEditor } = useElectronFeatures(actionSelected, canUndo?.(), canRedo?.());

Expand Down Expand Up @@ -329,7 +329,6 @@ const DesignPage: React.FC<RouteComponentProps<{ dialogId: string; projectId: st
onClick: () => {
createQnAFromUrlDialogBegin({
projectId,
showFromScratch: true,
});
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const QnAPage: React.FC<QnAPageProps> = (props) => {
key: 'Create KB from URL or file',
onClick: () => {
setCreateOnDialogId(dialog.id);
actions.createQnAFromUrlDialogBegin({ projectId, showFromScratch: false });
actions.createQnAFromUrlDialogBegin({ projectId });
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ const TableView: React.FC<TableViewProps> = (props) => {
data-testid={'createKnowledgeBase'}
text={formatMessage('Create new KB')}
onClick={() => {
actions.createQnAFromUrlDialogBegin({ projectId, showFromScratch: true });
actions.createQnAFromUrlDialogBegin({ projectId });
}}
/>
</div>
Expand Down
5 changes: 0 additions & 5 deletions Composer/packages/client/src/recoilModel/atoms/botState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,6 @@ export const showCreateQnAFromUrlDialogState = atomFamily<boolean, string>({
default: false,
});

export const showCreateQnAFromUrlDialogWithScratchState = atomFamily<boolean, string>({
key: getFullyQualifiedKey('showCreateQnAFromUrlDialogWithScratch'),
default: false,
});

export const showCreateQnAFromScratchDialogState = atomFamily<boolean, string>({
key: getFullyQualifiedKey('showCreateQnAFromScratchDialog'),
default: false,
Expand Down
8 changes: 0 additions & 8 deletions Composer/packages/client/src/recoilModel/dispatchers/qna.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
settingsState,
showCreateQnAFromScratchDialogState,
showCreateQnAFromUrlDialogState,
showCreateQnAFromUrlDialogWithScratchState,
onCreateQnAFromScratchDialogCompleteState,
onCreateQnAFromUrlDialogCompleteState,
} from '../atoms/botState';
Expand Down Expand Up @@ -203,18 +202,11 @@ export const qnaDispatcher = () => {
({ set }: CallbackInterface) => async ({
onComplete,
projectId,
showFromScratch,
}: {
onComplete?: () => void;
showFromScratch: boolean;
projectId: string;
}) => {
set(showCreateQnAFromUrlDialogState(projectId), true);
if (showFromScratch) {
set(showCreateQnAFromUrlDialogWithScratchState(projectId), true);
} else {
set(showCreateQnAFromUrlDialogWithScratchState(projectId), false);
}
set(onCreateQnAFromUrlDialogCompleteState(projectId), { func: onComplete });
}
);
Expand Down
16 changes: 13 additions & 3 deletions Composer/packages/server/src/controllers/formDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,19 @@ const deleteDialog = async (req: Request, res: Response) => {

const currentProject = await BotProjectService.getProjectById(projectId, user);
if (currentProject !== undefined) {
await currentProject.deleteFormDialog(dialogId);
const updatedProject = await BotProjectService.getProjectById(projectId, user);
res.status(200).json({ id: projectId, ...updatedProject.getProject() });
try {
const rootDialogId = currentProject.rootDialogId;
if (rootDialogId === dialogId) {
throw new Error('root dialog is not allowed to delete');
}
await currentProject.deleteFormDialog(dialogId);
const updatedProject = await BotProjectService.getProjectById(projectId, user);
res.status(200).json({ id: projectId, ...updatedProject.getProject() });
} catch (e) {
res.status(400).json({
message: e.message,
});
}
} else {
res.status(404).json({
message: `Could not delete form dialog. Project ${projectId} not found.`,
Expand Down
1 change: 1 addition & 0 deletions Composer/packages/server/src/models/bot/botProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export class BotProject implements IBotProject {
skills: this.skills,
diagnostics: this.diagnostics,
settings: this.settings,
filesWithoutRecognizers: Array.from(this.files.values()).filter(({ name }) => !isRecognizer(name)),
};
};

Expand Down
2 changes: 1 addition & 1 deletion extensions/azurePublish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@bfc/indexers": "../../Composer/packages/lib/indexers",
"@bfc/shared": "../../Composer/packages/lib/shared",
"@botframework-composer/types": "0.0.1",
"@microsoft/bf-lu": "^4.11.0-rc.20201030.a9f9b96",
"@microsoft/bf-lu": "4.11.0-dev.20201005.7e5e1b8",
"@microsoft/bf-luis-cli": "^4.10.0-dev.20200721.8bb21ac",
"@types/archiver": "3.1.0",
"@types/fs-extra": "8.1.0",
Expand Down
2 changes: 1 addition & 1 deletion extensions/azurePublish/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default async (composer: ExtensionRegistration): Promise<void> => {
*/
private init = async (project: any, srcTemplate: string, resourcekey: string, runtime: any) => {
// point to the declarative assets (possibly in remote storage)
const botFiles = project.getProject().files;
const botFiles = project.getProject().filesWithoutRecognizers;
const botFolder = this.getBotFolder(resourcekey, this.mode);
const runtimeFolder = this.getRuntimeFolder(resourcekey);

Expand Down
22 changes: 22 additions & 0 deletions extensions/azurePublish/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,28 @@
semver "^5.5.1"
tslib "^1.10.0"

"@microsoft/bf-lu@4.11.0-dev.20201005.7e5e1b8":
version "4.11.0-dev.20201005.7e5e1b8"
resolved "https://botbuilder.myget.org/F/botbuilder-v4-js-daily/npm/@microsoft/bf-lu/-/@microsoft/bf-lu-4.11.0-dev.20201005.7e5e1b8.tgz#62f9a37bb8340456e41853e179f2941dab9dfc87"
integrity sha1-Yvmje7g0BFbkGFPhefKUHaud/Ic=
dependencies:
"@azure/cognitiveservices-luis-authoring" "4.0.0-preview.1"
"@azure/ms-rest-azure-js" "2.0.1"
"@types/node-fetch" "~2.5.5"
antlr4 "^4.7.2"
chalk "2.4.1"
console-stream "^0.1.1"
deep-equal "^1.0.1"
delay "^4.3.0"
fs-extra "^8.1.0"
get-stdin "^6.0.0"
globby "^10.0.1"
intercept-stdout "^0.1.2"
lodash "^4.17.19"
node-fetch "~2.6.0"
semver "^5.5.1"
tslib "^1.10.0"

"@microsoft/bf-lu@^4.11.0-rc.20201030.a9f9b96":
version "4.11.0-rc.20201030.a9f9b96"
resolved "https://botbuilder.myget.org/F/botbuilder-v4-js-daily/npm/@microsoft/bf-lu/-/@microsoft/bf-lu-4.11.0-rc.20201030.a9f9b96.tgz#9fcb2a18d66bcef74eabc98f06df4574215c402f"
Expand Down

0 comments on commit dfcc65b

Please sign in to comment.