From 1e0f36236423c39b13c032f7e69d20ed27a8beca Mon Sep 17 00:00:00 2001 From: Igor O Date: Mon, 19 Oct 2020 13:53:41 -0700 Subject: [PATCH 1/2] fixed api scope subscriptions in profile --- src/services/productService.ts | 35 +++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/services/productService.ts b/src/services/productService.ts index 3f02cd83b..be07e8bcd 100644 --- a/src/services/productService.ts +++ b/src/services/productService.ts @@ -10,6 +10,7 @@ import * as Constants from "../constants"; import { Utils } from "../utils"; import { SearchQuery } from "../contracts/searchQuery"; import { SubscriptionSecrets } from "../contracts/subscriptionSecrets"; +import { ApiContract } from "../contracts/api"; /** * A service for management operations with products. @@ -118,19 +119,31 @@ export class ProductService { for (const subscription of subscriptions) { const subscriptionModel = new Subscription(subscription); + if (subscription.properties.scope.endsWith("/apis")) { subscriptionModel.productName = "All APIs"; - } else { - const productName = Utils.getResourceName("products", subscription.properties.scope); - - const productPromise = this.mapiClient - .get(`/products/${productName}`) - .then(product => { - subscriptionModel.productName = product.properties.displayName; - }); - - promises.push(productPromise); - } + } else + if (subscription.properties.scope.indexOf("/apis/") !== -1) { + const apiName = Utils.getResourceName("apis", subscription.properties.scope); + + const apiPromise = this.mapiClient + .get(`/apis/${apiName}`) + .then(api => { + subscriptionModel.productName = `API: ${api.properties.displayName}`; + }); + + promises.push(apiPromise); + } else { + const productName = Utils.getResourceName("products", subscription.properties.scope); + + const productPromise = this.mapiClient + .get(`/products/${productName}`) + .then(product => { + subscriptionModel.productName = product.properties.displayName; + }); + + promises.push(productPromise); + } const secretPromise = this.mapiClient .post(`${userId}/subscriptions/${subscription.name}/listSecrets`) From b107bae5de15f380f47dce7092cbe3ef67be99da Mon Sep 17 00:00:00 2001 From: Igor O Date: Mon, 19 Oct 2020 14:00:51 -0700 Subject: [PATCH 2/2] small fix --- src/services/productService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/productService.ts b/src/services/productService.ts index be07e8bcd..0b7d8204d 100644 --- a/src/services/productService.ts +++ b/src/services/productService.ts @@ -123,7 +123,7 @@ export class ProductService { if (subscription.properties.scope.endsWith("/apis")) { subscriptionModel.productName = "All APIs"; } else - if (subscription.properties.scope.indexOf("/apis/") !== -1) { + if (subscription.properties.scope.includes("/apis/")) { const apiName = Utils.getResourceName("apis", subscription.properties.scope); const apiPromise = this.mapiClient