Skip to content

Commit 2256ffc

Browse files
committed
Changes order of GitHub.com and GitHub Enterprise in the dropdown list
(#3901)
1 parent afb8a28 commit 2256ffc

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

src/constants.integrations.ts

+3
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,22 @@ export interface IntegrationDescriptor {
3939
name: string;
4040
icon: string;
4141
supports: IntegrationFeatures[];
42+
weight?: number;
4243
}
4344
export const supportedCloudIntegrationDescriptors: IntegrationDescriptor[] = [
4445
{
4546
id: HostingIntegrationId.GitHub,
4647
name: 'GitHub',
4748
icon: 'gl-provider-github',
4849
supports: ['prs', 'issues'],
50+
weight: 1,
4951
},
5052
{
5153
id: SelfHostedIntegrationId.CloudGitHubEnterprise,
5254
name: 'GitHub Enterprise',
5355
icon: 'gl-provider-github',
5456
supports: ['prs', 'issues'],
57+
weight: 0,
5558
},
5659
{
5760
id: HostingIntegrationId.GitLab,

src/webviews/home/homeWebview.ts

+17-8
Original file line numberDiff line numberDiff line change
@@ -830,22 +830,31 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
830830
);
831831

832832
const integrationsResults = await Promise.allSettled(promises);
833-
const integrations = [...filterMap(integrationsResults, r => getSettledValue(r))];
833+
const integrations: IntegrationState[] = [...filterMap(integrationsResults, r => getSettledValue(r))];
834834

835835
this._defaultSupportedCloudIntegrations ??= supportedCloudIntegrationDescriptors.map(d => ({
836836
...d,
837837
connected: false,
838838
}));
839839

840840
// union (uniquely by id) with supportedCloudIntegrationDescriptors
841-
integrations.push(
842-
...this._defaultSupportedCloudIntegrations.filter(d => !integrations.some(i => i.id === d.id)),
843-
);
844-
integrations.sort(
845-
(a, b) =>
841+
this._defaultSupportedCloudIntegrations.forEach(d => {
842+
const i = integrations.find(i => i.id === d.id);
843+
if (i == null) {
844+
integrations.push(d);
845+
} else if (d.weight !== undefined) {
846+
i.weight = d.weight;
847+
}
848+
});
849+
integrations.sort((a, b) => {
850+
if (a.weight !== undefined && b.weight !== undefined) {
851+
return -(a.weight - b.weight);
852+
}
853+
return (
846854
supportedOrderedCloudIntegrationIds.indexOf(a.id) -
847-
supportedOrderedCloudIntegrationIds.indexOf(b.id),
848-
);
855+
supportedOrderedCloudIntegrationIds.indexOf(b.id)
856+
);
857+
});
849858

850859
this._integrationStates = integrations;
851860
}

0 commit comments

Comments
 (0)