Azure / api-management-developer-portal

Developer portal provided by the Azure API Management service.
MIT License
479 stars 307 forks source link

Custom widgets - send location info of the main window to widgets #2284

Closed girish-tank-avnet closed 3 months ago

girish-tank-avnet commented 10 months ago

Hello @JMach1 before 1 month i had create a ticket regarding access parent page URL in azure APIM custom widget and you got resolved it by adding "parentLocation" property in Secret object.

Here is the old ticket/PR reference: [PR reference] (https://github.com/Azure/api-management-developer-portal/pull/2238) [Code commit URL] (https://github.com/Azure/api-management-developer-portal/commit/e873140222c72ed780ce06542ea7b3ebfce8dc94)

i saw that this change (adding parentLocation) has been merged into master branch in developer portal v2.24.0 and i think this developer portal version has been deployed but i am not able to get these changes in my custom widget code.

so, would you please let me know how can i get this change? is there any packages needs to be update in my custom widget source code?

@azure/api-management-custom-widgets-scaffolder npm package is used for communicating developer portal to get secret information and i have its latest version (1.0.0-beta.2) installed in my custom widget source code.

please let me know how can in get change that you have done in developer portal in my custom widget source code.

i am going to attach an image of get secret call in which you can see "parentLocation" URL property is not there.

image

Thanks in advance.

JMach1 commented 10 months ago

Hello, AFAIK Dev Portal release was rolled back because of some regressions, so it's still not there, @malincrist please correct me if I'm wrong. There is a release of the @azure/api-management-custom-widgets-tools package in progress as well, but it's not necessary for getting the new functionality going. With old version, you'll just need to add ts-ignore because of missing type, but the data should be coming, once the Dev Portal is released.

girish-tank-avnet commented 10 months ago

@JMach1, thanks for instant reply !!!!.

@malincrist , do you have any idea about release of developer portal with above mentioned change?

Thanks.

malincrist commented 10 months ago

Hi @girish-tank-avnet , unfortunately, the release was postponed. The new ETA is mid-September. Apologies for the delay.

girish-tank-avnet commented 10 months ago

Hi @malincrist. no problem. just 1 thing i need to know that how can i know once release will be done in the mid of September.?

is there any facility like i can receive an email or anything else?

girish-tank-avnet commented 9 months ago

Hello @malincrist and @JMach1 is there any update for when developer portal will be deployed with mentioned changes in this ticket? as now this is end of the September and this change is not on current deployed developer portal.

malincrist commented 9 months ago

Hello @girish-tank-avnet , the deployment is in progress, please give it a few days to reach all the regions. Apologies for the delay.

girish-tank-avnet commented 9 months ago

@malincrist Thank you very much for giving update!!!!!!!!

girish-tank-avnet commented 8 months ago

Hello @malincrist

should i know the progress of developer portal release if you have any information for the same?

Thanks in Advance......

malincrist commented 8 months ago

Hello @girish-tank-avnet , unfortunately, the deployment was cancelled due to found regressions. The new ETA for the release is 1 week. Apologies for the delay and the inconveniences caused by this.

girish-tank-avnet commented 8 months ago

Hello @JMach1 and @malincrist

first of all thanks for you all effort to keep me updated for developer portal deployment. we have received new portal changes what we need. but when i was doing code in my application i found one major issue in secret payload that we received from management portal.

there is a property added in secret payload namely "parentLocation" that was a change we want.

but now after new changes, property "managementApiURL" gives the value "/mapi" instead of full managementApiURL like "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"

we are use this managementApiUrl for calling management Api for getting user and subscription details but now the due to not getting correct value our whole functionality has been broken and not working even on production environment too.

i just want to know that is this change i.e. getting "/mapi" value in managementApiURL property instead of full value intentionally changed or it is a defect in new release?

if it is defect in new release then is there any chances to rollback of developer portal deployment from our APIM instances?

please find the image which shows the issue.

image

Please let me know your thought as soon as possible as it impacted our application process.

Thanks, Girish.

girish-tank-avnet commented 8 months ago

@JMach1 is there any option to navigate other page by assigning a URL to parent page 's address bar from custom widget?

i got the "parentLocation" property from secrets object and do process the product subscription. after done product subscription, i need to navigate to profile page to show all product subscription of logged-in user.

so i need to assign https:///profile URL to window.partent.location.href from custom widget but as custom widget is rendered in restricted iFrame, i cannot do this and got cross origin error.

image

please do needful.

Thanks, Girish

JMach1 commented 8 months ago

@girish-tank-avnet regarding the first issue, on my latest portal version, I was not able to reproduce it unfortunately. Is it still happening, did you try to update the "tools" dependency package of your custom widget?

Regarding the second issue, how are you managing the redirect? For me this works just fine: <a target="_parent" href="https://jm-apim.developer.azure-api.net/profile">profile</a>

girish-tank-avnet commented 8 months ago

@JMach1 Thanks for replying to my query.

for 1st issue: i have update @azure/api-management-custom-widgets-tools to latest version as you suggested but still i am getting same value in "managementApiUrl" i.e "/mapi".

before latest deployment of developer portal, I was getting full URL as i mentioned in my previous comment(https://management.azure.com/subscriptions/%7BsubscriptionId%7D/resourceGroups/%7BresourceGroupName%7D/providers/Microsoft.ApiManagement/service/%7BserviceName%7D )

i have attached image of secrets values which i have got from hook.ts file.

image

JMach1 commented 8 months ago

You are correct, I reproduced the issue, thank you for reporting it! Could you try to send requests to ${secrets.parentLocation.origin}${secrets.managementApiUrl}... (with valid api version at the end, so it will look for example something like https://-------.azure-api.net/mapi/apis?api-version=2021-08-01) In the React example, you can modify the useRequest custom hook to ${secrets.parentLocation.origin}${secrets.managementApiUrl}${url}?api-version=${secrets.apiVersion}. It's only workaround, we'll fix it properly ASAP.

girish-tank-avnet commented 8 months ago

Welcome.... @JMach1... i have 1 queries over here. as issue is found, have you guys any plan to rollback developer portal to previous version which does not have "parentLocation" property?

we don't want to rollback developer portal to previous version. please let us know if you are planning to do.

JMach1 commented 8 months ago

I would like to avoid rollback as well but I can promise you that, it depends what incident manager decide later.

Just to be sure, did the workaround resolved your issue?

girish-tank-avnet commented 8 months ago

Hello @JMach1 ,

yes, i have resolved my issue by replacing managementAPIUrl manually after getting secrets from management portal.