Skip to content

Commit

Permalink
Show modal if no highlights are configured & small improvements (#4198)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc authored Feb 8, 2023
1 parent af644e4 commit 98cf62e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
22 changes: 12 additions & 10 deletions scripts/apps/authoring-react/authoring-integration-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,23 @@ const getExportModal = (

const getHighlightsAction = (getItem: () => IArticle): IAuthoringAction => {
const showHighlightsModal = () => {
showModal(({closeModal}) => {
return (
<HighlightsModal
article={getItem()}
closeModal={closeModal}
/>
);
sdApi.highlights.fetchHighlights().then((res) => {
if (res._items.length === 0) {
ui.alert(gettext('No highlights have been created yet.'));
} else {
showModal(({closeModal}) => (
<HighlightsModal
article={getItem()}
closeModal={closeModal}
/>
));
}
});
};

return {
label: gettext('Highlights'),
onTrigger: () => (
showHighlightsModal()
),
onTrigger: () => showHighlightsModal(),
keyBindings: {
'ctrl+shift+h': () => {
showHighlightsModal();
Expand Down
1 change: 1 addition & 0 deletions scripts/core/ui-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const ui = {
showModal(({closeModal}) => {
return (
<Modal
position="top"
visible
onHide={closeModal}
zIndex={1050}
Expand Down

0 comments on commit 98cf62e

Please sign in to comment.