From 7085854756fd6ca1924a136dcb32e1c9b7e710fc Mon Sep 17 00:00:00 2001 From: Ravikumar Palanisamy Date: Mon, 20 Apr 2020 16:53:50 -0700 Subject: [PATCH] Group containers by compose project name (#1876) * Group containers by compose project name * localize description * Update src/tree/containers/ContainerProperties.ts Co-Authored-By: Brandon Waterloo [MSFT] <36966225+bwateratmsft@users.noreply.github.com> Co-authored-by: Brandon Waterloo [MSFT] <36966225+bwateratmsft@users.noreply.github.com> --- package.json | 3 +++ src/tree/LocalRootTreeItemBase.ts | 8 +++---- src/tree/containers/ContainerGroupTreeItem.ts | 1 + src/tree/containers/ContainerProperties.ts | 6 +++-- src/tree/containers/ContainersTreeItem.ts | 22 ++++++++++++++++++- src/tree/containers/LocalContainerInfo.ts | 15 +++++++++++++ 6 files changed, 48 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index b613737111..6a6421f0ac 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 +17,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: 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 { diff --git a/src/tree/containers/ContainersTreeItem.ts b/src/tree/containers/ContainersTreeItem.ts index 45821c6c2f..b6914de968 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,28 @@ 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;