Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the config options for the fields shown in the Publish and Send to Panel #4703

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions scripts/appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,34 @@ 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.authoring == null) {
appConfig.authoring = {};
}

if (appConfig.authoring.panels == null) {
appConfig.authoring.panels = {};
}

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';

Expand All @@ -34,14 +62,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 = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,25 +224,30 @@ export class WithPublishTab extends React.PureComponent<IProps, IState> {
);
}}
allowSettingEmbargo={appConfig.ui.publishEmbargo !== false}
allowSettingPublishSchedule={
appConfig.authoring.panels.publish.publishSchedule !== false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apply the default in appConfig

}
/>

<PublishingTargetSelect
value={this.state.publishingTarget}
onChange={(val) => {
this.setState(
{publishingTarget: val},
() => {
this.props.onDataChange?.({
...this.props.item,
...getPublishingTargetPatch(
this.props.item,
this.state.publishingTarget,
),
});
},
);
}}
/>
{appConfig.authoring.panels.publish.publishingTarget !== false && (
<PublishingTargetSelect
value={this.state.publishingTarget}
onChange={(val) => {
this.setState(
{publishingTarget: val},
() => {
this.props.onDataChange?.({
...this.props.item,
...getPublishingTargetPatch(
this.props.item,
this.state.publishingTarget,
),
});
},
);
}}
/>
)}
</div>

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export class SendToTab extends React.PureComponent<IProps, IState> {
this.setState({publishingDateOptions: val});
}}
allowSettingEmbargo={appConfig.ui.sendEmbargo !== false}
allowSettingPublishSchedule={appConfig.authoring.panels.sendTo.publishSchedule}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ interface IProps {
value: IPublishingDateOptions;
onChange(value: IPublishingDateOptions): void;
allowSettingEmbargo: boolean;
allowSettingPublishSchedule?: boolean;
}

export class PublishingDateOptions extends React.PureComponent<IProps> {
Expand All @@ -76,7 +77,7 @@ export class PublishingDateOptions extends React.PureComponent<IProps> {
&& this.props.allowSettingEmbargo
&& sdApi.user.hasPrivilege('embargo');

const canSetPublishSchedule = embargo == null;
const canSetPublishSchedule = embargo == null && this.props.allowSettingPublishSchedule;

return (
<div>
Expand Down
10 changes: 10 additions & 0 deletions scripts/core/superdesk-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3410,6 +3410,16 @@ declare module 'superdesk-api' {
preview?: {
hideContentLabels: boolean;
};

panels?: {
publish?: {
publishSchedule?: boolean
publishingTarget?: boolean;
}
sendTo?: {
publishSchedule?: boolean;
}
}
};
ui: {
/**
Expand Down
Loading