From b30252021bba7842a27da631fd6294750da4b708 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Fri, 27 Sep 2019 07:45:37 -0700 Subject: [PATCH] Sort endpoints (#7402) --- .../dialog/bdcDashboardOverviewPage.ts | 12 ++++++++++++ extensions/mssql/src/dashboard/serviceEndpoints.ts | 9 ++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardOverviewPage.ts b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardOverviewPage.ts index 1c0a49f17a..dd8a625b09 100644 --- a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardOverviewPage.ts +++ b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardOverviewPage.ts @@ -205,6 +205,18 @@ export class BdcDashboardOverviewPage { } this.endpointsRowContainer.clearItems(); + + // Sort the endpoints. The sort method is that SQL Server Master is first - followed by all + // others in alphabetical order by endpoint + const sqlServerMasterEndpoints = endpoints.filter(e => e.name === Endpoint.sqlServerMaster); + endpoints = endpoints.filter(e => e.name !== Endpoint.sqlServerMaster) + .sort((e1, e2) => { + if (e1.endpoint < e2.endpoint) { return -1; } + if (e1.endpoint > e2.endpoint) { return 1; } + return 0; + }); + endpoints.unshift(...sqlServerMasterEndpoints); + endpoints.forEach((e, i) => { createServiceEndpointRow(this.modelBuilder, this.endpointsRowContainer, e, this.model, hyperlinkedEndpoints.some(he => he === e.name), i === endpoints.length - 1); }); diff --git a/extensions/mssql/src/dashboard/serviceEndpoints.ts b/extensions/mssql/src/dashboard/serviceEndpoints.ts index 81eceebc66..8395d79c13 100644 --- a/extensions/mssql/src/dashboard/serviceEndpoints.ts +++ b/extensions/mssql/src/dashboard/serviceEndpoints.ts @@ -56,7 +56,14 @@ export function registerServiceEndpoints(context: vscode.ExtensionContext): void endpointsArray = endpointsArray.map(e => { e.description = getEndpointDisplayText(e.serviceName, e.description); return e; - }).sort((a, b) => a.endpoint.localeCompare(b.endpoint)); + }); + + // Sort the endpoints. The sort method is that SQL Server Master is first - followed by all + // others in alphabetical order by endpoint + const sqlServerMasterEndpoints = endpointsArray.filter(e => e.serviceName === Endpoint.sqlServerMaster); + endpointsArray = endpointsArray.filter(e => e.serviceName !== Endpoint.sqlServerMaster) + .sort((e1, e2) => e1.endpoint.localeCompare(e2.endpoint)); + endpointsArray.unshift(...sqlServerMasterEndpoints); const container = view.modelBuilder.flexContainer().withLayout({ flexFlow: 'column', width: '100%', height: '100%', alignItems: 'left' }).component(); endpointsArray.forEach(endpointInfo => {