diff --git a/e2e/client/playwright/article-send-to.spec.ts b/e2e/client/playwright/article-send-to.spec.ts new file mode 100644 index 0000000000..31925b3c13 --- /dev/null +++ b/e2e/client/playwright/article-send-to.spec.ts @@ -0,0 +1,71 @@ +import {test, expect} from '@playwright/test'; +import {Monitoring} from './page-object-models/monitoring'; +import {restoreDatabaseSnapshot, s} from './utils'; +import {TreeSelectDriver} from './utils/tree-select-driver'; + +test.describe('sending an article', async () => { + test('sending an article to another desk', async ({page}) => { + const monitoring = new Monitoring(page); + + await restoreDatabaseSnapshot(); + await page.goto('/#/workspace/monitoring'); + await monitoring.selectDeskOrWorkspace('Sports'); + + await monitoring.executeActionOnMonitoringItem( + page.locator(s('monitoring-group=Sports / Working Stage', 'article-item=story 2')), + 'Edit', + ); + + await page.locator(s('authoring-topbar', 'open-send-publish-pane')).click(); + await page.locator(s('interactive-actions-panel', 'tabs')).getByRole('tab', {name: 'Send to'}).click(); + + // selecting other desk + await new TreeSelectDriver( + page, + page.locator(s('destination-select')), + ).setValue(['Educations']); + await page + .locator(s('interactive-actions-panel', 'stage-select')) + .getByRole('radio', {name: 'Working Stage'}) + .check(); + await page.locator(s('interactive-actions-panel', 'send')).click(); + + await expect( + page.locator(s('monitoring-group=Sports / Working Stage', 'article-item=story 2')), + ).not.toBeVisible(); + await monitoring.selectDeskOrWorkspace('Educations'); + await expect( + page.locator(s('monitoring-group=Educations / Working Stage', 'article-item=story 2')), + ).toBeVisible(); + }); + + test('sending an article to another stage', async ({page}) => { + const monitoring = new Monitoring(page); + + await restoreDatabaseSnapshot(); + await page.goto('/#/workspace/monitoring'); + await monitoring.selectDeskOrWorkspace('Sports'); + + await monitoring.executeActionOnMonitoringItem( + page.locator(s('monitoring-group=Sports / Working Stage', 'article-item=story 2')), + 'Edit', + ); + + await page.locator(s('authoring-topbar', 'open-send-publish-pane')).click(); + await page.locator(s('interactive-actions-panel', 'tabs')).getByRole('tab', {name: 'Send to'}).click(); + + // selecting other stage + await page + .locator(s('interactive-actions-panel', 'stage-select')) + .getByRole('radio', {name: 'Incoming Stage'}) + .check(); + await page.locator(s('interactive-actions-panel', 'send')).click(); + + await expect( + page.locator(s('monitoring-group=Sports / Working Stage', 'article-item=story 2')), + ).not.toBeVisible(); + await expect( + page.locator(s('monitoring-group=Sports / Incoming Stage', 'article-item=story 2')), + ).toBeVisible(); + }); +}); diff --git a/package-lock.json b/package-lock.json index d6168ad806..e722ed2eaa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -818,7 +818,7 @@ }, "@typescript-eslint/parser": { "version": "5.57.0", - "resolved": "https://verdaccio.sourcefabric.org/@typescript-eslint/parser/-/parser-5.57.0.tgz", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.57.0.tgz", "integrity": "sha512-orrduvpWYkgLCyAdNtR1QIWovcNZlEm6yL8nwH/eTxWLd8gsP+25pdLHYzL2QdkqrieaDwLpytHqycncv0woUQ==", "requires": { "@typescript-eslint/scope-manager": "5.57.0", @@ -829,7 +829,7 @@ "dependencies": { "debug": { "version": "4.3.4", - "resolved": "https://verdaccio.sourcefabric.org/debug/-/debug-4.3.4.tgz", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "requires": { "ms": "2.1.2" @@ -1315,7 +1315,7 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" }, "prop-types": { "version": "15.8.1", @@ -8473,7 +8473,7 @@ "jsesc": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=" + "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==" }, "json-loader": { "version": "0.5.7", @@ -12028,7 +12028,7 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" } } }, @@ -12523,7 +12523,7 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" }, "prop-types": { "version": "15.7.2", @@ -12810,7 +12810,7 @@ "regexpu-core": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-1.0.0.tgz", - "integrity": "sha1-hqdj9Y7k18L2sQLkdkBQ3n7ZDGs=", + "integrity": "sha512-Ci+lDRlvAElKjFp5keqmVUaJLqZiHywekXhshT6wVUyDObGPdymNPhxBmf38ZVsaUGOnZ3Fot9YzxvoI31ymYw==", "requires": { "regenerate": "^1.2.1", "regjsgen": "^0.2.0", @@ -12820,12 +12820,12 @@ "regjsgen": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", - "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=" + "integrity": "sha512-x+Y3yA24uF68m5GA+tBjbGYo64xXVJpbToBaWCoSNSc1hdk6dfctaRWrNFTVJZIIhL5GxW8zwjoixbnifnK59g==" }, "regjsparser": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", - "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", + "integrity": "sha512-jlQ9gYLfk2p3V5Ag5fYhA7fv7OHzd1KUH0PRP46xc3TgwjwgROIW572AfYg/X9kaNq/LJnu6oJcFRXlIrGoTRw==", "requires": { "jsesc": "~0.5.0" } diff --git a/package.json b/package.json index 3cf9ffc63f..85d33d7d81 100644 --- a/package.json +++ b/package.json @@ -123,7 +123,7 @@ "sass-loader": "6.0.6", "shortid": "2.2.8", "style-loader": "0.20.2", - "superdesk-ui-framework": "^3.1.9", + "superdesk-ui-framework": "3.1.9", "ts-loader": "3.5.0", "typescript": "4.9.5", "uuid": "8.3.1", diff --git a/scripts/apps/archive/directives/HtmlPreview.ts b/scripts/apps/archive/directives/HtmlPreview.ts index 51e4e5fdcc..d6111a41ab 100644 --- a/scripts/apps/archive/directives/HtmlPreview.ts +++ b/scripts/apps/archive/directives/HtmlPreview.ts @@ -1,3 +1,4 @@ +import {adjustHTMLForPreview} from 'apps/authoring/preview/field-types/html'; import {getAnnotationsFromItem} from 'core/editor3/helpers/editor3CustomData'; import {META_FIELD_NAME} from 'core/editor3/helpers/fieldsMeta'; import ng from 'core/services/ng'; @@ -60,7 +61,7 @@ export function HtmlPreview($sce, $timeout) { templateUrl: 'scripts/apps/archive/views/html-preview.html', link: function(scope, elem, attrs) { scope.$watch('sdHtmlPreview', (html) => { - scope.html = $sce.trustAsHtml(html); + scope.html = $sce.trustAsHtml(adjustHTMLForPreview(html)); if (window.hasOwnProperty('instgrm')) { window.instgrm.Embeds.process(); diff --git a/scripts/apps/archive/related-item-widget/relatedItem.ts b/scripts/apps/archive/related-item-widget/relatedItem.ts index 674456d4e9..28655a53b6 100644 --- a/scripts/apps/archive/related-item-widget/relatedItem.ts +++ b/scripts/apps/archive/related-item-widget/relatedItem.ts @@ -104,14 +104,14 @@ function RelatedItemController( .then((items) => { if (items && items._items && items._items.length > 1) { $scope.options.existingRelations = items._items; - $scope.widget.configurable = false; + $scope.active.configurable = false; $scope.options.searchEnabled = false; - $scope.widget.label = gettext('Related Items'); + $scope.active.label = gettext('Related Items'); } else { $scope.options.existingRelations = false; - $scope.widget.configurable = true; + $scope.active.configurable = true; $scope.options.searchEnabled = true; - $scope.widget.label = gettext('Relate an item'); + $scope.active.label = gettext('Relate an item'); } }) .finally(() => { @@ -242,16 +242,16 @@ function RelatedItemController( }, true); function reset() { - if ($scope.widget && $scope.widget.configuration) { - $scope.widget.configuration.modificationDateAfter = storage.getItem('modificationDateAfter') || 'today'; - $scope.widget.configuration.sluglineMatch = storage.getItem('sluglineMatch') || 'EXACT'; + if ($scope.active && $scope.active.configuration) { + $scope.active.configuration.modificationDateAfter = storage.getItem('modificationDateAfter') || 'today'; + $scope.active.configuration.sluglineMatch = storage.getItem('sluglineMatch') || 'EXACT'; } } - if ($scope.widget) { - $scope.widget.save = function() { - storage.setItem('sluglineMatch', $scope.widget.configuration.sluglineMatch); - storage.setItem('modificationDateAfter', $scope.widget.configuration.modificationDateAfter); + if ($scope.active) { + $scope.active.save = function() { + storage.setItem('sluglineMatch', $scope.active.configuration.sluglineMatch); + storage.setItem('modificationDateAfter', $scope.active.configuration.modificationDateAfter); }; } diff --git a/scripts/apps/authoring/preview/field-types/html.tsx b/scripts/apps/authoring/preview/field-types/html.tsx index 76337c8200..3c2b0ef397 100644 --- a/scripts/apps/authoring/preview/field-types/html.tsx +++ b/scripts/apps/authoring/preview/field-types/html.tsx @@ -1,13 +1,41 @@ +import {sdApi} from 'api'; import React from 'react'; interface IProps { value: string; } +export function adjustHTMLForPreview(html: string): string { + const parsed: HTMLElement = + new DOMParser().parseFromString(html, 'text/html').body; + + parsed.querySelectorAll('[data-custom-block-type]').forEach((element) => { + const customBlockType = element.getAttribute('data-custom-block-type'); + const vocabulary = sdApi.vocabularies.getAll().get(customBlockType); + const separator = '
'; + + element.innerHTML = `