From 53b51362d60511ecb789e24ec3a099b39a9c3f99 Mon Sep 17 00:00:00 2001 From: Nikola Stojanovic <68916411+dzonidoo@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:57:05 +0100 Subject: [PATCH] Improve the config options for the fields shown in the Publish and Send to Panel (#4703) --- e2e/client/specs/content_spec.ts | 43 --------------- scripts/appConfig.ts | 52 ++++++++++++++++--- .../actions/publish-tab.tsx | 41 ++++++++------- .../actions/send-to-tab.tsx | 1 + .../subcomponents/publishing-date-options.tsx | 3 +- scripts/core/superdesk-api.d.ts | 10 ++++ 6 files changed, 80 insertions(+), 70 deletions(-) diff --git a/e2e/client/specs/content_spec.ts b/e2e/client/specs/content_spec.ts index 69ce29f5cc..37ea7a3c10 100644 --- a/e2e/client/specs/content_spec.ts +++ b/e2e/client/specs/content_spec.ts @@ -217,47 +217,4 @@ describe('content', () => { element(by.id('closeAuthoringBtn')).click(); }); - - it('can set embargo and send', () => { - // Initial steps before proceeding, to get initial state of send buttons. - workspace.editItem('item3', 'SPORTS'); - authoring.sendTo('Sports Desk', 'Incoming Stage'); - authoring.confirmSendTo(); - - workspace.editItem('item3', 'SPORTS'); - - el(['open-send-publish-pane']).click(); - - el(['authoring', 'interactive-actions-panel', 'tabs'], by.buttonText('Send to')).click(); - - const sendToButton = el(['authoring', 'interactive-actions-panel', 'send']); - - browser.wait(ECE.visibilityOf(sendToButton)); - - new TreeSelectDriver( - el(['interactive-actions-panel', 'destination-select']), - ).setValue('Sports Desk'); - - const stage = 'two'; - - // State after selecting different Stage in the same desk - el( - ['interactive-actions-panel', 'stage-select'], - by.cssContainingText('[data-test-id="item"]', stage), - ).click(); - - expect(sendToButton.isEnabled()).toBe(true); - - // State after setting Embargo - setEmbargo(); - browser.sleep(100); - expect(sendToButton.isEnabled()).toBe(true); - - // State after changing Desk - new TreeSelectDriver( - el(['interactive-actions-panel', 'destination-select']), - ).setValue('Politic Desk'); - - expect(sendToButton.isEnabled()).toBe(true); - }); }); diff --git a/scripts/appConfig.ts b/scripts/appConfig.ts index 11eaee563e..5d363920fb 100644 --- a/scripts/appConfig.ts +++ b/scripts/appConfig.ts @@ -12,6 +12,50 @@ if (appConfig.shortTimeFormat == null) { appConfig.shortTimeFormat = 'HH:mm'; // 24h format } +if (appConfig.ui == null) { + appConfig.ui = {}; +} + +if (appConfig.ui.sendEmbargo == null) { + appConfig.ui.sendEmbargo = false; +} + +if (appConfig.ui.italicAbstract == null) { + appConfig.ui.italicAbstract = true; +} + +if (appConfig.ui.publishEmbargo == null) { + appConfig.ui.publishEmbargo = true; +} + +if (appConfig.authoring == null) { + appConfig.authoring = {}; +} + +if (appConfig.authoring.panels == null) { + appConfig.authoring.panels = {}; +} + +if (appConfig.authoring.panels.publish == null) { + appConfig.authoring.panels.publish = {}; +} + +if (appConfig.authoring.panels.publish.publishSchedule == null) { + appConfig.authoring.panels.publish.publishSchedule = true; +} + +if (appConfig.authoring.panels.publish.publishingTarget == null) { + appConfig.authoring.panels.publish.publishingTarget = true; +} + +if (appConfig.authoring.panels.sendTo == null) { + appConfig.authoring.panels.sendTo = {}; +} + +if (appConfig.authoring.panels.sendTo.publishSchedule == null) { + appConfig.authoring.panels.sendTo.publishSchedule = false; +} + const defaultDateFormat = 'MM/DD'; const defaultTimeFormat = 'hh:mm'; @@ -34,14 +78,6 @@ if (appConfig.longDateFormat == null) { appConfig.longDateFormat = 'LLL'; } -if (appConfig.ui == null) { - appConfig.ui = {}; - - if (appConfig.ui.italicAbstract == null) { - appConfig.ui.italicAbstract = true; - } -} - if (appConfig.features == null) { appConfig.features = {}; } diff --git a/scripts/core/interactive-article-actions-panel/actions/publish-tab.tsx b/scripts/core/interactive-article-actions-panel/actions/publish-tab.tsx index 172c8190fa..16f502c2f6 100644 --- a/scripts/core/interactive-article-actions-panel/actions/publish-tab.tsx +++ b/scripts/core/interactive-article-actions-panel/actions/publish-tab.tsx @@ -223,26 +223,31 @@ export class WithPublishTab extends React.PureComponent { }, ); }} - allowSettingEmbargo={appConfig.ui.publishEmbargo !== false} + allowSettingEmbargo={appConfig.ui.publishEmbargo} + allowSettingPublishSchedule={ + appConfig.authoring.panels.publish.publishSchedule + } /> - { - this.setState( - {publishingTarget: val}, - () => { - this.props.onDataChange?.({ - ...this.props.item, - ...getPublishingTargetPatch( - this.props.item, - this.state.publishingTarget, - ), - }); - }, - ); - }} - /> + {appConfig.authoring.panels.publish.publishingTarget && ( + { + this.setState( + {publishingTarget: val}, + () => { + this.props.onDataChange?.({ + ...this.props.item, + ...getPublishingTargetPatch( + this.props.item, + this.state.publishingTarget, + ), + }); + }, + ); + }} + /> + )} { diff --git a/scripts/core/interactive-article-actions-panel/actions/send-to-tab.tsx b/scripts/core/interactive-article-actions-panel/actions/send-to-tab.tsx index 07efe50690..a0304d9477 100644 --- a/scripts/core/interactive-article-actions-panel/actions/send-to-tab.tsx +++ b/scripts/core/interactive-article-actions-panel/actions/send-to-tab.tsx @@ -147,6 +147,7 @@ export class SendToTab extends React.PureComponent { this.setState({publishingDateOptions: val}); }} allowSettingEmbargo={appConfig.ui.sendEmbargo !== false} + allowSettingPublishSchedule={appConfig.authoring.panels.sendTo.publishSchedule} /> ) } diff --git a/scripts/core/interactive-article-actions-panel/subcomponents/publishing-date-options.tsx b/scripts/core/interactive-article-actions-panel/subcomponents/publishing-date-options.tsx index b747176c01..4fcc86083a 100644 --- a/scripts/core/interactive-article-actions-panel/subcomponents/publishing-date-options.tsx +++ b/scripts/core/interactive-article-actions-panel/subcomponents/publishing-date-options.tsx @@ -60,6 +60,7 @@ interface IProps { value: IPublishingDateOptions; onChange(value: IPublishingDateOptions): void; allowSettingEmbargo: boolean; + allowSettingPublishSchedule?: boolean; } export class PublishingDateOptions extends React.PureComponent { @@ -76,7 +77,7 @@ export class PublishingDateOptions extends React.PureComponent { && this.props.allowSettingEmbargo && sdApi.user.hasPrivilege('embargo'); - const canSetPublishSchedule = embargo == null; + const canSetPublishSchedule = embargo == null && this.props.allowSettingPublishSchedule; return (
diff --git a/scripts/core/superdesk-api.d.ts b/scripts/core/superdesk-api.d.ts index 33e67dc371..67ba901fc3 100644 --- a/scripts/core/superdesk-api.d.ts +++ b/scripts/core/superdesk-api.d.ts @@ -3417,6 +3417,16 @@ declare module 'superdesk-api' { preview?: { hideContentLabels: boolean; }; + + panels?: { + publish?: { + publishSchedule?: boolean + publishingTarget?: boolean; + } + sendTo?: { + publishSchedule?: boolean; + } + } }; ui: { /**