Skip to content

Commit

Permalink
Check if the passed in node is a LocalProjectTreeItem (#3370)
Browse files Browse the repository at this point in the history
* Check if the passed in node is a LocalProjectTreeItem

* Add comment to replace isAzExtTreeItem
  • Loading branch information
nturinski committed Oct 15, 2022
1 parent 72ffbd1 commit c462215
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/commands/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ResolvedFunctionAppResource } from '../../tree/ResolvedFunctionAppResou
import { SlotTreeItem } from '../../tree/SlotTreeItem';
import { dotnetUtils } from '../../utils/dotnetUtils';
import { isPathEqual } from '../../utils/fs';
import { treeUtils } from '../../utils/treeUtils';
import { getWorkspaceSetting } from '../../vsCodeConfig/settings';
import { verifyInitForVSCode } from '../../vsCodeConfig/verifyInitForVSCode';
import { tryGetFunctionProjectRoot } from '../createNewProject/verifyIsProject';
Expand All @@ -37,6 +38,14 @@ async function deploy(actionContext: IActionContext, arg1: vscode.Uri | string |
addLocalFuncTelemetry(actionContext, deployPaths.workspaceFolder.uri.fsPath);

const context: IDeployContext = Object.assign(actionContext, deployPaths, { defaultAppSetting: 'defaultFunctionAppToDeploy' });
if (treeUtils.isAzExtTreeItem(arg1)) {
if (!arg1.contextValue.match(ResolvedFunctionAppResource.pickSlotContextValue) &&
!arg1.contextValue.match(ResolvedFunctionAppResource.productionContextValue)) {
// if the user uses the deploy button, it's possible for the local project node to be passed in, so we should reset it to undefined
arg1 = undefined;
}
}

const node: SlotTreeItem = await getDeployNode(context, ext.rgApi.tree, arg1, arg2, async () => ext.rgApi.pickAppResource(context, {
filter: functionFilter,
expectedChildContextValue: expectedContextValue
Expand Down
7 changes: 6 additions & 1 deletion src/utils/treeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { TreeItemIconPath } from '@microsoft/vscode-azext-utils';
import { AzExtTreeItem, TreeItemIconPath } from '@microsoft/vscode-azext-utils';
import * as path from 'path';
import { ext } from '../extensionVariables';

Expand All @@ -22,4 +22,9 @@ export namespace treeUtils {
function getResourcesPath(): string {
return ext.context.asAbsolutePath('resources');
}

// replace with azext-utils when it's released
export function isAzExtTreeItem(ti: unknown): ti is AzExtTreeItem {
return !!ti && (ti as AzExtTreeItem).fullId !== undefined && (ti as AzExtTreeItem).fullId !== null;
}
}

0 comments on commit c462215

Please sign in to comment.