From 4a61407d1d7164c13ce629b851bbebcb50ecdbbe Mon Sep 17 00:00:00 2001 From: Tomas Kikutis Date: Mon, 2 Jan 2023 14:24:04 +0100 Subject: [PATCH 1/3] display a message when the categories vocabulary is missing --- scripts/index.ts | 4 ++ scripts/validate-instance-configuration.tsx | 45 +++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 scripts/validate-instance-configuration.tsx diff --git a/scripts/index.ts b/scripts/index.ts index 87e230437e..b75a4e62f3 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -24,6 +24,7 @@ import {setupTansa} from 'apps/tansa'; import {i18n} from 'core/utils'; import {configurableAlgorithms} from 'core/ui/configurable-algorithms'; import {merge} from 'lodash'; +import {maybeDisplayInvalidInstanceConfigurationMessage} from 'validate-instance-configuration'; let body = angular.element('body'); @@ -197,6 +198,7 @@ export function startApp( document.write('Invalid date format specified in config.view.dateFormat'); return; } + /** * @ngdoc module * @name superdesk-client @@ -210,6 +212,8 @@ export function startApp( 'superdesk.register_extensions', ].concat(appConfig.apps || []), {strictDi: true}); + maybeDisplayInvalidInstanceConfigurationMessage(); + window['superdeskIsReady'] = true; body.attr('data-theme', 'dark-ui'); diff --git a/scripts/validate-instance-configuration.tsx b/scripts/validate-instance-configuration.tsx new file mode 100644 index 0000000000..8a0a2b53b9 --- /dev/null +++ b/scripts/validate-instance-configuration.tsx @@ -0,0 +1,45 @@ +import React from 'react'; +import {Modal} from 'superdesk-ui-framework/react'; +import ng from 'core/services/ng'; +import {gettext} from 'core/utils'; +import {showModal} from 'core/services/modalService'; + +const modalHeader = ( + + {gettext('Instance configuration is missing!')} + +); + +export function maybeDisplayInvalidInstanceConfigurationMessage() { + const issues: Array = []; + + ng.get('vocabularies').getAllActiveVocabularies().then((vocabularies) => { + const categoriesMissing = vocabularies.find(({_id}) => _id === 'categories') != null; + + if (categoriesMissing) { + issues.push( + ( + <> +

{gettext('Vocabulary with ID "categories" is required.')}

+

{gettext('Add it via Settings > Metadata')}

+ + ), + ); + } + + if (issues.length > 0) { + showModal(({closeModal}) => ( + + {issues[0]} + + )); + } + }); +} From c76c21cef78b454b2a52a8ba42ff1d3bdd66d58d Mon Sep 17 00:00:00 2001 From: Tomas Kikutis Date: Tue, 10 Jan 2023 21:41:42 +0100 Subject: [PATCH 2/3] avoid protractor timing out --- scripts/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/index.ts b/scripts/index.ts index b75a4e62f3..6b88ba7c7d 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -25,6 +25,7 @@ import {i18n} from 'core/utils'; import {configurableAlgorithms} from 'core/ui/configurable-algorithms'; import {merge} from 'lodash'; import {maybeDisplayInvalidInstanceConfigurationMessage} from 'validate-instance-configuration'; +import ng from 'core/services/ng'; let body = angular.element('body'); @@ -212,7 +213,11 @@ export function startApp( 'superdesk.register_extensions', ].concat(appConfig.apps || []), {strictDi: true}); - maybeDisplayInvalidInstanceConfigurationMessage(); + setTimeout(() => { // required to avoid protractor timing out and failing tests + if (ng.get('session').sessionId != null) { // user logged in + maybeDisplayInvalidInstanceConfigurationMessage(); + } + }); window['superdeskIsReady'] = true; From 02c512dac4595911faae7dca414a98613ea2fa8d Mon Sep 17 00:00:00 2001 From: Tomas Kikutis Date: Fri, 13 Jan 2023 11:11:39 +0100 Subject: [PATCH 3/3] fix e2e test can save and use language preferences --- e2e/client/specs/users_spec.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/e2e/client/specs/users_spec.ts b/e2e/client/specs/users_spec.ts index dfc2d5cc80..b38e87e9f1 100644 --- a/e2e/client/specs/users_spec.ts +++ b/e2e/client/specs/users_spec.ts @@ -47,6 +47,10 @@ describe('users', () => { element(by.css('.modal__dialog .btn--primary')).click(); browser.sleep(2000); // wait for reload + // close "missing categories" vocabulary warning + // most likely it appears because refreshing the page causes test data to disappear + element(by.css('.p-dialog-header-icons')).click(); + const header = element(by.css('[ng-hide="currentRoute.topTemplateUrl"]')); browser.wait(ECE.presenceOf(header), 1000);