diff --git a/Composer/packages/client/src/pages/publish/Publish.tsx b/Composer/packages/client/src/pages/publish/Publish.tsx index 2f8374350d..8aeff7eb33 100644 --- a/Composer/packages/client/src/pages/publish/Publish.tsx +++ b/Composer/packages/client/src/pages/publish/Publish.tsx @@ -48,6 +48,7 @@ const Publish: React.FC checkedSkillIds.some((id) => bot.id === id)); }, [checkedSkillIds]); + // The publishTypes are loaded from the server and put into the publishTypesState per project + // The botProjectSpaceSelector maps the publishTypes to the project bots. + // The localBotsDataSelector uses botProjectSpaceSelector + // The botPropertyData uses localBotsDataSelector + // When the botPropertyData is used (like in the canPull method), the publishTypes must be loaded for the current project. + // Otherwise the botPropertyData publishTypes will always be empty and this component won't function properly. + useEffect(() => { + if (projectId) { + getPublishTargetTypes(projectId); + } + }, [projectId]); + const canPull = useMemo(() => { return selectedBots.some((bot) => { const { publishTypes, publishTargets } = botPropertyData[bot.id]; - const type = publishTypes?.find( - (t) => t.name === publishTargets?.find((target) => target.name === bot.publishTarget)?.type - ); - if (type?.features?.pull) { - return true; - } - return false; + const botPublishTarget = publishTargets?.find((target) => target.name === bot.publishTarget); + const type = publishTypes?.find((t) => t.name === botPublishTarget?.type); + return type?.features?.pull; }); - }, [selectedBots]); + }, [selectedBots, botPropertyData]); const canPublish = checkedSkillIds.length > 0 && !isPublishPending && selectedBots.some((bot) => Boolean(bot.publishTarget));