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

Show modal if no highlights are configured & small improvements #4198

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 14 additions & 11 deletions scripts/apps/authoring-react/authoring-integration-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import {CompareArticleVersionsModal} from './toolbar/compare-article-versions';
import {httpRequestJsonLocal} from 'core/helpers/network';
import {getArticleAdapter} from './article-adapter';
import {ui} from 'core/ui-utils';
import TranslateModal from './toolbar/translate-modal';
import {MarkForDesksModal} from './toolbar/mark-for-desks/mark-for-desks-modal';

function getAuthoringActionsFromExtensions(
Expand Down Expand Up @@ -185,16 +184,20 @@ const getExportModal = (
const getHighlightsAction = (getItem: () => IArticle): IAuthoringAction => {
return {
label: gettext('Highlights'),
onTrigger: () => (
showModal(({closeModal}) => {
return (
<HighlightsModal
article={getItem()}
closeModal={closeModal}
/>
);
})
),
onTrigger: () => {
sdApi.highlights.fetchHighlights().then((res) => {
if ((res._items.length ?? 0) === 0) {
thecalcc marked this conversation as resolved.
Show resolved Hide resolved
ui.alert(gettext('Highlights aren\'t configured on this instance.'));
thecalcc marked this conversation as resolved.
Show resolved Hide resolved
} else {
showModal(({closeModal}) => (
<HighlightsModal
article={getItem()}
closeModal={closeModal}
/>
));
}
});
},
};
};

Expand Down
14 changes: 13 additions & 1 deletion scripts/core/ui-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@ import {showModal} from '@superdesk/common';
import {Modal} from 'superdesk-ui-framework/react';
import React from 'react';

type modalPosition =
'center'
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'top-left'
| 'top-right'
| 'bottom-left'
| 'bottom-right';

export const ui = {
alert: (message: string) => (
alert: (message: string, position: modalPosition = 'top') => (
showModal(({closeModal}) => {
return (
<Modal
position={position}
thecalcc marked this conversation as resolved.
Show resolved Hide resolved
visible
onHide={closeModal}
zIndex={1050}
Expand Down