Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
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
28 changes: 15 additions & 13 deletions extensions/azurePublish/src/components/ResourceGroupPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ type ResourceGroupItemChoice = {
};

type Props = {
disabled: boolean;
/**
* If this picker should be disabled.
*/
disabled?: boolean;
/**
* The resource groups to choose from.
* Set to undefined to disable this picker.
*/
resourceGroupNames?: string[];
/**
Expand Down Expand Up @@ -131,13 +133,15 @@ export const ResourceGroupPicker = ({
}, [debouncedNewName, resourceGroupNames]);

React.useEffect(() => {
const isNew = selectedName === CREATE_NEW_KEY;
onChange({
isNew,
name: isNew ? debouncedNewName : selectedName,
errorMessage: isNew ? newNameErrorMessage : undefined,
});
}, [selectedName, debouncedNewName, newNameErrorMessage]);
if (!disabled) {
const isNew = selectedName === CREATE_NEW_KEY;
onChange({
isNew,
name: isNew ? debouncedNewName : selectedName,
errorMessage: isNew ? newNameErrorMessage : undefined,
});
}
}, [disabled, selectedName, debouncedNewName, newNameErrorMessage]);

const options = React.useMemo(() => {
const optionsList: IDropdownOption[] =
Expand All @@ -151,8 +155,6 @@ export const ResourceGroupPicker = ({

// ----- Render -----//

const loading = resourceGroupNames === undefined;

const onRenderOption = (option) => {
return (
<div>
Expand All @@ -171,7 +173,7 @@ export const ResourceGroupPicker = ({
ariaLabel={formatMessage(
'A resource group is a collection of resources that share the same lifecycle, permissions, and policies'
)}
disabled={loading || disabled}
disabled={disabled}
label={formatMessage('Resource group')}
options={options}
placeholder={formatMessage('Select one')}
Expand All @@ -188,7 +190,7 @@ export const ResourceGroupPicker = ({
required
ariaLabel={formatMessage('Enter a name for the new resource group')}
data-testid={'newResourceGroupName'}
disabled={loading}
disabled={disabled}
errorMessage={newNameErrorMessage}
id={'newResourceGroupName'}
label={formatMessage('Resource group name')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ export const AzureProvisionDialog: React.FC = () => {

const resourceGroupNames = resourceGroups?.map((r) => r.name) || [];

const isNewResourceGroupName = !resourceGroupNames.includes(formData.resourceGroup);
const isNewResourceGroupName = !currentConfig?.resourceGroup && !resourceGroupNames.includes(formData.resourceGroup);

const PageChooseAction = (
<ScrollablePane
Expand Down Expand Up @@ -1032,6 +1032,7 @@ export const AzureProvisionDialog: React.FC = () => {
onClick={() => {
const selectedResources = formData.requiredResources.concat(formData.enabledResources);
onSubmit({
tenantId: formData.tenantId,
subscription: formData.subscriptionId,
resourceGroup: formData.resourceGroup,
hostname: formData.hostname,
Expand Down
1 change: 1 addition & 0 deletions extensions/azurePublish/src/node/provision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export class BotProjectProvision {
// ensure a tenantId is available.
if (!this.tenantId) {
this.tenantId = await this.getTenantId();
provisionResults.tenantId = this.tenantId;
}

// tokenCredentials is used for authentication across the API calls
Expand Down