Skip to content

Commit 69e07f0

Browse files
authored
Check if the passed in node is a LocalProjectTreeItem (#3370) (#3373)
* Check if the passed in node is a LocalProjectTreeItem * Add comment to replace isAzExtTreeItem
1 parent 72ffbd1 commit 69e07f0

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/commands/deploy/deploy.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ResolvedFunctionAppResource } from '../../tree/ResolvedFunctionAppResou
1515
import { SlotTreeItem } from '../../tree/SlotTreeItem';
1616
import { dotnetUtils } from '../../utils/dotnetUtils';
1717
import { isPathEqual } from '../../utils/fs';
18+
import { treeUtils } from '../../utils/treeUtils';
1819
import { getWorkspaceSetting } from '../../vsCodeConfig/settings';
1920
import { verifyInitForVSCode } from '../../vsCodeConfig/verifyInitForVSCode';
2021
import { tryGetFunctionProjectRoot } from '../createNewProject/verifyIsProject';
@@ -37,6 +38,14 @@ async function deploy(actionContext: IActionContext, arg1: vscode.Uri | string |
3738
addLocalFuncTelemetry(actionContext, deployPaths.workspaceFolder.uri.fsPath);
3839

3940
const context: IDeployContext = Object.assign(actionContext, deployPaths, { defaultAppSetting: 'defaultFunctionAppToDeploy' });
41+
if (treeUtils.isAzExtTreeItem(arg1)) {
42+
if (!arg1.contextValue.match(ResolvedFunctionAppResource.pickSlotContextValue) &&
43+
!arg1.contextValue.match(ResolvedFunctionAppResource.productionContextValue)) {
44+
// 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
45+
arg1 = undefined;
46+
}
47+
}
48+
4049
const node: SlotTreeItem = await getDeployNode(context, ext.rgApi.tree, arg1, arg2, async () => ext.rgApi.pickAppResource(context, {
4150
filter: functionFilter,
4251
expectedChildContextValue: expectedContextValue

src/utils/treeUtils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

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

@@ -22,4 +22,9 @@ export namespace treeUtils {
2222
function getResourcesPath(): string {
2323
return ext.context.asAbsolutePath('resources');
2424
}
25+
26+
// replace with azext-utils when it's released
27+
export function isAzExtTreeItem(ti: unknown): ti is AzExtTreeItem {
28+
return !!ti && (ti as AzExtTreeItem).fullId !== undefined && (ti as AzExtTreeItem).fullId !== null;
29+
}
2530
}

0 commit comments

Comments
 (0)