Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…mposer into toanzian/update-mac
  • Loading branch information
tonyanziano committed May 12, 2020
2 parents b8a30b1 + ebaec7b commit 540a0c8
Show file tree
Hide file tree
Showing 23 changed files with 2,623 additions and 69 deletions.
2 changes: 1 addition & 1 deletion Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@
"dependencies": {
"cross-env": "^6.0.3"
}
}
}
2 changes: 1 addition & 1 deletion Composer/packages/electron-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@bfc/electron-server",
"license": "MIT",
"author": "Microsoft Corporation",
"version": "0.0.1",
"version": "0.0.2",
"description": "Electron wrapper around Composer that launches Composer as a desktop application.",
"main": "./build/main.js",
"engines": {
Expand Down
6 changes: 5 additions & 1 deletion Composer/packages/lib/code-editor/src/BaseEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const BaseEditor: React.FC<BaseEditorProps> = props => {
placeholder,
hidePlaceholder,
value,
id,
errorMessage,
warningMessage,
diagnostics = [],
Expand All @@ -133,7 +134,10 @@ const BaseEditor: React.FC<BaseEditorProps> = props => {
const [hovered, setHovered] = useState(false);
const [focused, setFocused] = useState(false);
const [editor, setEditor] = useState<any>();
const initialValue = useMemo(() => value || (hidePlaceholder ? '' : placeholder), []);

// initialValue is designed to imporve local performance
// it should be force updated if id change, or previous value is empty.
const initialValue = useMemo(() => value || (hidePlaceholder ? '' : placeholder), [id, !!value]);

const onEditorMount: EditorDidMount = (getValue, editor) => {
setEditor(editor);
Expand Down
7 changes: 7 additions & 0 deletions Composer/packages/lib/code-editor/src/LgEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ export function LgEditor(props: LGLSPEditorProps) {
const { lgOption, languageServer, onInit: onInitProp, ...restProps } = props;
const lgServer = languageServer || defaultLGServer;

let editorId = '';
if (lgOption) {
const { projectId, fileId, templateId } = lgOption;
editorId = [projectId, fileId, templateId].join('/');
}

const onInit: OnInit = monaco => {
registerLGLanguage(monaco);

Expand Down Expand Up @@ -105,6 +111,7 @@ export function LgEditor(props: LGLSPEditorProps) {
<BaseEditor
placeholder={placeholder}
helpURL={LG_HELP}
id={editorId}
{...restProps}
onInit={onInit}
theme="lgtheme"
Expand Down
7 changes: 7 additions & 0 deletions Composer/packages/lib/code-editor/src/LuEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ const LuEditor: React.FC<LULSPEditorProps> = props => {
const { luOption, languageServer, onInit: onInitProp, placeholder = defaultPlaceholder, ...restProps } = props;
const luServer = languageServer || defaultLUServer;

let editorId = '';
if (luOption) {
const { projectId, fileId, sectionId } = luOption;
editorId = [projectId, fileId, sectionId].join('/');
}

const onInit: OnInit = monaco => {
registerLULanguage(monaco);
monacoRef.current = monaco;
Expand Down Expand Up @@ -145,6 +151,7 @@ const LuEditor: React.FC<LULSPEditorProps> = props => {
<BaseEditor
placeholder={placeholder}
helpURL={LU_HELP}
id={editorId}
{...restProps}
onInit={onInit}
theme="lu"
Expand Down
24 changes: 2 additions & 22 deletions Composer/packages/ui-plugins/lg/src/LgField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@

/** @jsx jsx */
import { jsx } from '@emotion/core';
import React, { useCallback, useState, useRef, useEffect } from 'react';
import React, { useCallback } from 'react';
import { LgEditor } from '@bfc/code-editor';
import { FieldProps, useShellApi } from '@bfc/extension';
import { FieldLabel } from '@bfc/adaptive-form';
import { LgMetaData, LgTemplateRef, LgType, CodeEditorSettings } from '@bfc/shared';
import { filterTemplateDiagnostics } from '@bfc/indexers';
import debounce from 'lodash/debounce';
import isEqual from 'lodash/isEqual';

const lspServerPath = '/lg-language-server';

Expand Down Expand Up @@ -68,31 +66,13 @@ const LgField: React.FC<FieldProps<string>> = props => {

const diagnostics = lgFile ? filterTemplateDiagnostics(lgFile.diagnostics, template) : [];

const [localValue, setLocalValue] = useState(template.body);
const sync = useRef(
debounce((shellData: any, localData: any) => {
if (!isEqual(shellData, localData)) {
setLocalValue(shellData);
}
}, 750)
).current;

useEffect(() => {
sync(template.body, localValue);

return () => {
sync.cancel();
};
}, [template.body]);

const lgOption = {
projectId,
fileId: lgFileId,
templateId: lgName,
};

const onChange = (body: string) => {
setLocalValue(body);
if (designerId) {
if (body) {
updateLgTemplate(body);
Expand All @@ -113,7 +93,7 @@ const LgField: React.FC<FieldProps<string>> = props => {
<FieldLabel id={id} label={label} description={description} helpLink={uiOptions?.helpLink} required={required} />
<LgEditor
height={225}
value={localValue}
value={template.body}
onChange={onChange}
diagnostics={diagnostics}
hidePlaceholder
Expand Down
14 changes: 6 additions & 8 deletions Composer/packages/ui-plugins/luis/src/LuisIntentEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/** @jsx jsx */
import { jsx } from '@emotion/core';
import React, { useState } from 'react';
import React from 'react';
import { LuEditor, inlineModePlaceholder } from '@bfc/code-editor';
import { FieldProps, useShellApi } from '@bfc/extension';
import { filterSectionDiagnostics } from '@bfc/indexers';
Expand All @@ -20,13 +20,12 @@ const LuisIntentEditor: React.FC<FieldProps<string>> = props => {
$kind.const && (intentName = new LuMetaData(new LuType($kind.const).toString(), designerId).toString());
}

const [luIntent, setLuIntent] = useState<LuIntentSection>(
const luIntent =
(luFile && luFile.intents.find(intent => intent.Name === intentName)) ||
({
Name: intentName,
Body: '',
} as LuIntentSection)
);
({
Name: intentName,
Body: '',
} as LuIntentSection);

if (!luFile || !intentName) {
return null;
Expand All @@ -38,7 +37,6 @@ const LuisIntentEditor: React.FC<FieldProps<string>> = props => {
}

const newIntent = { Name: intentName, Body: newValue };
setLuIntent(newIntent);
shellApi.updateLuIntent(luFile.id, intentName, newIntent);
onChange(intentName);
};
Expand Down
6 changes: 6 additions & 0 deletions Composer/plugins/azureFunctionsPublish/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
lib
publishHistory.txt
publishBots
cred.txt
provisionResult.json
Loading

0 comments on commit 540a0c8

Please sign in to comment.