Skip to content

Commit

Permalink
Fix eslint issues
Browse files Browse the repository at this point in the history
The issues were related to a change in Gutenberg where ActionCreators are not promisified.
See WordPress/gutenberg#52530
[MAILPOET-5714]
  • Loading branch information
costasovo committed Feb 15, 2024
1 parent 4f77afd commit 83c6f29
Show file tree
Hide file tree
Showing 56 changed files with 120 additions and 94 deletions.
Expand Up @@ -25,7 +25,9 @@ export const registerApiErrorHandler = (): void =>
const code = errorObject.code;

if (code === 'mailpoet_automation_not_valid') {
dispatch(storeName).setErrors({ steps: errorObject.data.errors });
void dispatch(storeName).setErrors({
steps: errorObject.data.errors,
});
return undefined;
}

Expand All @@ -35,7 +37,7 @@ export const registerApiErrorHandler = (): void =>
message ?? __('An unknown error occurred.', 'mailpoet'),
{ explicitDismiss: true },
);
dispatch(storeName).setErrors({ steps: [] });
void dispatch(storeName).setErrors({ steps: [] });
return undefined;
}

Expand Down
Expand Up @@ -32,7 +32,7 @@ export function TrashButton({
confirmButtonText={__('Yes, delete', 'mailpoet')}
onConfirm={async () => {
setIsBusy(true);
trash(() => {
void trash(() => {
setShowConfirmDialog(false);
setIsBusy(false);
performActionAfterDelete();
Expand Down
Expand Up @@ -29,7 +29,7 @@ export function AddTrigger({ step, index }: Props): JSX.Element {
context === 'edit'
? (event) => {
event.stopPropagation();
setInserterPopover({
void setInserterPopover({
anchor: (event.target as HTMLElement).closest('button'),
type: 'triggers',
});
Expand Down
Expand Up @@ -101,8 +101,8 @@ export function Step({ step, isSelected }: Props): JSX.Element {
context === 'edit'
? () =>
batch(() => {
openSidebar(stepSidebarKey);
selectStep(step);
void openSidebar(stepSidebarKey);
void selectStep(step);
})
: undefined
}
Expand Down
Expand Up @@ -47,8 +47,8 @@ function StepError({ stepId }: StepErrorProps): JSX.Element {
role="listitem"
state={compositeState}
onClick={() => {
openSidebar(stepSidebarKey);
selectStep(stepData);
void openSidebar(stepSidebarKey);
void selectStep(stepData);
}}
>
<ColoredIcon
Expand Down
Expand Up @@ -41,7 +41,7 @@ export function InserterPopover(): JSX.Element | null {
anchorRect={inserterPopover.anchor.getBoundingClientRect()}
onClose={() => {
if (!showModal) {
setInserterPopover(undefined);
void setInserterPopover(undefined);
}
}}
>
Expand Down
Expand Up @@ -56,27 +56,27 @@ export function KeyboardShortcuts(): null {
}, [registerShortcut]);

useShortcut('mailpoet/automation-editor/toggle-fullscreen', () => {
toggleFeature('fullscreenMode');
void toggleFeature('fullscreenMode');
});

useShortcut('mailpoet/automation-editor/toggle-sidebar', (event) => {
event.preventDefault();

if (isSidebarOpened()) {
closeSidebar();
void closeSidebar();
} else {
const sidebarToOpen = selectedStep()
? stepSidebarKey
: automationSidebarKey;
openSidebar(sidebarToOpen);
void openSidebar(sidebarToOpen);
}
});

useShortcut('mailpoet/automation-editor/save', (event) => {
event.preventDefault();

if (savedState === 'unsaved') {
save();
void save();
}
});

Expand Down
Expand Up @@ -30,7 +30,7 @@ export function DeactivateImmediatelyModal({
variant="primary"
onClick={() => {
setIsBusy(true);
dispatch(storeName).deactivate(true);
void dispatch(storeName).deactivate(true);
}}
>
{__('Deactivate now', 'mailpoet')}
Expand Down Expand Up @@ -139,7 +139,7 @@ export function DeactivateModal({
variant="primary"
onClick={() => {
setIsBusy(true);
dispatch(storeName).deactivate(
void dispatch(storeName).deactivate(
selected !== AutomationStatus.DEACTIVATING,
);
}}
Expand Down
Expand Up @@ -22,7 +22,7 @@ function PreStep({ onClose }): JSX.Element {
autoFocus={!isActivating}
onClick={() => {
setIsActivating(true);
activate();
void activate();
}}
>
{isActivating && __('Activating…', 'mailpoet')}
Expand Down Expand Up @@ -113,7 +113,7 @@ export function ActivatePanel(): JSX.Element {

useEffect(() => {
if (errors) {
closeActivationPanel();
void closeActivationPanel();
}
}, [errors, closeActivationPanel]);

Expand Down
2 changes: 1 addition & 1 deletion mailpoet/assets/js/src/automation/editor/store/actions.ts
Expand Up @@ -41,7 +41,7 @@ export const closeActivationPanel = () => ({
});

export const openSidebar = (key) => {
dispatch(storeName).closeActivationPanel();
void dispatch(storeName).closeActivationPanel();
return ({ registry }) =>
registry.dispatch(interfaceStore).enableComplementaryArea(storeName, key);
};
Expand Down
Expand Up @@ -4,7 +4,7 @@ import { storeName } from './constants';
import { StepType } from './types';

export const registerStepType = (stepType: StepType): void => {
dispatch(storeName).registerStepType(
void dispatch(storeName).registerStepType(
Hooks.applyFilters('mailpoet.automation.register_step_type', stepType),
);
};
Expand Up @@ -54,7 +54,7 @@ export function Edit(): JSX.Element {
rawValue.length === 0 || parseInt(rawValue, 10) < 1
? 1
: parseInt(rawValue, 10);
dispatch(storeName).updateStepArgs(
void dispatch(storeName).updateStepArgs(
selectedStep.id,
'delay',
value,
Expand Down
Expand Up @@ -81,7 +81,7 @@ export function Orders(): JSX.Element {
: 'asc',
};
}
dispatch(storeName).updateSection({
void dispatch(storeName).updateSection({
...ordersSection,
customQuery: {
...ordersSection.customQuery,
Expand Down
Expand Up @@ -69,7 +69,7 @@ export function Subscribers(): JSX.Element {
: 'asc',
};
}
dispatch(storeName).updateSection({
void dispatch(storeName).updateSection({
...subscriberSection,
customQuery: {
...subscriberSection.customQuery,
Expand Down
Expand Up @@ -89,7 +89,7 @@ function boot() {
select(storeName)
.getSections()
.forEach((section: Section) => {
dispatch(storeName).updateSection(section);
void dispatch(storeName).updateSection(section);
});
}

Expand Down
Expand Up @@ -15,7 +15,7 @@ export function openTab(tab: ValidTabs, currentView?: CurrentView): void {
},
currentView,
};
dispatch(storeName).updateSection(payload);
void dispatch(storeName).updateSection(payload);
}

const classMap: Record<ValidTabs, string> = {
Expand Down
Expand Up @@ -54,7 +54,7 @@ export function* updateSection(
section: Section,
queryParam: Query | undefined = undefined,
) {
dispatch(storeName).resetSectionData(section);
void dispatch(storeName).resetSectionData(section);

const sampleData = Hooks.applyFilters(
'mailpoet_analytics_section_sample_data',
Expand Down
Expand Up @@ -16,7 +16,7 @@ const sections: Record<string, Section> = {
return;
}
const { automation } = data;
dispatch(editorStoreName).updateAutomation(automation);
void dispatch(editorStoreName).updateAutomation(automation);
},
},
overview: {
Expand Down
Expand Up @@ -37,7 +37,7 @@ export function RunAutomationOnce(): JSX.Element {
label={__('Run this automation only once per subscriber.', 'mailpoet')}
checked={checked}
onChange={(value) => {
dispatch(storeName).updateAutomationMeta(
void dispatch(storeName).updateAutomationMeta(
'mailpoet:run-once-per-subscriber',
value,
);
Expand Down
Expand Up @@ -65,13 +65,13 @@ export function EditNewsletter(): JSX.Element {
},
});

dispatch(storeName).updateStepArgs(
void dispatch(storeName).updateStepArgs(
automationStepId,
'email_id',
parseInt(response.data.id as string, 10),
);

dispatch(storeName).save();
void dispatch(storeName).save();
}, [automationId, automationStepId]);

// This component is rendered only when no email ID is set. Once we have the ID
Expand Down
Expand Up @@ -55,7 +55,11 @@ export function EmailPanel(): JSX.Element {
currentName={(selectedStep.args.name as string) ?? ''}
defaultName={__('Send email', 'mailpoet')}
update={(value) => {
dispatch(storeName).updateStepArgs(selectedStep.id, 'name', value);
void dispatch(storeName).updateStepArgs(
selectedStep.id,
'name',
value,
);
}}
/>
<TextControl
Expand Down
Expand Up @@ -29,7 +29,7 @@ export function GoogleAnalyticsPanel(): JSX.Element {
<PremiumModal
onRequestClose={() => {
setEnabled(false);
updateStepArgs(selectedStep.id, 'ga_campaign', undefined);
void updateStepArgs(selectedStep.id, 'ga_campaign', undefined);
}}
>
{__(
Expand All @@ -51,7 +51,7 @@ export function GoogleAnalyticsPanel(): JSX.Element {
onChange={(value) => {
setEnabled(value);
if (!value) {
updateStepArgs(selectedStep.id, 'ga_campaign', undefined);
void updateStepArgs(selectedStep.id, 'ga_campaign', undefined);
}
}}
/>
Expand Down
Expand Up @@ -56,15 +56,15 @@ export function ReplyToPanel(): JSX.Element {
if (value) {
const name = prevValue.current?.name ?? defaultName;
const address = prevValue.current?.address ?? defaultAddress;
updateStepArgs(stepId, 'reply_to_name', name);
updateStepArgs(stepId, 'reply_to_address', address);
void updateStepArgs(stepId, 'reply_to_name', name);
void updateStepArgs(stepId, 'reply_to_address', address);
} else {
prevValue.current = {
name: args.reply_to_name,
address: args.reply_to_address,
};
updateStepArgs(stepId, 'reply_to_name', undefined);
updateStepArgs(stepId, 'reply_to_address', undefined);
void updateStepArgs(stepId, 'reply_to_name', undefined);
void updateStepArgs(stepId, 'reply_to_address', undefined);
}
}}
/>
Expand Down
Expand Up @@ -39,7 +39,7 @@ export function ListPanel(): JSX.Element {
value={selected}
suggestions={validSegments}
onChange={(values) => {
dispatch(storeName).updateStepArgs(
void dispatch(storeName).updateStepArgs(
selectedStep.id,
'segment_ids',
values.map((item) => item.id),
Expand Down
Expand Up @@ -57,7 +57,7 @@ export function RolePanel(): JSX.Element {
suggestions={userRoles}
placeholder={__('Any user role', 'mailpoet')}
onChange={(items) => {
dispatch(storeName).updateStepArgs(
void dispatch(storeName).updateStepArgs(
selectedStep.id,
'roles',
items.map((item) => item.id),
Expand Down
Expand Up @@ -14,7 +14,7 @@ export function Edit(): JSX.Element {
<PlainBodyTitle title={__('Settings', 'mailpoet')} />
<SelectControl
onChange={(id: string) => {
dispatch(storeName).updateStepArgs(
void dispatch(storeName).updateStepArgs(
selectedStep.id,
'wait',
parseInt(id, 10),
Expand Down
Expand Up @@ -58,7 +58,7 @@ export function Edit(): JSX.Element {
selected={current}
onChange={(items: Product[]) => {
setCurrent(items);
dispatch(storeName).updateStepArgs(
void dispatch(storeName).updateStepArgs(
selectedStep.id,
'product_ids',
items.map((item) => item.key),
Expand All @@ -75,7 +75,11 @@ export function Edit(): JSX.Element {
showTo
toLabel={__('Order status', 'mailpoet')}
onChange={(status, property) => {
dispatch(storeName).updateStepArgs(selectedStep.id, property, status);
void dispatch(storeName).updateStepArgs(
selectedStep.id,
property,
status,
);
}}
/>
</>
Expand Down
Expand Up @@ -58,7 +58,7 @@ export function Edit(): JSX.Element {
selected={current}
onChange={(items: Category[]) => {
setCurrent(items);
dispatch(storeName).updateStepArgs(
void dispatch(storeName).updateStepArgs(
selectedStep.id,
'category_ids',
items.map((item) => item.key),
Expand All @@ -75,7 +75,11 @@ export function Edit(): JSX.Element {
showTo
toLabel={__('Order status', 'mailpoet')}
onChange={(status, property) => {
dispatch(storeName).updateStepArgs(selectedStep.id, property, status);
void dispatch(storeName).updateStepArgs(
selectedStep.id,
property,
status,
);
}}
/>
</>
Expand Down
Expand Up @@ -19,7 +19,11 @@ export function Edit(): JSX.Element {
toLabel={__('Status changes to:', 'mailpoet')}
fromLabel={__('Status changes from:', 'mailpoet')}
onChange={(status, property) => {
dispatch(storeName).updateStepArgs(selectedStep.id, property, status);
void dispatch(storeName).updateStepArgs(
selectedStep.id,
property,
status,
);
}}
/>
);
Expand Down
Expand Up @@ -61,15 +61,15 @@ export function OrderStatusPanel({
value={fromSelected}
label={fromLabel}
options={[...options.values()]}
onChange={(value) => update(value, 'from')}
onChange={(value) => update(value as string, 'from')}
/>
)}
{showTo && (
<SelectControl
value={toSelected}
label={toLabel}
options={[...options.values()]}
onChange={(value) => update(value, 'to')}
onChange={(value) => update(value as string, 'to')}
/>
)}
{showPremiumModal && (
Expand Down

0 comments on commit 83c6f29

Please sign in to comment.