diff --git a/Composer/packages/client/src/pages/design/DebugPanel/TabExtensions/DiagnosticsTab/DiagnosticType.ts b/Composer/packages/client/src/pages/design/DebugPanel/TabExtensions/DiagnosticsTab/DiagnosticType.ts index f99fa35991..8324d0979d 100644 --- a/Composer/packages/client/src/pages/design/DebugPanel/TabExtensions/DiagnosticsTab/DiagnosticType.ts +++ b/Composer/packages/client/src/pages/design/DebugPanel/TabExtensions/DiagnosticsTab/DiagnosticType.ts @@ -38,6 +38,22 @@ export interface IDiagnosticInfo { friendlyLocationBreadcrumbItems?: string[]; } +type ResourceType = 'language-generation' | 'language-understanding' | 'knowledge-base'; +function generateResourcePageUrl( + rootProjectId: string, + skillId: string | null, + resourceType: ResourceType, + resourceId: string, + line = 0 +) { + let uri = `/bot/${rootProjectId}`; + if (skillId !== null && skillId !== rootProjectId) { + uri += `/skill/${skillId}`; + } + + return `${uri}/${resourceType}/${resourceId}/edit#L=${line}`; +} + const getFriendlyPath = (dialogPath: string | undefined, dialogs: DialogInfo[]) => { const breadcrumb: string[] = []; try { @@ -241,12 +257,17 @@ export class LgDiagnostic extends DiagnosticInfo { getUrl = () => { const { rootProjectId, projectId, resourceId, diagnostic, dialogPath } = this; - let uri = `/bot/${rootProjectId}/language-generation/${resourceId}/edit#L=${diagnostic.range?.start.line || 0}`; + let uri = generateResourcePageUrl( + rootProjectId, + projectId, + 'language-generation', + resourceId, + diagnostic.range?.start.line + ); //the format of item.id is lgFile#inlineTemplateId if (dialogPath) { uri = convertPathToUrl(rootProjectId, rootProjectId === projectId ? null : projectId, resourceId, dialogPath); } - return uri; }; } @@ -285,7 +306,13 @@ export class LuDiagnostic extends DiagnosticInfo { getUrl = () => { const { rootProjectId, projectId, resourceId, diagnostic, dialogPath } = this; - let uri = `/bot/${projectId}/language-understanding/${resourceId}/edit#L=${diagnostic.range?.start.line || 0}`; + let uri = generateResourcePageUrl( + rootProjectId, + projectId, + 'language-understanding', + resourceId, + diagnostic.range?.start.line + ); if (dialogPath) { uri = convertPathToUrl(rootProjectId, rootProjectId === projectId ? null : projectId, resourceId, dialogPath); } @@ -302,7 +329,13 @@ export class QnADiagnostic extends DiagnosticInfo { } getUrl = () => { - const { rootProjectId, resourceId, diagnostic } = this; - return `/bot/${rootProjectId}/knowledge-base/${resourceId}/edit#L=${diagnostic.range?.start.line || 0}`; + const { rootProjectId, resourceId, projectId, diagnostic } = this; + return generateResourcePageUrl( + rootProjectId, + projectId, + 'knowledge-base', + resourceId, + diagnostic.range?.start.line + ); }; } diff --git a/Composer/packages/client/src/router.tsx b/Composer/packages/client/src/router.tsx index 9fa97d67bd..cb436dd865 100644 --- a/Composer/packages/client/src/router.tsx +++ b/Composer/packages/client/src/router.tsx @@ -37,7 +37,6 @@ const QnAPage = React.lazy(() => import('./pages/knowledge-base/QnAPage')); const LGPage = React.lazy(() => import('./pages/language-generation/LGPage')); const SettingPage = React.lazy(() => import('./pages/setting/SettingsPage')); const BotProjectSettings = React.lazy(() => import('./pages/botProject/BotProjectSettings')); - const ExtensionsPage = React.lazy(() => import('./pages/extensions/ExtensionsPage')); const Publish = React.lazy(() => import('./pages/publish/Publish')); const BotCreationFlowRouter = React.lazy(() => import('./components/CreationFlow/CreationFlow')); diff --git a/Composer/packages/lib/indexers/src/lgIndexer.ts b/Composer/packages/lib/indexers/src/lgIndexer.ts index af7d0b69e7..09622de301 100644 --- a/Composer/packages/lib/indexers/src/lgIndexer.ts +++ b/Composer/packages/lib/indexers/src/lgIndexer.ts @@ -11,9 +11,6 @@ const { defaultFileResolver } = TemplatesParser; function parse(content: string, id = '', importResolver: ImportResolverDelegate = defaultFileResolver) { const lgFile = Templates.parseText(content, id, importResolver); - lgFile.diagnostics = lgFile.diagnostics.filter( - (diag) => !diag.message.includes('LG file must have at least one template definition.') - ); return convertTemplatesToLgFile(id, content, lgFile); } @@ -25,9 +22,6 @@ function index(files: FileInfo[], importResolver?: ImportResolverDelegate): LgFi if (name.endsWith('.lg')) { const id = getBaseName(name, '.lg'); const result = parse(content, id, importResolver); - result.diagnostics = result.diagnostics.filter( - (diag) => !diag.message.includes('LG file must have at least one template definition.') - ); delete result.parseResult; lgFiles.push(result); } diff --git a/Composer/packages/lib/indexers/src/utils/lgUtil.ts b/Composer/packages/lib/indexers/src/utils/lgUtil.ts index 14c7c181eb..fdfbdd61bd 100644 --- a/Composer/packages/lib/indexers/src/utils/lgUtil.ts +++ b/Composer/packages/lib/indexers/src/utils/lgUtil.ts @@ -71,6 +71,9 @@ function getLgResource(lgFile: LgFile, importResolver?: ImportResolverDelegate) } export function convertTemplatesToLgFile(id = '', content: string, parseResult: Templates): LgFile { + parseResult.diagnostics = parseResult.diagnostics.filter( + (diag) => !diag.message.includes('LG file must have at least one template definition.') + ); const diagnostics = parseResult.diagnostics.map((d: LGDiagnostic) => { return convertLGDiagnostic(d, id); });