Skip to content

Commit aaa44a2

Browse files
Merge branch 'v15/dev' into contrib
2 parents a72ffc8 + 0a86dc5 commit aaa44a2

File tree

342 files changed

+6350
-1779
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

342 files changed

+6350
-1779
lines changed

.vscode/launch.json

Lines changed: 121 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,123 @@
11
{
2-
"version": "0.2.0",
3-
"configurations": [
4-
{
5-
// Use IntelliSense to find out which attributes exist for C# debugging
6-
// Use hover for the description of the existing attributes
7-
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
8-
"name": ".NET Core Launch (web)",
9-
"type": "coreclr",
10-
"request": "launch",
11-
"program": "dotnet",
12-
"args": ["run"],
13-
"cwd": "${workspaceFolder}/src/Umbraco.Web.UI",
14-
"stopAtEntry": false,
15-
"requireExactSource": false,
16-
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
17-
"serverReadyAction": {
18-
"action": "openExternally",
19-
"pattern": "\\\\bNow listening on:\\\\s+(https?://\\\\S+)"
20-
},
21-
"env": {
22-
"ASPNETCORE_ENVIRONMENT": "Development"
23-
},
24-
"sourceFileMap": {
25-
"/Views": "${workspaceFolder}/Views"
26-
}
27-
},
28-
{
29-
"name": ".NET Core Attach",
30-
"type": "coreclr",
31-
"request": "attach",
32-
"processId": "${command:pickProcess}"
33-
}
34-
]
2+
"version": "0.2.0",
3+
"compounds": [
4+
{
5+
"name": "Backoffice Launch (Vite + .NET Core)",
6+
"configurations": [
7+
"Backoffice Launch Vite (Chrome)",
8+
".NET Core Serve with External Auth (web)"
9+
],
10+
"stopAll": true,
11+
"presentation": {
12+
"group": "1"
13+
}
14+
}
15+
],
16+
"configurations": [
17+
{
18+
"name": "Backoffice Launch Vite (Chrome)",
19+
"request": "launch",
20+
"env": {
21+
"VITE_UMBRACO_USE_MSW": "${input:AskForMockServer}"
22+
},
23+
"runtimeExecutable": "npx",
24+
"runtimeArgs": ["vite"],
25+
"type": "node",
26+
"cwd": "${workspaceFolder}/src/Umbraco.Web.UI.Client",
27+
"skipFiles": ["<node_internals>/**", "node_modules/**"],
28+
"smartStep": true,
29+
"autoAttachChildProcesses": true,
30+
"serverReadyAction": {
31+
"killOnServerStop": true,
32+
"action": "debugWithChrome",
33+
"pattern": "Local: http://localhost:([0-9]+)",
34+
"uriFormat": "http://localhost:%s",
35+
"webRoot": "${workspaceFolder}/src/Umbraco.Web.UI.Client"
36+
},
37+
"presentation": {
38+
"group": "2"
39+
}
40+
},
41+
{
42+
"name": "Backoffice Attach Vite (Chrome)",
43+
"request": "launch",
44+
"type": "chrome",
45+
"smartStep": true,
46+
"url": "http://localhost:5173/",
47+
"skipFiles": ["<node_internals>/**", "node_modules/**"],
48+
"webRoot": "${workspaceFolder}/src/Umbraco.Web.UI.Client",
49+
"presentation": {
50+
"group": "2"
51+
}
52+
},
53+
{
54+
// Use IntelliSense to find out which attributes exist for C# debugging
55+
// Use hover for the description of the existing attributes
56+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
57+
"name": ".NET Core Launch (web)",
58+
"type": "coreclr",
59+
"request": "launch",
60+
"program": "dotnet",
61+
"args": ["run"],
62+
"cwd": "${workspaceFolder}/src/Umbraco.Web.UI",
63+
"stopAtEntry": false,
64+
"requireExactSource": false,
65+
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
66+
"serverReadyAction": {
67+
"action": "openExternally",
68+
"pattern": "\\\\bNow listening on:\\\\s+(https?://\\\\S+)"
69+
},
70+
"env": {
71+
"ASPNETCORE_ENVIRONMENT": "Development"
72+
},
73+
"sourceFileMap": {
74+
"/Views": "${workspaceFolder}/Umbraco.Web.UI/Views"
75+
},
76+
"presentation": {
77+
"group": "3"
78+
}
79+
},
80+
{
81+
"name": ".NET Core Attach",
82+
"type": "coreclr",
83+
"request": "attach",
84+
"processId": "${command:pickProcess}",
85+
"presentation": {
86+
"group": "3"
87+
}
88+
},
89+
{
90+
"name": ".NET Core Serve with External Auth (web)",
91+
"type": "coreclr",
92+
"request": "launch",
93+
"program": "dotnet",
94+
"args": ["run"],
95+
"cwd": "${workspaceFolder}/src/Umbraco.Web.UI",
96+
"stopAtEntry": false,
97+
"requireExactSource": false,
98+
"checkForDevCert": true,
99+
"env": {
100+
"ASPNETCORE_ENVIRONMENT": "Development",
101+
"ASPNETCORE_URLS": "https://localhost:44339",
102+
"UMBRACO__CMS__SECURITY__BACKOFFICEHOST": "http://localhost:5173",
103+
"UMBRACO__CMS__SECURITY__AUTHORIZECALLBACKPATHNAME": "/oauth_complete",
104+
"UMBRACO__CMS__SECURITY__AUTHORIZECALLBACKLOGOUTPATHNAME": "/logout",
105+
"UMBRACO__CMS__SECURITY__AUTHORIZECALLBACKERRORPATHNAME": "/error"
106+
},
107+
"sourceFileMap": {
108+
"/Views": "${workspaceFolder}/Umbraco.Web.UI/Views"
109+
},
110+
"presentation": {
111+
"group": "3"
112+
}
113+
}
114+
],
115+
"inputs": [
116+
{
117+
"id": "AskForMockServer",
118+
"type": "promptString",
119+
"description": "Use Mock Service Worker (MSW) for Backoffice API calls (off requires a running server)?",
120+
"default": "off"
121+
}
122+
]
35123
}

src/Umbraco.Cms.Api.Management/Controllers/Document/GetPublicAccessDocumentController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public async Task<IActionResult> GetPublicAccess(CancellationToken cancellationT
4949
}
5050

5151
Attempt<PublicAccessEntry?, PublicAccessOperationStatus> accessAttempt =
52-
await _publicAccessService.GetEntryByContentKeyAsync(id);
52+
await _publicAccessService.GetEntryByContentKeyWithoutAncestorsAsync(id);
5353

5454
if (accessAttempt.Success is false || accessAttempt.Result is null)
5555
{

src/Umbraco.Cms.Api.Management/Factories/IndexPresentationFactory.cs

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using Examine;
2+
using Microsoft.Extensions.DependencyInjection;
3+
using Microsoft.Extensions.Logging;
24
using Umbraco.Cms.Api.Management.ViewModels.Indexer;
35
using Umbraco.Cms.Core;
6+
using Umbraco.Cms.Core.DependencyInjection;
47
using Umbraco.Cms.Infrastructure.Examine;
58
using Umbraco.Cms.Infrastructure.Services;
69

@@ -11,26 +14,44 @@ public class IndexPresentationFactory : IIndexPresentationFactory
1114
private readonly IIndexDiagnosticsFactory _indexDiagnosticsFactory;
1215
private readonly IIndexRebuilder _indexRebuilder;
1316
private readonly IIndexingRebuilderService _indexingRebuilderService;
17+
private readonly ILogger<IndexPresentationFactory> _logger;
1418

15-
public IndexPresentationFactory(IIndexDiagnosticsFactory indexDiagnosticsFactory, IIndexRebuilder indexRebuilder, IIndexingRebuilderService indexingRebuilderService)
19+
public IndexPresentationFactory(
20+
IIndexDiagnosticsFactory indexDiagnosticsFactory,
21+
IIndexRebuilder indexRebuilder,
22+
IIndexingRebuilderService indexingRebuilderService,
23+
ILogger<IndexPresentationFactory> logger)
1624
{
1725
_indexDiagnosticsFactory = indexDiagnosticsFactory;
1826
_indexRebuilder = indexRebuilder;
1927
_indexingRebuilderService = indexingRebuilderService;
28+
_logger = logger;
29+
}
30+
31+
[Obsolete("Use the non obsolete method instead. Scheduled for removal in v17")]
32+
public IndexPresentationFactory(IIndexDiagnosticsFactory indexDiagnosticsFactory, IIndexRebuilder indexRebuilder, IIndexingRebuilderService indexingRebuilderService)
33+
:this(
34+
indexDiagnosticsFactory,
35+
indexRebuilder,
36+
indexingRebuilderService,
37+
StaticServiceProvider.Instance.GetRequiredService<ILogger<IndexPresentationFactory>>())
38+
{
2039
}
2140

2241
public IndexResponseModel Create(IIndex index)
2342
{
43+
var isCorrupt = !TryGetSearcherName(index, out var searcherName);
44+
2445
if (_indexingRebuilderService.IsRebuilding(index.Name))
2546
{
2647
return new IndexResponseModel
2748
{
2849
Name = index.Name,
2950
HealthStatus = new HealthStatusResponseModel
3051
{
31-
Status = HealthStatus.Rebuilding,
52+
Status = isCorrupt ? HealthStatus.Corrupt : HealthStatus.Rebuilding,
3253
},
33-
SearcherName = index.Searcher.Name,
54+
SearcherName = searcherName,
3455
DocumentCount = 0,
3556
FieldCount = 0,
3657
};
@@ -55,21 +76,78 @@ public IndexResponseModel Create(IIndex index)
5576
}
5677
}
5778

79+
if (TryGetDocumentCount(indexDiag, index, out var documentCount) is false)
80+
{
81+
isCorrupt = true;
82+
}
83+
84+
if (TryGetFieldNameCount(indexDiag, index, out var fieldNameCount) is false)
85+
{
86+
isCorrupt = true;
87+
}
88+
5889
var indexerModel = new IndexResponseModel
5990
{
6091
Name = index.Name,
6192
HealthStatus = new HealthStatusResponseModel
6293
{
63-
Status = isHealthyAttempt.Success ? HealthStatus.Healthy : HealthStatus.Unhealthy,
94+
Status = isCorrupt
95+
? HealthStatus.Corrupt
96+
: isHealthyAttempt.Success ? HealthStatus.Healthy : HealthStatus.Unhealthy,
6497
Message = isHealthyAttempt.Result,
6598
},
66-
CanRebuild = _indexRebuilder.CanRebuild(index.Name),
67-
SearcherName = index.Searcher.Name,
68-
DocumentCount = indexDiag.GetDocumentCount(),
69-
FieldCount = indexDiag.GetFieldNames().Count(),
99+
CanRebuild = isCorrupt is false && _indexRebuilder.CanRebuild(index.Name),
100+
SearcherName = searcherName,
101+
DocumentCount = documentCount,
102+
FieldCount = fieldNameCount,
70103
ProviderProperties = properties,
71104
};
72105

73106
return indexerModel;
74107
}
108+
109+
private bool TryGetSearcherName(IIndex index, out string name)
110+
{
111+
try
112+
{
113+
name = index.Searcher.Name;
114+
return true;
115+
}
116+
catch (Exception e)
117+
{
118+
_logger.LogError(e, "An error occured trying to get the searcher name of index {IndexName}", index.Name);
119+
name = "Could not determine searcher name because of error.";
120+
return false;
121+
}
122+
}
123+
124+
private bool TryGetDocumentCount(IIndexDiagnostics indexDiag, IIndex index, out long documentCount)
125+
{
126+
try
127+
{
128+
documentCount = indexDiag.GetDocumentCount();
129+
return true;
130+
}
131+
catch (Exception e)
132+
{
133+
_logger.LogError(e, "An error occured trying to get the document count of index {IndexName}", index.Name);
134+
documentCount = 0;
135+
return false;
136+
}
137+
}
138+
139+
private bool TryGetFieldNameCount(IIndexDiagnostics indexDiag, IIndex index, out int fieldNameCount)
140+
{
141+
try
142+
{
143+
fieldNameCount = indexDiag.GetFieldNames().Count();
144+
return true;
145+
}
146+
catch (Exception e)
147+
{
148+
_logger.LogError(e, "An error occured trying to get the field name count of index {IndexName}", index.Name);
149+
fieldNameCount = 0;
150+
return false;
151+
}
152+
}
75153
}

src/Umbraco.Cms.Api.Management/Mapping/Permissions/DocumentPermissionMapper.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,31 @@ public IEnumerable<IPermissionPresentationModel> MapManyAsync(IEnumerable<IGranu
4242

4343
public IEnumerable<IGranularPermission> MapToGranularPermissions(IPermissionPresentationModel permissionViewModel)
4444
{
45-
if (permissionViewModel is DocumentPermissionPresentationModel documentPermissionPresentationModel)
45+
if (permissionViewModel is not DocumentPermissionPresentationModel documentPermissionPresentationModel)
4646
{
47-
foreach (var verb in documentPermissionPresentationModel.Verbs)
47+
yield break;
48+
}
49+
50+
if(documentPermissionPresentationModel.Verbs.Any() is false || (documentPermissionPresentationModel.Verbs.Count == 1 && documentPermissionPresentationModel.Verbs.Contains(string.Empty)))
51+
{
52+
yield return new DocumentGranularPermission
4853
{
49-
yield return new DocumentGranularPermission
50-
{
51-
Key = documentPermissionPresentationModel.Document.Id,
52-
Permission = verb,
53-
};
54+
Key = documentPermissionPresentationModel.Document.Id,
55+
Permission = string.Empty,
56+
};
57+
yield break;
58+
}
59+
foreach (var verb in documentPermissionPresentationModel.Verbs)
60+
{
61+
if (string.IsNullOrEmpty(verb))
62+
{
63+
continue;
5464
}
65+
yield return new DocumentGranularPermission
66+
{
67+
Key = documentPermissionPresentationModel.Document.Id,
68+
Permission = verb,
69+
};
5570
}
5671
}
5772
}

0 commit comments

Comments
 (0)