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
Original file line number Diff line number Diff line change
@@ -1,26 +1,45 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import React from 'react';
import { FieldProps, useRecognizerConfig } from '@bfc/extension-client';
import { DialogInfo, FieldProps, useRecognizerConfig, useShellApi } from '@bfc/extension-client';
import formatMessage from 'format-message';
import get from 'lodash/get';
import React from 'react';

import { FieldLabel } from '../FieldLabel';

const isLuisRecognizer = (dialog: DialogInfo) => {
if (!dialog) return false;
const recognizer = get(dialog, 'content.recognizer', '');
return typeof recognizer === 'string' && recognizer.endsWith('.lu.qna');
};

const luisEntityHelpUrl = 'https://docs.microsoft.com/en-us/composer/concept-language-understanding#utterances';

const IntentField: React.FC<FieldProps> = (props) => {
const { id, description, uiOptions, value, required, onChange } = props;
const { id, uiOptions, value, required, onChange } = props;
const { currentRecognizer } = useRecognizerConfig();
const { currentDialog } = useShellApi();

const Editor = currentRecognizer?.intentEditor;
const label = formatMessage('Trigger phrases');

let description = props.description;
let helpLink = uiOptions.helpLink;
if (isLuisRecognizer(currentDialog)) {
description = formatMessage(
'Trigger phrases are inputs from users that will be used to train your LUIS model. This follows .lu file format.'
);
helpLink = luisEntityHelpUrl;
}

const handleChange = () => {
onChange(value);
};

return (
<React.Fragment>
<FieldLabel description={description} helpLink={uiOptions?.helpLink} id={id} label={label} required={required} />
<FieldLabel description={description} helpLink={helpLink} id={id} label={label} required={required} />
Comment thread
hatpick marked this conversation as resolved.
{Editor ? (
<Editor {...props} onChange={handleChange} />
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useRecoilValue } from 'recoil';

import { TriggerFormData, TriggerFormDataErrors } from '../../utils/dialogUtil';
import { userSettingsState } from '../../recoilModel/atoms';
import { dialogsSelectorFamily } from '../../recoilModel';
import { currentDialogState, dialogsSelectorFamily, localeState, luFilesState } from '../../recoilModel';
import { isRegExRecognizerType, resolveRecognizer$kind } from '../../utils/dialogValidator';
import TelemetryClient from '../../telemetry/TelemetryClient';

Expand Down Expand Up @@ -50,6 +50,11 @@ export const TriggerCreationModal: React.FC<TriggerCreationModalProps> = (props)
const isRegEx = isRegExRecognizerType(dialogFile);
const regexIntents = (dialogFile?.content?.recognizer as RegexRecognizer)?.intents ?? [];

const luFiles = useRecoilValue(luFilesState(projectId));
const locale = useRecoilValue(localeState(projectId));
const currentDialog = useRecoilValue(currentDialogState({ projectId, dialogId }));
const luFile = luFiles.find((f) => f.id === `${currentDialog?.id}.${locale}`);

const [formData, setFormData] = useState(initialFormData);
const [selectedType, setSelectedType] = useState<string>(SDKKinds.OnIntent);

Expand All @@ -76,7 +81,8 @@ export const TriggerCreationModal: React.FC<TriggerCreationModalProps> = (props)
setFormData,
userSettings,
projectId,
dialogId
dialogId,
luFile
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import formatMessage from 'format-message';
import { Label } from 'office-ui-fabric-react/lib/Label';
import { TextField } from 'office-ui-fabric-react/lib/TextField';
import { PlaceHolderSectionName } from '@bfc/indexers/lib/utils/luUtil';
import { UserSettings, DialogInfo, SDKKinds } from '@bfc/shared';
import { UserSettings, DialogInfo, SDKKinds, LuFile } from '@bfc/shared';
import { LuEditor, inlineModePlaceholder } from '@bfc/code-editor';

import { TriggerFormData, TriggerFormDataErrors } from '../../utils/dialogUtil';
Expand All @@ -22,7 +22,8 @@ export function resolveTriggerWidget(
setFormData: (data: TriggerFormData) => void,
userSettings: UserSettings,
projectId: string,
dialogId: string
dialogId: string,
luFile?: LuFile
) {
const isRegEx = isRegExRecognizerType(dialogFile);
const isLUISnQnA = isLUISnQnARecognizerType(dialogFile) || isPVARecognizerType(dialogFile);
Expand Down Expand Up @@ -99,6 +100,7 @@ export function resolveTriggerWidget(
editorSettings={userSettings.codeEditor}
errorMessage={formData.errors.triggerPhrases}
height={225}
luFile={luFile}
luOption={{
projectId,
fileId: dialogId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function useRecognizerConfig(): RecognizerSchemaConfig {

const recognizerWidgets = plugins.widgets?.recognizer ?? {};
const schemas = Object.entries(plugins.uiSchema)
.filter(([_, uiOptions]) => uiOptions && uiOptions.recognizer)
.filter(([_, uiOptions]) => uiOptions?.recognizer)
.map(([$kind, uiOptions]) => {
const recognizerOptions = uiOptions?.recognizer as RecognizerOptions;
const intentEditor = resolveRecognizerWidget(recognizerOptions.intentEditor, recognizerWidgets);
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/lib/code-editor/src/lu/LuLabelingMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ export const LuLabelingMenu = ({ editor, luFile, onMenuToggled, onInsertEntity }
[onInsertEntity]
);

const { menuProps } = useLabelingMenuProps('filter', luFile, itemClick, {
const { menuProps, noEntities } = useLabelingMenuProps('filter', luFile, itemClick, {
menuHeaderText: formatMessage('Tag entity'),
});

return menuTargetElm ? (
return menuTargetElm && !noEntities ? (
<ContextualMenu
{...menuProps}
directionalHint={DirectionalHint.bottomLeftEdge}
Expand Down
18 changes: 9 additions & 9 deletions Composer/packages/server/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@
"apr_9_2020_3c8b47d7": {
"message": "Apr 9, 2020"
},
"are_you_sure_you_want_to_delete_your_bot_this_acti_214a9e11": {
"message": "Are you sure you want to delete your bot? This action cannot be undone and your bot and all related files in the bot project folder will be permanently deleted. Your Azure resources will remain unchanged."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nit: I would have 4 sentences here:
Are you sure you want to delete your bot? This action cannot be undone. Your bot and all related files in the bot project folder will be permanently deleted. Your Azure resources will remain unchanged.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GeoffCoxMSFT Out of curiosity, why would you opt for separate sentences?

},
"are_you_sure_you_want_to_exit_the_onboarding_produ_c2de1b23": {
"message": "Are you sure you want to exit the Onboarding Product Tour? You can restart the tour in the onboarding settings."
},
Expand Down Expand Up @@ -1427,9 +1430,6 @@
"extension_settings_899ccb55": {
"message": "Extension Settings"
},
"external_resources_will_not_be_changed_c08b0009": {
"message": "External resources will not be changed."
},
"external_service_adapters_5218e6a3": {
"message": "External service adapters"
},
Expand Down Expand Up @@ -1640,9 +1640,6 @@
"http_request_79847109": {
"message": "HTTP Request"
},
"i_want_to_delete_this_bot_f81a4735": {
"message": "I want to delete this bot"
},
"i_want_to_keep_the_template_content_in_the_file_ju_769331d9": {
"message": "I want to keep the template content in the file, just want to dereference from this response (hint: keep the content if you currently, or plan to re-use in another location)"
},
Expand Down Expand Up @@ -3446,6 +3443,9 @@
"trigger_connects_user_intent_with_bot_responses_th_57279180": {
"message": "Trigger connects user intent with bot responses. Think of a trigger as one capability of your bot. So a dialog contains a collection of triggers. To add a new trigger from the dialog menu."
},
"trigger_phrases_are_inputs_from_users_that_will_be_f8c61866": {
"message": "Trigger phrases are inputs from users that will be used to train your LUIS model. This follows .lu file format."
},
"trigger_phrases_f6754fa": {
"message": "Trigger phrases"
},
Expand Down Expand Up @@ -3638,9 +3638,6 @@
"warning_aacb8c24": {
"message": "Warning"
},
"warning_the_action_you_are_about_to_take_cannot_be_1071a3c3": {
"message": "Warning: the action you are about to take cannot be undone. Going further will delete this bot and any related files in the bot project folder."
},
"warningsmsg_e2c04bfe": {
"message": "{ warningsMsg }"
},
Expand Down Expand Up @@ -3731,6 +3728,9 @@
"yes_dde87d5": {
"message": "Yes"
},
"yes_delete_d43476ee": {
"message": "Yes, delete"
},
"you_already_have_a_kb_with_that_name_choose_anothe_b7f7c517": {
"message": "You already have a KB with that name. Choose another name and try again."
},
Expand Down