Skip to content

Commit

Permalink
address issues raised in code review
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaskikutis committed Oct 24, 2023
1 parent 2d57a45 commit ad2d915
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions scripts/core/interactive-article-actions-panel/index-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {FetchToTab} from './actions/fetch-to-tab';
import {UnspikeTab} from './actions/unspike-tab';
import {IArticleActionInteractive, IPanelAction} from './interfaces';

const singleColumnWidthRem = 40; // rem

const handleUnsavedChangesDefault = (items: Array<IArticle>) => Promise.resolve(items);

function getTabLabel(id: IArticleActionInteractive) {
Expand Down Expand Up @@ -106,7 +108,11 @@ export class InteractiveArticleActionsPanel

function PanelWithHeader({columnCount = 1, children}: {columnCount?: number, children: React.ReactNode}) {
return (
<Panel width={`${40 * columnCount}rem`} markupV2={markupV2} data-test-id="interactive-actions-panel">
<Panel
width={`${singleColumnWidthRem * columnCount}rem`}
markupV2={markupV2}
data-test-id="interactive-actions-panel"
>
{panelHeader}
{children}
</Panel>
Expand All @@ -115,9 +121,15 @@ export class InteractiveArticleActionsPanel

if (activeTab === 'publish') {
if (items.length !== 1) {
logger.error(new Error('Publishing multiple items from authoring pane is not supported'));
// this block should never run, but I'm handling it anyway just in case

const error = gettext('Publishing multiple items from authoring pane is not supported');

return null;
logger.error(new Error(error));

return (
<div>{error}</div>
);
}

const item = items[0];
Expand All @@ -140,11 +152,17 @@ export class InteractiveArticleActionsPanel
)}
</WithPublishTab>
);
} if (activeTab === 'correct') {
} else if (activeTab === 'correct') {
if (items.length !== 1) {
logger.error(new Error('Correcting multiple items from authoring pane is not supported'));
// this block should never run, but I'm handling it anyway just in case

const error = gettext('Correcting multiple items from authoring pane is not supported');

logger.error(new Error(error));

return null;
return (
<div>{error}</div>
);
}

const item = items[0];
Expand Down Expand Up @@ -183,7 +201,7 @@ export class InteractiveArticleActionsPanel
/>
</PanelWithHeader>
);
} if (activeTab === 'duplicate_to') {
} else if (activeTab === 'duplicate_to') {
return (
<PanelWithHeader>
<DuplicateToTab
Expand All @@ -193,7 +211,7 @@ export class InteractiveArticleActionsPanel
/>
</PanelWithHeader>
);
} if (activeTab === 'unspike') {
} else if (activeTab === 'unspike') {
return (
<PanelWithHeader>
<UnspikeTab
Expand Down

0 comments on commit ad2d915

Please sign in to comment.