Move BC compatibility for UserRole to entity data getter
[MAILPOET-3469]
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
|||||||
GroupFilterValue,
|
GroupFilterValue,
|
||||||
Segment,
|
Segment,
|
||||||
StateType,
|
StateType,
|
||||||
SubscriberActionTypes, SubscriberCount,
|
SubscriberCount,
|
||||||
WindowCustomFields,
|
WindowCustomFields,
|
||||||
WindowEditableRoles,
|
WindowEditableRoles,
|
||||||
WindowNewslettersList,
|
WindowNewslettersList,
|
||||||
@@ -14,7 +14,6 @@ import {
|
|||||||
WindowSubscriptionProducts,
|
WindowSubscriptionProducts,
|
||||||
WindowWooCommerceCountries,
|
WindowWooCommerceCountries,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { SubscriberSegmentOptions } from '../dynamic_segments_filters/subscriber';
|
|
||||||
|
|
||||||
export const getProducts = (state: StateType): WindowProducts => (
|
export const getProducts = (state: StateType): WindowProducts => (
|
||||||
state.products
|
state.products
|
||||||
@@ -69,17 +68,6 @@ export const findFiltersValueForSegment = (
|
|||||||
itemSearch: Segment
|
itemSearch: Segment
|
||||||
): FilterRow[] => {
|
): FilterRow[] => {
|
||||||
const found: FilterRow[] = [];
|
const found: FilterRow[] = [];
|
||||||
if (itemSearch.filters === undefined) {
|
|
||||||
// bc compatibility, the wordpress user role segment doesn't have action
|
|
||||||
const filterValue: FilterValue = SubscriberSegmentOptions.find(
|
|
||||||
(value) => value.value === SubscriberActionTypes.WORDPRESS_ROLE
|
|
||||||
);
|
|
||||||
found.push({
|
|
||||||
filterValue,
|
|
||||||
index: 0,
|
|
||||||
});
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
itemSearch.filters.forEach((formItem: AnyFormItem, index) => {
|
itemSearch.filters.forEach((formItem: AnyFormItem, index) => {
|
||||||
state.allAvailableFilters.forEach((filter: GroupFilterValue) => {
|
state.allAvailableFilters.forEach((filter: GroupFilterValue) => {
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace MailPoet\Entities;
|
namespace MailPoet\Entities;
|
||||||
|
|
||||||
|
use MailPoet\Segments\DynamicSegments\Filters\UserRole;
|
||||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,7 +28,12 @@ class DynamicSegmentFilterData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getData(): ?array {
|
public function getData(): ?array {
|
||||||
return $this->filterData;
|
$filterData = $this->filterData;
|
||||||
|
// bc compatibility, the wordpress user role segment didn't have action
|
||||||
|
if (($this->filterData['segmentType'] ?? null) === self::TYPE_USER_ROLE && !isset($this->filterData['action'])) {
|
||||||
|
$filterData['action'] = UserRole::TYPE;
|
||||||
|
}
|
||||||
|
return $filterData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user