Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppSource Gallery follow-up fixes #586

Merged
merged 50 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
87bdee7
Fixes and create json utilities codeunit
blrobl Feb 12, 2024
aa7cbb3
Coduenit for language and market functionality
blrobl Feb 12, 2024
a12ff70
Use Pascal casing
blrobl Feb 12, 2024
a06c3cd
code review
blrobl Feb 12, 2024
6649ee7
Move Open App Source action to page lvl
blrobl Feb 13, 2024
e09791b
fix
blrobl Feb 13, 2024
e41630c
Several minor fixes
blrobl Feb 13, 2024
ef956da
Merge branch 'main' of https://github.com/microsoft/BCApps into priva…
SBalslev Feb 14, 2024
27a6274
Catch if princingTypes does not exist
SBalslev Feb 14, 2024
2e1dbe8
Do nto show publisher type by default.
SBalslev Feb 14, 2024
39fb63a
Clean unused vars
SBalslev Feb 14, 2024
f59ccaa
Rename file to match object name
SBalslev Feb 14, 2024
cf3beef
Remove unused variables, make rating count visible and reorganize col…
SBalslev Feb 14, 2024
ef99fff
Update test to reflect rename of method
SBalslev Feb 14, 2024
4d0dc92
Rename field caption
SBalslev Feb 14, 2024
82160fc
Rename parameter to avoid name conflict
SBalslev Feb 14, 2024
e3ff597
fix
blrobl Feb 14, 2024
e81e95e
set focus on the top of the page by findset
SBalslev Feb 14, 2024
ec57367
Ensure dependency is interface after refactoring.
SBalslev Feb 14, 2024
e842a1b
Eula
blrobl Feb 14, 2024
04dd108
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
blrobl Feb 14, 2024
eec267a
Update test after refactoring
SBalslev Feb 14, 2024
0688d6a
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
SBalslev Feb 14, 2024
2e2bb39
Update casing
SBalslev Feb 14, 2024
4904f33
fix
blrobl Feb 14, 2024
e100abb
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
blrobl Feb 14, 2024
448157b
Update to use UriBuilder.AddODataQueryParameter
SBalslev Feb 15, 2024
2f38ac5
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
SBalslev Feb 15, 2024
beccc2d
Simplify can install
SBalslev Feb 15, 2024
97e50cb
Move "AppSource Market Locale Helper" to manager codeunit
blrobl Feb 15, 2024
79fd00b
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
blrobl Feb 15, 2024
54fb8a7
presever filters and fix error on loading products
blrobl Feb 15, 2024
4feb2af
sort on name
blrobl Feb 15, 2024
d1bdf69
code review
blrobl Feb 15, 2024
78acc41
fix implicit with error
blrobl Feb 15, 2024
54ebee2
Fix codecop
blrobl Feb 15, 2024
163305d
0 index array should stop at L-1
SBalslev Feb 15, 2024
fbc920d
typos
blrobl Feb 16, 2024
7d191a7
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
blrobl Feb 16, 2024
5188c6c
Add scope
SBalslev Feb 16, 2024
fe81efd
fix keyvault access
blrobl Feb 16, 2024
ad944e6
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
blrobl Feb 16, 2024
99d1f53
clean
blrobl Feb 16, 2024
6885bce
delete redundant methods
blrobl Feb 16, 2024
7e0a566
codecop
blrobl Feb 16, 2024
d06127f
fix AA0005
blrobl Feb 19, 2024
259bb82
use dependencies SetCommonHeaders
blrobl Feb 19, 2024
bd1231c
do not call SetCommonHeaders in tests
blrobl Feb 19, 2024
94e85ea
check if saas
blrobl Feb 19, 2024
81201ad
clean
blrobl Feb 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/System Application/App/AppSource Gallery/app.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "79952567-63d7-4586-8b47-ba13a11a8a18",
"name": "Microsoft AppSource Product Gallery",
"name": "AppSource Product Gallery",
"publisher": "Microsoft",
"brief": "Microsoft AppSource Product Gallery app provides a Gallery for navigating Microsoft AppSource apps.",
"description": "Using Microsoft AppSource Product Gallery you can explore apps from Microsoft AppSource and choose to install them on the current environment.",
"brief": "AppSource Product Gallery app provides a Gallery for navigating Microsoft AppSource apps.",
"description": "Using AppSource Product Gallery you can explore apps from Microsoft AppSource and choose to install them on the current environment.",
"version": "24.0.0.0",
"privacyStatement": "https://go.microsoft.com/fwlink/?linkid=724009",
"EULA": "https://go.microsoft.com/fwlink/?linkid=2009120",
Expand Down Expand Up @@ -63,7 +63,7 @@
],
"internalsVisibleTo": [
{
"name": "Microsoft AppSource Product Gallery Test",
"name": "AppSource Product Gallery Test",
SBalslev marked this conversation as resolved.
Show resolved Hide resolved
"id": "c1830429-77f6-4469-837a-7bfd4705ff41",
"publisher": "Microsoft"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace System.Apps.AppSource;

/// <summary>
/// Library for managing AppSource product retrival and usage.
/// </summary>
codeunit 2516 "AppSource Json Utilities"
{
Access = Internal;
InherentEntitlements = x;
InherentPermissions = X;

procedure GetDecimalValue(JsonObject: JsonObject; PropertyName: Text): Decimal
var
JsonValue: JsonValue;
begin
if GetJsonValue(JsonObject, PropertyName, JsonValue) then
exit(JsonValue.AsDecimal());
exit(0);
end;

procedure GetIntegerValue(JsonObject: JsonObject; PropertyName: Text): Integer
var
JsonValue: JsonValue;
begin
if GetJsonValue(JsonObject, PropertyName, JsonValue) then
exit(JsonValue.AsInteger());
exit(0);
end;

procedure GetDateTimeValue(JsonObject: JsonObject; PropertyName: Text): DateTime
var
JsonValue: JsonValue;
begin
if GetJsonValue(JsonObject, PropertyName, JsonValue) then
exit(JsonValue.AsDateTime());
exit(0DT);
end;

procedure GetStringValue(JsonObject: JsonObject; PropertyName: Text): Text
var
JsonValue: JsonValue;
begin
if GetJsonValue(JsonObject, PropertyName, JsonValue) then
exit(JsonValue.AsText());
exit('');
end;

procedure GetJsonValue(JsonObject: JsonObject; PropertyName: Text; var ReturnValue: JsonValue): Boolean
var
JsonToken: JsonToken;
begin
if JsonObject.Contains(PropertyName) then
if JsonObject.Get(PropertyName, JsonToken) then
if not JsonToken.AsValue().IsNull() then begin
ReturnValue := JsonToken.AsValue();
exit(true);
end;
exit(false);
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ table 2515 "AppSource Product"
}
field(9; RatingCount; Integer)
{
Caption = '# Ratings';
Caption = 'No. Of Ratings';
}
field(10; ProductType; Text[200])
{
Caption = 'Product Type';
}
field(11; AppID; Text[36])
field(11; AppID; Guid)
{
Caption = 'Application Identifier';
}
Expand Down Expand Up @@ -98,14 +98,4 @@ table 2515 "AppSource Product"
{
}
}

procedure ReloadAllProducts()
var
AppSourceProductManager: Codeunit "AppSource Product Manager";
begin
Clear(Rec);
Rec.DeleteAll();
AppSourceProductManager.GetProductsAndPopulateRecord(Rec);
Rec.SetCurrentKey(Rec.DisplayName);
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ page 2516 "AppSource Product Details"
ApplicationArea = All;
Editable = false;
Caption = 'App Overview';
DataCaptionExpression = AppSourceProductManager.GetStringValue(ProductObject, 'displayName');
DataCaptionExpression = AppSourceJsonUtilities.GetStringValue(ProductObject, 'displayName');

InherentEntitlements = X;
InherentPermissions = X;
Expand All @@ -34,34 +34,34 @@ page 2516 "AppSource Product Details"
ToolTip = 'Specifies the unique product identifier.';
Visible = false;
}
field(Offer_ProductType; AppSourceProductManager.GetStringValue(ProductObject, 'productType'))
field(Offer_ProductType; AppSourceJsonUtilities.GetStringValue(ProductObject, 'productType'))
{
Caption = 'Product Type';
ToolTip = 'Specifies the delivery method or deployment mode of the offer.';
Visible = false;
}
field(Offer_DisplayName; AppSourceProductManager.GetStringValue(ProductObject, 'displayName'))
field(Offer_DisplayName; AppSourceJsonUtilities.GetStringValue(ProductObject, 'displayName'))
{
Caption = 'Display Name';
ToolTip = 'Specifies the display name of the offer.';
}
field(Offer_PublisherID; AppSourceProductManager.GetStringValue(ProductObject, 'publisherId'))
field(Offer_PublisherID; AppSourceJsonUtilities.GetStringValue(ProductObject, 'publisherId'))
{
Caption = 'Publisher ID';
ToolTip = 'Specifies the ID of the publisher.';
Visible = false;
}
field(Offer_PublisherDisplayName; AppSourceProductManager.GetStringValue(ProductObject, 'publisherDisplayName'))
field(Offer_PublisherDisplayName; AppSourceJsonUtilities.GetStringValue(ProductObject, 'publisherDisplayName'))
{
Caption = 'Publisher Display Name';
ToolTip = 'Specifies the display name of the publisher.';
}
field(Offer_PublisherType; AppSourceProductManager.GetStringValue(ProductObject, 'publisherType'))
field(Offer_PublisherType; AppSourceJsonUtilities.GetStringValue(ProductObject, 'publisherType'))
{
Caption = 'Publisher Type';
ToolTip = 'Specifies whether the offer is a Microsoft or third party product.';
}
field(Offer_LastModifiedDateTime; AppSourceProductManager.GetStringValue(ProductObject, 'lastModifiedDateTime'))
field(Offer_LastModifiedDateTime; AppSourceJsonUtilities.GetStringValue(ProductObject, 'lastModifiedDateTime'))
{
Caption = 'Last Modified Date Time';
ToolTip = 'Specifies the date the offer was last updated.';
Expand All @@ -71,7 +71,7 @@ page 2516 "AppSource Product Details"
{
ShowCaption = false;

field(Description_Description; AppSourceProductManager.GetStringValue(ProductObject, 'description'))
field(Description_Description; AppSourceJsonUtilities.GetStringValue(ProductObject, 'description'))
{
Caption = 'Description';
MultiLine = true;
Expand All @@ -98,17 +98,17 @@ page 2516 "AppSource Product Details"
{
Caption = 'Rating';

field(Rating_Popularity; AppSourceProductManager.GetStringValue(ProductObject, 'popularity'))
field(Rating_Popularity; AppSourceJsonUtilities.GetStringValue(ProductObject, 'popularity'))
{
Caption = 'Popularity';
ToolTip = 'Specifies a value from 0-10 indicating the popularity of the offer.';
}
field(Rating_RatingAverage; AppSourceProductManager.GetStringValue(ProductObject, 'ratingAverage'))
field(Rating_RatingAverage; AppSourceJsonUtilities.GetStringValue(ProductObject, 'ratingAverage'))
{
Caption = 'Rating Average';
ToolTip = 'Specifies a value from 0-5 indicating the average user rating.';
}
field(Rating_RatingCount; AppSourceProductManager.GetStringValue(ProductObject, 'ratingCount'))
field(Rating_RatingCount; AppSourceJsonUtilities.GetStringValue(ProductObject, 'ratingCount'))
{
Caption = 'Rating Count';
ToolTip = 'Specifies the number of users that have rated the offer.';
Expand All @@ -119,19 +119,19 @@ page 2516 "AppSource Product Details"
{
Caption = 'Links';

field(Links_LegalTermsUri; AppSourceProductManager.GetStringValue(ProductObject, 'legalTermsUri'))
field(Links_LegalTermsUri; AppSourceJsonUtilities.GetStringValue(ProductObject, 'legalTermsUri'))
{
Caption = 'Legal Terms Uri';
ToolTip = 'Specifies the legal terms of the offer.';
ExtendedDatatype = Url;
}
field(Links_PrivacyPolicyUri; AppSourceProductManager.GetStringValue(ProductObject, 'privacyPolicyUri'))
field(Links_PrivacyPolicyUri; AppSourceJsonUtilities.GetStringValue(ProductObject, 'privacyPolicyUri'))
{
Caption = 'Privacy Policy Uri';
ToolTip = 'Specifies the privacy policy of the offer.';
ExtendedDatatype = Url;
}
field(Links_SupportUri; AppSourceProductManager.GetStringValue(ProductObject, 'supportUri'))
field(Links_SupportUri; AppSourceJsonUtilities.GetStringValue(ProductObject, 'supportUri'))
{
Caption = 'Support Uri';
ToolTip = 'Specifies the support Uri of the offer.';
Expand Down Expand Up @@ -161,7 +161,7 @@ page 2516 "AppSource Product Details"

trigger OnAction()
begin
AppSourceProductManager.OpenInAppSource(UniqueProductID);
AppSourceProductManager.OpenAppInAppSource(UniqueProductID);
end;
}

Expand Down Expand Up @@ -202,6 +202,7 @@ page 2516 "AppSource Product Details"
}

var
AppSourceJsonUtilities: Codeunit "AppSource Json Utilities";
ExtensionManagement: Codeunit "Extension Management";
AppSourceProductManager: Codeunit "AppSource Product Manager";
ProductObject: JsonObject;
Expand All @@ -228,11 +229,11 @@ page 2516 "AppSource Product Details"
ProductPlansToken: JsonToken;
begin
ProductObject := ToProductObject;
UniqueProductID := AppSourceProductManager.GetStringValue(ProductObject, 'uniqueProductId');
UniqueProductID := AppSourceJsonUtilities.GetStringValue(ProductObject, 'uniqueProductId');
AppId := AppSourceProductManager.ExtractAppIDFromUniqueProductID(UniqueProductID);
CurrentRecordCanBeUninstalled := false;
CurrentRecordCanBeInstalled := false;
if (AppID <> '') then
if (not IsNullGuid(AppID)) then
CurrentRecordCanBeUninstalled := ExtensionManagement.IsInstalledByAppID(AppID);

if ProductObject.Get('plans', ProductPlansToken) then
Expand Down Expand Up @@ -347,25 +348,25 @@ page 2516 "AppSource Product Details"

local procedure GetTerms(Terms: JsonArray; var Monthly: decimal; var Yearly: decimal; var Currency: Text)
var
item: JsonToken;
priceToken: JsonToken;
price: JsonObject;
priceValue: Decimal;
Item: JsonToken;
PriceToken: JsonToken;
Price: JsonObject;
PriceValue: Decimal;
i: integer;
begin
for i := 0 to Terms.Count do
if (Terms.Get(i, item)) then begin
item.SelectToken('price', priceToken);
price := priceToken.AsObject();
Currency := GetStringValue(price, 'currencyCode');
if not evaluate(priceValue, GetStringValue(price, 'listPrice')) then
priceValue := 0;

case GetStringValue(item.AsObject(), 'termUnit') of
for i := 0 to Terms.Count() do
if (Terms.Get(i, Item)) then begin
Item.SelectToken('price', PriceToken);
Price := PriceToken.AsObject();
Currency := GetStringValue(Price, 'currencyCode');
if not evaluate(PriceValue, GetStringValue(Price, 'listPrice')) then
PriceValue := 0;

case GetStringValue(Item.AsObject(), 'termUnit') of
'P1Y':
Yearly := priceValue;
Yearly := PriceValue;
'P1M':
Monthly := priceValue;
Monthly := PriceValue;
end;
end;
end;
Expand All @@ -381,12 +382,12 @@ page 2516 "AppSource Product Details"

procedure GetJsonValue(JsonObject: JsonObject; PropertyName: Text; var ReturnValue: JsonValue): Boolean
var
jsonToken: JsonToken;
JsonToken: JsonToken;
begin
if jsonObject.Contains(PropertyName) then
if jsonObject.Get(PropertyName, jsonToken) then
if not jsonToken.AsValue().IsNull() then begin
ReturnValue := jsonToken.AsValue();
if JsonObject.Contains(PropertyName) then
if JsonObject.Get(PropertyName, JsonToken) then
if not JsonToken.AsValue().IsNull() then begin
ReturnValue := JsonToken.AsValue();
exit(true);
end;
exit(false);
Expand Down
Loading
Loading