Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 92c4450

Browse files
authored
feat/dotcom: show subscription UUID in Enterprise Portal format (#63482)
The current "name" thing is not used anywhere for subscriptions - all internal capabilities and APIs depend use the UUID, and Enterprise Portal will use the UUID as well. This change replaces all name/IDs with the UUID, prefixed in Enterprise Portal format, as we prepare to launch Enterprise Portal in more places (such as Cody Analytics: https://linear.app/sourcegraph/issue/CORE-101). This is particularly relevant for Cody Analytics so I can document how to find the UUID in a way that isn't "get it from the URL". It's not super beautiful in the subscriptions list, but as we progress on the migration to Enterprise Portal I plan to replace the ID in the list with "Display name", which is a first-class citizen in Enterprise Portal. ## Test plan <img width="953" alt="image" src="https://github.com/sourcegraph/sourcegraph/assets/23356519/30c4ae6b-e50b-485c-a2c8-e4ab6445fc01"> ![image](https://github.com/sourcegraph/sourcegraph/assets/23356519/cca8e6d1-2e20-4954-8f72-7694ad1d8bfa)
1 parent b79cf5b commit 92c4450

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

client/web/src/enterprise/site-admin/dotcom/productSubscriptions/SiteAdminProductSubscriptionNode.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { AccountName } from '../../../dotcom/productSubscriptions/AccountName'
88
import { ProductSubscriptionLabel } from '../../../dotcom/productSubscriptions/ProductSubscriptionLabel'
99
import { ProductLicenseTags } from '../../../productSubscription/ProductLicenseTags'
1010

11+
import { enterprisePortalID } from './utils'
12+
1113
export const SiteAdminProductSubscriptionNodeHeader: React.FunctionComponent<React.PropsWithChildren<unknown>> = () => (
1214
<thead>
1315
<tr>
@@ -31,9 +33,9 @@ export const SiteAdminProductSubscriptionNode: React.FunctionComponent<
3133
React.PropsWithChildren<SiteAdminProductSubscriptionNodeProps>
3234
> = ({ node }) => (
3335
<tr>
34-
<td className="text-nowrap">
36+
<td>
3537
<LinkOrSpan to={node.urlForSiteAdmin} className="mr-3">
36-
{node.name}
38+
{enterprisePortalID(node.uuid)}
3739
</LinkOrSpan>
3840
</td>
3941
<td className="w-100">

client/web/src/enterprise/site-admin/dotcom/productSubscriptions/SiteAdminProductSubscriptionPage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
import { CodyServicesSection } from './CodyServicesSection'
3939
import { SiteAdminGenerateProductLicenseForSubscriptionForm } from './SiteAdminGenerateProductLicenseForSubscriptionForm'
4040
import { SiteAdminProductLicenseNode } from './SiteAdminProductLicenseNode'
41-
import { accessTokenPath, errorForPath } from './utils'
41+
import { accessTokenPath, errorForPath, enterprisePortalID } from './utils'
4242

4343
interface Props extends TelemetryV2Props {}
4444

@@ -130,7 +130,7 @@ export const SiteAdminProductSubscriptionPage: React.FunctionComponent<React.Pro
130130
headingElement="h2"
131131
path={[
132132
{ text: 'Enterprise subscriptions', to: '/site-admin/dotcom/product/subscriptions' },
133-
{ text: productSubscription.name },
133+
{ text: enterprisePortalID(subscriptionUUID) },
134134
]}
135135
description={
136136
<span className="text-muted">
@@ -152,7 +152,7 @@ export const SiteAdminProductSubscriptionPage: React.FunctionComponent<React.Pro
152152
<tbody>
153153
<tr>
154154
<th className="text-nowrap">ID</th>
155-
<td className="w-100">{productSubscription.name}</td>
155+
<td className="w-100">{enterprisePortalID(subscriptionUUID)}</td>
156156
</tr>
157157
<tr>
158158
<th className="text-nowrap">Current Plan</th>

client/web/src/enterprise/site-admin/dotcom/productSubscriptions/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,11 @@ export function errorForPath(error: ApolloError | undefined, path: (string | num
4242
export const accessTokenPath = ['dotcom', 'productSubscription', 'currentSourcegraphAccessToken']
4343

4444
export const numberFormatter = new Intl.NumberFormat()
45+
46+
/**
47+
* Prefixes the ID with subscriptionsv1.EnterpriseSubscriptionIDPrefix to get
48+
* the Enterprise Portal external subscription UUID format.
49+
*/
50+
export function enterprisePortalID(id: string): string {
51+
return `es_${id}`
52+
}

0 commit comments

Comments
 (0)