From 29a96043837a81e87613503343237d884be99911 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Mon, 5 Apr 2021 14:26:33 -0500 Subject: [PATCH 1/3] fix #6649 - detect dependencies in all projects not just curent projcet --- .../GetStarted/GetStartedNextSteps.tsx | 18 +++++++++--------- .../packages/client/src/components/Header.tsx | 17 +++++++---------- .../src/recoilModel/selectors/project.ts | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/Composer/packages/client/src/components/GetStarted/GetStartedNextSteps.tsx b/Composer/packages/client/src/components/GetStarted/GetStartedNextSteps.tsx index eff75ef6f3..972b3d9617 100644 --- a/Composer/packages/client/src/components/GetStarted/GetStartedNextSteps.tsx +++ b/Composer/packages/client/src/components/GetStarted/GetStartedNextSteps.tsx @@ -73,26 +73,26 @@ export const GetStartedNextSteps: React.FC = (props) => { }; const updateLuisSettings = (newLuisSettings) => { - setSettings(projectId, { + setSettings(rootBotProjectId, { ...mergedSettings, luis: { ...mergedSettings.luis, ...newLuisSettings }, }); }; const updateQNASettings = (newQNASettings) => { - setSettings(projectId, { + setSettings(rootBotProjectId, { ...mergedSettings, qna: { ...mergedSettings.qna, ...newQNASettings }, }); }; - const linkToPackageManager = `/bot/${projectId}/plugin/package-manager/package-manager`; - const linkToConnections = `/bot/${projectId}/botProjectsSettings/#connections`; - const linkToPublishProfile = `/bot/${projectId}/botProjectsSettings/#addNewPublishProfile`; - const linkToLUISSettings = `/bot/${projectId}/botProjectsSettings/#luisKey`; - const linktoQNASettings = `/bot/${projectId}/botProjectsSettings/#qnaKey`; - const linkToLGEditor = `/bot/${projectId}/language-generation`; - const linkToLUEditor = `/bot/${projectId}/language-understanding`; + const linkToPackageManager = `/bot/${rootBotProjectId}/plugin/package-manager/package-manager`; + const linkToConnections = `/bot/${rootBotProjectId}/botProjectsSettings/#connections`; + const linkToPublishProfile = `/bot/${rootBotProjectId}/botProjectsSettings/#addNewPublishProfile`; + const linkToLUISSettings = `/bot/${rootBotProjectId}/botProjectsSettings/#luisKey`; + const linktoQNASettings = `/bot/${rootBotProjectId}/botProjectsSettings/#qnaKey`; + const linkToLGEditor = `/bot/${rootBotProjectId}/language-generation`; + const linkToLUEditor = `/bot/${rootBotProjectId}/language-understanding`; useEffect(() => { const newNextSteps: NextSteps[] = []; diff --git a/Composer/packages/client/src/components/Header.tsx b/Composer/packages/client/src/components/Header.tsx index e5e7c36593..14c7af3c36 100644 --- a/Composer/packages/client/src/components/Header.tsx +++ b/Composer/packages/client/src/components/Header.tsx @@ -14,7 +14,6 @@ import { NeutralColors, SharedColors, FontSizes, CommunicationColors } from '@ui import { useRecoilValue } from 'recoil'; import { FontWeights } from 'office-ui-fabric-react/lib/Styling'; import { Panel, PanelType } from 'office-ui-fabric-react/lib/Panel'; -import { BotIndexer } from '@bfc/indexers'; import { TeachingBubble } from 'office-ui-fabric-react/lib/TeachingBubble'; import { useLocation } from '../utils/hooks'; @@ -26,12 +25,11 @@ import { botDisplayNameState, localeState, currentProjectIdState, + rootBotProjectIdSelector, settingsState, webChatEssentialsSelector, isWebChatPanelVisibleState, - dialogsWithLuProviderSelectorFamily, - luFilesSelectorFamily, - qnaFilesSelectorFamily, + allRequiredRecognizersSelector, } from '../recoilModel'; import composerIcon from '../images/composerIcon.svg'; import { AppUpdaterStatus } from '../constants'; @@ -155,6 +153,7 @@ const calloutDescription = css` export const Header = () => { const { setAppUpdateShowing, setLocale } = useRecoilValue(dispatcherState); const projectId = useRecoilValue(currentProjectIdState); + const rootBotProjectId = useRecoilValue(rootBotProjectIdSelector) || projectId; const projectName = useRecoilValue(botDisplayNameState(projectId)); const locale = useRecoilValue(localeState(projectId)); const appUpdate = useRecoilValue(appUpdateState); @@ -176,11 +175,9 @@ export const Header = () => { // These are needed to determine if the bot needs LUIS or QNA // this data is passed into the GetStarted widget // ... if the get started widget moves, this code should too! - const dialogs = useRecoilValue(dialogsWithLuProviderSelectorFamily(projectId)); - const luFiles = useRecoilValue(luFilesSelectorFamily(projectId)); - const qnaFiles = useRecoilValue(qnaFilesSelectorFamily(projectId)); - const requiresLUIS = BotIndexer.shouldUseLuis(dialogs, luFiles); - const requiresQNA = BotIndexer.shouldUseQnA(dialogs, qnaFiles); + const requiredStuff = useRecoilValue(allRequiredRecognizersSelector); + const requiresLUIS = requiredStuff.filter((p) => p.requiresLUIS)?.length ? true : false; + const requiresQNA = requiredStuff.filter((p) => p.requiresQNA)?.length ? true : false; // ... end of get started stuff const isShow = useBotControllerBar(); @@ -413,7 +410,7 @@ export const Header = () => { ) : null} { + const ids = get(botProjectIdsState); + return ids.reduce((result: { projectId: string; requiresLUIS: boolean; requiresQNA: boolean }[], id: string) => { + const botAssets = get(botAssetsSelectFamily(id)); + if (botAssets) { + const { dialogs, luFiles, qnaFiles } = botAssets; + const requiresLUIS = BotIndexer.shouldUseLuis(dialogs, luFiles); + const requiresQNA = BotIndexer.shouldUseQnA(dialogs, qnaFiles); + result.push({ projectId: id, requiresLUIS, requiresQNA }); + } + return result; + }, []); + }, +}); From 70aa7d42f1da330a0bda09c9ea4175be67a002a1 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Mon, 5 Apr 2021 17:45:34 -0500 Subject: [PATCH 2/3] Update Composer/packages/client/src/components/Header.tsx Co-authored-by: Andy Brown --- Composer/packages/client/src/components/Header.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Composer/packages/client/src/components/Header.tsx b/Composer/packages/client/src/components/Header.tsx index 14c7af3c36..e09f46748d 100644 --- a/Composer/packages/client/src/components/Header.tsx +++ b/Composer/packages/client/src/components/Header.tsx @@ -176,7 +176,7 @@ export const Header = () => { // this data is passed into the GetStarted widget // ... if the get started widget moves, this code should too! const requiredStuff = useRecoilValue(allRequiredRecognizersSelector); - const requiresLUIS = requiredStuff.filter((p) => p.requiresLUIS)?.length ? true : false; + const requiresLUIS = requiredStuff.some((p) => p.requiresLUIS); const requiresQNA = requiredStuff.filter((p) => p.requiresQNA)?.length ? true : false; // ... end of get started stuff From 0f1c0d79b15738c48e2f68436003e5b20ccc5494 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Mon, 5 Apr 2021 17:45:39 -0500 Subject: [PATCH 3/3] Update Composer/packages/client/src/components/Header.tsx Co-authored-by: Andy Brown --- Composer/packages/client/src/components/Header.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Composer/packages/client/src/components/Header.tsx b/Composer/packages/client/src/components/Header.tsx index e09f46748d..90f456dfd5 100644 --- a/Composer/packages/client/src/components/Header.tsx +++ b/Composer/packages/client/src/components/Header.tsx @@ -177,7 +177,7 @@ export const Header = () => { // ... if the get started widget moves, this code should too! const requiredStuff = useRecoilValue(allRequiredRecognizersSelector); const requiresLUIS = requiredStuff.some((p) => p.requiresLUIS); - const requiresQNA = requiredStuff.filter((p) => p.requiresQNA)?.length ? true : false; + const requiresQNA = requiredStuff.some((p) => p.requiresQNA); // ... end of get started stuff const isShow = useBotControllerBar();