Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tenants view #869

Merged
merged 24 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,20 @@
"category": "Azure"
},
{
"command": "azureTenant.refresh",
"command": "azureTenantsView.refresh",
"title": "%azureResourceGroups.refresh%",
"category": "Azure",
"icon": "$(refresh)"
},
{
"command": "azureTenant.refreshTree",
"command": "azureTenantsView.refreshTree",
"title": "%azureResourceGroups.refresh%",
"category": "Azure",
"icon": "$(refresh)"
},
{
"command": "azureTenant.signInToTenant",
"title": "%azureTenant.signInToTenant%",
"command": "azureTenantsView.signInToTenant",
"title": "%azureTenantsView.signInToTenant%",
"category": "Azure",
"icon": "$(sign-in)"
}
Expand Down Expand Up @@ -291,7 +291,7 @@
"visibility": "visible"
},
{
"id": "azureTenant",
"id": "azureTenantsView",
"name": "Accounts & Tenants",
"visibility": "collapsed"
},
Expand Down Expand Up @@ -379,8 +379,8 @@
"group": "navigation@10"
},
{
"command": "azureTenant.refreshTree",
"when": "view == azureTenant",
"command": "azureTenantsView.refreshTree",
"when": "view == azureTenantsView",
"group": "navigation@10"
},
{
Expand Down Expand Up @@ -461,13 +461,13 @@
"group": "9@1"
},
{
"command": "azureTenant.signInToTenant",
"when": "view == azureTenant && viewItem =~ /tenantNameNotSignedIn/",
"command": "azureTenantsView.signInToTenant",
"when": "view == azureTenantsView && viewItem =~ /tenantNameNotSignedIn/",
"group": "inline@1"
},
{
"command": "azureTenant.signInToTenant",
"when": "view == azureTenant && viewItem =~ /tenantNameNotSignedIn/",
"command": "azureTenantsView.signInToTenant",
"when": "view == azureTenantsView && viewItem =~ /tenantNameNotSignedIn/",
"group": "1@1"
}
],
Expand All @@ -493,7 +493,7 @@
"when": "never"
},
{
"command": "azureTenant.refresh",
"command": "azureTenantsView.refresh",
"when": "never"
},
{
Expand Down
4 changes: 2 additions & 2 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"azureResourceGroups.openInPortal": "Open in Portal",
"azureResourceGroups.refresh": "Refresh",
"azureWorkspace.refresh": "Refresh Workspace",
"azureTenant.refresh": "Refresh Accounts & Tenants",
"azureTenant.signInToTenant": "Sign in to Tenant",
"azureTenantsView.refresh": "Refresh Accounts & Tenants",
"azureTenantsView.signInToTenant": "Sign in to Tenant",
"azureResourceGroups.selectedSubscriptions": "Selected Subscriptions",
"azureResourceGroups.revealResource": "Reveal Resource",
"azureResourceGroups.viewProperties": "View Properties",
Expand Down
6 changes: 3 additions & 3 deletions src/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function registerCommands(): void {
registerCommand('azureResourceGroups.refreshTree', () => ext.actions.refreshAzureTree());
registerCommand('azureWorkspace.refreshTree', () => ext.actions.refreshWorkspaceTree());
registerCommand('azureFocusView.refreshTree', () => ext.actions.refreshFocusTree());
registerCommand('azureTenant.refreshTree', () => ext.actions.refreshTenantTree());
registerCommand('azureTenantsView.refreshTree', () => ext.actions.refreshTenantTree());

// v1.5 client extensions attach these commands to tree item context menus for refreshing their tree items
registerCommand('azureResourceGroups.refresh', async (context, node?: ResourceGroupsItem) => {
Expand All @@ -65,12 +65,12 @@ export function registerCommands(): void {
ext.actions.refreshFocusTree(node);
});

registerCommand('azureTenant.refresh', async (context, node?: ResourceGroupsItem) => {
registerCommand('azureTenantsView.refresh', async (context, node?: ResourceGroupsItem) => {
await handleAzExtTreeItemRefresh(context, node); // for compatibility with v1.5 client extensions
motm32 marked this conversation as resolved.
Show resolved Hide resolved
ext.actions.refreshTenantTree(node);
});

registerCommand('azureTenant.signInToTenant', async (_context, node: TenantTreeItem, account?: AuthenticationSessionAccountInformation) => {
registerCommand('azureTenantsView.signInToTenant', async (_context, node: TenantTreeItem, account?: AuthenticationSessionAccountInformation) => {
await (await ext.subscriptionProviderFactory()).signIn(node.tenantId, account);
ext.actions.refreshTenantTree(node);
});
Expand Down
5 changes: 2 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export async function activate(context: vscode.ExtensionContext, perfStats: { lo
});

const tenantResourcesBranchDataItemCache = new BranchDataItemCache();
const tenantResourceTreeDataProvider = registerTenantTree(context, {
registerTenantTree(context, {
tenantResourceProviderManager,
tenantResourceBranchDataProviderManager,
refreshEvent: refreshTenantTreeEmitter.event,
Expand All @@ -173,7 +173,7 @@ export async function activate(context: vscode.ExtensionContext, perfStats: { lo
azureResourceTreeDataProvider,
workspaceResourceProviderManager,
workspaceResourceBranchDataProviderManager,
workspaceResourceTreeDataProvider
workspaceResourceTreeDataProvider,
),
activity: {
registerActivity
Expand All @@ -188,7 +188,6 @@ export async function activate(context: vscode.ExtensionContext, perfStats: { lo

ext.appResourceTree = new CompatibleAzExtTreeDataProvider(azureResourceTreeDataProvider);
ext.workspaceTree = new CompatibleAzExtTreeDataProvider(workspaceResourceTreeDataProvider);
ext.tenantTree = new CompatibleAzExtTreeDataProvider(tenantResourceTreeDataProvider);

const getSubscriptions: (filter: boolean) => Promise<AzureSubscription[]> =
async (filter: boolean) => { return await (await getAzureSubscriptionProvider(azureResourceTreeDataProvider)).getSubscriptions(filter) };
Expand Down
1 change: 0 additions & 1 deletion src/extensionVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export namespace ext {
// TODO: do we need this? only used by load more command
export let workspaceTree: AzExtTreeDataProvider;
export let workspaceTreeView: TreeView<unknown>;
export let tenantTree: AzExtTreeDataProvider;
export let tenantTreeView: TreeView<unknown>
export let activityLogTree: AzExtTreeDataProvider;
export let activityLogTreeItem: ActivityLogTreeItem;
Expand Down
60 changes: 32 additions & 28 deletions src/tree/OnGetChildrenBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,40 @@ export async function OnGetChildrenBase(subscriptionProvider: AzureSubscriptionP

if (subscriptionProvider) {
if (isLoggingIn()) {
return [new GenericItem(
localize('signingIn', 'Waiting for Azure sign-in...'),
{
commandId: 'azureResourceGroups.logIn',
iconPath: new vscode.ThemeIcon('loading~spin')
}
)];
} else if (!(await subscriptionProvider.isSignedIn())) {
children.push(new GenericItem(
localize('signInLabel', 'Sign in to Azure...'),
{
commandId: 'azureResourceGroups.logIn',
iconPath: new vscode.ThemeIcon('sign-in')
}
));
if (tdp) {
children.push(new GenericItem(
localize('createAccountLabel', 'Create an Azure Account...'),
return [
new GenericItem(
localize('signingIn', 'Waiting for Azure sign-in...'),
{
commandId: 'azureResourceGroups.openUrl',
commandArgs: ['https://aka.ms/VSCodeCreateAzureAccount'],
iconPath: new vscode.ThemeIcon('add')
}));
children.push(new GenericItem(
localize('createStudentAccount', 'Create an Azure for Students Account...'),
commandId: 'azureResourceGroups.logIn',
iconPath: new vscode.ThemeIcon('loading~spin')
}
)];
} else if (!(await subscriptionProvider.isSignedIn())) {
children.push(
new GenericItem(
localize('signInLabel', 'Sign in to Azure...'),
{
commandId: 'azureResourceGroups.openUrl',
commandArgs: ['https://aka.ms/student-account'],
iconPath: new vscode.ThemeIcon('mortar-board')
}));
commandId: 'azureResourceGroups.logIn',
iconPath: new vscode.ThemeIcon('sign-in')
}
));
if (tdp) {
children.push(
new GenericItem(
localize('createAccountLabel', 'Create an Azure Account...'),
{
commandId: 'azureResourceGroups.openUrl',
commandArgs: ['https://aka.ms/VSCodeCreateAzureAccount'],
iconPath: new vscode.ThemeIcon('add')
}));
children.push(
new GenericItem(
localize('createStudentAccount', 'Create an Azure for Students Account...'),
{
commandId: 'azureResourceGroups.openUrl',
commandArgs: ['https://aka.ms/student-account'],
iconPath: new vscode.ThemeIcon('mortar-board')
}));
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/tree/azure/AzureResourceTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class AzureResourceTreeDataProvider extends AzureResourceTreeDataProvider
return await element.getChildren();
} else {
const subscriptionProvider = await getAzureSubscriptionProvider(this);
// When a user is signed in 'OnGetChildrenBase' will return the no children
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// When a user is signed in 'OnGetChildrenBase' will return the no children
// When a user is signed in 'OnGetChildrenBase' will return no children

const children: ResourceGroupsItem[] = await OnGetChildrenBase(subscriptionProvider, this);

if (children.length === 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/tree/tenants/registerTenantTree.ts
alexweininger marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function registerTenantTree(context: vscode.ExtensionContext, options: Re
new TenantResourceTreeDataProvider(tenantResourceBranchDataProviderManager, tenantResourceBranchDataProviderManager.onDidChangeTreeData, refreshEvent, tenantResourceProviderManager, itemCache);
context.subscriptions.push(tenantResourceTreeDataProvider);

const treeView = createTreeView('azureTenant', {
const treeView = createTreeView('azureTenantsView', {
canSelectMany: true,
showCollapseAll: true,
itemCache,
Expand Down Expand Up @@ -60,7 +60,7 @@ async function updateTenantsSetting(_context: IActionContext, tenants: vscode.Tr
} else if (state === vscode.TreeItemCheckboxState.Checked) {
const treeItem = await tenantTreeItem.getTreeItem();
if (treeItem?.contextValue === 'tenantNameNotSignedIn') {
await vscode.commands.executeCommand('azureTenant.signInToTenant', tenantTreeItem, tenantTreeItem.account);
await vscode.commands.executeCommand('azureTenantsView.signInToTenant', tenantTreeItem, tenantTreeItem.account);
ext.actions.refreshTenantTree();
}
unselectedTenantsSet.delete(getKeyForTenant(tenantTreeItem.tenantId, tenantTreeItem.account.id));
Expand Down
Loading