Files
Umbraco-CMS/src/Umbraco.PublishedCache.NuCache/ContentStore.cs

1705 lines
64 KiB
C#
Raw Normal View History

using System;
2016-05-27 14:26:28 +02:00
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CSharpTest.Net.Collections;
2020-09-15 12:40:35 +02:00
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Exceptions;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PublishedCache;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.PublishedCache.Snap;
2016-05-27 14:26:28 +02:00
namespace Umbraco.Cms.Infrastructure.PublishedCache
2016-05-27 14:26:28 +02:00
{
/// <summary>
/// Stores content in memory and persists it back to disk
/// </summary>
/// <remarks>
/// <para>
/// Methods in this class suffixed with the term "Locked" means that those methods can only be called within a WriteLock. A WriteLock
/// is acquired by the GetScopedWriteLock method. Locks are not allowed to be recursive.
/// </para>
/// <para>
/// This class's logic is based on the <see cref="SnapDictionary{TKey, TValue}"/> class but has been slightly modified to suit these purposes.
/// </para>
/// </remarks>
public class ContentStore
2016-05-27 14:26:28 +02:00
{
// this class is an extended version of SnapDictionary
// most of the snapshots management code, etc is an exact copy
// SnapDictionary has unit tests to ensure it all works correctly
// For locking information, see SnapDictionary
2016-05-27 14:26:28 +02:00
2017-10-31 12:48:24 +01:00
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
2018-04-30 21:29:49 +02:00
private readonly IVariationContextAccessor _variationContextAccessor;
2020-09-15 12:40:35 +02:00
private readonly ILogger _logger;
private readonly ILoggerFactory _loggerFactory;
2016-05-27 14:26:28 +02:00
private readonly ConcurrentDictionary<int, LinkedNode<ContentNode>> _contentNodes;
2019-04-22 17:51:07 +02:00
private LinkedNode<ContentNode> _root;
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
// We must keep separate dictionaries for by id and by alias because we track these in snapshot/layers
// and it is possible that the alias of a content type can be different for the same id in another layer
// whereas the GUID -> INT cross reference can never be different
private readonly ConcurrentDictionary<int, LinkedNode<IPublishedContentType>> _contentTypesById;
2019-04-15 13:04:14 +02:00
private readonly ConcurrentDictionary<string, LinkedNode<IPublishedContentType>> _contentTypesByAlias;
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
private readonly ConcurrentDictionary<Guid, int> _contentTypeKeyToIdMap;
private readonly ConcurrentDictionary<Guid, int> _contentKeyToIdMap;
2016-05-27 14:26:28 +02:00
private readonly IPublishedModelFactory _publishedModelFactory;
2016-05-27 14:26:28 +02:00
private BPlusTree<int, ContentNodeKit> _localDb;
2019-02-22 15:30:55 +01:00
private readonly ConcurrentQueue<GenObj> _genObjs;
private GenObj _genObj;
2016-05-27 14:26:28 +02:00
private readonly object _wlocko = new object();
private readonly object _rlocko = new object();
private long _liveGen, _floorGen;
private bool _nextGen, _collectAuto;
private Task _collectTask;
private List<KeyValuePair<int, ContentNodeKit>> _wchanges;
2016-05-27 14:26:28 +02:00
// TODO: collection trigger (ok for now)
2016-05-27 14:26:28 +02:00
// see SnapDictionary notes
private const long CollectMinGenDelta = 8;
#region Ctor
public ContentStore(
IPublishedSnapshotAccessor publishedSnapshotAccessor,
IVariationContextAccessor variationContextAccessor,
2020-09-15 12:40:35 +02:00
ILogger logger,
ILoggerFactory loggerFactory,
IPublishedModelFactory publishedModelFactory,
BPlusTree<int, ContentNodeKit> localDb = null)
2016-05-27 14:26:28 +02:00
{
2017-10-31 12:48:24 +01:00
_publishedSnapshotAccessor = publishedSnapshotAccessor;
2018-04-30 21:29:49 +02:00
_variationContextAccessor = variationContextAccessor;
2016-05-27 14:26:28 +02:00
_logger = logger;
2020-09-15 12:40:35 +02:00
_loggerFactory = loggerFactory;
_publishedModelFactory = publishedModelFactory;
2016-05-27 14:26:28 +02:00
_localDb = localDb;
_contentNodes = new ConcurrentDictionary<int, LinkedNode<ContentNode>>();
2019-04-22 17:51:07 +02:00
_root = new LinkedNode<ContentNode>(new ContentNode(), 0);
2019-04-15 13:04:14 +02:00
_contentTypesById = new ConcurrentDictionary<int, LinkedNode<IPublishedContentType>>();
_contentTypesByAlias = new ConcurrentDictionary<string, LinkedNode<IPublishedContentType>>(StringComparer.InvariantCultureIgnoreCase);
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
_contentTypeKeyToIdMap = new ConcurrentDictionary<Guid, int>();
_contentKeyToIdMap = new ConcurrentDictionary<Guid, int>();
2016-05-27 14:26:28 +02:00
2019-02-22 15:30:55 +01:00
_genObjs = new ConcurrentQueue<GenObj>();
_genObj = null; // no initial gen exists
2016-05-27 14:26:28 +02:00
_liveGen = _floorGen = 0;
_nextGen = false; // first time, must create a snapshot
_collectAuto = true; // collect automatically by default
}
#endregion
#region Locking
// see notes on SnapDictionary
private readonly string _instanceId = Guid.NewGuid().ToString("N");
private class WriteLockInfo
{
#pragma warning disable IDE1006 // Naming Styles
// This is a field that is used for ref operations
public bool Taken;
#pragma warning restore IDE1006 // Naming Styles
}
// a scope contextual that represents a locked writer to the dictionary
2019-03-14 19:48:44 +01:00
private class ScopedWriteLock : ScopeContextualBase
{
private readonly WriteLockInfo _lockinfo = new WriteLockInfo();
2019-02-22 15:43:37 +01:00
private readonly ContentStore _store;
private int _released;
2019-03-14 19:48:44 +01:00
public ScopedWriteLock(ContentStore store, bool scoped)
{
_store = store;
store.Lock(_lockinfo, scoped);
}
public override void Release(bool completed)
{
2019-02-22 15:43:37 +01:00
if (Interlocked.CompareExchange(ref _released, 1, 0) != 0)
return;
_store.Release(_lockinfo, completed);
}
}
// gets a scope contextual representing a locked writer to the dictionary
// TODO: GetScopedWriter? should the dict have a ref onto the scope provider?
2019-03-14 19:48:44 +01:00
public IDisposable GetScopedWriteLock(IScopeProvider scopeProvider)
{
2019-03-14 19:48:44 +01:00
return ScopeContextualBase.Get(scopeProvider, _instanceId, scoped => new ScopedWriteLock(this, scoped));
}
private void EnsureLocked()
{
if (!Monitor.IsEntered(_wlocko))
throw new InvalidOperationException("Write lock must be acquried.");
}
private void Lock(WriteLockInfo lockInfo, bool forceGen = false)
2016-05-27 14:26:28 +02:00
{
if (Monitor.IsEntered(_wlocko))
throw new InvalidOperationException("Recursive locks not allowed");
Monitor.Enter(_wlocko, ref lockInfo.Taken);
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
lock (_rlocko)
2016-05-27 14:26:28 +02:00
{
// see SnapDictionary
try { }
finally
2016-05-27 14:26:28 +02:00
{
if (_nextGen == false || (forceGen))
2016-05-27 14:26:28 +02:00
{
// because we are changing things, a new generation
// is created, which will trigger a new snapshot
2019-03-14 19:48:44 +01:00
if (_nextGen)
_genObjs.Enqueue(_genObj = new GenObj(_liveGen));
_liveGen += 1;
2019-03-14 19:48:44 +01:00
_nextGen = true;
2016-05-27 14:26:28 +02:00
}
}
}
}
2016-05-27 14:26:28 +02:00
private void Release(WriteLockInfo lockInfo, bool commit = true)
{
2020-01-06 21:39:26 +11:00
try
{
2020-01-06 21:39:26 +11:00
if (commit == false)
2016-05-27 14:26:28 +02:00
{
2020-01-06 21:39:26 +11:00
lock (_rlocko)
2016-05-27 14:26:28 +02:00
{
2020-01-06 21:39:26 +11:00
// see SnapDictionary
try { }
finally
{
_nextGen = false;
_liveGen -= 1;
}
2016-05-27 14:26:28 +02:00
}
2020-01-06 21:39:26 +11:00
Rollback(_contentNodes);
RollbackRoot();
Rollback(_contentTypesById);
Rollback(_contentTypesByAlias);
2016-05-27 14:26:28 +02:00
}
2020-01-06 21:39:26 +11:00
else if (_localDb != null && _wchanges != null)
2016-05-27 14:26:28 +02:00
{
2020-01-06 21:39:26 +11:00
foreach (var change in _wchanges)
{
if (change.Value.IsNull)
_localDb.TryRemove(change.Key, out ContentNodeKit unused);
else
_localDb[change.Key] = change.Value;
}
_wchanges = null;
_localDb.Commit();
2016-05-27 14:26:28 +02:00
}
}
2020-01-06 21:39:26 +11:00
finally
2016-05-27 14:26:28 +02:00
{
2020-01-06 21:39:26 +11:00
if (lockInfo.Taken)
Monitor.Exit(_wlocko);
2016-05-27 14:26:28 +02:00
}
}
2016-05-27 14:26:28 +02:00
2019-04-22 17:51:07 +02:00
private void RollbackRoot()
{
if (_root.Gen <= _liveGen) return;
if (_root.Next != null)
_root = _root.Next;
}
private void Rollback<TKey, TValue>(ConcurrentDictionary<TKey, LinkedNode<TValue>> dictionary)
where TValue : class
{
foreach (var item in dictionary)
2016-05-27 14:26:28 +02:00
{
var link = item.Value;
if (link.Gen <= _liveGen) continue;
var key = item.Key;
if (link.Next == null)
dictionary.TryRemove(key, out link);
else
dictionary.TryUpdate(key, link.Next, link);
2016-05-27 14:26:28 +02:00
}
}
#endregion
#region LocalDb
public void ReleaseLocalDb()
{
var lockInfo = new WriteLockInfo();
try
2016-05-27 14:26:28 +02:00
{
try
{
// Trying to lock could throw exceptions so always make sure to clean up.
Lock(lockInfo);
}
finally
{
try
{
_localDb?.Dispose();
}
catch (Exception ex)
{
/* TBD: May already be throwing so don't throw again */
2020-09-15 08:45:40 +02:00
_logger.LogError(ex, "Error trying to release DB");
}
finally
{
_localDb = null;
}
}
}
catch (Exception ex)
{
2020-09-15 08:45:40 +02:00
_logger.LogError(ex, "Error trying to lock");
throw;
}
finally
{
Release(lockInfo);
}
}
private void RegisterChange(int id, ContentNodeKit kit)
{
if (_wchanges == null) _wchanges = new List<KeyValuePair<int, ContentNodeKit>>();
_wchanges.Add(new KeyValuePair<int, ContentNodeKit>(id, kit));
2016-05-27 14:26:28 +02:00
}
2016-05-27 14:26:28 +02:00
#endregion
#region Content types
/// <summary>
/// Sets data for new content types
/// </summary>
/// <param name="types"></param>
/// <remarks>
/// This methods MUST be called from within a write lock, normally wrapped within GetScopedWriteLock
/// otherwise an exception will occur.
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if this method is not called within a write lock
/// </exception>
public void NewContentTypesLocked(IEnumerable<IPublishedContentType> types)
2017-07-17 17:59:46 +02:00
{
EnsureLocked();
2017-07-17 17:59:46 +02:00
foreach (var type in types)
2017-07-17 17:59:46 +02:00
{
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
SetContentTypeLocked(type);
2017-07-17 17:59:46 +02:00
}
}
/// <summary>
/// Sets data for updated content types
/// </summary>
/// <param name="types"></param>
/// <remarks>
/// This methods MUST be called from within a write lock, normally wrapped within GetScopedWriteLock
/// otherwise an exception will occur.
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if this method is not called within a write lock
/// </exception>
public void UpdateContentTypesLocked(IEnumerable<IPublishedContentType> types)
2017-07-17 17:59:46 +02:00
{
//nothing to do if this is empty, no need to lock/allocate/iterate/etc...
if (!types.Any()) return;
EnsureLocked();
2017-07-17 17:59:46 +02:00
var index = types.ToDictionary(x => x.Id, x => x);
2017-07-17 17:59:46 +02:00
foreach (var type in index.Values)
{
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
SetContentTypeLocked(type);
2017-07-17 17:59:46 +02:00
}
foreach (var link in _contentNodes.Values)
2017-07-17 17:59:46 +02:00
{
var node = link.Value;
if (node == null) continue;
var contentTypeId = node.ContentType.Id;
if (index.TryGetValue(contentTypeId, out var contentType) == false) continue;
SetValueLocked(_contentNodes, node.Id, new ContentNode(node, _publishedModelFactory, contentType));
2017-07-17 17:59:46 +02:00
}
}
/// <summary>
/// Updates/sets data for all content types
/// </summary>
/// <param name="types"></param>
/// <remarks>
/// This methods MUST be called from within a write lock, normally wrapped within GetScopedWriteLock
/// otherwise an exception will occur.
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if this method is not called within a write lock
/// </exception>
public void SetAllContentTypesLocked(IEnumerable<IPublishedContentType> types)
2016-05-27 14:26:28 +02:00
{
EnsureLocked();
// clear all existing content types
ClearLocked(_contentTypesById);
ClearLocked(_contentTypesByAlias);
// set all new content types
foreach (var type in types)
{
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
SetContentTypeLocked(type);
}
// beware! at that point the cache is inconsistent,
// assuming we are going to SetAll content items!
}
/// <summary>
/// Updates/sets/removes data for content types
/// </summary>
/// <param name="removedIds"></param>
/// <param name="refreshedTypes"></param>
/// <param name="kits"></param>
/// <remarks>
/// This methods MUST be called from within a write lock, normally wrapped within GetScopedWriteLock
/// otherwise an exception will occur.
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if this method is not called within a write lock
/// </exception>
public void UpdateContentTypesLocked(IReadOnlyCollection<int> removedIds, IReadOnlyCollection<IPublishedContentType> refreshedTypes, IReadOnlyCollection<ContentNodeKit> kits)
{
EnsureLocked();
var removedIdsA = removedIds ?? Array.Empty<int>();
var refreshedTypesA = refreshedTypes ?? Array.Empty<IPublishedContentType>();
var refreshedIdsA = refreshedTypesA.Select(x => x.Id).ToList();
kits = kits ?? Array.Empty<ContentNodeKit>();
if (kits.Count == 0 && refreshedIdsA.Count == 0 && removedIdsA.Count == 0)
return; //exit - there is nothing to do here
var removedContentTypeNodes = new List<int>();
var refreshedContentTypeNodes = new List<int>();
// find all the nodes that are either refreshed or removed,
// because of their content type being either refreshed or removed
foreach (var link in _contentNodes.Values)
{
var node = link.Value;
if (node == null) continue;
var contentTypeId = node.ContentType.Id;
if (removedIdsA.Contains(contentTypeId)) removedContentTypeNodes.Add(node.Id);
if (refreshedIdsA.Contains(contentTypeId)) refreshedContentTypeNodes.Add(node.Id);
}
2016-05-27 14:26:28 +02:00
// perform deletion of content with removed content type
// removing content types should have removed their content already
// but just to be 100% sure, clear again here
foreach (var node in removedContentTypeNodes)
ClearBranchLocked(node);
// perform deletion of removed content types
foreach (var id in removedIdsA)
{
if (_contentTypesById.TryGetValue(id, out var link) == false || link.Value == null)
continue;
SetValueLocked(_contentTypesById, id, null);
SetValueLocked(_contentTypesByAlias, link.Value.Alias, null);
}
2016-05-27 14:26:28 +02:00
// perform update of refreshed content types
foreach (var type in refreshedTypesA)
{
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
SetContentTypeLocked(type);
}
// perform update of content with refreshed content type - from the kits
// skip missing type, skip missing parents & un-buildable kits - what else could we do?
// kits are ordered by level, so ParentExists is ok here
var visited = new List<int>();
foreach (var kit in kits.Where(x =>
refreshedIdsA.Contains(x.ContentTypeId) &&
BuildKit(x, out _)))
{
// replacing the node: must preserve the parents
var node = GetHead(_contentNodes, kit.Node.Id)?.Value;
if (node != null)
kit.Node.FirstChildContentId = node.FirstChildContentId;
SetValueLocked(_contentNodes, kit.Node.Id, kit.Node);
2016-05-27 14:26:28 +02:00
visited.Add(kit.Node.Id);
if (_localDb != null) RegisterChange(kit.Node.Id, kit);
}
// all content should have been refreshed - but...
var orphans = refreshedContentTypeNodes.Except(visited);
foreach (var id in orphans)
ClearBranchLocked(id);
2016-05-27 14:26:28 +02:00
}
/// <summary>
/// Updates data types
/// </summary>
/// <param name="dataTypeIds"></param>
/// <param name="getContentType"></param>
/// <remarks>
/// This methods MUST be called from within a write lock, normally wrapped within GetScopedWriteLock
/// otherwise an exception will occur.
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if this method is not called within a write lock
/// </exception>
public void UpdateDataTypesLocked(IEnumerable<int> dataTypeIds, Func<int, IPublishedContentType> getContentType)
2016-05-27 14:26:28 +02:00
{
2020-01-13 22:28:25 +11:00
EnsureLocked();
var contentTypes = _contentTypesById
2016-05-27 14:26:28 +02:00
.Where(kvp =>
kvp.Value.Value != null &&
kvp.Value.Value.PropertyTypes.Any(p => dataTypeIds.Contains(p.DataType.Id)))
2016-05-27 14:26:28 +02:00
.Select(kvp => kvp.Value.Value)
.Select(x => getContentType(x.Id))
.Where(x => x != null) // poof, gone, very unlikely and probably an anomaly
.ToArray();
var contentTypeIdsA = contentTypes.Select(x => x.Id).ToArray();
var contentTypeNodes = new Dictionary<int, List<int>>();
foreach (var id in contentTypeIdsA)
contentTypeNodes[id] = new List<int>();
foreach (var link in _contentNodes.Values)
{
var node = link.Value;
if (node != null && contentTypeIdsA.Contains(node.ContentType.Id))
contentTypeNodes[node.ContentType.Id].Add(node.Id);
}
2016-05-27 14:26:28 +02:00
foreach (var contentType in contentTypes)
{
// again, weird situation
if (contentTypeNodes.ContainsKey(contentType.Id) == false)
continue;
2016-05-27 14:26:28 +02:00
foreach (var id in contentTypeNodes[contentType.Id])
2016-05-27 14:26:28 +02:00
{
_contentNodes.TryGetValue(id, out var link);
if (link?.Value == null)
2016-05-27 14:26:28 +02:00
continue;
var node = new ContentNode(link.Value, _publishedModelFactory, contentType);
SetValueLocked(_contentNodes, id, node);
if (_localDb != null) RegisterChange(id, node.ToKit());
2016-05-27 14:26:28 +02:00
}
}
2016-05-27 14:26:28 +02:00
}
2020-04-01 13:13:15 +11:00
/// <summary>
/// Validate the <see cref="ContentNodeKit"/> and try to create a parent <see cref="LinkedNode{ContentNode}"/>
/// </summary>
/// <param name="kit"></param>
/// <param name="parent"></param>
/// <returns>
/// Returns false if the parent was not found or if the kit validation failed
/// </returns>
private bool BuildKit(ContentNodeKit kit, out LinkedNode<ContentNode> parent)
2016-05-27 14:26:28 +02:00
{
// make sure parent exists
parent = GetParentLink(kit.Node, null);
if (parent == null)
{
_logger.LogWarning("Skip item id={kitNodeId}, could not find parent id={kitNodeParentContentId}.", kit.Node.Id, kit.Node.ParentContentId);
return false;
}
// We cannot continue if there's no value. This shouldn't happen but it can happen if the database umbracoNode.path
// data is invalid/corrupt. If that is the case, the parentId might be ok but not the Path which can result in null
// because the data sort operation is by path.
if (parent.Value == null)
{
_logger.LogWarning("Skip item id={kitNodeId}, no Data assigned for linked node with path {kitNodePath} and parent id {kitNodeParentContentId}. This can indicate data corruption for the Path value for node {kitNodeId}. See the Health Check dashboard in Settings to resolve data integrity issues.", kit.Node.Id, kit.Node.Path, kit.Node.ParentContentId, kit.Node.Id);
return false;
}
2016-05-27 14:26:28 +02:00
// make sure the kit is valid
if (kit.DraftData == null && kit.PublishedData == null)
{
_logger.LogWarning("Skip item id={kitNodeId}, both draft and published data are null.", kit.Node.Id);
2016-05-27 14:26:28 +02:00
return false;
}
2016-05-27 14:26:28 +02:00
// unknown = bad
2019-04-15 13:04:14 +02:00
if (_contentTypesById.TryGetValue(kit.ContentTypeId, out var link) == false || link.Value == null)
{
_logger.LogWarning("Skip item id={kitNodeId}, could not find content type id={kitContentTypeId}.", kit.Node.Id, kit.ContentTypeId);
2016-05-27 14:26:28 +02:00
return false;
}
2018-07-05 17:08:40 +02:00
// check whether parent is published
var canBePublished = ParentPublishedLocked(kit);
2016-05-27 14:26:28 +02:00
// and use
kit.Build(link.Value, _publishedSnapshotAccessor, _variationContextAccessor, _publishedModelFactory, canBePublished);
2016-05-27 14:26:28 +02:00
return true;
}
#endregion
#region Set, Clear, Get
2017-07-12 14:09:31 +02:00
public int Count => _contentNodes.Count;
2016-05-27 14:26:28 +02:00
/// <summary>
/// Get the most recent version of the LinkedNode stored in the dictionary for the supplied key
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="dict"></param>
/// <param name="key"></param>
/// <returns></returns>
2017-07-12 14:09:31 +02:00
private static LinkedNode<TValue> GetHead<TKey, TValue>(ConcurrentDictionary<TKey, LinkedNode<TValue>> dict, TKey key)
2016-05-27 14:26:28 +02:00
where TValue : class
{
2019-04-22 17:51:07 +02:00
dict.TryGetValue(key, out var link); // else null
2016-05-27 14:26:28 +02:00
return link;
}
/// <summary>
/// Sets the data for a <see cref="ContentNodeKit"/>
/// </summary>
/// <param name="kit"></param>
/// <returns></returns>
/// <remarks>
/// This methods MUST be called from within a write lock, normally wrapped within GetScopedWriteLock
/// otherwise an exception will occur.
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if this method is not called within a write lock
/// </exception>
public bool SetLocked(ContentNodeKit kit)
2016-05-27 14:26:28 +02:00
{
EnsureLocked();
2016-05-27 14:26:28 +02:00
// ReSharper disable LocalizableElement
if (kit.IsEmpty)
2017-07-12 14:09:31 +02:00
throw new ArgumentException("Kit is empty.", nameof(kit));
2019-04-22 17:51:07 +02:00
if (kit.Node.FirstChildContentId > 0)
2017-07-12 14:09:31 +02:00
throw new ArgumentException("Kit content cannot have children.", nameof(kit));
2016-05-27 14:26:28 +02:00
// ReSharper restore LocalizableElement
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Set content ID: {KitNodeId}", kit.Node.Id);
2016-05-27 14:26:28 +02:00
// get existing
_contentNodes.TryGetValue(kit.Node.Id, out var link);
var existing = link?.Value;
2016-05-27 14:26:28 +02:00
if (!BuildKit(kit, out var parent))
return false;
2016-05-27 14:26:28 +02:00
// moving?
var moving = existing != null && existing.ParentContentId != kit.Node.ParentContentId;
2016-05-27 14:26:28 +02:00
// manage children
if (existing != null)
{
2019-04-22 17:51:07 +02:00
kit.Node.FirstChildContentId = existing.FirstChildContentId;
kit.Node.LastChildContentId = existing.LastChildContentId;
}
2016-05-27 14:26:28 +02:00
// set
SetValueLocked(_contentNodes, kit.Node.Id, kit.Node);
if (_localDb != null) RegisterChange(kit.Node.Id, kit);
2016-05-27 14:26:28 +02:00
// manage the tree
if (existing == null)
{
// new, add to parent
AddTreeNodeLocked(kit.Node, parent);
}
else if (moving || existing.SortOrder != kit.Node.SortOrder)
{
// moved, remove existing from its parent, add content to its parent
RemoveTreeNodeLocked(existing);
AddTreeNodeLocked(kit.Node);
}
else
{
// replacing existing, handle siblings
kit.Node.NextSiblingContentId = existing.NextSiblingContentId;
kit.Node.PreviousSiblingContentId = existing.PreviousSiblingContentId;
}
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
_contentKeyToIdMap[kit.Node.Uid] = kit.Node.Id;
return true;
2016-05-27 14:26:28 +02:00
}
2019-04-22 17:51:07 +02:00
private void ClearRootLocked()
{
if (_root.Gen != _liveGen)
2019-04-22 17:51:07 +02:00
_root = new LinkedNode<ContentNode>(new ContentNode(), _liveGen, _root);
else
_root.Value.FirstChildContentId = -1;
}
/// <summary>
/// Builds all kits on startup using a fast forward only cursor
/// </summary>
/// <param name="kits">
/// All kits sorted by Level + Parent Id + Sort order
/// </param>
/// <param name="fromDb">True if the data is coming from the database (not the local cache db)</param>
/// <returns></returns>
/// <remarks>
/// <para>
/// This requires that the collection is sorted by Level + ParentId + Sort Order.
/// This should be used only on a site startup as the first generations.
/// This CANNOT be used after startup since it bypasses all checks for Generations.
/// </para>
/// <para>
/// This methods MUST be called from within a write lock, normally wrapped within GetScopedWriteLock
/// otherwise an exception will occur.
/// </para>
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if this method is not called within a write lock
/// </exception>
public bool SetAllFastSortedLocked(IEnumerable<ContentNodeKit> kits, bool fromDb)
{
EnsureLocked();
var ok = true;
ClearLocked(_contentNodes);
ClearRootLocked();
// The name of the game here is to populate each kit's
// FirstChildContentId
// LastChildContentId
// NextSiblingContentId
// PreviousSiblingContentId
ContentNode previousNode = null;
ContentNode parent = null;
foreach (var kit in kits)
{
if (!BuildKit(kit, out var parentLink))
{
ok = false;
continue; // skip that one
}
var thisNode = kit.Node;
2019-09-16 17:21:22 +02:00
if (parent == null)
{
// first parent
parent = parentLink.Value;
parent.FirstChildContentId = thisNode.Id; // this node is the first node
}
else if (parent.Id != parentLink.Value.Id)
{
// new parent
parent = parentLink.Value;
parent.FirstChildContentId = thisNode.Id; // this node is the first node
previousNode = null; // there is no previous sibling
}
2019-08-19 17:18:45 +10:00
_logger.LogDebug("Set {thisNodeId} with parent {thisNodeParentContentId}", thisNode.Id, thisNode.ParentContentId);
SetValueLocked(_contentNodes, thisNode.Id, thisNode);
// if we are initializing from the database source ensure the local db is updated
if (fromDb && _localDb != null) RegisterChange(thisNode.Id, kit);
// this node is always the last child
parent.LastChildContentId = thisNode.Id;
// wire previous node as previous sibling
if (previousNode != null)
{
previousNode.NextSiblingContentId = thisNode.Id;
thisNode.PreviousSiblingContentId = previousNode.Id;
}
// this node becomes the previous node
previousNode = thisNode;
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
_contentKeyToIdMap[kit.Node.Uid] = kit.Node.Id;
}
return ok;
}
/// <summary>
/// Set all data for a collection of <see cref="ContentNodeKit"/>
/// </summary>
/// <param name="kits"></param>
/// <returns></returns>
/// <remarks>
/// This methods MUST be called from within a write lock, normally wrapped within GetScopedWriteLock
/// otherwise an exception will occur.
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if this method is not called within a write lock
/// </exception>
public bool SetAllLocked(IEnumerable<ContentNodeKit> kits)
2016-05-27 14:26:28 +02:00
{
EnsureLocked();
var ok = true;
ClearLocked(_contentNodes);
ClearRootLocked();
2016-05-27 14:26:28 +02:00
// do NOT clear types else they are gone!
//ClearLocked(_contentTypesById);
//ClearLocked(_contentTypesByAlias);
2016-05-27 14:26:28 +02:00
foreach (var kit in kits)
{
if (!BuildKit(kit, out var parent))
2016-05-27 14:26:28 +02:00
{
ok = false;
continue; // skip that one
}
_logger.LogDebug("Set {kitNodeId} with parent {kitNodeParentContentId}", kit.Node.Id, kit.Node.ParentContentId);
SetValueLocked(_contentNodes, kit.Node.Id, kit.Node);
if (_localDb != null) RegisterChange(kit.Node.Id, kit);
AddTreeNodeLocked(kit.Node, parent);
2018-03-30 14:00:44 +02:00
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
_contentKeyToIdMap[kit.Node.Uid] = kit.Node.Id;
}
return ok;
2016-05-27 14:26:28 +02:00
}
/// <summary>
/// Sets data for a branch of <see cref="ContentNodeKit"/>
/// </summary>
/// <param name="rootContentId"></param>
/// <param name="kits"></param>
/// <returns></returns>
/// <remarks>
/// <para>
/// IMPORTANT kits must be sorted out by LEVEL and by SORT ORDER
/// </para>
/// <para>
/// This methods MUST be called from within a write lock, normally wrapped within GetScopedWriteLock
/// otherwise an exception will occur.
/// </para>
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if this method is not called within a write lock
/// </exception>
public bool SetBranchLocked(int rootContentId, IEnumerable<ContentNodeKit> kits)
2016-05-27 14:26:28 +02:00
{
EnsureLocked();
var ok = true;
// get existing
_contentNodes.TryGetValue(rootContentId, out var link);
var existing = link?.Value;
2016-05-27 14:26:28 +02:00
// clear
if (existing != null)
{
//this zero's out the branch (recursively), if we're in a new gen this will add a NULL placeholder for the gen
ClearBranchLocked(existing);
2020-04-08 11:22:15 +10:00
//TODO: This removes the current GEN from the tree - do we really want to do that? (not sure if this is still an issue....)
RemoveTreeNodeLocked(existing);
}
2016-05-27 14:26:28 +02:00
// now add them all back
foreach (var kit in kits)
{
if (!BuildKit(kit, out var parent))
2016-05-27 14:26:28 +02:00
{
ok = false;
continue; // skip that one
2016-05-27 14:26:28 +02:00
}
SetValueLocked(_contentNodes, kit.Node.Id, kit.Node);
if (_localDb != null) RegisterChange(kit.Node.Id, kit);
AddTreeNodeLocked(kit.Node, parent);
2016-05-27 14:26:28 +02:00
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
_contentKeyToIdMap[kit.Node.Uid] = kit.Node.Id;
}
return ok;
2016-05-27 14:26:28 +02:00
}
/// <summary>
/// Clears data for a given node id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
/// <remarks>
/// This methods MUST be called from within a write lock, normally wrapped within GetScopedWriteLock
/// otherwise an exception will occur.
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if this method is not called within a write lock
/// </exception>
public bool ClearLocked(int id)
2016-05-27 14:26:28 +02:00
{
EnsureLocked();
// try to find the content
// if it is not there, nothing to do
_contentNodes.TryGetValue(id, out var link); // else null
if (link?.Value == null) return false;
2016-05-27 14:26:28 +02:00
var content = link.Value;
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Clear content ID: {ContentId}", content.Id);
2016-05-27 14:26:28 +02:00
// clear the entire branch
ClearBranchLocked(content);
2016-05-27 14:26:28 +02:00
// manage the tree
RemoveTreeNodeLocked(content);
2016-05-27 14:26:28 +02:00
return true;
2016-05-27 14:26:28 +02:00
}
private void ClearBranchLocked(int id)
{
2018-03-30 14:00:44 +02:00
_contentNodes.TryGetValue(id, out var link);
2017-07-12 14:09:31 +02:00
if (link?.Value == null)
2016-05-27 14:26:28 +02:00
return;
ClearBranchLocked(link.Value);
}
private void ClearBranchLocked(ContentNode content)
{
2020-04-08 11:22:15 +10:00
// This should never be null, all code that calls this method is null checking but we've seen
// issues of null ref exceptions in issue reports so we'll double check here
if (content == null) throw new ArgumentNullException(nameof(content));
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
2016-05-27 14:26:28 +02:00
SetValueLocked(_contentNodes, content.Id, null);
if (_localDb != null) RegisterChange(content.Id, ContentNodeKit.Null);
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
_contentKeyToIdMap.TryRemove(content.Uid, out _);
2018-03-30 14:00:44 +02:00
2019-04-22 17:51:07 +02:00
var id = content.FirstChildContentId;
while (id > 0)
2016-05-27 14:26:28 +02:00
{
// get the required link node, this ensures that both `link` and `link.Value` are not null
var link = GetRequiredLinkedNode(id, "child", null);
var linkValue = link.Value; // capture local since clearing in recurse can clear it
ClearBranchLocked(linkValue); // recurse
id = linkValue.NextSiblingContentId;
2016-05-27 14:26:28 +02:00
}
}
/// <summary>
/// Gets the link node and if it doesn't exist throw a <see cref="PanicException"/>
/// </summary>
/// <param name="id"></param>
/// <param name="description"></param>
/// <param name="gen">the generation requested, null for the latest stored</param>
/// <returns></returns>
private LinkedNode<ContentNode> GetRequiredLinkedNode(int id, string description, long? gen)
2019-06-12 08:55:03 +02:00
{
if (_contentNodes.TryGetValue(id, out var link))
{
link = GetLinkedNodeGen(link, gen);
if (link != null && link.Value != null)
return link;
}
2019-06-12 08:55:03 +02:00
2019-08-16 16:18:58 +10:00
throw new PanicException($"failed to get {description} with id={id}");
2019-06-12 08:55:03 +02:00
}
/// <summary>
/// Gets the parent link node, may be null or root if ParentContentId is less than 0
/// </summary>
/// <param name="gen">the generation requested, null for the latest stored</param>
private LinkedNode<ContentNode> GetParentLink(ContentNode content, long? gen)
2016-05-27 14:26:28 +02:00
{
if (content.ParentContentId < 0)
{
var root = GetLinkedNodeGen(_root, gen);
return root;
}
if (_contentNodes.TryGetValue(content.ParentContentId, out var link))
link = GetLinkedNodeGen(link, gen);
2016-05-27 14:26:28 +02:00
return link;
}
/// <summary>
/// Gets the linked parent node and if it doesn't exist throw a <see cref="PanicException"/>
/// </summary>
/// <param name="content"></param>
/// <param name="gen">the generation requested, null for the latest stored</param>
/// <returns></returns>
private LinkedNode<ContentNode> GetRequiredParentLink(ContentNode content, long? gen)
{
return content.ParentContentId < 0 ? _root : GetRequiredLinkedNode(content.ParentContentId, "parent", gen);
}
/// <summary>
/// Iterates over the LinkedNode's generations to find the correct one
/// </summary>
/// <param name="link"></param>
/// <param name="gen">The generation requested, use null to avoid the lookup</param>
/// <returns></returns>
private LinkedNode<TValue> GetLinkedNodeGen<TValue>(LinkedNode<TValue> link, long? gen)
where TValue : class
{
if (!gen.HasValue) return link;
//find the correct snapshot, find the first that is <= the requested gen
while (link != null && link.Gen > gen)
{
link = link.Next;
}
return link;
}
/// <summary>
/// This removes this current node from the tree hiearchy by removing it from it's parent's linked list
/// </summary>
/// <param name="content"></param>
/// <remarks>
/// This is called within a lock which means a new Gen is being created therefore this will not modify any existing content in a Gen.
/// </remarks>
private void RemoveTreeNodeLocked(ContentNode content)
2016-05-27 14:26:28 +02:00
{
// NOTE: DO NOT modify `content` here, this would modify data for an existing Gen, all modifications are done to clones
// which would be targeting the new Gen.
2019-06-12 08:55:03 +02:00
var parentLink = content.ParentContentId < 0
? _root
: GetRequiredLinkedNode(content.ParentContentId, "parent", null);
2019-04-22 17:51:07 +02:00
var parent = parentLink.Value;
2019-06-12 15:48:19 +02:00
// must have children
if (parent.FirstChildContentId < 0)
2019-08-16 16:18:58 +10:00
throw new PanicException("no children");
2019-06-12 15:48:19 +02:00
2019-09-16 17:21:22 +02:00
// if first/last, clone parent, then remove
if (parent.FirstChildContentId == content.Id || parent.LastChildContentId == content.Id)
2019-04-22 17:51:07 +02:00
parent = GenCloneLocked(parentLink);
2019-09-16 17:21:22 +02:00
if (parent.FirstChildContentId == content.Id)
2019-04-22 17:51:07 +02:00
parent.FirstChildContentId = content.NextSiblingContentId;
if (parent.LastChildContentId == content.Id)
parent.LastChildContentId = content.PreviousSiblingContentId;
// maintain linked list
2019-04-22 17:51:07 +02:00
if (content.NextSiblingContentId > 0)
{
var nextLink = GetRequiredLinkedNode(content.NextSiblingContentId, "next sibling", null);
var next = GenCloneLocked(nextLink);
next.PreviousSiblingContentId = content.PreviousSiblingContentId;
}
2019-04-22 17:51:07 +02:00
if (content.PreviousSiblingContentId > 0)
{
var prevLink = GetRequiredLinkedNode(content.PreviousSiblingContentId, "previous sibling", null);
var prev = GenCloneLocked(prevLink);
prev.NextSiblingContentId = content.NextSiblingContentId;
2016-05-27 14:26:28 +02:00
}
}
2018-07-05 17:08:40 +02:00
private bool ParentPublishedLocked(ContentNodeKit kit)
{
if (kit.Node.ParentContentId < 0)
return true;
var link = GetParentLink(kit.Node, null);
2018-07-05 17:08:40 +02:00
var node = link?.Value;
return node != null && node.HasPublished;
2018-07-05 17:08:40 +02:00
}
2019-04-22 17:51:07 +02:00
private ContentNode GenCloneLocked(LinkedNode<ContentNode> link)
2016-05-27 14:26:28 +02:00
{
2019-04-22 17:51:07 +02:00
var node = link.Value;
if (node != null && link.Gen != _liveGen)
2019-04-22 17:51:07 +02:00
{
node = new ContentNode(link.Value, _publishedModelFactory);
2019-04-22 17:51:07 +02:00
if (link == _root)
SetRootLocked(node);
else
SetValueLocked(_contentNodes, node.Id, node);
}
return node;
}
/// <summary>
/// Adds a node to the tree structure.
/// </summary>
private void AddTreeNodeLocked(ContentNode content, LinkedNode<ContentNode> parentLink = null)
2019-04-22 17:51:07 +02:00
{
parentLink = parentLink ?? GetRequiredParentLink(content, null);
2019-04-22 17:51:07 +02:00
var parent = parentLink.Value;
// We are doing a null check here but this should no longer be possible because we have a null check in BuildKit
// for the parent.Value property and we'll output a warning. However I'll leave this additional null check in place.
// see https://github.com/umbraco/Umbraco-CMS/issues/7868
if (parent == null)
throw new PanicException($"A null Value was returned on the {nameof(parentLink)} LinkedNode with id={content.ParentContentId}, potentially your database paths are corrupted.");
2019-06-12 15:48:19 +02:00
// if parent has no children, clone parent + add as first child
2019-04-22 17:51:07 +02:00
if (parent.FirstChildContentId < 0)
{
parent = GenCloneLocked(parentLink);
parent.FirstChildContentId = content.Id;
parent.LastChildContentId = content.Id;
2019-04-22 17:51:07 +02:00
return;
}
2019-06-12 15:48:19 +02:00
// get parent's first child
var childLink = GetRequiredLinkedNode(parent.FirstChildContentId, "first child", null);
2019-06-12 15:48:19 +02:00
var child = childLink.Value;
2019-04-22 17:51:07 +02:00
2019-06-12 15:48:19 +02:00
// if first, clone parent + insert as first child
// NOTE: Don't perform this check if loading from local DB since we know it's already sorted
2019-06-12 15:48:19 +02:00
if (child.SortOrder > content.SortOrder)
2019-04-22 17:51:07 +02:00
{
content.NextSiblingContentId = parent.FirstChildContentId;
content.PreviousSiblingContentId = -1;
2019-04-22 17:51:07 +02:00
parent = GenCloneLocked(parentLink);
parent.FirstChildContentId = content.Id;
child = GenCloneLocked(childLink);
child.PreviousSiblingContentId = content.Id;
2019-04-22 17:51:07 +02:00
return;
}
// get parent's last child
var lastChildLink = GetRequiredLinkedNode(parent.LastChildContentId, "last child", null);
var lastChild = lastChildLink.Value;
// if last, clone parent + append as last child
if (lastChild.SortOrder <= content.SortOrder)
{
content.PreviousSiblingContentId = parent.LastChildContentId;
content.NextSiblingContentId = -1;
parent = GenCloneLocked(parentLink);
parent.LastChildContentId = content.Id;
lastChild = GenCloneLocked(lastChildLink);
lastChild.NextSiblingContentId = content.Id;
return;
}
// else it's going somewhere in the middle,
// TODO: There was a note about performance when this occurs and that this only happens when moving and not very often, but that is not true,
// this also happens anytime a middle node is unpublished or republished (which causes a branch update), i'm unsure if this has perf impacts,
// i think this used to but it doesn't seem bad anymore that I can see...
2019-06-12 15:48:19 +02:00
while (child.NextSiblingContentId > 0)
2019-04-22 17:51:07 +02:00
{
2019-06-12 15:48:19 +02:00
// get next child
var nextChildLink = GetRequiredLinkedNode(child.NextSiblingContentId, "next child", null);
2019-06-12 15:48:19 +02:00
var nextChild = nextChildLink.Value;
2019-04-22 17:51:07 +02:00
2019-06-12 15:48:19 +02:00
// if here, clone previous + append/insert
// NOTE: Don't perform this check if loading from local DB since we know it's already sorted
2019-04-22 17:51:07 +02:00
if (nextChild.SortOrder > content.SortOrder)
{
content.NextSiblingContentId = nextChild.Id;
content.PreviousSiblingContentId = nextChild.PreviousSiblingContentId;
2019-06-12 15:48:19 +02:00
child = GenCloneLocked(childLink);
child.NextSiblingContentId = content.Id;
var nnext = GenCloneLocked(nextChildLink);
nnext.PreviousSiblingContentId = content.Id;
2019-04-22 17:51:07 +02:00
return;
}
2019-06-12 15:48:19 +02:00
childLink = nextChildLink;
child = nextChild;
2019-04-22 17:51:07 +02:00
}
// should never get here
throw new PanicException("No more children.");
2019-04-22 17:51:07 +02:00
}
2019-06-12 15:48:19 +02:00
// replaces the root node
2019-04-22 17:51:07 +02:00
private void SetRootLocked(ContentNode node)
{
if (_root.Gen != _liveGen)
{
_root = new LinkedNode<ContentNode>(node, _liveGen, _root);
2016-05-27 14:26:28 +02:00
}
else
{
2019-04-22 17:51:07 +02:00
_root.Value = node;
2016-05-27 14:26:28 +02:00
}
}
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
private void SetContentTypeLocked(IPublishedContentType type)
{
SetValueLocked(_contentTypesById, type.Id, type);
SetValueLocked(_contentTypesByAlias, type.Alias, type);
// ensure the key/id map is accurate
_contentTypeKeyToIdMap[type.Key] = type.Id;
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
}
2019-06-12 15:48:19 +02:00
// set a node (just the node, not the tree)
2016-05-27 14:26:28 +02:00
private void SetValueLocked<TKey, TValue>(ConcurrentDictionary<TKey, LinkedNode<TValue>> dict, TKey key, TValue value)
where TValue : class
{
// this is safe only because we're write-locked
var link = GetHead(dict, key);
if (link != null)
{
// already in the dict
if (link.Gen != _liveGen)
{
// for an older gen - if value is different then insert a new
2016-05-27 14:26:28 +02:00
// link for the new gen, with the new value
if (link.Value != value)
dict.TryUpdate(key, new LinkedNode<TValue>(value, _liveGen, link), link);
}
else
{
// for the live gen - we can fix the live gen - and remove it
// if value is null and there's no next gen
if (value == null && link.Next == null)
dict.TryRemove(key, out link);
else
link.Value = value;
}
}
else
{
dict.TryAdd(key, new LinkedNode<TValue>(value, _liveGen));
}
}
private void ClearLocked<TKey, TValue>(ConcurrentDictionary<TKey, LinkedNode<TValue>> dict)
where TValue : class
{
// this is safe only because we're write-locked
foreach (var kvp in dict.Where(x => x.Value != null))
2016-05-27 14:26:28 +02:00
{
if (kvp.Value.Gen != _liveGen)
2016-05-27 14:26:28 +02:00
{
var link = new LinkedNode<TValue>(null, _liveGen, kvp.Value);
dict.TryUpdate(kvp.Key, link, kvp.Value);
2016-05-27 14:26:28 +02:00
}
else
{
kvp.Value.Value = null;
}
}
2016-05-27 14:26:28 +02:00
}
public ContentNode Get(int id, long gen)
{
return GetValue(_contentNodes, id, gen);
}
2018-03-30 14:00:44 +02:00
public ContentNode Get(Guid uid, long gen)
{
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
return _contentKeyToIdMap.TryGetValue(uid, out var id)
2018-03-30 14:00:44 +02:00
? GetValue(_contentNodes, id, gen)
: null;
}
2016-05-27 14:26:28 +02:00
public IEnumerable<ContentNode> GetAtRoot(long gen)
{
var root = GetLinkedNodeGen(_root, gen);
if (root == null)
2019-04-22 17:51:07 +02:00
yield break;
var id = root.Value.FirstChildContentId;
2019-04-22 17:51:07 +02:00
while (id > 0)
{
var link = GetRequiredLinkedNode(id, "root", gen);
2019-04-22 17:51:07 +02:00
yield return link.Value;
id = link.Value.NextSiblingContentId;
2016-05-27 14:26:28 +02:00
}
}
private TValue GetValue<TKey, TValue>(ConcurrentDictionary<TKey, LinkedNode<TValue>> dict, TKey key, long gen)
where TValue : class
{
// look ma, no lock!
var link = GetHead(dict, key);
link = GetLinkedNodeGen(link, gen);
return link?.Value; // may be null
2016-05-27 14:26:28 +02:00
}
public IEnumerable<ContentNode> GetAll(long gen)
{
// enumerating on .Values locks the concurrent dictionary,
// so better get a shallow clone in an array and release
var links = _contentNodes.Values.ToArray();
foreach (var l in links)
{
var link = GetLinkedNodeGen(l, gen);
if (link?.Value != null)
yield return link.Value;
}
}
2016-05-27 14:26:28 +02:00
public bool IsEmpty(long gen)
{
var has = _contentNodes.Any(x =>
{
var link = GetLinkedNodeGen(x.Value, gen);
return link?.Value != null;
2016-05-27 14:26:28 +02:00
});
return has == false;
}
2019-04-15 13:04:14 +02:00
public IPublishedContentType GetContentType(int id, long gen)
2016-05-27 14:26:28 +02:00
{
return GetValue(_contentTypesById, id, gen);
}
2019-04-15 13:04:14 +02:00
public IPublishedContentType GetContentType(string alias, long gen)
2016-05-27 14:26:28 +02:00
{
return GetValue(_contentTypesByAlias, alias, gen);
}
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
public IPublishedContentType GetContentType(Guid key, long gen)
{
if (!_contentTypeKeyToIdMap.TryGetValue(key, out var id))
return null;
return GetContentType(id, gen);
}
2016-05-27 14:26:28 +02:00
#endregion
#region Snapshots
public Snapshot CreateSnapshot()
{
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
lock (_rlocko)
2016-05-27 14:26:28 +02:00
{
// if no next generation is required, and we already have one,
// use it and create a new snapshot
2019-02-22 15:30:55 +01:00
if (_nextGen == false && _genObj != null)
return new Snapshot(this, _genObj.GetGenRef()
2016-05-27 14:26:28 +02:00
#if DEBUG
, _loggerFactory.CreateLogger<Snapshot>()
2016-05-27 14:26:28 +02:00
#endif
);
// else we need to try to create a new gen ref
// whether we are wlocked or not, noone can rlock while we do,
// so _liveGen and _nextGen are safe
if (Monitor.IsEntered(_wlocko))
2016-05-27 14:26:28 +02:00
{
// write-locked, cannot use latest gen (at least 1) so use previous
var snapGen = _nextGen ? _liveGen - 1 : _liveGen;
// create a new gen ref unless we already have it
2019-02-22 15:30:55 +01:00
if (_genObj == null)
_genObjs.Enqueue(_genObj = new GenObj(snapGen));
else if (_genObj.Gen != snapGen)
throw new PanicException($"The generation {_genObj.Gen} does not equal the snapshot generation {snapGen}");
2016-05-27 14:26:28 +02:00
}
else
{
// not write-locked, can use latest gen, create a new gen ref
2019-02-22 15:30:55 +01:00
_genObjs.Enqueue(_genObj = new GenObj(_liveGen));
2016-05-27 14:26:28 +02:00
_nextGen = false; // this is the ONLY thing that triggers a _liveGen++
}
// so...
// the genRefRef has a weak ref to the genRef, and is queued
// the snapshot has a ref to the genRef, which has a ref to the genRefRef
// when the snapshot is disposed, it decreases genRefRef counter
// so after a while, one of these conditions is going to be true:
// - the genRefRef counter is zero because all snapshots have properly been disposed
// - the genRefRef weak ref is dead because all snapshots have been collected
// in both cases, we will dequeue and collect
2019-02-22 15:30:55 +01:00
var snapshot = new Snapshot(this, _genObj.GetGenRef()
2016-05-27 14:26:28 +02:00
#if DEBUG
, _loggerFactory.CreateLogger<Snapshot>()
2016-05-27 14:26:28 +02:00
#endif
);
// reading _floorGen is safe if _collectTask is null
if (_collectTask == null && _collectAuto && _liveGen - _floorGen > CollectMinGenDelta)
{
2016-05-27 14:26:28 +02:00
CollectAsyncLocked();
}
2016-05-27 14:26:28 +02:00
return snapshot;
}
2016-05-27 14:26:28 +02:00
}
2017-07-18 19:24:27 +02:00
public Snapshot LiveSnapshot => new Snapshot(this, _liveGen
#if DEBUG
, _loggerFactory.CreateLogger<Snapshot>()
2017-07-18 19:24:27 +02:00
#endif
);
2016-05-27 14:26:28 +02:00
public Task CollectAsync()
{
lock (_rlocko)
{
return CollectAsyncLocked();
}
}
private Task CollectAsyncLocked()
{
// NOTE: What in the heck is going on here? Why is any of this running in async contexts?
// SD: From what I can tell this was designed to be a set and forget background task to do the
// collecting which is why it's called from non-async methods within this class. This is
// slightly dangerous because it's not taking into account app shutdown.
// TODO: There should be a different method or class responsible for executing the cleanup on a
// background (set and forget) thread.
2016-05-27 14:26:28 +02:00
if (_collectTask != null)
{
2016-05-27 14:26:28 +02:00
return _collectTask;
}
2016-05-27 14:26:28 +02:00
// ReSharper disable InconsistentlySynchronizedField
var task = _collectTask = Task.Run((Action)Collect);
2016-05-27 14:26:28 +02:00
_collectTask.ContinueWith(_ =>
{
lock (_rlocko)
{
_collectTask = null;
}
},
CancellationToken.None,
TaskContinuationOptions.ExecuteSynchronously,
// Must explicitly specify this, see https://blog.stephencleary.com/2013/10/continuewith-is-dangerous-too.html
TaskScheduler.Default);
2016-05-27 14:26:28 +02:00
// ReSharper restore InconsistentlySynchronizedField
return task;
}
private void Collect()
{
// see notes in CreateSnapshot
#if DEBUG
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Collect.");
2016-05-27 14:26:28 +02:00
#endif
2019-02-22 15:30:55 +01:00
while (_genObjs.TryPeek(out var genObj) && (genObj.Count == 0 || genObj.WeakGenRef.IsAlive == false))
2016-05-27 14:26:28 +02:00
{
2019-02-22 15:30:55 +01:00
_genObjs.TryDequeue(out genObj); // cannot fail since TryPeek has succeeded
_floorGen = genObj.Gen;
2016-05-27 14:26:28 +02:00
#if DEBUG
2020-09-15 08:45:40 +02:00
//_logger.LogDebug("_floorGen=" + _floorGen + ", _liveGen=" + _liveGen);
2016-05-27 14:26:28 +02:00
#endif
}
Collect(_contentNodes);
2019-04-22 17:51:07 +02:00
CollectRoot();
2016-05-27 14:26:28 +02:00
Collect(_contentTypesById);
Collect(_contentTypesByAlias);
}
2019-04-22 17:51:07 +02:00
private void CollectRoot()
{
var link = _root;
while (link.Next != null && link.Next.Gen > _floorGen)
link = link.Next;
link.Next = null;
}
2016-05-27 14:26:28 +02:00
private void Collect<TKey, TValue>(ConcurrentDictionary<TKey, LinkedNode<TValue>> dict)
where TValue : class
{
// it is OK to enumerate a concurrent dictionary and it does not lock
// it - and here it's not an issue if we skip some items, they will be
// processed next time we collect
long liveGen;
lock (_rlocko) // r is good
{
liveGen = _liveGen;
if (_nextGen == false)
liveGen += 1;
}
foreach (var kvp in dict)
{
var link = kvp.Value;
#if DEBUG
2020-09-15 08:45:40 +02:00
//_logger.LogDebug("Collect id:" + kvp.Key + ", gen:" + link.Gen +
// ", nxt:" + (link.Next == null ? "null" : "link") +
2016-05-27 14:26:28 +02:00
// ", val:" + (link.Value == null ? "null" : "value"));
#endif
// reasons to collect the head:
// gen must be < liveGen (we never collect live gen)
// next == null && value == null (we have no data at all)
// next != null && value == null BUT gen > floor (noone wants us)
// not live means .Next and .Value are safe
if (link.Gen < liveGen && link.Value == null
&& (link.Next == null || link.Gen <= _floorGen))
{
// not live, null value, no next link = remove that one -- but only if
2016-05-27 14:26:28 +02:00
// the dict has not been updated, have to do it via ICollection<> (thanks
// Mr Toub) -- and if the dict has been updated there is nothing to collect
var idict = dict as ICollection<KeyValuePair<TKey, LinkedNode<TValue>>>;
idict.Remove(kvp);
continue;
}
// in any other case we're not collecting the head, we need to go to Next
// and if there is no Next, skip
if (link.Next == null)
continue;
// else go to Next and loop while above floor, and kill everything below
while (link.Next != null && link.Next.Gen > _floorGen)
link = link.Next;
link.Next = null;
}
}
// TODO: This is never used? Should it be? Maybe move to TestHelper below?
//public async Task WaitForPendingCollect()
//{
// Task task;
// lock (_rlocko)
// {
// task = _collectTask;
// }
// if (task != null)
// await task;
//}
2016-05-27 14:26:28 +02:00
2019-02-22 15:30:55 +01:00
public long GenCount => _genObjs.Count;
2016-05-27 14:26:28 +02:00
2019-02-22 15:30:55 +01:00
public long SnapCount => _genObjs.Sum(x => x.Count);
2016-05-27 14:26:28 +02:00
#endregion
#region Internals/Unit testing
2016-05-27 14:26:28 +02:00
private TestHelper _unitTesting;
// note: nothing here is thread-safe
internal class TestHelper
{
2017-07-12 14:09:31 +02:00
private readonly ContentStore _store;
2016-05-27 14:26:28 +02:00
2017-07-12 14:09:31 +02:00
public TestHelper(ContentStore store)
2016-05-27 14:26:28 +02:00
{
_store = store;
}
2017-07-12 14:09:31 +02:00
public long LiveGen => _store._liveGen;
public long FloorGen => _store._floorGen;
public bool NextGen => _store._nextGen;
public bool CollectAuto
{
get => _store._collectAuto;
set => _store._collectAuto = value;
}
2016-05-27 14:26:28 +02:00
/// <summary>
/// Return a list of Gen/ContentNode values
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public (long gen, ContentNode contentNode)[] GetValues(int id)
2016-05-27 14:26:28 +02:00
{
2017-07-12 14:09:31 +02:00
_store._contentNodes.TryGetValue(id, out LinkedNode<ContentNode> link); // else null
2016-05-27 14:26:28 +02:00
if (link == null)
return Array.Empty<(long, ContentNode)>();
2016-05-27 14:26:28 +02:00
var tuples = new List<(long, ContentNode)>();
2016-05-27 14:26:28 +02:00
do
{
tuples.Add((link.Gen, link.Value));
2016-05-27 14:26:28 +02:00
link = link.Next;
} while (link != null);
return tuples.ToArray();
}
}
2017-07-12 14:09:31 +02:00
internal TestHelper Test => _unitTesting ?? (_unitTesting = new TestHelper(this));
2016-05-27 14:26:28 +02:00
#endregion
#region Classes
public class Snapshot : IDisposable
{
2017-07-12 14:09:31 +02:00
private readonly ContentStore _store;
2016-05-27 14:26:28 +02:00
private readonly GenRef _genRef;
private long _gen;
#if DEBUG
private readonly ILogger<Snapshot> _logger;
2016-05-27 14:26:28 +02:00
#endif
//private static int _count;
//private readonly int _thisCount;
2017-07-12 14:09:31 +02:00
internal Snapshot(ContentStore store, GenRef genRef
2016-05-27 14:26:28 +02:00
#if DEBUG
, ILogger<Snapshot> logger
2016-05-27 14:26:28 +02:00
#endif
)
{
_store = store;
_genRef = genRef;
_gen = genRef.Gen;
2019-02-22 15:30:55 +01:00
Interlocked.Increment(ref genRef.GenObj.Count);
2016-05-27 14:26:28 +02:00
//_thisCount = _count++;
#if DEBUG
_logger = logger;
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Creating snapshot.");
2016-05-27 14:26:28 +02:00
#endif
}
2017-07-18 19:24:27 +02:00
internal Snapshot(ContentStore store, long gen
#if DEBUG
, ILogger<Snapshot> logger
2017-07-18 19:24:27 +02:00
#endif
)
{
_store = store;
_gen = gen;
2017-07-18 19:24:27 +02:00
#if DEBUG
_logger = logger;
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Creating live.");
2017-07-18 19:24:27 +02:00
#endif
}
2016-05-27 14:26:28 +02:00
public ContentNode Get(int id)
{
if (_gen < 0)
throw new ObjectDisposedException("snapshot" /*+ " (" + _thisCount + ")"*/);
return _store.Get(id, _gen);
}
public ContentNode Get(Guid id)
{
if (_gen < 0)
throw new ObjectDisposedException("snapshot" /*+ " (" + _thisCount + ")"*/);
2018-03-30 14:00:44 +02:00
return _store.Get(id, _gen);
}
2016-05-27 14:26:28 +02:00
public IEnumerable<ContentNode> GetAtRoot()
{
if (_gen < 0)
throw new ObjectDisposedException("snapshot" /*+ " (" + _thisCount + ")"*/);
return _store.GetAtRoot(_gen);
}
2018-03-30 14:00:44 +02:00
public IEnumerable<ContentNode> GetAll()
{
if (_gen < 0)
throw new ObjectDisposedException("snapshot" /*+ " (" + _thisCount + ")"*/);
return _store.GetAll(_gen);
}
2019-04-15 13:04:14 +02:00
public IPublishedContentType GetContentType(int id)
2016-05-27 14:26:28 +02:00
{
if (_gen < 0)
throw new ObjectDisposedException("snapshot" /*+ " (" + _thisCount + ")"*/);
return _store.GetContentType(id, _gen);
}
2019-04-15 13:04:14 +02:00
public IPublishedContentType GetContentType(string alias)
2016-05-27 14:26:28 +02:00
{
if (_gen < 0)
throw new ObjectDisposedException("snapshot" /*+ " (" + _thisCount + ")"*/);
return _store.GetContentType(alias, _gen);
}
Block Editor List (#8273) * add style to create-option in itempicker + removing overflow hidden * style adjustment * clean up of html * correct sentence to use the number 7 * correct overlays, so they can use size * numberrange prevalue editor * add confirmRemove overlay * correcting primary btn colors * move confirmMessage below content of overlay. * min max validation for numberrange * remove comment * improved actions for block list * use file tree for view picker * style adjustment to border of creator item in item-picker * vertical align * clean up + validation limit range * rename ElementTypes to Blocks * implement block list editor * renaming * use Chrome Headless for unit tests * test for blockEditorService * safer code * block list editor * rename view to overlayView * block editor work * Revert "rename view to overlayView" This reverts commit 5b910c178a4f193d190367c4f1da3402aa8c4d0e. * block editor implementation * sync models * block list editor copy paste feature * order var declarations * remove unused paste function * block list editor better naming * simpler label generation * clean up * compile config for test mode * Chrome Debug for VS code * promise test working * space change * another two tests * more tests for block list editor * provide key on blockModel for angularJS performance optimization * syncronization from infinite editing layers * use an isolated scope * more tests * fix C# test * remove unused block watcher component * clean css * only show on hover or focus for block-actions * clean up and prepare for implementing settings * remove console * Add ability to render block list editor using Grid style rendering extension * Enable Block List Editor settings editing * Add Stacked Content to Block List migration * Block Editor: Clean-up, refactoring, one step closer being ready for Content-Apps * changes naming to Submit, to avoid misunderstanding. * use a common variable on the block model for isOpen, to be able to make Actions show when open. * NotSupported property editor, to be used when an editor is not supported in the given context. * remove unused controller * Hide group header if only one group is presented * rename notsupport property editor css class * smaller header for property group * hide description if no description is presented * css adjustments * Inline create button styling: Better spacing, darker blue color for Focus Outline, moving the plus icon to mouse position for better visual appearance. * css correction * Add references for picked items * Revert commit 45e892f3505059674779c6e1a43084a367c2862f - Changes api to GetData * Use the .Data propertry as opposed to GetData in this PartialView * Fix block list test failures * Just parsing layout as model for partial views. * minor adjustments * Remove DB migrations so that they can be reviewed as a block * Add migrations for new block editor * Update default rendering partial view * Add error handling to default template * Handle color picker data in stacked content * BlockList PreValue Editor opens configurations as overlay * translation for prevalue editor property group headlines * blockcard corrections * block list prevalue corrections * revert agressive clean up * Block Picker * MaxPropertyWidth PreValue + Implementation * Incorporate latest block list editor changes, update migration for changed configuration * Change declared converter type * Handle invalid data type references * Remove code duplicated from PR #7957 * use ElementModel for the ContentModel of an ElementType. So we can use ElementTypeModel for the ModelDefinition aka. the Type. * do still show itempicker for BlockConfiguration even though there is no ElementTypes to pick. This enables the option to create a new ElementType to be used. * use the right wrapper, for correct spacing * parse item * correct fallback for label * removed unused callback * paste feature for block-picker * localize block-picker tabs * Slightly change for shadow on block-picker item hover * Localization of BlockEditor Settings Tab * localizationService * only filter when more than 8 items available * Add multiple blocks if hold down CTRL or SuperKey * adds notes * ability to add a scoped stylesheet for block view * make scoped block draggable + style adjustments * provide index for custom view * rename contentModel to data + rename layoutModel to layout * clean up * more localization * openSettings option for block editor * minor changes for a better developer experience * paste mistake corrected * only manipulate content-content-app if its present * make small overlays slightly bigger * moved block list entry editor into block list editor folder * limit labelinterpretator to only runs ones pr. edit. and lets make sure to have a label thought we dont have any properties. * fixed inline views gulp watcher * changed vm to a better controller instance name * make watch for views work again. * able to re run watch * make js up to date * fix white background of image-picker * media-picker container class * loading indication * adjust unit tests to latest interface * getting started on JS Docs * converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs. * revert change * add todo * use Guid for Key * use key * Updates the caching layer to handle GUID keys for content types while preserving backwards compat, fixes unit tests, removes the strongly typed lists for the block editor value since it's unecessary * Reverts the nested content changes, fixes up the GetEmptyByKey * Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests. * Allows key in SimpleContentType * correct for the new spelling * appended this. since the method is a non-static class method. * only add background-image if value isnt null * simplifyed limits validation * clean up * no need to execute a digest. * define the full model for new configurations * removed setDataFromBlockModel and general clean up and added documentation * default size should be medium * use retriveValuesFrom method to transfer data. * ability to disable an navigation item * createElementTypeAndCallback working again for settings. * still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. * disable clipboard tab if no available paste options * ups, should stay as alias * disable clipboard when empty * use property alias for content add button * use a grey that can be seen on top of grey and on top of white. * some accessibility improvements * rename entry to block * appended ' and added space in Element Type * use background color for hover to corospond with active state * make nested content unsupported * Moving BlockEditorModelObject into its own file for Documentation purpose. Same goes for renaming BlockModel to BlockObject. and a lot of documentation written. * fix links in js docs * added a blocklistentryeditor for unsupported blocks * ability to retrive the $scope from UmbVariantContentEditors, needed for Block Editor to get a scope existing across variants and splitview. * Appending the block objects to layout, to share it across variants and in split-view. * removed trailing comma * Unsupported block * Dont copy unsupported blocks * use grey color for unsupported block * text correction * we dont have this fallback anymore * sort properties * Text change * css correction * use active to determine if an inline editor is expanded. To enable the inline editor to be expanded on creation. * using udi instead of key. * bringing the runtime block key back * live editing ability * live editing for settings data * call formSubmit before property editor are removed from DOM. Both for overlay-editing and inline-editing. Fire an postFormSubmitting event after formSubmitting event to let editors know that data could have been updated. * make sure settings object exists * only set active to false if it was false before opening the editor. * update test with new scope parameter * move destroy responsibility to blockObject * rename onDestroy to destroy * added some JS-Docs * correction jsDocs * Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead * Remove partially completed ConvertToElement migration, fixed in issue 7939 instead. * Remove external property editor migration * corrected naming of umbBlockListScopedBlock and umbBlockListBlock * correct ngdoc type * removed vscode specific configuration of karma * Finished Todo, gets name of documentType if copying all entities in an infinite editor * changed comment from TODO to something that explains the state. * stop tracking build output files. * rename files to match file name conventions * this should not happen. * remove dublicated code * rename requestCopyBlock to copyBlock * make sure images does not repeat. * scale thumbnail for block showcase * renamed blockcard.component to umb-block-card and moved it. * removed inline style * correct style location * corrected filepath * corrected file path * keep elementTypes up to date through the EventService. * mark Umbraco.BlockList as unsupported inside Nested Content * correct js docs name * remove comment * remove comment * remove unused controller * rename inline method name * corrected spelling mistake * remove not very used vars * make binding one-way * split in multiple lines * corrected default rendering * removing documentation that is relevant for developers of new block editors. this documentation will be transfered to Our documentation. * added danish translation * corrected blog to blok * Remove invalid using statement * use native forEach Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Benjamin Carleski <benjamin@proworks.com> Co-authored-by: Warren Buckley <warren@umbraco.com> Co-authored-by: Niels Lyngsø <nsl@umbraco.com> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Claus <claus@claus.nu>
2020-06-30 19:52:42 +10:00
public IPublishedContentType GetContentType(Guid key)
{
if (_gen < 0)
throw new ObjectDisposedException("snapshot" /*+ " (" + _thisCount + ")"*/);
return _store.GetContentType(key, _gen);
}
// this code is here just so you don't try to implement it
// the only way we can iterate over "all" without locking the entire cache forever
// is by shallow cloning the cache, which is quite expensive, so we should probably not do it,
// and implement cache-level indexes
//public IEnumerable<ContentNode> GetAll()
//{
// if (_gen < 0)
// throw new ObjectDisposedException("snapshot" /*+ " (" + _thisCount + ")"*/);
// return _store.GetAll(_gen);
//}
2016-05-27 14:26:28 +02:00
public bool IsEmpty
{
get
{
if (_gen < 0)
throw new ObjectDisposedException("snapshot" /*+ " (" + _thisCount + ")"*/);
return _store.IsEmpty(_gen);
}
}
public long Gen
{
get
{
if (_gen < 0)
throw new ObjectDisposedException("snapshot" /*+ " (" + _thisCount + ")"*/);
return _gen;
}
}
public void Dispose()
{
if (_gen < 0) return;
#if DEBUG
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Dispose snapshot ({Snapshot})", _genRef?.GenObj.Count.ToString() ?? "live");
2016-05-27 14:26:28 +02:00
#endif
_gen = -1;
if (_genRef != null)
2019-02-22 15:30:55 +01:00
Interlocked.Decrement(ref _genRef.GenObj.Count);
2016-05-27 14:26:28 +02:00
GC.SuppressFinalize(this);
}
}
#endregion
}
}