diff --git a/Oqtane.Server/Services/SiteService.cs b/Oqtane.Server/Services/SiteService.cs index ccb4c97e..cdf04490 100644 --- a/Oqtane.Server/Services/SiteService.cs +++ b/Oqtane.Server/Services/SiteService.cs @@ -69,6 +69,7 @@ namespace Oqtane.Services return await GetSite(siteId); }); + // trim pages based on user permissions var pages = new List(); foreach (Page page in site.Pages) { @@ -77,6 +78,9 @@ namespace Oqtane.Services pages.Add(page); } } + + // clone object so that cache is not mutated + site = site.Clone(site); site.Pages = pages; return site; diff --git a/Oqtane.Shared/Models/Site.cs b/Oqtane.Shared/Models/Site.cs index 3dfa5691..8b173552 100644 --- a/Oqtane.Shared/Models/Site.cs +++ b/Oqtane.Shared/Models/Site.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; namespace Oqtane.Models { @@ -11,7 +12,7 @@ namespace Oqtane.Models public class Site : ModelBase, IDeletable { /// - /// Internal ID, not to be confused with the + /// The ID of the Site /// public int SiteId { get; set; } @@ -22,7 +23,6 @@ namespace Oqtane.Models /// /// The site Name - /// TODO: todoc where this will be used / shown /// public string Name { get; set; } @@ -37,15 +37,37 @@ namespace Oqtane.Models /// Reference to a which has the FavIcon for this site. /// Should be an image. /// The theme can then use this where needed. - /// TODO: todoc does this get applied automatically, or does the Theme do this? /// public int? FaviconFileId { get; set; } + /// + /// Default theme for the site + /// public string DefaultThemeType { get; set; } + + /// + /// Default container for the site + /// public string DefaultContainerType { get; set; } + + /// + /// Default admin container + /// public string AdminContainerType { get; set; } + + /// + /// Indicates if the site is a progressive web application (PWA) + /// public bool PwaIsEnabled { get; set; } + + /// + /// The app icon for the progressive web application (PWA) + /// public int? PwaAppIconFileId { get; set; } + + /// + /// The splash icon for the progressive web application (PWA) + /// public int? PwaSplashIconFileId { get; set; } /// @@ -54,7 +76,7 @@ namespace Oqtane.Models public bool AllowRegistration { get; set; } /// - /// Determines if visitors will be tracked + /// Determines if site visitors will be recorded /// public bool VisitorTracking { get; set; } @@ -94,7 +116,7 @@ namespace Oqtane.Models public string Version { get; set; } /// - /// The home page of the site which will be used as a fallback if no page has a path of "/" + /// The home page of the site - the "/" path will be used by default if no home page is specified /// public int? HomePageId { get; set; } @@ -109,42 +131,101 @@ namespace Oqtane.Models public string BodyContent { get; set; } /// - /// The ImageFile extensions + /// Indicates if site is deleted + /// + public bool IsDeleted { get; set; } + + /// + /// The user who deleted site + /// + public string DeletedBy { get; set; } + + /// + /// Date site was deleted + /// + public DateTime? DeletedOn { get; set; } + + /// + /// The allowable iamge file extensions /// [NotMapped] public string ImageFiles { get; set; } /// - /// The UploadableFile extensions + /// The allowable file extensions which can be uploaded /// [NotMapped] public string UploadableFiles { get; set; } + /// + /// Used when provisioning a site from a site template + /// + [NotMapped] + public string SiteTemplateType { get; set; } + + /// + /// The settings for the site + /// [NotMapped] public Dictionary Settings { get; set; } + /// + /// List of pages for the site + /// [NotMapped] public List Pages { get; set; } - //[NotMapped] - //public List Modules { get; set; } - + /// + /// List of languages for the site + /// [NotMapped] public List Languages { get; set; } + /// + /// List of themes for the site + /// [NotMapped] public List Themes { get; set; } - #region IDeletable Properties - - public string DeletedBy { get; set; } - public DateTime? DeletedOn { get; set; } - public bool IsDeleted { get; set; } - - #endregion - - [NotMapped] - public string SiteTemplateType { get; set; } + public Site Clone(Site site) + { + return new Site + { + SiteId = site.SiteId, + TenantId = site.TenantId, + Name = site.Name, + LogoFileId = site.LogoFileId, + FaviconFileId = site.FaviconFileId, + DefaultThemeType = site.DefaultThemeType, + DefaultContainerType = site.DefaultContainerType, + AdminContainerType = site.AdminContainerType, + PwaIsEnabled = site.PwaIsEnabled, + PwaAppIconFileId = site.PwaAppIconFileId, + PwaSplashIconFileId = site.PwaSplashIconFileId, + AllowRegistration = site.AllowRegistration, + VisitorTracking = site.VisitorTracking, + CaptureBrokenUrls = site.CaptureBrokenUrls, + SiteGuid = site.SiteGuid, + RenderMode = site.RenderMode, + Runtime = site.Runtime, + Prerender = site.Prerender, + Hybrid = site.Hybrid, + Version = site.Version, + HomePageId = site.HomePageId, + HeadContent = site.HeadContent, + BodyContent = site.BodyContent, + IsDeleted = site.IsDeleted, + DeletedBy = site.DeletedBy, + DeletedOn = site.DeletedOn, + ImageFiles = site.ImageFiles, + UploadableFiles = site.UploadableFiles, + SiteTemplateType = site.SiteTemplateType, + Settings = site.Settings.ToDictionary(), + Pages = site.Pages.ToList(), + Languages = site.Languages.ToList(), + Themes = site.Themes.ToList() + }; + } #region Obsolete properties [NotMapped]