diff --git a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs index bf3b3edaf91c..5aa62eae1982 100644 --- a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs +++ b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs @@ -180,6 +180,7 @@ private void AddCoreServices() Services.AddUnique(); Services.AddUnique(); + Services.AddUnique(); // will be injected in controllers when needed to invoke rest endpoints on Our Services.AddUnique(); diff --git a/src/Umbraco.Core/Models/UserData.cs b/src/Umbraco.Core/Models/UserData.cs new file mode 100644 index 000000000000..07b45b3c547b --- /dev/null +++ b/src/Umbraco.Core/Models/UserData.cs @@ -0,0 +1,19 @@ +using System.Runtime.Serialization; + +namespace Umbraco.Cms.Core.Models +{ + [DataContract] + public class UserData + { + [DataMember(Name = "name")] + public string Name { get; } + [DataMember(Name = "data")] + public string Data { get; } + + public UserData(string name, string data) + { + Name = name; + Data = data; + } + } +} diff --git a/src/Umbraco.Core/Services/IUserDataService.cs b/src/Umbraco.Core/Services/IUserDataService.cs new file mode 100644 index 000000000000..e63ee3f6973c --- /dev/null +++ b/src/Umbraco.Core/Services/IUserDataService.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using Umbraco.Cms.Core.Models; + +namespace Umbraco.Cms.Core.Services +{ + public interface IUserDataService + { + IEnumerable GetUserData(); + } +} diff --git a/src/Umbraco.Core/Services/UserDataService.cs b/src/Umbraco.Core/Services/UserDataService.cs new file mode 100644 index 000000000000..490b5af6a8a0 --- /dev/null +++ b/src/Umbraco.Core/Services/UserDataService.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Threading; +using Umbraco.Cms.Core.Configuration; +using Umbraco.Cms.Core.Models; +using Umbraco.Extensions; + +namespace Umbraco.Cms.Core.Services +{ + public class UserDataService : IUserDataService + { + private readonly IUmbracoVersion _version; + private readonly ILocalizationService _localizationService; + + public UserDataService(IUmbracoVersion version, ILocalizationService localizationService) + { + _version = version; + _localizationService = localizationService; + } + + public IEnumerable GetUserData() => + new List + { + new("Server OS", RuntimeInformation.OSDescription), + new("Server Framework", RuntimeInformation.FrameworkDescription), + new("Default Language", _localizationService.GetDefaultLanguageIsoCode()), + new("Umbraco Version", _version.SemanticVersion.ToSemanticStringWithoutBuild()), + new("Current Culture", Thread.CurrentThread.CurrentCulture.ToString()), + new("Current UI Culture", Thread.CurrentThread.CurrentUICulture.ToString()), + new("Current Webserver", GetCurrentWebServer()) + }; + + private string GetCurrentWebServer() => IsRunningInProcessIIS() ? "IIS" : "Kestrel"; + + public bool IsRunningInProcessIIS() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return false; + } + + string processName = Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().ProcessName); + return (processName.Contains("w3wp") || processName.Contains("iisexpress")); + } + } +} diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts new file mode 100644 index 000000000000..2cb5ce70c835 --- /dev/null +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -0,0 +1,47 @@ +/// + +function openSystemInformation(){ + //We have to wait for page to load, if the site is slow + cy.get('[data-element="global-help"]').should('be.visible').click(); + cy.get('.umb-help-list-item').last().should('be.visible').click(); + cy.get('.umb-drawer-content').scrollTo('bottom', {ensureScrollable : false}); +} + +context('System Information', () => { + + beforeEach(() => { + //arrange + cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); + cy.umbracoSetCurrentUserLanguage('en-US'); + }); + afterEach(() => { + cy.umbracoSetCurrentUserLanguage('en-US'); + }); + + it('Check System Info Displays', () => { + openSystemInformation(); + cy.get('.table').find('tr').should('have.length', 10); + cy.contains('Current Culture').parent().should('contain', 'en-US'); + cy.contains('Current UI Culture').parent().should('contain', 'en-US'); + }); + + it('Checks language displays correctly after switching', () => { + + //Navigate to edit user and change language + cy.umbracoGlobalUser().click(); + cy.get('[alias="editUser"]').click(); + cy.get('[name="culture"]').select('string:da-DK', { force: true}); + cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); + //Refresh site to display new language + cy.reload(); + cy.get('.umb-tour-step', { timeout: 60000 }).should('be.visible'); // We now due to the api calls this will be shown, but slow computers can take a while + cy.get('.umb-tour-step__close').click(); + openSystemInformation(); + //Assert + cy.contains('Current Culture').parent().should('contain', 'da-DK'); + cy.contains('Current UI Culture').parent().should('contain', 'da-DK'); + cy.get('.umb-button__content').last().click(); + //Clean + cy.umbracoSetCurrentUserLanguage('en-US'); + }); +}); diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tabs/tabs.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tabs/tabs.ts index 77729912a6b0..92365d742610 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tabs/tabs.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tabs/tabs.ts @@ -1,30 +1,108 @@ /// import { - DocumentTypeBuilder, - AliasHelper -} from 'umbraco-cypress-testhelpers'; - -const tabsDocTypeName = 'Tabs Test Document'; -const tabsDocTypeAlias = AliasHelper.toAlias(tabsDocTypeName); - -context('Tabs', () => { + DocumentTypeBuilder, + AliasHelper + } from 'umbraco-cypress-testhelpers'; - beforeEach(() => { - cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'), false); - }); + const tabsDocTypeName = 'Tabs Test Document'; + const tabsDocTypeAlias = AliasHelper.toAlias(tabsDocTypeName); - afterEach(() => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName) - }); + context('Tabs', () => { + + beforeEach(() => { + cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'), false); + }); + + afterEach(() => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName) + }); + + function OpenDocTypeFolder(){ + cy.umbracoSection('settings'); + cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); + cy.get('.umb-tree-item__inner > .umb-tree-item__arrow').eq(0).click(); + cy.get('.umb-tree-item__inner > .umb-tree-item__label').contains(tabsDocTypeName).click(); + } + + function CreateDocWithTabAndNavigate(){ + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + } + + it('Create tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + cy.deleteAllContent(); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addGroup() + .withName('Tabs1Group') + .addUrlPickerProperty() + .withAlias('picker') + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + //Create a tab + cy.get('.umb-group-builder__tabs__add-tab').click(); + cy.get('ng-form.ng-invalid > .umb-group-builder__group-title-input').type('Tab 1'); + //Create a 2nd tab manually + cy.get('.umb-group-builder__tabs__add-tab').click(); + cy.get('ng-form.ng-invalid > .umb-group-builder__group-title-input').type('Tab 2'); + //Create a textstring property + cy.get('[aria-hidden="false"] > .umb-box-content > .umb-group-builder__group-add-property').click(); + cy.get('.editor-label').type('property name'); + cy.get('[data-element="editor-add"]').click(); + + //Search for textstring + cy.get('#datatype-search').type('Textstring'); - function OpenDocTypeFolder(){ - cy.umbracoSection('settings'); - cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); - cy.get('.umb-tree-item__inner > .umb-tree-item__arrow').eq(0).click(); - cy.get('.umb-tree-item__inner > .umb-tree-item__label').contains(tabsDocTypeName).click(); - } + // Choose first item + cy.get('[title="Textstring"]').closest("li").click(); - function CreateDocWithTabAndNavigate(){ + // Save property + cy.get('.btn-success').last().click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title="tab1"]').should('be.visible'); + cy.get('[title="tab2"]').should('be.visible'); + }); + + it('Delete tabs', () => { + CreateDocWithTabAndNavigate(); + //Check if tab is there, else if it wasnt created, this test would always pass + cy.get('[title="aTab 1"]').should('be.visible'); + //Delete a tab + cy.get('.btn-reset > .icon-trash').click(); + cy.get('.umb-button > .btn').last().click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.get('[title="aTab 1"]').should('not.exist'); + //Clean + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + }); + + it('Delete property in tab', () => { cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); const tabsDocType = new DocumentTypeBuilder() .withName(tabsDocTypeName) @@ -38,515 +116,437 @@ context('Tabs', () => { .addUrlPickerProperty() .withAlias("urlPicker") .done() + .addContentPickerProperty() + .withAlias('picker') + .done() .done() .done() - .build(); + .build(); cy.saveDocumentType(tabsDocType); OpenDocTypeFolder(); - } - - it('Create tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - cy.deleteAllContent(); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addGroup() - .withName('Tabs1Group') - .addUrlPickerProperty() - .withAlias('picker') - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - //Create a tab - cy.get('.umb-group-builder__tabs__add-tab').click(); - cy.get('ng-form.ng-invalid > .umb-group-builder__group-title-input').type('Tab 1'); - //Create a 2nd tab manually - cy.get('.umb-group-builder__tabs__add-tab').click(); - cy.get('ng-form.ng-invalid > .umb-group-builder__group-title-input').type('Tab 2'); - //Create a textstring property - cy.get('[aria-hidden="false"] > .umb-box-content > .umb-group-builder__group-add-property').click(); - cy.get('.editor-label').type('property name'); - cy.get('[data-element="editor-add"]').click(); - - //Search for textstring - cy.get('#datatype-search').type('Textstring'); - - // Choose first item - cy.get('[title="Textstring"]').closest("li").click(); - - // Save property - cy.get('.btn-success').last().click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title="tab1"]').should('be.visible'); - cy.get('[title="tab2"]').should('be.visible'); - }); - - it('Delete tabs', () => { - CreateDocWithTabAndNavigate(); - //Check if tab is there, else if it wasnt created, this test would always pass - cy.get('[title="aTab 1"]').should('be.visible'); - //Delete a tab - cy.get('.btn-reset > .icon-trash').click(); - cy.get('.umb-button > .btn').last().click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.get('[title="aTab 1"]').should('not.exist'); - //Clean - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - }); - - it('Delete property in tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withAlias("urlPicker") + cy.get('[aria-label="Delete property"]').last().click(); + cy.umbracoButtonByLabelKey('actions_delete').click(); + cy.umbracoButtonByLabelKey('buttons_save').click() + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title=urlPicker]').should('be.visible'); + cy.get('[title=picker]').should('not.exist'); + }); + + it('Delete group in tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .done() .done() - .addContentPickerProperty() - .withAlias('picker') + .addGroup() + .withName('Content Picker Group') + .addContentPickerProperty() + .withAlias('picker') + .done() .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - cy.get('[aria-label="Delete property"]').last().click(); - cy.umbracoButtonByLabelKey('actions_delete').click(); - cy.umbracoButtonByLabelKey('buttons_save').click() - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title=urlPicker]').should('be.visible'); - cy.get('[title=picker]').should('not.exist'); - }); - - it('Delete group in tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withAlias("urlPicker") + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + //Delete group + cy.get('.umb-group-builder__group-remove > .icon-trash').eq(1).click(); + cy.umbracoButtonByLabelKey('actions_delete').click(); + cy.umbracoButtonByLabelKey('buttons_save').click() + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title=picker]').should('be.visible'); + cy.get('[title=urlPicker]').should('not.exist'); + }); + + it('Reorders tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group 1') + .addUrlPickerProperty() + .withLabel('Url picker 1') + .withAlias("urlPicker") + .done() .done() - .done() - .addGroup() - .withName('Content Picker Group') - .addContentPickerProperty() - .withAlias('picker') + .done() + .addTab() + .withName('Tab 2') + .addGroup() + .withName('Tab group 2') + .addUrlPickerProperty() + .withLabel('Url picker 2') + .withAlias("pickerTab 2") + .done() .done() - .done() - .done() + .done() + .addTab() + .withName('Tab 3') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withLabel('Url picker 3') + .withAlias('pickerTab3') + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + //Check if there are any tabs + cy.get('ng-form.ng-valid-required > .umb-group-builder__group-title-input').should('be.visible'); + cy.get('[alias="reorder"]').click(); + //Type order in + cy.get('.umb-group-builder__tab-sort-order > .umb-property-editor-tiny').first().type('3'); + cy.get('[alias="reorder"]').click(); + //Assert + cy.get('.umb-group-builder__group-title-input').eq(0).invoke('attr', 'title').should('eq', 'aTab 2') + cy.get('.umb-group-builder__group-title-input').eq(1).invoke('attr', 'title').should('eq', 'aTab 3') + cy.get('.umb-group-builder__group-title-input').eq(2).invoke('attr', 'title').should('eq', 'aTab 1') + }); + + it('Reorders groups in a tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group 1') + .addUrlPickerProperty() + .withLabel('Url picker 1') + .withAlias("urlPicker") + .done() + .done() + .addGroup() + .withName('Tab group 2') + .addUrlPickerProperty() + .withLabel('Url picker 2') + .withAlias('urlPickerTwo') + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + cy.get('[alias="reorder"]').click(); + cy.get('.umb-property-editor-tiny').eq(2).type('1'); + + cy.get('[alias="reorder"]').click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('.umb-group-builder__group-title-input').eq(2) + .invoke('attr', 'title').should('eq', 'aTab 1/aTab group 2'); + }); + + it('Reorders properties in a tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withLabel('PickerOne') + .withAlias("urlPicker") + .done() + .addUrlPickerProperty() + .withLabel('PickerTwo') + .withAlias('urlPickerTwo') + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + //Reorder + cy.get('[alias="reorder"]').click(); + cy.get('.umb-group-builder__group-sort-value').first().type('2'); + cy.get('[alias="reorder"]').click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('.umb-locked-field__input').last().invoke('attr', 'title').should('eq', 'urlPicker'); + }); + + it('Tab name cannot be empty', () => { + CreateDocWithTabAndNavigate(); + cy.get('.umb-group-builder__group-title-input').first().clear(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoErrorNotification().should('be.visible'); + }); + + it('Two tabs cannot have the same name', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .done() + .done() + .done() .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - //Delete group - cy.get('.umb-group-builder__group-remove > .icon-trash').eq(1).click(); - cy.umbracoButtonByLabelKey('actions_delete').click(); - cy.umbracoButtonByLabelKey('buttons_save').click() - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title=picker]').should('be.visible'); - cy.get('[title=urlPicker]').should('not.exist'); - }); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + //Create a 2nd tab manually + cy.get('.umb-group-builder__tabs__add-tab').click(); + cy.get('ng-form.ng-invalid > .umb-group-builder__group-title-input').type('Tab 1'); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoErrorNotification().should('be.visible'); + }); - it('Reorders tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group 1') - .addUrlPickerProperty() - .withLabel('Url picker 1') - .withAlias("urlPicker") + it('Group name cannot be empty', () => { + CreateDocWithTabAndNavigate(); + cy.get('.clearfix > .-placeholder').click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoErrorNotification().should('be.visible'); + }); + + it('Group name cannot have the same name', () => { + CreateDocWithTabAndNavigate(); + cy.get('.clearfix > .-placeholder').click(); + cy.get('.umb-group-builder__group-title-input').last().type('Tab group'); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoErrorNotification().should('be.visible'); + }); + + it('Drag a group into another tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .done() .done() - .done() - .done() - .addTab() + .done() + .addTab() .withName('Tab 2') .addGroup() - .withName('Tab group 2') + .withName('Tab group tab 2') .addUrlPickerProperty() - .withLabel('Url picker 2') - .withAlias("pickerTab 2") + .withAlias('urlPickerTabTwo') .done() .done() - .done() - .addTab() - .withName('Tab 3') .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withLabel('Url picker 3') - .withAlias('pickerTab3') + .withName('Tab group 2') + .addUrlPickerProperty() + .withAlias('urlPickerTwo') + .done() .done() - .done() - .done() + .done() .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - //Check if there are any tabs - cy.get('ng-form.ng-valid-required > .umb-group-builder__group-title-input').should('be.visible'); - cy.get('[alias="reorder"]').click(); - //Type order in - cy.get('.umb-group-builder__tab-sort-order > .umb-property-editor-tiny').first().type('3'); - cy.get('[alias="reorder"]').click(); - //Assert - cy.get('.umb-group-builder__group-title-input').eq(0).invoke('attr', 'title').should('eq', 'aTab 2') - cy.get('.umb-group-builder__group-title-input').eq(1).invoke('attr', 'title').should('eq', 'aTab 3') - cy.get('.umb-group-builder__group-title-input').eq(2).invoke('attr', 'title').should('eq', 'aTab 1') - }); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + cy.get('[alias="reorder"]').click(); + cy.get('body') + .then(($body) => { + while($body.find('.umb-group-builder__tabs-overflow--right > .caret').hasClass('active')){ + cy.click(); + } + }); + cy.get('.umb-group-builder__tab').last().click(); + cy.get('.umb-group-builder__group-title-icon').last().trigger('mousedown', { which: 1 }) + cy.get('.umb-group-builder__tab').eq(1).trigger('mousemove', {which: 1, force: true}); + cy.get('.umb-group-builder__tab').eq(1).should('have.class', 'is-active').trigger('mouseup', {force:true}); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title="aTab 1/aTab group 2"]').should('be.visible'); + }); - it('Reorders groups in a tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') + it('Drag and drop reorders a tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .done() + .done() + .done() + .addTab() + .withName('Tab 2') .addGroup() - .withName('Tab group 1') + .withName('Tab group tab 2') .addUrlPickerProperty() - .withLabel('Url picker 1') - .withAlias("urlPicker") + .withAlias('urlPickerTabTwo') .done() .done() .addGroup() - .withName('Tab group 2') - .addUrlPickerProperty() - .withLabel('Url picker 2') - .withAlias('urlPickerTwo') + .withName('Tab group 2') + .addUrlPickerProperty() + .withAlias('urlPickerTwo') + .done() .done() - .done() - .done() + .done() .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - cy.get('[alias="reorder"]').click(); - cy.get('.umb-property-editor-tiny').eq(2).type('1'); - - cy.get('[alias="reorder"]').click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('.umb-group-builder__group-title-input').eq(2) - .invoke('attr', 'title').should('eq', 'aTab 1/aTab group 2'); - }); - - it('Reorders properties in a tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withLabel('PickerOne') - .withAlias("urlPicker") - .done() - .addUrlPickerProperty() - .withLabel('PickerTwo') - .withAlias('urlPickerTwo') - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - //Reorder - cy.get('[alias="reorder"]').click(); - cy.get('.umb-group-builder__group-sort-value').first().type('2'); - cy.get('[alias="reorder"]').click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('.umb-locked-field__input').last().invoke('attr', 'title').should('eq', 'urlPicker'); - }); - - it('Tab name cannot be empty', () => { - CreateDocWithTabAndNavigate(); - cy.get('.umb-group-builder__group-title-input').first().clear(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoErrorNotification().should('be.visible'); - }); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + cy.get('[alias="reorder"]').click(); + //Scroll right so we can see tab 2 + cy.get('body') + .then(($body) => { + while($body.find('.umb-group-builder__tabs-overflow--right > .caret').hasClass('active')){ + cy.click(); + } + }); + cy.get('.umb-group-builder__tab-title-icon').eq(1).trigger('mousedown', { which: 1 }) + cy.get('.umb-group-builder__tab').eq(1).trigger('mousemove', {which: 1, force: true}); + cy.get('.umb-group-builder__tab').eq(1).should('have.class', 'is-active').trigger('mouseup', {force:true}); + cy.get('[alias="reorder"]').click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title="aTab 2"]').should('be.visible'); + }); - it('Two tabs cannot have the same name', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withAlias("urlPicker") - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - //Create a 2nd tab manually - cy.get('.umb-group-builder__tabs__add-tab').click(); - cy.get('ng-form.ng-invalid > .umb-group-builder__group-title-input').type('Tab 1'); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoErrorNotification().should('be.visible'); - }); - - it('Group name cannot be empty', () => { - CreateDocWithTabAndNavigate(); - cy.get('.clearfix > .-placeholder').click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoErrorNotification().should('be.visible'); - }); - - it('Group name cannot have the same name', () => { - CreateDocWithTabAndNavigate(); - cy.get('.clearfix > .-placeholder').click(); - cy.get('.umb-group-builder__group-title-input').last().type('Tab group'); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoErrorNotification().should('be.visible'); - }); - - it('Drag a group into another tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withAlias("urlPicker") + it('Drags and drops a property in a tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .withLabel('UrlPickerOne') + .done() .done() - .done() - .done() - .addTab() - .withName('Tab 2') - .addGroup() - .withName('Tab group tab 2') - .addUrlPickerProperty() - .withAlias('urlPickerTabTwo') - .done() .done() - .addGroup() - .withName('Tab group 2') - .addUrlPickerProperty() - .withAlias('urlPickerTwo') - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - cy.get('[alias="reorder"]').click(); - cy.get('body') - .then(($body) => { - while($body.find('.umb-group-builder__tabs-overflow--right > .caret').hasClass('active')){ - cy.click(); - } - }); - cy.get('.umb-group-builder__tab').last().click(); - cy.get('.umb-group-builder__group-title-icon').last().trigger('mousedown', { which: 1 }) - cy.get('.umb-group-builder__tab').eq(1).trigger('mousemove', {which: 1, force: true}); - cy.get('.umb-group-builder__tab').eq(1).should('have.class', 'is-active').trigger('mouseup', {force:true}); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title="aTab 1/aTab group 2"]').should('be.visible'); - }); - - it('Drag and drop reorders a tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') + .addTab() + .withName('Tab 2') .addGroup() - .withName('Tab group') + .withName('Tab group tab 2') .addUrlPickerProperty() - .withAlias("urlPicker") + .withAlias('urlPickerTabTwo') + .withLabel('UrlPickerTabTwo') .done() - .done() - .done() - .addTab() - .withName('Tab 2') - .addGroup() - .withName('Tab group tab 2') - .addUrlPickerProperty() - .withAlias('urlPickerTabTwo') - .done() - .done() - .addGroup() - .withName('Tab group 2') .addUrlPickerProperty() - .withAlias('urlPickerTwo') - .done() + .withAlias('urlPickerTwo') + .withLabel('UrlPickerTwo') + .done() .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - cy.get('[alias="reorder"]').click(); - //Scroll right so we can see tab 2 - cy.get('body') + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + cy.get('[alias="reorder"]').click(); + //Scroll so we are sure we see tab 2 + cy.get('body') .then(($body) => { while($body.find('.umb-group-builder__tabs-overflow--right > .caret').hasClass('active')){ cy.click(); } }); - cy.get('.umb-group-builder__tab-title-icon').eq(1).trigger('mousedown', { which: 1 }) - cy.get('.umb-group-builder__tab').eq(1).trigger('mousemove', {which: 1, force: true}); - cy.get('.umb-group-builder__tab').eq(1).should('have.class', 'is-active').trigger('mouseup', {force:true}); - cy.get('[alias="reorder"]').click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title="aTab 2"]').should('be.visible'); - }); - - it('Drags and drops a property in a tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withAlias("urlPicker") - .withLabel('UrlPickerOne') + //Navigate to tab 2 + cy.get('.umb-group-builder__tab').last().click(); + cy.get('.umb-group-builder__property-meta > .flex > .icon').eq(1).trigger('mousedown', {which: 1}) + cy.get('.umb-group-builder__tab').eq(1).trigger('mousemove', {which: 1, force: true}); + cy.get('.umb-group-builder__tab').eq(1).should('have.class', 'is-active'); + cy.get('.umb-group-builder__property') + .first().trigger('mousemove', {which: 1, force: true}).trigger('mouseup', {which: 1, force:true}); + cy.get('[alias="reorder"]').click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title="urlPickerTabTwo"]').should('be.visible'); + }); + + it('Drags and drops a group and converts to tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .withLabel('UrlPickerOne') + .done() .done() + .addGroup() + .withName('Tab group 2') + .addUrlPickerProperty() + .withAlias('urlPickerTwo') + .withLabel('UrlPickerTwo') + .done() .done() - .done() - .addTab() - .withName('Tab 2') - .addGroup() - .withName('Tab group tab 2') - .addUrlPickerProperty() - .withAlias('urlPickerTabTwo') - .withLabel('UrlPickerTabTwo') - .done() - .addUrlPickerProperty() - .withAlias('urlPickerTwo') - .withLabel('UrlPickerTwo') - .done() .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - cy.get('[alias="reorder"]').click(); - //Scroll so we are sure we see tab 2 - cy.get('body') - .then(($body) => { - while($body.find('.umb-group-builder__tabs-overflow--right > .caret').hasClass('active')){ - cy.click(); - } - }); - //Navigate to tab 2 - cy.get('.umb-group-builder__tab').last().click(); - cy.get('.umb-group-builder__property-meta > .flex > .icon').eq(1).trigger('mousedown', {which: 1}) - cy.get('.umb-group-builder__tab').eq(1).trigger('mousemove', {which: 1, force: true}); - cy.get('.umb-group-builder__tab').eq(1).should('have.class', 'is-active'); - cy.get('.umb-group-builder__property') - .first().trigger('mousemove', {which: 1, force: true}).trigger('mouseup', {which: 1, force:true}); - cy.get('[alias="reorder"]').click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title="urlPickerTabTwo"]').should('be.visible'); - }); - - it('Drags and drops a group and converts to tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') + .addTab() + .withName('Tab 2') .addGroup() - .withName('Tab group') + .withName('Tab group tab 2') .addUrlPickerProperty() - .withAlias("urlPicker") - .withLabel('UrlPickerOne') + .withAlias('urlPickerTabTwo') + .withLabel('UrlPickerTabTwo') .done() .done() - .addGroup() - .withName('Tab group 2') - .addUrlPickerProperty() - .withAlias('urlPickerTwo') - .withLabel('UrlPickerTwo') - .done() - .done() - .done() - .addTab() - .withName('Tab 2') - .addGroup() - .withName('Tab group tab 2') - .addUrlPickerProperty() - .withAlias('urlPickerTabTwo') - .withLabel('UrlPickerTabTwo') - .done() .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - cy.get('[alias="reorder"]').click(); - cy.get('.umb-group-builder__group-title-icon').eq(1).trigger('mousedown', {which: 1}) - cy.get('.umb-group-builder__convert-dropzone').trigger('mousemove', {which: 1, force: true}); - cy.get('.umb-group-builder__convert-dropzone').trigger('mouseup', {which: 1, force:true}); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title="tabGroup"]').should('be.visible'); - }); -}); \ No newline at end of file + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + cy.get('[alias="reorder"]').click(); + cy.get('.umb-group-builder__group-title-icon').eq(1).trigger('mousedown', {which: 1}) + cy.get('.umb-group-builder__convert-dropzone').trigger('mousemove', {which: 1, force: true}); + cy.get('.umb-group-builder__convert-dropzone').trigger('mouseup', {which: 1, force:true}); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title="tabGroup"]').should('be.visible'); + }); + }); \ No newline at end of file diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/backofficeTour.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tours/backofficeTour.ts similarity index 99% rename from src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/backofficeTour.ts rename to src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tours/backofficeTour.ts index d3950d7d1928..8bdd052e94fd 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/backofficeTour.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tours/backofficeTour.ts @@ -100,4 +100,4 @@ function runBackOfficeIntroTour(percentageComplete, buttonText, timeout) { cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); cy.umbracoGlobalHelp().should("be.visible"); -} +} \ No newline at end of file diff --git a/src/Umbraco.Tests.AcceptanceTest/package.json b/src/Umbraco.Tests.AcceptanceTest/package.json index 2b85faaf9c0e..20a5a774e097 100644 --- a/src/Umbraco.Tests.AcceptanceTest/package.json +++ b/src/Umbraco.Tests.AcceptanceTest/package.json @@ -11,7 +11,7 @@ "del": "^6.0.0", "ncp": "^2.0.0", "prompt": "^1.0.0", - "umbraco-cypress-testhelpers": "^1.0.0-beta-57" + "umbraco-cypress-testhelpers": "^1.0.0-beta-58" }, "dependencies": { "typescript": "^3.9.2" diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs new file mode 100644 index 000000000000..74179763697e --- /dev/null +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs @@ -0,0 +1,110 @@ +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Threading; +using Moq; +using NUnit.Framework; +using Umbraco.Cms.Core.Configuration; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Semver; +using Umbraco.Cms.Core.Services; + +namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Services +{ + [TestFixture] + public class UserDataServiceTests + { + private IUmbracoVersion _umbracoVersion; + + [OneTimeSetUp] + public void CreateMocks() => CreateUmbracoVersion(9, 0, 0); + + [Test] + [TestCase("en-US")] + [TestCase("de-DE")] + [TestCase("en-NZ")] + [TestCase("sv-SE")] + public void GetCorrectDefaultLanguageTest(string culture) + { + var userDataService = CreateUserDataService(culture); + var defaultLanguage = userDataService.GetUserData().FirstOrDefault(x => x.Name == "Default Language"); + Assert.Multiple(() => + { + Assert.IsNotNull(defaultLanguage); + Assert.AreEqual(culture, defaultLanguage.Data); + }); + } + + [Test] + [TestCase("en-US")] + [TestCase("de-DE")] + [TestCase("en-NZ")] + [TestCase("sv-SE")] + public void GetCorrectCultureTest(string culture) + { + Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); + var userDataService = CreateUserDataService(culture); + var currentCulture = userDataService.GetUserData().FirstOrDefault(x => x.Name == "Current Culture"); + Assert.Multiple(() => + { + Assert.IsNotNull(currentCulture); + Assert.AreEqual(culture, currentCulture.Data); + }); + } + + [Test] + [TestCase("en-US")] + [TestCase("de-DE")] + [TestCase("en-NZ")] + [TestCase("sv-SE")] + public void GetCorrectUICultureTest(string culture) + { + Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture); + var userDataService = CreateUserDataService(culture); + var currentCulture = userDataService.GetUserData().FirstOrDefault(x => x.Name == "Current UI Culture"); + Assert.Multiple(() => + { + Assert.IsNotNull(currentCulture); + Assert.AreEqual(culture, currentCulture.Data); + }); + } + + [Test] + [TestCase("en-US")] + [TestCase("de-DE")] + [TestCase("en-NZ")] + [TestCase("sv-SE")] + public void RunTimeInformationNotNullTest(string culture) + { + var userDataService = CreateUserDataService(culture); + IEnumerable userData = userDataService.GetUserData().ToList(); + Assert.Multiple(() => + { + Assert.IsNotNull(userData.Select(x => x.Name == "Server OS")); + Assert.IsNotNull(userData.Select(x => x.Name == "Server Framework")); + Assert.IsNotNull(userData.Select(x => x.Name == "Current Webserver")); + }); + } + + private UserDataService CreateUserDataService(string culture) + { + var localizationService = CreateILocalizationService(culture); + return new UserDataService(_umbracoVersion, localizationService); + } + + private ILocalizationService CreateILocalizationService(string culture) + { + var localizationService = new Mock(); + localizationService.Setup(x => x.GetDefaultLanguageIsoCode()).Returns(culture); + return localizationService.Object; + } + + private void CreateUmbracoVersion(int major, int minor, int patch) + { + var umbracoVersion = new Mock(); + var semVersion = new SemVersion(major, minor, patch); + umbracoVersion.Setup(x => x.SemanticVersion).Returns(semVersion); + _umbracoVersion = umbracoVersion.Object; + } + } +} diff --git a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs index ba6ca3608583..16b6590e576f 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Newtonsoft.Json; using Umbraco.Cms.Core; @@ -22,11 +22,10 @@ using Umbraco.Cms.Core.Security; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Strings; -using Umbraco.Cms.Web.BackOffice.Extensions; using Umbraco.Cms.Web.BackOffice.Filters; -using Umbraco.Cms.Web.Common.ActionsResults; using Umbraco.Cms.Web.Common.Attributes; using Umbraco.Cms.Web.Common.Authorization; +using Umbraco.Cms.Web.Common.DependencyInjection; using Umbraco.Cms.Web.Common.Security; using Umbraco.Extensions; using Constants = Umbraco.Cms.Core.Constants; @@ -47,12 +46,13 @@ public class CurrentUserController : UmbracoAuthorizedJsonController private readonly IUserService _userService; private readonly IUmbracoMapper _umbracoMapper; private readonly IBackOfficeUserManager _backOfficeUserManager; - private readonly ILoggerFactory _loggerFactory; private readonly ILocalizedTextService _localizedTextService; private readonly AppCaches _appCaches; private readonly IShortStringHelper _shortStringHelper; private readonly IPasswordChanger _passwordChanger; + private readonly IUserDataService _userDataService; + [ActivatorUtilitiesConstructor] public CurrentUserController( MediaFileManager mediaFileManager, IOptions contentSettings, @@ -62,11 +62,11 @@ public CurrentUserController( IUserService userService, IUmbracoMapper umbracoMapper, IBackOfficeUserManager backOfficeUserManager, - ILoggerFactory loggerFactory, ILocalizedTextService localizedTextService, AppCaches appCaches, IShortStringHelper shortStringHelper, - IPasswordChanger passwordChanger) + IPasswordChanger passwordChanger, + IUserDataService userDataService) { _mediaFileManager = mediaFileManager; _contentSettings = contentSettings.Value; @@ -76,11 +76,42 @@ public CurrentUserController( _userService = userService; _umbracoMapper = umbracoMapper; _backOfficeUserManager = backOfficeUserManager; - _loggerFactory = loggerFactory; _localizedTextService = localizedTextService; _appCaches = appCaches; _shortStringHelper = shortStringHelper; _passwordChanger = passwordChanger; + _userDataService = userDataService; + } + + [Obsolete("This constructor is obsolete and will be removed in v11, use constructor with all values")] + public CurrentUserController( + MediaFileManager mediaFileManager, + IOptions contentSettings, + IHostingEnvironment hostingEnvironment, + IImageUrlGenerator imageUrlGenerator, + IBackOfficeSecurityAccessor backofficeSecurityAccessor, + IUserService userService, + IUmbracoMapper umbracoMapper, + IBackOfficeUserManager backOfficeUserManager, + ILocalizedTextService localizedTextService, + AppCaches appCaches, + IShortStringHelper shortStringHelper, + IPasswordChanger passwordChanger) : this( + mediaFileManager, + contentSettings, + hostingEnvironment, + imageUrlGenerator, + backofficeSecurityAccessor, + userService, + umbracoMapper, + backOfficeUserManager, + localizedTextService, + appCaches, + shortStringHelper, + passwordChanger, + StaticServiceProvider.Instance.GetRequiredService()) + { + } @@ -167,6 +198,8 @@ public IEnumerable GetUserTours() return userTours; } + public IEnumerable GetUserData() => _userDataService.GetUserData(); + /// /// When a user is invited and they click on the invitation link, they will be partially logged in /// where they can set their username/password diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/currentuser.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/currentuser.resource.js index a3be6996b1b8..23870d882f17 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/currentuser.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/currentuser.resource.js @@ -51,7 +51,6 @@ function currentUserResource($q, $http, umbRequestHelper, umbDataFormatter) { [{ permissionToCheck: permission }, { nodeId: id }])), 'Failed to check permission for item ' + id); }, - getCurrentUserLinkedLogins: function () { return umbRequestHelper.resourcePromise( @@ -61,6 +60,14 @@ function currentUserResource($q, $http, umbRequestHelper, umbDataFormatter) { "GetCurrentUserLinkedLogins")), 'Server call failed for getting current users linked logins'); }, + getUserData: function () { + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "currentUserApiBaseUrl", + "GetUserData")), + 'Server call failed for getting current user data'); + }, saveTourStatus: function (tourStatus) { diff --git a/src/Umbraco.Web.UI.Client/src/common/services/platform.service.js b/src/Umbraco.Web.UI.Client/src/common/services/platform.service.js index 7834c2f781ab..acd953315152 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/platform.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/platform.service.js @@ -1,23 +1,84 @@ -(function() { - 'use strict'; +(function () { + 'use strict'; - function platformService() { + function platformService() { + const userAgentRules = [ + ['Aol', /AOLShield\/([0-9\._]+)/], + ['Edge', /Edge\/([0-9\._]+)/], + ['Edge-ios', /EdgiOS\/([0-9\._]+)/], + ['Yandexbrowser', /YaBrowser\/([0-9\._]+)/], + ['Kakaotalk', /KAKAOTALK\s([0-9\.]+)/], + ['Samsung', /SamsungBrowser\/([0-9\.]+)/], + ['Silk', /\bSilk\/([0-9._-]+)\b/], + ['MiUI', /MiuiBrowser\/([0-9\.]+)$/], + ['Beaker', /BeakerBrowser\/([0-9\.]+)/], + ['Edge-chromium', /EdgA?\/([0-9\.]+)/], + ['chromium-webview', /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], + ['Chrome', /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], + ['PhantomJS', /PhantomJS\/([0-9\.]+)(:?\s|$)/], + ['Crios', /CriOS\/([0-9\.]+)(:?\s|$)/], + ['Firefox', /Firefox\/([0-9\.]+)(?:\s|$)/], + ['FxiOS', /FxiOS\/([0-9\.]+)/], + ['Opera-mini', /Opera Mini.*Version\/([0-9\.]+)/], + ['Opera', /Opera\/([0-9\.]+)(?:\s|$)/], + ['Opera', /OPR\/([0-9\.]+)(:?\s|$)/], + ['IE', /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], + ['IE', /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], + ['IE', /MSIE\s(7\.0)/], + ['BB10', /BB10;\sTouch.*Version\/([0-9\.]+)/], + ['Android', /Android\s([0-9\.]+)/], + ['iOS', /Version\/([0-9\._]+).*Mobile.*Safari.*/], + ['Safari', /Version\/([0-9\._]+).*Safari/], + ['Facebook', /FB[AS]V\/([0-9\.]+)/], + ['Instagram', /Instagram\s([0-9\.]+)/], + ['iOS-webview', /AppleWebKit\/([0-9\.]+).*Mobile/], + ['iOS-webview', /AppleWebKit\/([0-9\.]+).*Gecko\)$/], + ['Curl', /^curl\/([0-9\.]+)$/] + ]; - function isMac() { - return navigator.platform.toUpperCase().indexOf('MAC')>=0; - } + function isMac() { + return navigator.platform.toUpperCase().indexOf('MAC') >= 0; + } - //////////// - - var service = { - isMac: isMac + function getBrowserInfo(){ + let data = matchUserAgent(navigator.userAgent); + console.log(data); + if(data){ + const test = data[1]; + return { + name : data[0], + version : test[1] }; + } + return null; + } + + function matchUserAgent(ua) { + return (ua !== '' && userAgentRules.reduce ( + (matched, [browser, regex]) => { + if (matched) { + return matched; + } + const uaMatch = regex.exec(ua); + return !!uaMatch && [browser, uaMatch]; + }, + false + ) + ); + } + + //////////// + + var service = { + isMac: isMac, + getBrowserInfo : getBrowserInfo + }; - return service; + return service; - } + } - angular.module('umbraco.services').factory('platformService', platformService); + angular.module('umbraco.services').factory('platformService', platformService); })(); diff --git a/src/Umbraco.Web.UI.Client/src/less/components/application/umb-drawer.less b/src/Umbraco.Web.UI.Client/src/less/components/application/umb-drawer.less index 5c77a15ec702..7660e930a5d1 100644 --- a/src/Umbraco.Web.UI.Client/src/less/components/application/umb-drawer.less +++ b/src/Umbraco.Web.UI.Client/src/less/components/application/umb-drawer.less @@ -101,9 +101,9 @@ } /* Make sure typography looks good */ -.umb-help-article h1, -.umb-help-article h2, -.umb-help-article h3, +.umb-help-article h1, +.umb-help-article h2, +.umb-help-article h3, .umb-help-article h4 { line-height: 1.3em; font-weight: bold; @@ -138,7 +138,7 @@ } .umb-help-section__title { - margin:0 0 10px; + margin:0 0 10px; } /* Help list */ @@ -147,10 +147,10 @@ list-style: none; margin-left: 0; margin-bottom: 0; - background: @white; + background: @white; border-radius: 3px; box-shadow: 0 1px 1px 0 rgba(0,0,0,0.16); - + [data-element*="help-tours"] & { margin-bottom:5px; } @@ -166,9 +166,20 @@ border: 0 none; } + .umb-help-list-item:last-child { border-bottom: none; } +.umb-help-list-item__title-wrapper { + display:flex; + justify-content: space-between; + align-items: center; + + .umb-help-list-item { + flex: 1 0 auto; + width: auto; + } +} .umb-help-list-item__group-title i { margin-right:2px; @@ -185,7 +196,7 @@ .umb-help-list-item:hover, .umb-help-list-item:focus, .umb-help-list-item:active, -.umb-help-list-item > a:hover, +.umb-help-list-item > a:hover, .umb-help-list-item > a:focus, .umb-help-list-item > a:active { text-decoration: none; diff --git a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js index c212a0895190..5b9626c676ff 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js @@ -1,11 +1,10 @@ (function () { "use strict"; - function HelpDrawerController($scope, $routeParams, $timeout, dashboardResource, localizationService, userService, eventsService, helpService, appState, tourService, $filter, editorState) { + function HelpDrawerController($scope, $routeParams, $timeout, dashboardResource, localizationService, userService, eventsService, helpService, appState, tourService, $filter, editorState, notificationsService, currentUserResource, platformService) { var vm = this; var evts = []; - vm.title = ""; vm.subtitle = "Umbraco version" + " " + Umbraco.Sys.ServerVariables.application.version; vm.section = $routeParams.section; @@ -13,16 +12,19 @@ vm.sectionName = ""; vm.customDashboard = null; vm.tours = []; + vm.systemInfoDisplay = false; vm.closeDrawer = closeDrawer; vm.startTour = startTour; vm.getTourGroupCompletedPercentage = getTourGroupCompletedPercentage; vm.showTourButton = showTourButton; + vm.copyInformation = copyInformation; vm.showDocTypeTour = false; vm.docTypeTours = []; + vm.systemInfo = []; vm.nodeName = ''; - + function startTour(tour) { tourService.startTour(tour); closeDrawer(); @@ -34,7 +36,14 @@ localizationService.localize("general_help").then(function(data){ vm.title = data; }); - + currentUserResource.getUserData().then(function(systemInfo){ + vm.systemInfo = systemInfo; + let browserInfo = platformService.getBrowserInfo(); + if(browserInfo != null){ + vm.systemInfo.push({name :"Browser", data: browserInfo.name + " " + browserInfo.version}); + } + vm.systemInfo.push({name :"Browser OS", data: getPlatform()}); + }); tourService.getGroupedTours().then(function(groupedTours) { vm.tours = groupedTours; getTourGroupCompletedPercentage(); @@ -52,11 +61,11 @@ setSectionName(); userService.getCurrentUser().then(function (user) { - + vm.userType = user.userType; vm.userLang = user.locale; - vm.hasAccessToSettings = _.contains(user.allowedSections, 'settings'); + vm.hasAccessToSettings = _.contains(user.allowedSections, 'settings'); evts.push(eventsService.on("appState.treeState.changed", function (e, args) { handleSectionChange(); @@ -72,7 +81,7 @@ }); setDocTypeTour(editorState.getCurrent()); - + // check if a tour is running - if it is open the matching group var currentTour = tourService.getCurrentTour(); @@ -89,7 +98,7 @@ function handleSectionChange() { $timeout(function () { if (vm.section !== $routeParams.section || vm.tree !== $routeParams.tree) { - + vm.section = $routeParams.section; vm.tree = $routeParams.tree; @@ -107,7 +116,7 @@ vm.topics = topics; }); } - + var rq = {}; rq.section = vm.section; @@ -134,7 +143,7 @@ helpService.findVideos(rq).then(function (videos) { vm.videos = videos; }); - } + } } function setSectionName() { @@ -190,7 +199,7 @@ tourService.getToursForDoctype(node.contentTypeAlias).then(function (data) { if (data && data.length > 0) { vm.docTypeTours = data; - var currentVariant = _.find(node.variants, (x) => x.active); + var currentVariant = _.find(node.variants, (x) => x.active); vm.nodeName = currentVariant.name; vm.showDocTypeTour = true; } @@ -198,7 +207,23 @@ } } } - + function copyInformation(){ + let copyText = "\n\n\n\nCategory | Data\n-- | --\n"; + vm.systemInfo.forEach(function (info){ + copyText += info.name + " | " + info.data + "\n"; + }); + copyText += "\n\n\n" + navigator.clipboard.writeText(copyText); + if(copyText != null){ + notificationsService.success("Copied!", "Your system information is now in your clipboard"); + } + else{ + notificationsService.error("Error", "Could not copy system information"); + } + } + function getPlatform() { + return window.navigator.platform; + } evts.push(eventsService.on("appState.tour.complete", function (event, tour) { tourService.getGroupedTours().then(function(groupedTours) { vm.tours = groupedTours; @@ -206,7 +231,7 @@ getTourGroupCompletedPercentage(); }); })); - + $scope.$on('$destroy', function () { for (var e in evts) { eventsService.unsubscribe(evts[e]); diff --git a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.html b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.html index 82a37e6efbff..6f32e89988fd 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.html @@ -149,6 +149,47 @@
+ +
+ +
System Information
+
+
+ + +
+
+ + + + + + + + + +
CategoryData
{{info.name}}{{info.data}}
+
+
+