Skip to content

Commit

Permalink
Merge branch 'main' into zhixzhan/skill-manifest-error
Browse files Browse the repository at this point in the history
  • Loading branch information
cwhitten authored Apr 28, 2021
2 parents c74a1a4 + a449b51 commit 6b64270
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ export const SelectIntent: React.FC<SelectIntentProps> = (props) => {
) : (
<StackItem>
<LuEditor
toolbarHidden
height={300}
luOption={{
projectId,
Expand All @@ -286,6 +285,7 @@ export const SelectIntent: React.FC<SelectIntentProps> = (props) => {
luFeatures: luFeatures,
}}
telemetryClient={TelemetryClient}
toolbarOptions={{ hidden: true }}
value={displayContent}
warningMessage={warningMsg}
onChange={setDisplayContent}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const GetStartedNextSteps: React.FC<GetStartedProps> = (props) => {
TelemetryClient.track('GettingStartedActionClicked', { taskName: 'editlu', priority: 'recommended' });
openLink(linkToLUEditor);
},
hideFeatureStep: false,
hideFeatureStep: isPVABot,
});

setRecommendedNextSteps(newRecomendedSteps);
Expand Down Expand Up @@ -274,7 +274,7 @@ export const GetStartedNextSteps: React.FC<GetStartedProps> = (props) => {
TelemetryClient.track('GettingStartedActionClicked', { taskName: 'insights', priority: 'optional' });
openLink(linkToAppInsights);
},
hideFeatureStep: isPVABot,
hideFeatureStep: false,
},
{
key: 'devops',
Expand All @@ -286,7 +286,7 @@ export const GetStartedNextSteps: React.FC<GetStartedProps> = (props) => {
TelemetryClient.track('GettingStartedActionClicked', { taskName: 'devops', priority: 'optional' });
openLink(linkToDevOps);
},
hideFeatureStep: false,
hideFeatureStep: isPVABot,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ const CodeEditor: React.FC<CodeEditorProps> = (props) => {
</ActionButton>
)}
<QnAEditor
toolbarHidden
diagnostics={currentDiagnostics}
editorDidMount={editorDidMount}
editorSettings={userSettings.codeEditor}
Expand All @@ -113,6 +112,7 @@ const CodeEditor: React.FC<CodeEditorProps> = (props) => {
}}
placeholder={defaultQnAPlaceholder}
telemetryClient={TelemetryClient}
toolbarOptions={{ hidden: true }}
value={content}
onChange={onChangeContent}
onChangeSettings={handleSettingsChange}
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/utils/pageLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const topLinks = (
iconName: 'Table',
labelName: formatMessage('Forms (preview)'),
disabled: !botLoaded || skillIsRemote,
isDisabledForPVA: false,
isDisabledForPVA: isPVASchema,
},
]
: []),
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/lib/code-editor/src/LgEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const LgEditor = (props: LgEditorProps) => {

return mode === 'codeEditor' ? (
<LgCodeEditor
toolbarHidden={codeEditorToolbarHidden}
toolbarOptions={{ hidden: codeEditorToolbarHidden }}
{...(editorProps as LgCodeEditorProps)}
options={{ folding: false, ...editorProps.options }}
/>
Expand Down
11 changes: 8 additions & 3 deletions Composer/packages/lib/code-editor/src/LuEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ export interface LULSPEditorProps extends BaseEditorProps {
path: string;
}
| string;
toolbarHidden?: boolean;
toolbarOptions?: Partial<{
hidden: boolean;
disabled: boolean;
tooltip: string;
}>;
telemetryClient: TelemetryClient;
onNavigateToLuPage?: (luFileId: string, luSectionId?: string) => void;
}
Expand Down Expand Up @@ -129,7 +133,7 @@ const LuEditor: React.FC<LULSPEditorProps> = (props) => {
};

const {
toolbarHidden,
toolbarOptions,
onNavigateToLuPage,
luOption,
luFile,
Expand Down Expand Up @@ -296,11 +300,12 @@ const LuEditor: React.FC<LULSPEditorProps> = (props) => {
return (
<>
<Stack verticalFill>
{!toolbarHidden && (
{toolbarOptions?.hidden !== true && (
<LuEditorToolbar
editor={editor}
labelingMenuVisible={labelingMenuVisible}
luFile={luFile}
options={toolbarOptions}
onDefineEntity={defineEntity}
onInsertEntity={insertEntity}
/>
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/lib/code-editor/src/lg/LgCodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const LgCodeEditor = (props: LgCodeEditorProps) => {
};

const {
toolbarHidden,
toolbarOptions,
lgOption,
languageServer,
onInit: onInitProp,
Expand Down Expand Up @@ -270,7 +270,7 @@ export const LgCodeEditor = (props: LgCodeEditorProps) => {
return (
<>
<Stack verticalFill>
{!toolbarHidden && (
{toolbarOptions?.hidden !== true && (
<EditorToolbar
farItems={toolbarFarItems}
lgTemplates={lgTemplates}
Expand Down
14 changes: 10 additions & 4 deletions Composer/packages/lib/code-editor/src/lu/DefineEntityButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ const buttonStyles = {
icon: { color: FluentTheme.palette.black, fontSize: 12 },
};

const CommandBarButton = React.memo(
withTooltip({ content: formatMessage('Define new entity') }, DefaultCommandBarButton)
);
const getCommandBarButton = (tooltipContent: string) =>
withTooltip({ content: tooltipContent }, DefaultCommandBarButton);

type Props = {
onDefineEntity: (entityType: ToolbarLuEntityType, entityName?: string) => void;
disabled?: boolean;
tooltip?: string;
};

export const DefineEntityButton = React.memo((props: Props) => {
const { onDefineEntity } = props;
const { onDefineEntity, disabled = false, tooltip } = props;

const { iconName, text } = React.useMemo(() => getLuToolbarItemTextAndIcon('defineEntity'), []);
const { onRenderMenuList, query, setQuery } = useSearchableMenuListCallback(
Expand Down Expand Up @@ -154,10 +155,15 @@ export const DefineEntityButton = React.memo((props: Props) => {
};
}, [menuItems]);

const CommandBarButton = React.useMemo(() => getCommandBarButton(tooltip || formatMessage('Define new entity')), [
tooltip,
]);

return (
<CommandBarButton
className={jsLuToolbarMenuClassName}
data-testid="menuButton"
disabled={disabled}
iconProps={{ iconName }}
menuProps={menuProps}
styles={buttonStyles}
Expand Down
21 changes: 17 additions & 4 deletions Composer/packages/lib/code-editor/src/lu/InsertEntityButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,23 @@ type Props = {
insertEntityDisabled: boolean;
tagEntityDisabled: boolean;
luFile?: LuFile;
disabled?: boolean;
tooltip?: string;
};

const getCommandBarButton = (tooltipContent: string) =>
withTooltip({ content: tooltipContent }, DefaultCommandBarButton);

export const InsertEntityButton = React.memo((props: Props) => {
const { luFile, labelingMenuVisible, tagEntityDisabled, insertEntityDisabled, onInsertEntity } = props;
const {
luFile,
labelingMenuVisible,
tagEntityDisabled,
insertEntityDisabled,
onInsertEntity,
disabled = false,
tooltip,
} = props;

const itemClick = React.useCallback(
(_, item?: IContextualMenuItem) => {
Expand All @@ -55,7 +65,8 @@ export const InsertEntityButton = React.memo((props: Props) => {

const { menuProps, noEntities } = useLabelingMenuProps(labelingMenuVisible ? 'disable' : 'none', luFile, itemClick);

const disabled = React.useMemo(() => noEntities || insertEntityDisabled || labelingMenuVisible, [
const isDisabled = React.useMemo(() => disabled || noEntities || insertEntityDisabled || labelingMenuVisible, [
disabled,
noEntities,
insertEntityDisabled,
tagEntityDisabled,
Expand All @@ -64,13 +75,15 @@ export const InsertEntityButton = React.memo((props: Props) => {

const { iconName, text } = React.useMemo(() => getLuToolbarItemTextAndIcon('useEntity'), []);

const CommandBarButton = React.useMemo(() => getCommandBarButton(formatMessage('Insert defined entity')), []);
const CommandBarButton = React.useMemo(() => getCommandBarButton(tooltip || formatMessage('Insert defined entity')), [
tooltip,
]);

return (
<CommandBarButton
className={jsLuToolbarMenuClassName}
data-testid="menuButton"
disabled={disabled}
disabled={isDisabled}
iconProps={{ iconName }}
menuProps={menuProps}
styles={buttonStyles}
Expand Down
12 changes: 10 additions & 2 deletions Composer/packages/lib/code-editor/src/lu/LuEditorToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ type Props = {
labelingMenuVisible: boolean;
onDefineEntity: (entityType: ToolbarLuEntityType, entityName?: string) => void;
onInsertEntity: (entityName: string, entityType: string) => void;
options?: Partial<{
disabled: boolean;
tooltip: string;
}>;
};

export const LuEditorToolbar = React.memo((props: Props) => {
const { editor, luFile, labelingMenuVisible, className, onDefineEntity, onInsertEntity } = props;
const { editor, luFile, labelingMenuVisible, className, onDefineEntity, onInsertEntity, options } = props;

const [insertEntityDisabled, setInsertEntityDisabled] = React.useState(true);
const [tagEntityDisabled, setTagEntityDisabled] = React.useState(true);
Expand All @@ -55,7 +59,9 @@ export const LuEditorToolbar = React.memo((props: Props) => {
const defineLuEntityItem: ICommandBarItemProps = React.useMemo(() => {
return {
key: 'defineLuEntityItem',
commandBarButtonAs: () => <DefineEntityButton onDefineEntity={onDefineEntity} />,
commandBarButtonAs: () => (
<DefineEntityButton disabled={options?.disabled} tooltip={options?.tooltip} onDefineEntity={onDefineEntity} />
),
};
}, [onDefineEntity]);

Expand All @@ -64,10 +70,12 @@ export const LuEditorToolbar = React.memo((props: Props) => {
key: 'useLuEntityItem',
commandBarButtonAs: () => (
<InsertEntityButton
disabled={options?.disabled}
insertEntityDisabled={insertEntityDisabled}
labelingMenuVisible={labelingMenuVisible}
luFile={luFile}
tagEntityDisabled={tagEntityDisabled}
tooltip={options?.tooltip}
onInsertEntity={onInsertEntity}
/>
),
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/lib/code-editor/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type LgResponseEditorProps = LgCommonEditorProps & {
export type LgCodeEditorProps = LgCommonEditorProps &
BaseEditorProps & {
popExpandOptions?: { onEditorPopToggle?: (expanded: boolean) => void; popExpandTitle: string };
toolbarHidden?: boolean;
toolbarOptions?: Partial<{ hidden: boolean }>;
showDirectTemplateLink?: boolean;
onNavigateToLgPage?: (lgFileId: string, options?: { templateId?: string; line?: number }) => void;
languageServer?:
Expand Down
11 changes: 10 additions & 1 deletion Composer/packages/ui-plugins/luis/src/LuisIntentEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import React, { useMemo, useCallback } from 'react';
import { LuEditor, inlineModePlaceholder } from '@bfc/code-editor';
import { FieldProps, useShellApi } from '@bfc/extension-client';
import { filterSectionDiagnostics } from '@bfc/indexers';
import { LuIntentSection, CodeEditorSettings, LuMetaData, LuType } from '@bfc/shared';
import { LuIntentSection, CodeEditorSettings, LuMetaData, LuType, checkForPVASchema } from '@bfc/shared';
import formatMessage from 'format-message';

const LuisIntentEditor: React.FC<FieldProps<string>> = (props) => {
const { onChange, value, schema, placeholder } = props;
const { schemas } = useShellApi();
const isPVABot = useMemo(() => checkForPVASchema(schemas.sdk), [schemas.sdk]);

const {
currentDialog,
Expand Down Expand Up @@ -96,6 +99,12 @@ const LuisIntentEditor: React.FC<FieldProps<string>> = (props) => {
luOption={{ fileId: luFile.id, sectionId: luIntent.Name, projectId, luFeatures }}
placeholder={placeholder || inlineModePlaceholder}
telemetryClient={shellApi.telemetryClient}
toolbarOptions={{
disabled: isPVABot,
tooltip: isPVABot
? formatMessage('Power Virtual Agents bots cannot use this functionality at this time.')
: undefined,
}}
value={luIntent.Body}
onChange={commitChanges}
onChangeSettings={handleSettingsChange}
Expand Down

0 comments on commit 6b64270

Please sign in to comment.