From 27aebecb764f4df470a090c0b744e046484c789b Mon Sep 17 00:00:00 2001 From: Ravikumar Palanisamy Date: Thu, 16 Apr 2020 13:07:10 -0700 Subject: [PATCH 1/3] Group containers by compose project name --- package.json | 3 +++ src/tree/LocalRootTreeItemBase.ts | 8 ++++---- src/tree/containers/ContainerGroupTreeItem.ts | 1 + src/tree/containers/ContainerProperties.ts | 5 +++-- src/tree/containers/ContainersTreeItem.ts | 20 ++++++++++++++++++- src/tree/containers/LocalContainerInfo.ts | 15 ++++++++++++++ 6 files changed, 45 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index db13b78afc..5692e781e1 100644 --- a/package.json +++ b/package.json @@ -1572,6 +1572,7 @@ "default": "None", "description": "%vscode-docker.config.docker.containers.groupBy%", "enum": [ + "Compose Project Name", "ContainerId", "ContainerName", "CreatedTime", @@ -1599,6 +1600,7 @@ "items": { "type": "string", "enum": [ + "Compose Project Name", "ContainerId", "ContainerName", "CreatedTime", @@ -1621,6 +1623,7 @@ "default": "FullTag", "description": "%vscode-docker.config.docker.containers.label%", "enum": [ + "Compose Project Name", "ContainerId", "ContainerName", "CreatedTime", diff --git a/src/tree/LocalRootTreeItemBase.ts b/src/tree/LocalRootTreeItemBase.ts index 7084fef288..5f49fe5b76 100644 --- a/src/tree/LocalRootTreeItemBase.ts +++ b/src/tree/LocalRootTreeItemBase.ts @@ -53,10 +53,10 @@ export abstract class LocalRootTreeItemBase[] = [ ...imageProperties, @@ -16,7 +16,8 @@ export const containerProperties: ITreePropertyInfo[] = [ { property: 'Networks', exampleValue: 'mybridge_network' }, { property: 'Ports', exampleValue: '8080' }, { property: 'State', exampleValue: 'exited' }, - { property: 'Status', exampleValue: 'Exited (0) 2 hours ago' } + { property: 'Status', exampleValue: 'Exited (0) 2 hours ago' }, + { property: 'Compose Project Name', description: 'Value used to associate containers launched by a \'compose up\' command' }, ]; export function getContainerStateIcon(state: string): IconPath { diff --git a/src/tree/containers/ContainersTreeItem.ts b/src/tree/containers/ContainersTreeItem.ts index 45821c6c2f..9377a8e46e 100644 --- a/src/tree/containers/ContainersTreeItem.ts +++ b/src/tree/containers/ContainersTreeItem.ts @@ -13,7 +13,7 @@ import { ITreeArraySettingInfo, ITreeSettingInfo } from "../settings/ITreeSettin import { ContainerGroupTreeItem } from "./ContainerGroupTreeItem"; import { containerProperties, ContainerProperty } from "./ContainerProperties"; import { ContainerTreeItem } from "./ContainerTreeItem"; -import { ILocalContainerInfo, LocalContainerInfo } from "./LocalContainerInfo"; +import { ILocalContainerInfo, LocalContainerInfo, NonComposeGroupName } from "./LocalContainerInfo"; export class ContainersTreeItem extends LocalRootTreeItemBase { public treePrefix: string = 'containers'; @@ -67,8 +67,26 @@ export class ContainersTreeItem extends LocalRootTreeItemBase ({ label: label, value: this.data.Labels[label] })); + + const composeProject = labels.find(l => l.label === 'com.docker.compose.project'); + if (composeProject) { + return composeProject.value; + } else { + return NonComposeGroupName; + } + } + public get treeId(): string { // include state in treeId so that auto-refresh will detect and show a new icon when state changes return this.containerId + this.state; From 2033a12050defc39611874acca87bbd664b6ce3d Mon Sep 17 00:00:00 2001 From: Ravikumar Palanisamy Date: Fri, 17 Apr 2020 09:38:07 -0700 Subject: [PATCH 2/3] localize description --- src/tree/containers/ContainerProperties.ts | 3 ++- src/tree/containers/ContainersTreeItem.ts | 4 +++- src/tree/containers/LocalContainerInfo.ts | 8 ++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/tree/containers/ContainerProperties.ts b/src/tree/containers/ContainerProperties.ts index 3ee759c409..790497b771 100644 --- a/src/tree/containers/ContainerProperties.ts +++ b/src/tree/containers/ContainerProperties.ts @@ -3,6 +3,7 @@ * Licensed under the MIT License. See LICENSE.md in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { localize } from "../../localize"; import { getThemedIconPath, IconPath } from "../IconPath"; import { imageProperties, ImageProperty } from "../images/ImageProperties"; import { ITreePropertyInfo } from "../settings/ITreeSettingInfo"; @@ -17,7 +18,7 @@ export const containerProperties: ITreePropertyInfo[] = [ { property: 'Ports', exampleValue: '8080' }, { property: 'State', exampleValue: 'exited' }, { property: 'Status', exampleValue: 'Exited (0) 2 hours ago' }, - { property: 'Compose Project Name', description: 'Value used to associate containers launched by a \'compose up\' command' }, + { property: 'Compose Project Name', description: localize('vscode-docker.tree.containers.properties.composeProjectName', 'Value used to associate containers launched by a \'compose up\' command') }, ]; export function getContainerStateIcon(state: string): IconPath { diff --git a/src/tree/containers/ContainersTreeItem.ts b/src/tree/containers/ContainersTreeItem.ts index 9377a8e46e..b6914de968 100644 --- a/src/tree/containers/ContainersTreeItem.ts +++ b/src/tree/containers/ContainersTreeItem.ts @@ -68,13 +68,15 @@ export class ContainersTreeItem extends LocalRootTreeItemBase ({ label: label, value: this.data.Labels[label] })); From 90b8d646d8427ac6aaafb72208d37e720a3c9e9a Mon Sep 17 00:00:00 2001 From: Ravikumar Palanisamy Date: Mon, 20 Apr 2020 15:49:44 -0700 Subject: [PATCH 3/3] Update src/tree/containers/ContainerProperties.ts Co-Authored-By: Brandon Waterloo [MSFT] <36966225+bwateratmsft@users.noreply.github.com> --- src/tree/containers/ContainerProperties.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tree/containers/ContainerProperties.ts b/src/tree/containers/ContainerProperties.ts index 790497b771..d0d5eded7f 100644 --- a/src/tree/containers/ContainerProperties.ts +++ b/src/tree/containers/ContainerProperties.ts @@ -18,7 +18,7 @@ export const containerProperties: ITreePropertyInfo[] = [ { property: 'Ports', exampleValue: '8080' }, { property: 'State', exampleValue: 'exited' }, { property: 'Status', exampleValue: 'Exited (0) 2 hours ago' }, - { property: 'Compose Project Name', description: localize('vscode-docker.tree.containers.properties.composeProjectName', 'Value used to associate containers launched by a \'compose up\' command') }, + { property: 'Compose Project Name', description: localize('vscode-docker.tree.containers.properties.composeProjectName', 'Value used to associate containers launched by a \'docker-compose up\' command') }, ]; export function getContainerStateIcon(state: string): IconPath {