Skip to content

Commit

Permalink
[releases/24.0] AppSource Gallery bug fixes and test refactoring (#697)
Browse files Browse the repository at this point in the history
<!-- Thank you for submitting a Pull Request. If you're new to
contributing to BCApps please read our pull request guideline below
* https://github.com/microsoft/BCApps/Contributing.md
-->
#### Summary 
Cherry-picks of the following AppSource Gallery-related PR's.
#610 
#657 
#675 

#### Work Item(s) <!-- Add the issue number here after the #. The issue
needs to be open and approved. Submitting PRs with no linked issues or
unapproved issues is highly discouraged. -->
Fixes
[AB#504560](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/504560)

---------

Co-authored-by: Steffen Balslev <[email protected]>
Co-authored-by: Alexander Holstrup <[email protected]>
  • Loading branch information
3 people authored Mar 12, 2024
1 parent 7c15c5c commit c7863af
Show file tree
Hide file tree
Showing 13 changed files with 650 additions and 557 deletions.
6 changes: 3 additions & 3 deletions src/System Application/App/AppSource Gallery/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
],
"internalsVisibleTo": [
{
"name": "AppSource Product Gallery Test",
"id": "c1830429-77f6-4469-837a-7bfd4705ff41",
"id": "ba17b564-d600-44d5-be0b-ca7ff7ac28fc",
"name": "AppSource Gallery Test Library",
"publisher": "Microsoft"
}
],
Expand All @@ -73,7 +73,7 @@
"idRanges": [
{
"from": 2515,
"to": 2517
"to": 2518
}
],
"target": "OnPrem"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace System.Apps.AppSource;

/// <summary>
/// Library for managing AppSource product retrival and usage.
/// Library for managing AppSource product retrieval and usage.
/// </summary>
codeunit 2516 "AppSource Json Utilities"
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ page 2516 "AppSource Product Details"
{
actionref(Open_Promoted; OpenInAppSource) { }
actionref(Install_Promoted; Install) { }
actionref(InstallFromAppSource_Promoted; InstallFromAppSource) { }
actionref(Uninstall_Promoted; Uninstall) { }
}

Expand All @@ -169,7 +170,8 @@ page 2516 "AppSource Product Details"
{
Caption = 'Install App';
Scope = Page;
Enabled = CurrentRecordCanBeInstalled;
Enabled = (not CurrentRecordCanBeUninstalled) and CurrentRecordCanBeInstalled;
Visible = (not CurrentRecordCanBeUninstalled) and CurrentRecordCanBeInstalled;
Image = Insert;
ToolTip = 'Installs the app.';

Expand All @@ -184,6 +186,21 @@ page 2516 "AppSource Product Details"
end;
}

action(InstallFromAppSource)
{
Caption = 'Install From AppSource';
Scope = Page;
Image = Insert;
ToolTip = 'Installs the app from Microsoft AppSource.';
Enabled = (not CurrentRecordCanBeUninstalled) and (not CurrentRecordCanBeInstalled);
Visible = (not CurrentRecordCanBeUninstalled) and (not CurrentRecordCanBeInstalled);

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

action(Uninstall)
{
Caption = 'Uninstall App';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ page 2515 "AppSource Product List"

trigger OnOpenPage()
begin
ReloadAllProducts();
Rec.SetCurrentKey(DisplayName);
ReloadAllProducts();
end;

trigger OnAfterGetCurrRecord()
Expand All @@ -201,8 +201,9 @@ page 2515 "AppSource Product List"
var
AppSourceProductTemp: Record "AppSource Product";
begin
AppSourceProductTemp.Copy(Rec);
AppSourceProductManager.GetProductsAndPopulateRecord(AppSourceProductTemp);
AppSourceProductTemp.CopyFilters(Rec);
Rec.Copy(AppSourceProductTemp, true);
Rec.FindFirst();
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ using System.Environment.Configuration;
using System.Globalization;
using System.Azure.Identity;
using System.Utilities;
using System.Environment;
using System.Azure.KeyVault;
using System.RestClient;

/// <summary>
/// Library for managing AppSource product retrival and usage.
/// Library for managing AppSource product retrieval and usage.
/// </summary>
codeunit 2515 "AppSource Product Manager" implements "AppSource Product Manager Dependencies"
codeunit 2515 "AppSource Product Manager"
{
Access = Internal;
InherentEntitlements = X;
Expand All @@ -39,66 +38,6 @@ codeunit 2515 "AppSource Product Manager" implements "AppSource Product Manager
UnsupportedLanguageNotificationLbl: Label 'Language %1 is not supported by AppSource. Defaulting to "en". Change the language in the user profile to use another language.', Comment = '%1=Language ID, such as en';
UnsupportedMarketNotificationLbl: Label 'Market %1 is not supported by AppSource. Defaulting to "us". Change the region in the user profile to use another market.', Comment = '%1=Market ID, such as "us"';

#region Dependency Interface implementation
procedure GetCountryLetterCode(): Code[2]
var
AzureAdTenant: Codeunit "Azure AD Tenant";
begin
exit(AzureAdTenant.GetCountryLetterCode());
end;

procedure GetPreferredLanguage(): Text
var
AzureAdTenant: Codeunit "Azure AD Tenant";
begin
exit(AzureAdTenant.GetPreferredLanguage());
end;

procedure GetApplicationFamily(): Text
var
EnvironmentInformation: Codeunit "Environment Information";
begin
exit(EnvironmentInformation.GetApplicationFamily());
end;

procedure IsSaas(): boolean
var
EnvironmentInformation: Codeunit "Environment Information";
begin
exit(EnvironmentInformation.IsSaas());
end;

procedure GetFormatRegionOrDefault(FormatRegion: Text[80]): Text
var
Language: Codeunit Language;
begin
exit(Language.GetFormatRegionOrDefault(FormatRegion));
end;

procedure GetAsJSon(var RestClient: Codeunit "Rest Client"; RequestUri: Text): JsonToken
begin
exit(RestClient.GetAsJSon(RequestUri));
end;

procedure GetUserSettings(UserSecurityId: Guid; var TempUserSettingsRecord: record "User Settings" temporary)
var
UserSettings: Codeunit "User Settings";
begin
UserSettings.GetUserSettings(Database.UserSecurityID(), TempUserSettingsRecord);
end;

procedure ShouldSetCommonHeaders(): Boolean
begin
exit(true);
end;

#endregion
procedure SetDependencies(SpecificDependencies: Interface "AppSource Product Manager Dependencies")
begin
AppSourceProductManagerDependencies := SpecificDependencies;
IsDependenciesInterfaceSet := true;
end;

#region Product helpers
/// <summary>
/// Opens Microsoft AppSource web page for the region is specified in the UserSessionSettings or 'en-us' by default.
Expand Down Expand Up @@ -494,9 +433,14 @@ codeunit 2515 "AppSource Product Manager" implements "AppSource Product Manager

local procedure SetDefaultDependencyImplementation()
var
AppSourceProductManager: Codeunit "AppSource Product Manager";
AppSrcProductDepsProvider: Codeunit "AppSrc Product Deps. Provider";
begin
SetDependencies(AppSrcProductDepsProvider);
end;

internal procedure SetDependencies(AppSourceProductManagerDependencyProvider: Interface "AppSource Product Manager Dependencies")
begin
SetDependencies(AppSourceProductManager);
AppSourceProductManagerDependencies := AppSourceProductManagerDependencyProvider;
IsDependenciesInterfaceSet := true;
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// ------------------------------------------------------------------------------------------------
// 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;

using System.Environment.Configuration;
using System.Globalization;
using System.Azure.Identity;
using System.Environment;
using System.RestClient;

/// <summary>
/// Provides the dependencies used by the AppSource Gallery module.
/// </summary>
codeunit 2518 "AppSrc Product Deps. Provider" implements "AppSource Product Manager Dependencies"
{
Access = Internal;
InherentEntitlements = X;
InherentPermissions = X;

procedure GetCountryLetterCode(): Code[2]
var
AzureAdTenant: Codeunit "Azure AD Tenant";
begin
exit(AzureAdTenant.GetCountryLetterCode());
end;

procedure GetPreferredLanguage(): Text
var
AzureAdTenant: Codeunit "Azure AD Tenant";
begin
exit(AzureAdTenant.GetPreferredLanguage());
end;

procedure GetApplicationFamily(): Text
var
EnvironmentInformation: Codeunit "Environment Information";
begin
exit(EnvironmentInformation.GetApplicationFamily());
end;

procedure IsSaas(): boolean
var
EnvironmentInformation: Codeunit "Environment Information";
begin
exit(EnvironmentInformation.IsSaas());
end;

procedure GetFormatRegionOrDefault(FormatRegion: Text[80]): Text
var
Language: Codeunit Language;
begin
exit(Language.GetFormatRegionOrDefault(FormatRegion));
end;

procedure GetAsJSon(var RestClient: Codeunit "Rest Client"; RequestUri: Text): JsonToken
begin
exit(RestClient.GetAsJSon(RequestUri));
end;

procedure GetUserSettings(UserSecurityId: Guid; var TempUserSettingsRecord: record "User Settings" temporary)
var
UserSettings: Codeunit "User Settings";
begin
UserSettings.GetUserSettings(Database.UserSecurityID(), TempUserSettingsRecord);
end;

procedure ShouldSetCommonHeaders(): Boolean
begin
exit(true);
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,20 @@ page 2500 "Extension Management"
end;
#endif
}
action("Microsoft AppSource Gallery")
{
Caption = 'AppSource Gallery';
Enabled = IsSaaS;
Image = NewItem;
ToolTip = 'Browse the Microsoft AppSource Gallery for new extensions to install.';
Visible = not IsOnPremDisplay;
RunPageMode = View;

trigger OnAction()
begin
Page.Run(2515);
end;
}
action("Upload Extension")
{
Caption = 'Upload Extension';
Expand Down
44 changes: 44 additions & 0 deletions src/System Application/Test Library/AppSource Gallery/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"id": "ba17b564-d600-44d5-be0b-ca7ff7ac28fc",
"name": "AppSource Gallery Test Library",
"publisher": "Microsoft",
"brief": "Test objects for the AppSource Gallery module.",
"description": "Test objects for the AppSource Gallery module.",
"version": "24.0.0.0",
"privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724009",
"EULA": "https://go.microsoft.com/fwlink/?linkid=2009120",
"help": "",
"url": "https://go.microsoft.com/fwlink/?LinkId=724011",
"logo": "",
"dependencies": [
{
"id": "79952567-63d7-4586-8b47-ba13a11a8a18",
"name": "AppSource Product Gallery",
"publisher": "Microsoft",
"version": "24.0.0.0"
},
{
"id": "812b339d-a9db-4a6e-84e4-fe35cbef0c44",
"name": "Rest Client",
"publisher": "Microsoft",
"version": "24.0.0.0"
},
{
"id": "7b9b59f5-a68d-4271-b11a-0d3b9c0938dd",
"name": "User Settings",
"publisher": "Microsoft",
"version": "24.0.0.0"
}
],
"screenshots": [

],
"idRanges": [
{
"from": 132935,
"to": 132936
}
],
"platform": "24.0.0.0",
"target": "OnPrem"
}
Loading

0 comments on commit c7863af

Please sign in to comment.