-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix media tracking of items added via macro parameters in RTE and Grid #12139
Fix media tracking of items added via macro parameters in RTE and Grid #12139
Conversation
…ia-items-picked-as-macro-params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pattern matching is the new hotness 🔥
src/Umbraco.Infrastructure/Templates/HtmlMacroParameterParser.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Infrastructure/Templates/HtmlMacroParameterParser.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Infrastructure/Templates/HtmlMacroParameterParser.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MacroRepository.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MacroRepository.cs
Outdated
Show resolved
Hide resolved
Great job! I've fixed up some of the small edge-cases but the rest LGTM! 👓 |
@@ -77,7 +77,7 @@ public IMacro GetByAlias(string alias) | |||
|
|||
public IEnumerable<IMacro> GetAllByAlias(string[] aliases) | |||
{ | |||
if (aliases.Any() == false) | |||
if (aliases.Any() is false) | |||
{ | |||
return base.GetMany(); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Zeegaan shouldn't it just use Length
here since the aliases is string[]
.
for example:
if (aliases?.Length == 0)
{
return base.GetMany();
}
As far I know Any()
check first item if collection, but with Array
, List
, ICollection
etc, Length
or Count
property already know the size of the array/collection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @bjarnef, thanks for your comment, i had to check how this works 👀 When it is an array, Any() will also use the Count
property like this:
And because of that, i think its more readable if we use Any()
instead of Length
…cked-as-macro-params Fix media tracking of items added via macro parameters in RTE and Grid
Cherry picked for 9.4 |
Details
Fixes #8131 for Umbraco 9
After adding the item tracking improvements, there was still the issue that media items were not tracked when added via macro parameters in Rich Text Editor and Grid layout. @marcemarc had made a PR for Umbraco 8 resolving the issue (🎉 H5YR! 💪 ) and this is the fix for Umbraco 9.
Test
Create a Partial View Macro File called
InsertFiles.cshtml
( ❗ Note: code below)Allow the macro with the same name to be used in Rich Text Editor and the Grid
Add a macro parameter (ex:
Files (files) : Umbraco.MultipleMediaPicker
)In a Rich Text area on a content node, insert the macro and pick a media item as the macro param
Save and Publish
View the media item in the backoffice, and you should see that this is now referenced from this page
You can do the same thing with the Grid
Contents of
InsertFiles.cshtml
: