Skip to content

Private/waabusea/move media to resources #2391

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

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion src/System Application/App/AI/app.json
Original file line number Diff line number Diff line change
@@ -71,6 +71,12 @@
"publisher": "Microsoft",
"version": "26.0.0.0"
},
{
"id": "e31ad830-3d46-472e-afeb-1d3d35247943",
"name": "BLOB Storage",
"publisher": "Microsoft",
"version": "26.0.0.0"
},
{
"id": "c64d75f0-e9f1-4d0f-9949-cd453b9b1466",
"name": "Guided Experience",
@@ -95,4 +101,4 @@
],
"target": "OnPrem",
"contextSensitiveHelpUrl": "https://learn.microsoft.com/dynamics365/business-central/"
}
}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
namespace System.AI;

using System.Environment;
using System.Environment.Configuration;

/// <summary>
/// Page for when copilot is unavailable due to various reasons. Fx capability disabled, cross region data movement is disabled.
@@ -27,7 +28,7 @@ page 7771 "Copilot Not Available"
ShowCaption = false;
Visible = BannerVisible;

field(Banner; MediaResources."Media Reference")
field(Banner; TenantMediaSet."Media ID")
{
ApplicationArea = All;
Editable = false;
@@ -86,7 +87,7 @@ page 7771 "Copilot Not Available"
end;

var
MediaResources: Record "Media Resources";
TenantMediaSet: Record "Tenant Media Set";
CopilotCapability: Enum "Copilot Capability";
BannerVisible: Boolean;
OpenCopilotLbl: Label 'Overview Copilot & AI Capabilities';
@@ -104,8 +105,14 @@ page 7771 "Copilot Not Available"
end;

local procedure LoadBanner()
var
GuidedExperience: Codeunit "Guided Experience";
begin
if MediaResources.Get('COPILOTNOTAVAILABLE.PNG') then
BannerVisible := MediaResources."Media Reference".HasValue;
BannerVisible := GuidedExperience.LoadFileFromTenantMediaSet(TenantMediaSet, 'CopilotNotAvailable.png');
Comment on lines -108 to +111
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand, why are we loading Media using procedures from GuidedExperience here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are loading wizard images from tenant media set, there is a fine line of ownership I agree. but it is the best place I could find


if not BannerVisible then begin
GuidedExperience.InsertSystemFileToTenantMediaSet(TenantMediaSet, 'images/', 'CopilotNotAvailable.png');
BannerVisible := TenantMediaSet."Media ID".HasValue;
end;
end;
}
Original file line number Diff line number Diff line change
@@ -14,5 +14,5 @@ permissionset 1481 "Edit in Excel - Read"

IncludedPermissionSets = "Edit in Excel - Objects";

Permissions = tabledata "Media Resources" = r;
Permissions = tabledata "Tenant Media Set" = r;
}
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ page 1480 "Excel Centralized Depl. Wizard"
SourceTable = "Edit in Excel Settings";
Extensible = false;
AccessByPermission = tabledata "Edit in Excel Settings" = M;
Permissions = tabledata "Media Resources" = r;
Permissions = tabledata "Tenant Media Set" = r;
HelpLink = 'https://go.microsoft.com/fwlink/?linkid=2221526';

layout
@@ -33,7 +33,7 @@ page 1480 "Excel Centralized Depl. Wizard"
Editable = false;
ShowCaption = false;
Visible = TopBannerVisible;
field(NotDoneIcon; MediaResourcesStandard."Media Reference")
field(NotDoneIcon; TenantMediaSet."Media ID")
{
ApplicationArea = All;
Editable = false;
@@ -315,14 +315,15 @@ page 1480 "Excel Centralized Depl. Wizard"
end;

local procedure LoadTopBanners()
var
TenantMediaSetCompleted, TenantMediaSetInfo : Record "Tenant Media Set";
GuidedExperience: Codeunit "Guided Experience";
begin
if MediaResourcesStandard.Get('ASSISTEDSETUP-NOTEXT-400PX.PNG') and (CurrentClientType() = ClientType::Web)
then
TopBannerVisible := MediaResourcesStandard."Media Reference".HasValue();
TopBannerVisible := GuidedExperience.LoadTopBanners(TenantMediaSet, TenantMediaSetCompleted, TenantMediaSetInfo);
end;

var
MediaResourcesStandard: Record "Media Resources";
TenantMediaSet: Record "Tenant Media Set";
TopBannerVisible: Boolean;
Step: Option Start,Step2,Finish;
BackActionEnabled: Boolean;
8 changes: 7 additions & 1 deletion src/System Application/App/Email/app.json
Original file line number Diff line number Diff line change
@@ -112,6 +112,12 @@
"name": "Data Compression",
"publisher": "Microsoft",
"version": "26.0.0.0"
},
{
"id": "c64d75f0-e9f1-4d0f-9949-cd453b9b1466",
"name": "Guided Experience",
"publisher": "Microsoft",
"version": "26.0.0.0"
}
],
"internalsVisibleTo": [
@@ -136,4 +142,4 @@
],
"target": "OnPrem",
"contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2134520"
}
}
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ permissionset 8900 "Email - Read"
tabledata "Email View Policy" = r,
tabledata Field = r,
tabledata Media = r, // Email Account Wizard requires this
tabledata "Media Resources" = r,
tabledata "Tenant Media Set" = r,
tabledata "Sent Email" = r,
tabledata "Tenant Media" = r,
tabledata User = R;
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ namespace System.Email;

using System.Telemetry;
using System.Environment;
using System.Environment.Configuration;
using System.Apps;

/// <summary>
@@ -26,8 +27,7 @@ page 8886 "Email Account Wizard"
Editable = true;
ShowFilter = false;
LinksAllowed = false;
Permissions = tabledata Media = r,
tabledata "Media Resources" = r,
Permissions = tabledata "Tenant Media Set" = r,
tabledata "Email Rate Limit" = imd;

layout
@@ -40,7 +40,7 @@ page 8886 "Email Account Wizard"
Editable = false;
ShowCaption = false;
Visible = not DoneVisible and TopBannerVisible;
field(NotDoneIcon; MediaResourcesStandard."Media Reference")
field(NotDoneIcon; TenantMediaSetStandard."Media ID")
{
ApplicationArea = All;
Editable = false;
@@ -54,7 +54,7 @@ page 8886 "Email Account Wizard"
Editable = false;
ShowCaption = false;
Visible = DoneVisible and TopBannerVisible;
field(DoneIcon; MediaResourcesDone."Media Reference")
field(DoneIcon; TenantMediaSetCompleted."Media ID")
{
ApplicationArea = All;
Editable = false;
@@ -539,18 +539,16 @@ page 8886 "Email Account Wizard"
end;

local procedure LoadTopBanners()
var
GuidedExperience: Codeunit "Guided Experience";
begin
if MediaResourcesStandard.Get('ASSISTEDSETUP-NOTEXT-400PX.PNG') and
MediaResourcesDone.Get('ASSISTEDSETUPDONE-NOTEXT-400PX.PNG') and (CurrentClientType() = ClientType::Web)
then
TopBannerVisible := MediaResourcesDone."Media Reference".HasValue();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, are we taking dependency from Email module to Guided Experience to load Media?

I see we have a System Module called Image, might be more suitable for this purpose

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think that Guided Experince doesn't fit, but the existing image modules don't really either.

TopBannerVisible := GuidedExperience.LoadTopBanners(TenantMediaSetStandard, TenantMediaSetCompleted, TenantMediaSetInfo);
end;

var
RegisteredAccount: Record "Email Account";
RegisteredRateLimit: Record "Email Rate Limit";
MediaResourcesStandard: Record "Media Resources";
MediaResourcesDone: Record "Media Resources";
TenantMediaSetStandard, TenantMediaSetCompleted, TenantMediaSetInfo : Record "Tenant Media Set";
[RunOnClient]
AppSource: DotNet AppSource;
Step: Option Welcome,"Choose Connector","Register Account",Done;
7 changes: 6 additions & 1 deletion src/System Application/App/Guided Experience/app.json
Original file line number Diff line number Diff line change
@@ -88,6 +88,11 @@
"id": "4af62c1c-2f6d-4574-ba34-bb5c149cdf93",
"name": "Guided Experience Test",
"publisher": "Microsoft"
},
{
"id": "d3433b68-4901-445f-9547-fdfeca57575a",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should encourage this, using internalsvisibleto can easily get out of hand.
Create an API in the GuidedExperience Facade and use ModuleInfo to block non-Microsoft from invoking it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I was just considering if this is something we would like to make internal or not. Probably no need and I will switch it to public.

"name": "AI SDK",
"publisher": "Microsoft"
}
],
"screenshots": [],
@@ -136,4 +141,4 @@
],
"target": "OnPrem",
"contextSensitiveHelpUrl": "https://learn.microsoft.com/dynamics365/business-central/"
}
}
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ namespace System.Environment.Configuration;

using System.Globalization;
using System.Apps;
using System.Environment;

permissionset 1993 "Guided Experience - Edit"
{
@@ -21,5 +22,7 @@ permissionset 1993 "Guided Experience - Edit"
tabledata "Checklist Item User" = IMD,
tabledata "Checklist Setup" = IMd,
tabledata "Published Application" = imd,
tabledata "Spotlight Tour Text" = imd;
tabledata "Spotlight Tour Text" = imd,
tabledata "Tenant Media" = imd,
tabledata "Tenant Media Set" = imd;
}
Original file line number Diff line number Diff line change
@@ -35,5 +35,7 @@ permissionset 1991 "Guided Experience - Read"
tabledata "Spotlight Tour Text" = r,
tabledata User = r,
tabledata "User Checklist Status" = R,
tabledata "User Personalization" = r;
tabledata "User Personalization" = r,
tabledata "Tenant Media" = r,
tabledata "Tenant Media Set" = r;
}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@

namespace System.Environment.Configuration;

using System.Environment;
using System.Globalization;
using System.Reflection;

@@ -24,5 +25,7 @@ permissionset 1992 "Guided Experience - View"
tabledata "Guided Experience Item" = imd,
tabledata "Primary Guided Experience Item" = imd,
tabledata "Spotlight Tour Text" = imd,
tabledata "User Checklist Status" = im;
tabledata "User Checklist Status" = im,
tabledata "Tenant Media" = im,
tabledata "Tenant Media Set" = im;
}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@

namespace System.Environment.Configuration;

using System.Environment;
using System.Media;

/// <summary>
@@ -443,6 +444,37 @@ codeunit 1990 "Guided Experience"
GuidedExperienceItemCleanup.CleanupOldGuidedExperienceItems(OnlyFirstParty, Threshold);
end;

/// <summary> Loads Assisted Setup top banners from tenant media set.</summary>
/// <param name="TenantMediaSetStandard">Tenant Media set record by var for standard image.</param>
/// <param name="TenantMediaSetCompleted">Tenant Media set record by var for done image.</param>
/// <param name="TenantMediaSetInfo">Tenant Media set record by var for info image.</param>
/// <returns>True if the top banners are loaded successfuly</returns>
procedure LoadTopBanners(var TenantMediaSetStandard: Record "Tenant Media Set"; var TenantMediaSetCompleted: Record "Tenant Media Set"; var TenantMediaSetInfo: Record "Tenant Media Set"): Boolean
begin
exit(GuidedExperienceImpl.LoadTopBanners(TenantMediaSetStandard, TenantMediaSetCompleted, TenantMediaSetInfo));
end;

/// <summary> Loads an image from tenant media set.</summary>
/// <param name="TenantMediaSet">Tenant Media set record by var for standard image.</param>
/// <param name="FileName">Image name.</param>
/// <returns>True if the the image is loaded successfuly</returns>
procedure LoadFileFromTenantMediaSet(var TenantMediaSet: Record "Tenant Media Set"; FileName: Text[250]): Boolean
var
begin
exit(GuidedExperienceImpl.LoadFileFromTenantMediaSet(TenantMediaSet, FileName));
end;

/// <summary> Insert an image to tenant media set from system app resources.</summary>
/// <param name="TenantMediaSet">Tenant Media set record by var for standard image.</param>
/// <param name="FilePath">Path to file name.</param>
/// <param name="FileName">File name.</param>
/// <returns>True if the the image is loaded successfuly</returns>
internal procedure InsertSystemFileToTenantMediaSet(var TenantMediaSet: Record "Tenant Media Set"; FilePath: Text[100]; FileName: Text[250])
var
begin
GuidedExperienceImpl.InsertSystemFileToTenantMediaSet(TenantMediaSet, FilePath, FileName);
end;

Comment on lines +447 to +477
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how those procedures fit in Guided Experience, consider Image module per previous comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First one, is strictly for banners in a wizard, and should definitely be there. The problem with the rest is that they are not really only for images, as resources can be anything in the future

/// <summary>Notifies that the list of assisted setups is being gathered, and that new items might be added.</summary>
[IntegrationEvent(false, false)]
internal procedure OnRegisterAssistedSetup()
Original file line number Diff line number Diff line change
@@ -21,7 +21,9 @@ codeunit 1991 "Guided Experience Impl."
Permissions = tabledata AllObj = r,
tabledata "Guided Experience Item" = rimd,
tabledata "Primary Guided Experience Item" = rimd,
tabledata "Spotlight Tour Text" = rimd;
tabledata "Spotlight Tour Text" = rimd,
tabledata "Tenant Media Set" = rim,
tabledata "Tenant Media" = rim;

var
TempBlob: Codeunit "Temp Blob";
@@ -569,6 +571,44 @@ codeunit 1991 "Guided Experience Impl."
InsertGuidedExperienceItemsInTempVar(GuidedExperienceItem, TempGuidedExperienceItem);
end;

procedure LoadTopBanners(var TenantMediaSetStandard: Record "Tenant Media Set"; var TenantMediaSetCompleted: Record "Tenant Media Set"; var TenantMediaSetInfo: Record "Tenant Media Set"): Boolean
begin
if not LoadFileFromTenantMediaSet(TenantMediaSetStandard, 'AssistedSetup-NoText-400px.png') then
InsertSystemFileToTenantMediaSet(TenantMediaSetStandard, 'images/', 'AssistedSetup-NoText-400px.png');

if not LoadFileFromTenantMediaSet(TenantMediaSetCompleted, 'AssistedSetupDone-NoText-400px.png') then
InsertSystemFileToTenantMediaSet(TenantMediaSetCompleted, 'images/', 'AssistedSetupDone-NoText-400px.png');

if not LoadFileFromTenantMediaSet(TenantMediaSetInfo, 'AssistedSetupInfo-NoText.png') then
InsertSystemFileToTenantMediaSet(TenantMediaSetInfo, 'images/', 'AssistedSetupInfo-NoText.png');

exit((TenantMediaSetStandard."Media ID".HasValue) and (TenantMediaSetCompleted."Media ID".HasValue) and (TenantMediaSetInfo."Media ID".HasValue));
end;

procedure LoadFileFromTenantMediaSet(var TenantMediaSet: Record "Tenant Media Set"; FileName: Text[250]): Boolean
var
TenantMedia: Record "Tenant Media";
begin
TenantMedia.SetFilter(Description, FileName);
if TenantMedia.FindFirst() then
if TenantMediaSet.Get(TenantMedia.ID, TenantMedia.ID) then
exit(TenantMediaSet."Media ID".HasValue);
end;

procedure InsertSystemFileToTenantMediaSet(var TenantMediaSet: Record "Tenant Media Set"; FilePath: Text[100]; FileName: Text[250])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this procedure should be set to local. I would like a function that first looks in the tenant media, if there is nothing there, then it should be inserted from the resources.
And then the FilePath is also useless, it is currently always "images/".

var
BannerInStream: InStream;
begin
NavApp.GetResource(FilePath + FileName, BannerInStream);
if BannerInStream.Length = 0 then
exit;

TenantMediaSet.Init();
TenantMediaSet."Media ID".ImportStream(BannerInStream, FileName);
TenantMediaSet.ID := TenantMediaSet."Media ID".MediaId;
TenantMediaSet.Insert();
end;

local procedure InsertGuidedExperienceItemsInTempVar(var GuidedExperienceItem: Record "Guided Experience Item"; var TempGuidedExperienceItem: Record "Guided Experience Item" temporary)
var
PrevGuidedExperienceItem: Record "Guided Experience Item";
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
// ------------------------------------------------------------------------------------------------

namespace System.Integration;
using System.Environment;

permissionset 2718 "Page Summary - Admin"
{
@@ -13,5 +14,6 @@ permissionset 2718 "Page Summary - Admin"

IncludedPermissionSets = "Page Summary Provider - Read";

Permissions = tabledata "Page Summary Settings" = IMD;
Permissions = tabledata "Page Summary Settings" = IMD,
tabledata "Tenant Media Set" = i;
}
Original file line number Diff line number Diff line change
@@ -17,10 +17,8 @@ permissionset 2715 "Page Summary Provider - Read"
IncludedPermissionSets = "Page Summary Provider - Obj.";

Permissions = tabledata Company = r,
tabledata Media = r,
tabledata "Media Resources" = r,
tabledata "Page Data Personalization" = R,
tabledata "Page Metadata" = r,
tabledata "Tenant Media Set" = r,
tabledata "Tenant Media Thumbnails" = r; // Page Summary Provider Settings Wizard requires this
tabledata "Tenant Media" = r,
tabledata "Tenant Media Set" = r; // Page Summary Provider Settings Wizard requires this
}
Original file line number Diff line number Diff line change
@@ -19,8 +19,8 @@ page 2718 "Page Summary Settings"
PageType = NavigatePage;
Extensible = false;
AccessByPermission = tabledata "Page Summary Settings" = M;
Permissions = tabledata Media = r,
tabledata "Media Resources" = r;
Permissions = tabledata "Tenant Media" = r,
tabledata "Tenant Media Set" = r;
UsageCategory = Administration;

layout
@@ -32,7 +32,7 @@ page 2718 "Page Summary Settings"
Editable = false;
ShowCaption = false;
Visible = TopBannerVisible and not DoneStepVisible and not TryItOutStepVisible;
field(NotDoneIcon; MediaResourcesStandard."Media Reference")
field(NotDoneIcon; TenantMediaSetStandard."Media ID")
{
ApplicationArea = All;
Editable = false;
@@ -44,8 +44,8 @@ page 2718 "Page Summary Settings"
{
Editable = false;
ShowCaption = false;
Visible = CompletedBannerVisible and (DoneActionVisible or TryItOutStepVisible);
field(CompletedIcon; CompletedMediaResourcesStandard."Media Reference")
Visible = TopBannerVisible and (DoneActionVisible or TryItOutStepVisible);
field(CompletedIcon; TenantMediaSetCompleted."Media ID")
{
ApplicationArea = All;
Editable = false;
@@ -428,12 +428,10 @@ page 2718 "Page Summary Settings"
end;

local procedure LoadTopBanner()
var
GuidedExperience: Codeunit "Guided Experience";
begin
if MediaResourcesStandard.Get('ASSISTEDSETUP-NOTEXT-400PX.PNG') and (CurrentClientType() = ClientType::Web) then
TopBannerVisible := MediaResourcesStandard."Media Reference".HasValue();

if CompletedMediaResourcesStandard.Get('ASSISTEDSETUPDONE-NOTEXT-400px.PNG') and (CurrentClientType() = ClientType::Web) then
CompletedBannerVisible := CompletedMediaResourcesStandard."Media Reference".HasValue();
TopBannerVisible := GuidedExperience.LoadTopBanners(TenantMediaSetStandard, TenantMediaSetCompleted, TenantMediaSetInfo);
end;

local procedure SaveSettings()
@@ -451,9 +449,9 @@ page 2718 "Page Summary Settings"
end;

var
MediaResourcesStandard, CompletedMediaResourcesStandard : Record "Media Resources";
TenantMediaSetStandard, TenantMediaSetCompleted, TenantMediaSetInfo : Record "Tenant Media Set";
Step: Option Intro,Configure,Done,TryItOut;
TopBannerVisible, CompletedBannerVisible : Boolean;
TopBannerVisible: Boolean;
IntroSaasStepVisible, IntroOnPremStepVisible, ConfigureStepVisible, DoneStepVisible, TryItOutStepVisible : Boolean;
NextActionVisible, BackActionVisible, DoneActionVisible, CloseActionVisible, TryItOutActionVisible : Boolean;
IsSaaS: Boolean;
5 changes: 4 additions & 1 deletion src/System Application/App/app.json
Original file line number Diff line number Diff line change
@@ -36,10 +36,13 @@
"TranslationFile",
"GenerateCaptions"
],
"resourceFolders": [
".resources"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you using .ressource because ressources is not possible? At least that's what I've discovered. Dot folders are currently always for content that is not repository relevant. Like .alpackages, .vscode, .snapshots. I would prefer data here.

],
"resourceExposurePolicy": {
"allowDebugging": true,
"allowDownloadingSource": true,
"includeSourceInSymbolFile": true
},
"contextSensitiveHelpUrl": "https://learn.microsoft.com/dynamics365/business-central/"
}
}