Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
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
38 changes: 29 additions & 9 deletions Composer/packages/client/src/pages/publish/Publish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,39 @@ const Publish: React.FC<RouteComponentProps<{ projectId: string; targetName?: st
navigateTo(url);
};

const isPublishingToAzure = (items: BotStatus[]) => {
for (const bot of items) {
const setting = botPropertyData[bot.id].setting;
const publishTargets = botPropertyData[bot.id].publishTargets;
if (!(bot.publishTarget && publishTargets && setting)) {
continue;
}
if (bot.publishTarget && publishTargets) {
const selectedTarget = publishTargets.find((target) => target.name === bot.publishTarget);
if (selectedTarget?.type === 'azurePublish' || selectedTarget?.type === 'azureFunctionsPublish') {
return true;
}
}
}
return false;
};

const publish = async (items: BotStatus[]) => {
// get token
let token = '';
if (isGetTokenFromUser()) {
token = getTokenFromCache('accessToken');
} else {
let tenant = getTenantIdFromCache();
if (!tenant) {
const tenants = await AuthClient.getTenants();
tenant = tenants?.[0]?.tenantId;
setTenantId(tenant);
if (isPublishingToAzure(items)) {
// TODO: this logic needs to be moved into the Azure publish extensions
if (isGetTokenFromUser()) {
token = getTokenFromCache('accessToken');
} else {
let tenant = getTenantIdFromCache();
if (!tenant) {
const tenants = await AuthClient.getTenants();
tenant = tenants?.[0]?.tenantId;
setTenantId(tenant);
}
token = await AuthClient.getARMTokenForTenant(tenant);
}
token = await AuthClient.getARMTokenForTenant(tenant);
}

setPublishDialogVisiblity(false);
Expand Down