Skip to content

Commit 0f3e5fd

Browse files
committed
refactor(ui): improve API name parsing in pricing and test components
1 parent 0acda80 commit 0f3e5fd

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/ui/src/components/pricing-layout/PricingLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ const PricingLayout = (): React.JSX.Element => {
433433
entry.units.forEach((unit) => {
434434
items.push({
435435
apiName: entry.name,
436-
displayName: entry.name.split('/')[1] || entry.name,
436+
displayName: entry.name.includes('/') ? entry.name.split('/').slice(1).join('/') : entry.name,
437437
unitName: unit.name,
438438
price: unit.price,
439439
});

src/ui/src/components/test-studio/TestComparison.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ const TestComparison = ({ preSelectedTestRunIds = [] }: TestComparisonProps): Re
356356
const lastUnderscoreIndex = serviceUnit.lastIndexOf('_');
357357
const serviceApi = serviceUnit.substring(0, lastUnderscoreIndex);
358358
const unit = serviceUnit.substring(lastUnderscoreIndex + 1);
359-
const [service, api] = serviceApi.split('/');
359+
const [service, ...apiParts] = serviceApi.split('/');
360+
const api = apiParts.join('/');
360361
allCostItems.add(`${context}|${service}/${api}|${unit}`);
361362
});
362363
});
@@ -1257,7 +1258,8 @@ const TestComparison = ({ preSelectedTestRunIds = [] }: TestComparisonProps): Re
12571258
const lastUnderscoreIndex = serviceUnit.lastIndexOf('_');
12581259
const serviceApi = serviceUnit.substring(0, lastUnderscoreIndex);
12591260
const unit = serviceUnit.substring(lastUnderscoreIndex + 1);
1260-
const [service, api] = serviceApi.split('/');
1261+
const [service, ...apiParts] = serviceApi.split('/');
1262+
const api = apiParts.join('/');
12611263
allCostItems.add(`${context}|${service}/${api}|${unit}`);
12621264
});
12631265
});
@@ -1421,7 +1423,8 @@ const TestComparison = ({ preSelectedTestRunIds = [] }: TestComparisonProps): Re
14211423
const lastUnderscoreIndex = serviceUnit.lastIndexOf('_');
14221424
const serviceApi = serviceUnit.substring(0, lastUnderscoreIndex);
14231425
const unit = serviceUnit.substring(lastUnderscoreIndex + 1);
1424-
const [service, api] = serviceApi.split('/');
1426+
const [service, ...apiParts] = serviceApi.split('/');
1427+
const api = apiParts.join('/');
14251428
allUsageItems.add(`${context}|${service}/${api}|${unit}`);
14261429
});
14271430
});

src/ui/src/components/test-studio/TestResults.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ const ComprehensiveBreakdown = ({
217217
const lastUnderscoreIndex = serviceUnit.lastIndexOf('_');
218218
const serviceApi = serviceUnit.substring(0, lastUnderscoreIndex);
219219
const unit = serviceUnit.substring(lastUnderscoreIndex + 1);
220-
const [service, api] = serviceApi.split('/');
220+
const [service, ...apiParts] = serviceApi.split('/');
221+
const api = apiParts.join('/');
221222

222223
const cost = (details.estimated_cost as number) || 0;
223224
contextSubtotal += cost;

0 commit comments

Comments
 (0)