in Composer/packages/client/src/components/AddRemoteSkillModal/CreateSkillModal.tsx [232:338]
text: formatMessage(item.name),
};
});
}, [skillManifest]);
const handleManifestUrlChange = (_, currentManifestUrl = '') => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { manifestUrl, ...rest } = formData;
debouncedValidateManifestURl(
{
formData: { manifestUrl: currentManifestUrl },
...validationHelpers,
},
skillUrls
);
setFormData({
...rest,
manifestUrl: currentManifestUrl,
});
setSkillManifest(null);
setShowDetail(false);
};
const validateUrl = useCallback(
(event) => {
event.preventDefault();
setShowDetail(true);
const localManifestPath = formData.manifestUrl.replace(/\\/g, '/');
getSkillManifest(projectId, formData.manifestUrl, setSkillManifest, setFormDataErrors, setShowDetail);
setManifestDirPath(localManifestPath.substring(0, localManifestPath.lastIndexOf('/')));
},
[projectId, formData]
);
const handleSubmit = async (event, content: string, enable: boolean) => {
event.preventDefault();
// add a remote skill, add skill identifier into botProj file
await addRemoteSkill(formData.manifestUrl, formData.endpointName, zipContent);
TelemetryClient.track('AddNewSkillCompleted', {
from: Object.keys(zipContent).length > 0 ? 'zip' : 'url',
});
// if added remote skill fail, just not addTrigger to root.
const skillId = location.href.match(/skill\/([^/]*)/)?.[1];
//if the root dialog is orchestrator recoginzer type or user chooses orchestrator type before connecting,
//add the trigger to the root dialog.
const boundId =
rootDialog && (rootDialog.luProvider === SDKKinds.OrchestratorRecognizer || enable) ? rootDialog.id : dialogId;
if (skillId) {
// add trigger with connect to skill action to root bot
const triggerFormData = getTriggerFormData(skillManifest.name, content);
await addTriggerToRoot(boundId, triggerFormData, skillId);
TelemetryClient.track('AddNewTriggerCompleted', { kind: 'Microsoft.OnIntent' });
}
if (enable) {
// update recognizor type to orchestrator
await updateRecognizer(projectId, boundId, SDKKinds.OrchestratorRecognizer);
}
};
const handleDismiss = () => {
setShowSetAppIdDialog(true);
onDismiss();
};
const handleGotoAddSkill = (publishTargetName: string) => {
const profileTarget = publishTargets.find((target) => target.name === publishTargetName);
const configuration = JSON.parse(profileTarget?.configuration || '');
setMicrosoftAppProperties(
projectId,
configuration.settings.MicrosoftAppId,
configuration.settings.MicrosoftAppPassword
);
setShowSetAppIdDialog(false);
setTitle({
subText: '',
title: addSkillDialog.SKILL_MANIFEST_FORM.title,
});
};
const handleGotoCreateProfile = () => {
setCreateSkillDialogHidden(true);
};
const handleBrowseButtonUpdate = async (path: string, files: Record<string, JSZipObject>) => {
// update path in input field
setFormData({
...formData,
manifestUrl: path,
});
const result = await validateLocalZip(files);
setFormDataErrors(result.error);
result.path && setManifestDirPath(result.path);
result.zipContent && setZipContent(result.zipContent);
if (result.manifestContent) {
validateSKillName(result.manifestContent, setSkillManifest);
setShowDetail(true);
}
};
useEffect(() => {
if (skillManifest?.endpoints) {
setFormData({