From a9f5419a792811145ec39f0dc8147fdb48e85706 Mon Sep 17 00:00:00 2001 From: Dmitry Dzygin Date: Thu, 17 Aug 2017 13:33:01 +0200 Subject: [PATCH 01/57] Refactoring --- .../XmlDataProviderDocumentCache.cs | 22 ++++++++-------- .../XmlDataProvider/XmlDataTypeStore.cs | 25 ++++++++----------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Composite/Plugins/Data/DataProviders/XmlDataProvider/Foundation/XmlDataProviderDocumentCache.cs b/Composite/Plugins/Data/DataProviders/XmlDataProvider/Foundation/XmlDataProviderDocumentCache.cs index 8fd6e53d86..9873e2b6a5 100644 --- a/Composite/Plugins/Data/DataProviders/XmlDataProvider/Foundation/XmlDataProviderDocumentCache.cs +++ b/Composite/Plugins/Data/DataProviders/XmlDataProvider/Foundation/XmlDataProviderDocumentCache.cs @@ -47,10 +47,7 @@ internal static void RegisterExternalFileChangeAction(string filename, Action ac } - public static object SyncRoot - { - get { return _documentEditingSyncRoot; } - } + public static object SyncRoot => _documentEditingSyncRoot; [System.Diagnostics.CodeAnalysis.SuppressMessage("Composite.IO", "Composite.DoNotUseFileClass:DoNotUseFileClass", Justification = "This is what we want, handle broken saves")] @@ -132,7 +129,7 @@ private static List ExtractElements(XDocument xDocument) xDocument.Root.RemoveNodes(); - return result; + return result; } @@ -157,13 +154,15 @@ private static void SaveChanges(FileRecord fileRecord) /// private static IList GetCandidateFiles(string filePath) { - List files = new List(); + var files = new List(); if (C1File.Exists(filePath)) { files.Add(new C1FileInfo(filePath)); } - var tmpFilePaths = C1Directory.GetFiles(Path.GetDirectoryName(filePath), string.Format("{0}.*.tmp", Path.GetFileName(filePath))); + var tmpFilePaths = C1Directory.GetFiles( + Path.GetDirectoryName(filePath), + $"{Path.GetFileName(filePath)}.*.tmp"); foreach (string tmpFilePath in tmpFilePaths) { @@ -331,19 +330,19 @@ private static FileRecord LoadFileRecordFromDisk(string filePath, string element } catch (Exception) { - Log.LogWarning(LogTitle, "Failed to clean up ghost file '{0}'.", filePath); + Log.LogWarning(LogTitle, $"Failed to clean up ghost file '{filePath}'."); } } } - DateTime lastModifiedFileDate = usedFile != null ? usedFile.LastWriteTime : DateTime.Now; + DateTime lastModifiedFileDate = usedFile?.LastWriteTime ?? DateTime.Now; return new FileRecord { FilePath = filePath, ElementName = elementName, RecordSet = new RecordSet { Index = index }, - ReadOnlyElementsList = new List(elements), + ReadOnlyElementsList = elements, LastModified = DateTime.Now, FileModificationDate = lastModifiedFileDate }; @@ -356,8 +355,7 @@ private static XDocument TryLoad(C1FileInfo candidateFile) XDocument dataDocument = null; try { - XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); - xmlReaderSettings.CheckCharacters = false; + var xmlReaderSettings = new XmlReaderSettings { CheckCharacters = false }; using (XmlReader xmlReader = XmlReaderUtils.Create(candidateFile.FullName, xmlReaderSettings)) { diff --git a/Composite/Plugins/Data/DataProviders/XmlDataProvider/XmlDataTypeStore.cs b/Composite/Plugins/Data/DataProviders/XmlDataProvider/XmlDataTypeStore.cs index 7a3c41bf46..d9a7d52735 100644 --- a/Composite/Plugins/Data/DataProviders/XmlDataProvider/XmlDataTypeStore.cs +++ b/Composite/Plugins/Data/DataProviders/XmlDataProvider/XmlDataTypeStore.cs @@ -20,7 +20,7 @@ namespace Composite.Plugins.Data.DataProviders.XmlDataProvider /// This class contains one entry per data-scope/locale-scope that contains /// the filename and element name. /// - [DebuggerDisplay("{DataTypeDescriptor}")] + [DebuggerDisplay("{" + nameof(DataTypeDescriptor) + "}")] internal sealed class XmlDataTypeStore { private IXmlDataProviderHelper _helper; @@ -30,12 +30,9 @@ internal sealed class XmlDataTypeStore public XmlDataTypeStore(DataTypeDescriptor dataTypeDescriptor, Type dataProviderHelperType, Type dataIdClassType, IEnumerable xmlDateTypeStoreDataScopes, bool isGeneratedDataType) { - if (dataProviderHelperType == null) throw new ArgumentNullException("dataProviderHelperType"); - if (dataIdClassType == null) throw new ArgumentNullException("dataIdClassType"); - - DataTypeDescriptor = dataTypeDescriptor; - DataProviderHelperType = dataProviderHelperType; - DataIdClassType = dataIdClassType; + DataTypeDescriptor = dataTypeDescriptor ?? throw new ArgumentNullException(nameof(dataTypeDescriptor)); + DataProviderHelperType = dataProviderHelperType ?? throw new ArgumentNullException(nameof(dataProviderHelperType)); + DataIdClassType = dataIdClassType ?? throw new ArgumentNullException(nameof(dataIdClassType)); IsGeneratedDataType = isGeneratedDataType; _xmlDateTypeStoreDataScopes = xmlDateTypeStoreDataScopes.Evaluate(); @@ -62,17 +59,16 @@ public XmlDataTypeStore(DataTypeDescriptor dataTypeDescriptor, Type dataProvider } - public DataTypeDescriptor DataTypeDescriptor { get; private set; } + public DataTypeDescriptor DataTypeDescriptor { get; } /// /// This is a implementation of and /// - public Type DataProviderHelperType { get; private set; } - - public Type DataIdClassType { get; private set; } + public Type DataProviderHelperType { get; } + public Type DataIdClassType { get; } - public bool IsGeneratedDataType { get; private set; } + public bool IsGeneratedDataType { get; } public bool HasDataScopeName(DataScopeIdentifier dataScopeIdentifier) @@ -103,8 +99,7 @@ public XmlDataTypeStoreDataScope GetDataScope(DataScopeIdentifier dataScope, Cul { if (culture.Equals(CultureInfo.InvariantCulture) && DataLocalizationFacade.IsLocalized(type)) { - throw new InvalidOperationException("Failed to get data for type '{0}', no localization scope is provided for a localized type." - .FormatWith(type.FullName)); + throw new InvalidOperationException($"Failed to get data for type '{type.FullName}', no localization scope is provided for a localized type."); } throw new InvalidOperationException("Failed to get '{0}' data for data scope ({1}, {2})" @@ -115,7 +110,7 @@ public XmlDataTypeStoreDataScope GetDataScope(DataScopeIdentifier dataScope, Cul } - internal IEnumerable XmlDataTypeStoreDataScopes { get { return _xmlDateTypeStoreDataScopes; } } + internal IEnumerable XmlDataTypeStoreDataScopes => _xmlDateTypeStoreDataScopes; public IXmlDataProviderHelper Helper From 2e98ca3eae633c14f0f35c1bce6bad371a5cec65 Mon Sep 17 00:00:00 2001 From: Dmitry Dzygin Date: Fri, 18 Aug 2017 13:12:08 +0200 Subject: [PATCH 02/57] Fixing exceptions in the code handling the externally added workflows --- .../Workflow/FilePersistenceService.cs | 2 +- .../C1Console/Workflow/WorkflowFacadeImpl.cs | 35 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Composite/C1Console/Workflow/FilePersistenceService.cs b/Composite/C1Console/Workflow/FilePersistenceService.cs index 3f22a2f45d..cc7b6c11e0 100644 --- a/Composite/C1Console/Workflow/FilePersistenceService.cs +++ b/Composite/C1Console/Workflow/FilePersistenceService.cs @@ -25,7 +25,7 @@ internal class FileWorkflowPersistenceService : WorkflowPersistenceService private C1FileSystemWatcher _fileWatcher; - private readonly ConcurrentDictionary _createdWorkflows = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary _createdWorkflows = new ConcurrentDictionary(); public FileWorkflowPersistenceService(string baseDirectory) { diff --git a/Composite/C1Console/Workflow/WorkflowFacadeImpl.cs b/Composite/C1Console/Workflow/WorkflowFacadeImpl.cs index d00013e8bc..2f4f3504f0 100644 --- a/Composite/C1Console/Workflow/WorkflowFacadeImpl.cs +++ b/Composite/C1Console/Workflow/WorkflowFacadeImpl.cs @@ -197,12 +197,12 @@ public WorkflowInstance CreateNewWorkflow(Type workflowType, Dictionary(); + var managementConsoleMessageService = flowControllerServicesContainer?.GetService(); if (managementConsoleMessageService == null) return false; @@ -1460,16 +1461,16 @@ public Resources() this.EventHandleFilters = new Dictionary(); } - public Dictionary WorkflowStatusDictionary { get; set; } - public Dictionary FormData { get; set; } - public Dictionary FlowControllerServicesContainers { get; set; } + public Dictionary WorkflowStatusDictionary { get; } + public Dictionary FormData { get; } + public Dictionary FlowControllerServicesContainers { get; } - public Dictionary WorkflowPersistingTypeDictionary { get; set; } + public Dictionary WorkflowPersistingTypeDictionary { get; } - public Dictionary WorkflowIdleWaitSemaphores { get; set; } - public Dictionary ExceptionFromWorkflow { get; set; } + public Dictionary WorkflowIdleWaitSemaphores { get; private set; } + public Dictionary ExceptionFromWorkflow { get; private set; } - public Dictionary EventHandleFilters { get; set; } + public Dictionary EventHandleFilters { get; } public static void InitializeResources(Resources resources) { From d17e759384a85255389b4c60d6064cfef9d5de68 Mon Sep 17 00:00:00 2001 From: Dmitry Dzygin Date: Tue, 22 Aug 2017 15:21:01 +0200 Subject: [PATCH 03/57] Compatibility fix for the EntityToken.DoDeserialize(..., out Dictionary dictionary) method --- Composite/C1Console/Security/EntityToken.cs | 75 +++++++++++---------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/Composite/C1Console/Security/EntityToken.cs b/Composite/C1Console/Security/EntityToken.cs index 9c1696c816..07823a8dc7 100644 --- a/Composite/C1Console/Security/EntityToken.cs +++ b/Composite/C1Console/Security/EntityToken.cs @@ -88,51 +88,55 @@ protected string DoSerialize() } - /// protected static void DoDeserialize(string serializedEntityToken, out string type, out string source, out string id) { - if(CompositeJsonSerializer.IsJsonSerialized(serializedEntityToken)) + DoDeserialize(serializedEntityToken, out type, out source, out id, + out Dictionary _); + } + + + /// + protected static void DoDeserialize(string serializedEntityToken, out string type, out string source, out string id, out Dictionary dictionary) + { + if (!CompositeJsonSerializer.IsJsonSerialized(serializedEntityToken)) { - var entityToken = - CompositeJsonSerializer.Deserialize>(serializedEntityToken); - if (entityToken.ContainsKey(nameof(Type)) && - entityToken.ContainsKey(nameof(Source)) && - entityToken.ContainsKey(nameof(Id))) - { - type = entityToken[nameof(Type)]; - source = entityToken[nameof(Source)]; - id = entityToken[nameof(Id)]; - } - else - { - throw new ArgumentException("Is not a serialized entity token", nameof(serializedEntityToken)); - } + DoDeserializeLegacy(serializedEntityToken, out type, out source, out id, out dictionary); + return; } - else - { - Dictionary dic; - DoDeserialize(serializedEntityToken, out type, out source, out id, out dic); + var properties = CompositeJsonSerializer.Deserialize>(serializedEntityToken); + + if (!properties.TryGetValue(nameof(Type), out type) + || !properties.TryGetValue(nameof(Source), out source) + || !properties.TryGetValue(nameof(Id), out id)) + { + throw new ArgumentException("Is not a serialized entity token", nameof(serializedEntityToken)); } - + + properties.Remove(nameof(Type)); + properties.Remove(nameof(Source)); + properties.Remove(nameof(Id)); + + dictionary = properties; } + /// - protected static void DoDeserialize(string serializedEntityToken, out string type, out string source, out string id, out Dictionary dic) + private static void DoDeserializeLegacy(string serializedEntityToken, out string type, out string source, out string id, out Dictionary dic) { dic = StringConversionServices.ParseKeyValueCollection(serializedEntityToken); - - if (!dic.ContainsKey("_EntityToken_Type_") || - !dic.ContainsKey("_EntityToken_Source_") || - !dic.ContainsKey("_EntityToken_Id_")) + + if (!dic.TryGetValue("_EntityToken_Type_", out string serializedType) || + !dic.TryGetValue("_EntityToken_Source_", out string serializedSource) || + !dic.TryGetValue("_EntityToken_Id_", out string serializedId)) { throw new ArgumentException("Is not a serialized entity token", nameof(serializedEntityToken)); } - type = StringConversionServices.DeserializeValueString(dic["_EntityToken_Type_"]); - source = StringConversionServices.DeserializeValueString(dic["_EntityToken_Source_"]); - id = StringConversionServices.DeserializeValueString(dic["_EntityToken_Id_"]); + type = StringConversionServices.DeserializeValueString(serializedType); + source = StringConversionServices.DeserializeValueString(serializedSource); + id = StringConversionServices.DeserializeValueString(serializedId); } @@ -145,7 +149,7 @@ protected static void DoDeserialize(string serializedEntityToken, out string typ /// public virtual string GetPrettyHtml(Dictionary piggybag) { - EntityTokenHtmlPrettyfier entityTokenHtmlPrettyfier = new EntityTokenHtmlPrettyfier(this, piggybag); + var entityTokenHtmlPrettyfier = new EntityTokenHtmlPrettyfier(this, piggybag); OnGetPrettyHtml(entityTokenHtmlPrettyfier); @@ -175,13 +179,10 @@ public virtual void OnGetPrettyHtml(EntityTokenHtmlPrettyfier entityTokenHtmlPre /// public override bool Equals(object obj) { - EntityToken entityToken = obj as EntityToken; - - if (entityToken == null) return false; - - if (entityToken.GetVersionHashCode() != GetVersionHashCode()) return false; - - return entityToken.VersionId == this.VersionId && EqualsWithVersionIgnore(entityToken); + return obj is EntityToken entityToken + && entityToken.GetVersionHashCode() == GetVersionHashCode() + && entityToken.VersionId == this.VersionId + && EqualsWithVersionIgnore(entityToken); } /// From 7709a55d1db7e5bc7302e173f71769efa9bc1864 Mon Sep 17 00:00:00 2001 From: Inna Boitsun Date: Mon, 28 Aug 2017 15:08:52 +0300 Subject: [PATCH 04/57] Add primaryColor variable to be able to use in different styled components --- Website/Composite/console/components/colors.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Website/Composite/console/components/colors.js b/Website/Composite/console/components/colors.js index a0e4f93b2b..6084a61daa 100644 --- a/Website/Composite/console/components/colors.js +++ b/Website/Composite/console/components/colors.js @@ -1,16 +1,22 @@ -export default { - baseFontColor: '#333', +export default { + primaryColor: '#22B980', + baseFontColor: '#333', + mutedTextColor: '#999', + borderColor: '#ccc', + darkBackground: '#EFEFEF', + + /* BUTTON */ buttonTextColor: '#575757', - borderColor: '#ccc', - darkBackground: '#EFEFEF', buttonDropShadowColor: '#DDD', buttonHighlightColor: '#22B980', - buttonShadingColor: '#1ea371', + buttonShadingColor: '#1ea371', + /* end BUTTON */ + fieldsetBackgroundColor: '#F7F7F7', fieldsetLegendColor: '#22B980', fieldFocusColor: '#22B980', dialogHeaderColor: '#22B980', - fieldLabelColor: '#999', + fieldLabelColor: '#999', scrollbarThumbColor: '#CACACA', scrollbarTrackColor: '#FAFAFA', tableBorderColor: '#DDD', From c4512745de1c58c95a151ae6da82d38a38b2e0d6 Mon Sep 17 00:00:00 2001 From: Marcus Wendt Date: Thu, 31 Aug 2017 14:54:02 +0200 Subject: [PATCH 05/57] Update README.md adding link to reviews --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7474778182..f135ffcf1d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# C1 CMS Foundation +# C1 CMS Foundation[![Reviews here...!](http://hackathon.composite.net/maw/github/reviews.png)](https://www.facebook.com/pg/C1CMS/reviews) C1 CMS Foundation - a .NET based Web Content Management System, open source and a bundle of joy! -[![screen shots from the new C1 user interface (the C1 Console)](http://hackathon.composite.net/maw/github/6-pack-screenshots-small.png)](http://hackathon.composite.net/maw/github/6-pack-screenshots.png) +[![screen shots from the new C1 user interface (the C1 Console)](http://hackathon.composite.net/maw/github/6-pack-screenshots-smallr.png)](http://hackathon.composite.net/maw/github/6-pack-screenshots.png) [![Join the chat at https://gitter.im/Orckestra/C1-CMS](https://badges.gitter.im/Orckestra/C1-CMS.svg)](https://gitter.im/Orckestra/C1-CMS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) From a4e898da43ca6d27e80003d0c3063130176ad94a Mon Sep 17 00:00:00 2001 From: Marcus Wendt Date: Fri, 1 Sep 2017 12:47:31 +0200 Subject: [PATCH 06/57] Update README.md Fixing bad screenshot url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f135ffcf1d..7634b0528b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ C1 CMS Foundation - a .NET based Web Content Management System, open source and a bundle of joy! -[![screen shots from the new C1 user interface (the C1 Console)](http://hackathon.composite.net/maw/github/6-pack-screenshots-smallr.png)](http://hackathon.composite.net/maw/github/6-pack-screenshots.png) +[![screen shots from the new C1 user interface (the C1 Console)](http://hackathon.composite.net/maw/github/6-pack-screenshots-small.png)](http://hackathon.composite.net/maw/github/6-pack-screenshots.png) [![Join the chat at https://gitter.im/Orckestra/C1-CMS](https://badges.gitter.im/Orckestra/C1-CMS.svg)](https://gitter.im/Orckestra/C1-CMS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) From 5ac96fadb1a9f38ecd259b9296116883adc8e294 Mon Sep 17 00:00:00 2001 From: Inna Boitsun Date: Tue, 5 Sep 2017 13:41:50 +0300 Subject: [PATCH 07/57] Added TextArea presantation component --- .../Composite/console/components/colors.js | 6 +++-- .../components/presentation/TextArea.js | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 Website/Composite/console/components/presentation/TextArea.js diff --git a/Website/Composite/console/components/colors.js b/Website/Composite/console/components/colors.js index 6084a61daa..16d42c1b0f 100644 --- a/Website/Composite/console/components/colors.js +++ b/Website/Composite/console/components/colors.js @@ -14,9 +14,11 @@ fieldsetBackgroundColor: '#F7F7F7', fieldsetLegendColor: '#22B980', - fieldFocusColor: '#22B980', - dialogHeaderColor: '#22B980', + fieldFocusColor: '#22B980', + fieldBorderColor: '#ccc', fieldLabelColor: '#999', + + dialogHeaderColor: '#22B980', scrollbarThumbColor: '#CACACA', scrollbarTrackColor: '#FAFAFA', tableBorderColor: '#DDD', diff --git a/Website/Composite/console/components/presentation/TextArea.js b/Website/Composite/console/components/presentation/TextArea.js new file mode 100644 index 0000000000..8fe01c5389 --- /dev/null +++ b/Website/Composite/console/components/presentation/TextArea.js @@ -0,0 +1,27 @@ +import styled from 'styled-components'; +import colors from 'console/components/colors.js'; + +const Textarea = styled.textarea` + box-sizing: border-box; + vertical-align: middle; + display: block; + border: 1px solid ${colors.fieldBorderColor}; + border-radius: 4px; + padding: 5px 7px; + margin: 2px 0 7px 0; + background-color: #fff; + height: 90px; + overflow: hidden; + width: ${props => !props.withHelp ? '100%' : 'calc(100% - 20px)'}; + + + &:focus { + border-color: ${colors.fieldFocusColor}; + } +`; + +Textarea.defaultProps = { + value: '' +}; + +export default Textarea; From fc9b540b028dbcf224c881841f4b6d3a24c0fbee Mon Sep 17 00:00:00 2001 From: Inna Boitsun Date: Wed, 6 Sep 2017 13:32:27 +0300 Subject: [PATCH 08/57] Added TextArea to DataField presantation and use it in Products Sets feature --- .../components/presentation/DataField.js | 49 +++++++++++-------- .../components/presentation/HelpIcon.js | 5 +- .../console/components/presentation/Input.js | 13 ++--- 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/Website/Composite/console/components/presentation/DataField.js b/Website/Composite/console/components/presentation/DataField.js index 74552d3c14..4c92d65a6f 100644 --- a/Website/Composite/console/components/presentation/DataField.js +++ b/Website/Composite/console/components/presentation/DataField.js @@ -1,8 +1,9 @@ -import React, { PropTypes } from 'react'; +import React, { PropTypes } from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import HelpIcon from 'console/components/presentation/HelpIcon.js'; import Select from 'console/components/presentation/Select.js'; import Input from 'console/components/presentation/Input.js'; +import TextArea from 'console/components/presentation/TextArea.js'; import Checkbox from 'console/components/presentation/Checkbox.js'; import styled from 'styled-components'; import colors from 'console/components/colors.js'; @@ -17,8 +18,10 @@ const Headline = styled.h4` const Label = styled.label` display: inline-block; - padding-left: 10px; - padding-right: 0; + margin: 0; + font-size: 12px; + padding: 5px 0 4px 0; + color: ${colors.fieldLabelColor}; width: calc(100% - 56px); `; @@ -51,33 +54,37 @@ const DataField = props => { clearable={false} multi={false} options={options} - onChange={handleChange} - placeholder={props.placeholder}> + onChange={handleChange} + placeholder={props.placeholder}> ; - break; + break; + case 'textarea': + inputElement =