Skip to content

Commit

Permalink
Merge branch 'develop' into use-npm-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaskikutis committed Jun 19, 2024
2 parents 4054304 + 3250d4a commit 8c4fee5
Show file tree
Hide file tree
Showing 15 changed files with 213 additions and 139 deletions.
71 changes: 71 additions & 0 deletions e2e/client/playwright/article-send-to.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion scripts/apps/archive/directives/HtmlPreview.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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();
Expand Down
22 changes: 11 additions & 11 deletions scripts/apps/archive/related-item-widget/relatedItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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);
};
}

Expand Down
30 changes: 29 additions & 1 deletion scripts/apps/authoring/preview/field-types/html.tsx
Original file line number Diff line number Diff line change
@@ -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 = '<div style="border-top: 2px solid lightgray; margin-top: 10px; margin-bottom: 10px;"></div>';

element.innerHTML = `<div>
${separator}
<div class="mb-1 mt-0-5">
<span class="label label--translucent">${vocabulary.display_name}</span>
</div>
${element.innerHTML}
${separator}
</div>`;
});

return parsed.innerHTML;
}

export class HtmlPreview extends React.Component<IProps> {
render() {
const html = this.props.value;

return (
<div dangerouslySetInnerHTML={{__html: this.props.value}} />
<div dangerouslySetInnerHTML={{__html: adjustHTMLForPreview(html)}} />
);
}
}
2 changes: 1 addition & 1 deletion scripts/apps/authoring/styles/themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ body, html {
width: 100%;
display: table;
table-layout: fixed;
margin: 10px 0;
margin-top: 1.5em;
&.item-association {
margin: 0;
}
Expand Down
78 changes: 23 additions & 55 deletions scripts/apps/authoring/widgets/views/authoring-widgets.html
Original file line number Diff line number Diff line change
@@ -1,44 +1,11 @@
<div class="pinned-tab__wrapper">
<section class="tabcontent">
<!--
react based widgets use WidgetHeading component
that has pinning button already inside
this was done to prevent absolutely positioned pinning button
from covering other components
-->
<div
ng-if="pinnedWidget.component == null"
class="tabcontent-actions"
>
<button class="icn-btn active" ng-click="pinWidget(widget)">
<i class="icon-pin"></i>
</button>
</div>

<div
ng-if="pinnedWidget.component == null"
sd-widget
data-widget="pinnedWidget"
data-configurable="pinnedWidget.configurable"
data-save="pinnedWidget.save()"
>
<div ng-include="pinnedWidget.template" class="sd-wrap-helper"></div>
</div>

<sd-widget-react
ng-if="pinnedWidget.component != null"
widget="pinnedWidget"
article="item"
class="sd-widget"
></sd-widget-react>
</section>
</div>

<div class="widget-wrapper"
<div
class="widget-wrapper"
ng-class="{
'active-right': active,
'right-extended': active.extended}">
'right-extended': active.extended
}"
>
<!-- AVAILABLE WIDGETS LIST START -->
<div class="sd-sidetab-menu sd-sidetab-menu--right" ng-if="item">
<ul class="navigation-tabs" data-test-id="navigation-tabs">
<li ng-repeat="widget in widgets | orderBy:'order'"
Expand All @@ -64,31 +31,32 @@
</li>
</ul>
</div>

<div class="tabpane right-tabpane open-tabpane widget-{{active._id}}"
ng-if="active && !isWidgetLocked(active) && !active.pinned"
<!-- AVAILABLE WIDGETS LIST END -->
<div
ng-if="active || pinnedWidget"
ng-class="{
'pinned-tab__wrapper': active._id == pinnedWidget._id,
'tabpane open-tabpane right-tabpane': active._id != null && (active._id != pinnedWidget._id),
}"
class="widget-{{active._id}}"
data-test-id="authoring-widget-panel"
data-test-value="{{active.label}}"
>
<section class="tabcontent" ng-init="widget=active">
<!--
react based widgets use WidgetHeading component
that has pinning button already inside
this was done to prevent absolutely positioned pinning button
from covering other components
-->
<div
ng-if="active.component == null"
ng-if="active.template != null"
class="tabcontent-actions"
>
<button class="icn-btn" ng-click="pinWidget(active)" ng-class="{'active': widget.pinned}">
<button
class="icn-btn"
ng-click="pinWidget(active)"
ng-class="{'active': active.pinned}"
>
<i class="icon-pin"></i>
</button>
</div>

<div
ng-if="active.component == null"
ng-if="active.template != null"
sd-widget
data-widget="active"
data-configurable="active.configurable"
Expand All @@ -98,8 +66,8 @@
</div>

<sd-widget-react
ng-if="active.component != null"
widget="active"
ng-if="active.component != null || pinnedWidget.component != null"
widget="{active, pinnedWidget}"
article="item"
class="sd-widget"
></sd-widget-react>
Expand Down
Loading

0 comments on commit 8c4fee5

Please sign in to comment.