Skip to content

Commit

Permalink
Added Back Open Docker Hub Item in Browser (#4033)
Browse files Browse the repository at this point in the history
* added view docker hub item in browser command

* updated npm package

* Added More Commands Back (#4031)

* adjusted scheduleRunReuqest to work with new registries tree

* delete azure repository command implementation

* actually added back delete azure repository

* added back delete Azure Registry command

* changed registry tree util file name to be more general

* added openInAzurePortalCommand

* added back create azure registry command

* move createAzureClient to azureUtils

* added viewAzureProperties command back (partially)

* small tweak to make build image in azure work

* added untag azure image commad

* added logout of docker cli command

* add case sensitivity operator to be consistent

* Update src/tree/registries/Azure/AzureRegistryDataProvider.ts

Co-authored-by: Brandon Waterloo [MSFT] <[email protected]>

* added void

* removed symbol as it already exists

---------

Co-authored-by: Brandon Waterloo [MSFT] <[email protected]>

* minor tweak to avoid index out of bounds

* use built in methods to determine the type of item

---------

Co-authored-by: Brandon Waterloo [MSFT] <[email protected]>
  • Loading branch information
alexyaang and bwateratmsft authored Aug 11, 2023
1 parent bdac083 commit c967595
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@
},
{
"command": "vscode-docker.registries.dockerHub.openInBrowser",
"when": "view == dockerRegistries && viewItem =~ /dockerHub;DockerHubV2;(Tag|Repository|Registry);/",
"when": "view == dockerRegistries && viewItem =~ /(dockerHubRegistry|dockerHubRepository|dockerHubTag)/i",
"group": "regs_zzz_common@1"
},
{
Expand Down
3 changes: 2 additions & 1 deletion src/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import { viewAzureProperties } from "./registries/azure/viewAzureProperties";
import { copyRemoteFullTag } from "./registries/copyRemoteFullTag";
import { copyRemoteImageDigest } from "./registries/copyRemoteImageDigest";
import { disconnectRegistry } from "./registries/disconnectRegistry";
import { openDockerHubInBrowser } from "./registries/dockerHub/openDockerHubInBrowser";
import { logInToDockerCli } from "./registries/logInToDockerCli";
import { logOutOfDockerCli } from "./registries/logOutOfDockerCli";
import { pullImageFromRepository, pullRepository } from "./registries/pullImages";
Expand Down Expand Up @@ -186,7 +187,7 @@ export function registerCommands(): void {
registerWorkspaceCommand('vscode-docker.registries.pullRepository', pullRepository);
// registerCommand('vscode-docker.registries.reconnectRegistry', reconnectRegistry);

// registerCommand('vscode-docker.registries.dockerHub.openInBrowser', openDockerHubInBrowser);
registerCommand('vscode-docker.registries.dockerHub.openInBrowser', openDockerHubInBrowser);

registerWorkspaceCommand('vscode-docker.registries.azure.buildImage', buildImageInAzure);
registerCommand('vscode-docker.registries.azure.createRegistry', createAzureRegistry);
Expand Down
52 changes: 27 additions & 25 deletions src/commands/registries/dockerHub/openDockerHubInBrowser.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
// /*---------------------------------------------------------------------------------------------
// * Copyright (c) Microsoft Corporation. All rights reserved.
// * Licensed under the MIT License. See LICENSE.md in the project root for license information.
// *--------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

// import { IActionContext, contextValueExperience } from "@microsoft/vscode-azext-utils";
// import * as vscode from "vscode";
// import { ext } from "../../../extensionVariables";
// import { UnifiedRegistryItem } from "../../../tree/registries/UnifiedRegistryTreeDataProvider";
import { IActionContext, contextValueExperience } from "@microsoft/vscode-azext-utils";
import { CommonRegistryItem, isRegistry, isRepository, isTag } from "@microsoft/vscode-docker-registries";
import * as vscode from "vscode";
import { dockerHubUrl } from "../../../constants";
import { ext } from "../../../extensionVariables";
import { UnifiedRegistryItem } from "../../../tree/registries/UnifiedRegistryTreeDataProvider";

// export async function openDockerHubInBrowser(context: IActionContext, node?: UnifiedRegistryItem<unknown>): Promise<void> {
// if (!node) {
// node = await contextValueExperience(context, ext.registriesRoot, { include: 'dockerhubregistry' });
// }
export async function openDockerHubInBrowser(context: IActionContext, node?: UnifiedRegistryItem<CommonRegistryItem>): Promise<void> {
if (!node) {
node = await contextValueExperience(context, ext.registriesRoot, { include: ['dockerHubRegistry', 'dockerHubRepository', 'dockerHubTag'] });
}

// let url = dockerHubUrl;
// if (node instanceof DockerHubNamespaceTreeItem) {
// url += `u/${node.namespace}`;
// } else if (node instanceof DockerHubRepositoryTreeItem) {
// url += `r/${node.parent.namespace}/${node.repoName}`;
// } else {
// const repoTI = <DockerHubRepositoryTreeItem>node.parent;
// url += `r/${repoTI.parent.namespace}/${repoTI.repoName}/tags`;
// }
let url = dockerHubUrl;
const dockerHubItem = node.wrappedItem;

// const url = '';
// // TODO: review this later
if (isRegistry(dockerHubItem)) {
url = `${url}u/${dockerHubItem.label}`;
} else if (isRepository(dockerHubItem)) {
url = `${url}r/${dockerHubItem.parent.label}/${dockerHubItem.label}`;
} else if (isTag(dockerHubItem)) {
url = `${url}r/${dockerHubItem.parent.parent.label}/${dockerHubItem.parent.label}/tags`;
} else {
throw new Error(`Unexpected node type ${dockerHubItem.additionalContextValues || ''}`);
}

// await vscode.env.openExternal(vscode.Uri.parse(url));
// }
await vscode.env.openExternal(vscode.Uri.parse(url));
}

0 comments on commit c967595

Please sign in to comment.