Remove "inactive" status for now, use "draft" instead

[MAILPOET-4757]
This commit is contained in:
Jan Jakes
2022-11-04 11:09:06 +01:00
committed by David Remer
parent f1abfe557a
commit af1e09f46f
12 changed files with 13 additions and 41 deletions

View File

@@ -38,11 +38,7 @@ export function DocumentActions({ children }): JSX.Element {
let chipClass = 'mailpoet-automation-editor-chip-gray';
if (workflowStatus === WorkflowStatus.ACTIVE) {
chipClass = 'mailpoet-automation-editor-chip-success';
} else if (
[WorkflowStatus.INACTIVE, WorkflowStatus.DEACTIVATING].includes(
workflowStatus,
)
) {
} else if (workflowStatus === WorkflowStatus.DEACTIVATING) {
chipClass = 'mailpoet-automation-editor-chip-danger';
}
@@ -79,8 +75,6 @@ export function DocumentActions({ children }): JSX.Element {
>
{workflowStatus === WorkflowStatus.ACTIVE &&
__('Active', 'mailpoet')}
{workflowStatus === WorkflowStatus.INACTIVE &&
__('Inactive', 'mailpoet')}
{workflowStatus === WorkflowStatus.DEACTIVATING &&
__('Deactivating', 'mailpoet')}
{workflowStatus === WorkflowStatus.DRAFT &&

View File

@@ -276,12 +276,6 @@ export function Header({
/>
</>
)}
{workflowStatus === WorkflowStatus.INACTIVE && (
<ActivateButton
onClick={toggleActivatePanel}
label={__('Update & Activate', 'mailpoet')}
/>
)}
<PinnedItems.Slot scope={storeName} />
<MoreMenu />
</div>

View File

@@ -56,7 +56,7 @@ export function DeactivateModal({
[],
);
const [selected, setSelected] = useState<
WorkflowStatus.INACTIVE | WorkflowStatus.DEACTIVATING
WorkflowStatus.DRAFT | WorkflowStatus.DEACTIVATING
>(WorkflowStatus.DEACTIVATING);
const [isBusy, setIsBusy] = useState<boolean>(false);
// translators: %s is the name of the automation.
@@ -107,7 +107,7 @@ export function DeactivateModal({
<li>
<label
className={
selected === WorkflowStatus.INACTIVE
selected === WorkflowStatus.DRAFT
? 'mailpoet-automation-option active'
: 'mailpoet-automation-option'
}
@@ -117,8 +117,8 @@ export function DeactivateModal({
type="radio"
disabled={isBusy}
name="deactivation-method"
checked={selected === WorkflowStatus.INACTIVE}
onChange={() => setSelected(WorkflowStatus.INACTIVE)}
checked={selected === WorkflowStatus.DRAFT}
onChange={() => setSelected(WorkflowStatus.DRAFT)}
/>
</span>
<span>

View File

@@ -118,13 +118,13 @@ export function* deactivate(deactivateWorkflowRuns = true) {
data: {
...workflow,
status: deactivateWorkflowRuns
? WorkflowStatus.INACTIVE
? WorkflowStatus.DRAFT
: WorkflowStatus.DEACTIVATING,
},
});
const { createNotice } = dispatch(noticesStore as StoreDescriptor);
if (deactivateWorkflowRuns && data?.data.status === WorkflowStatus.INACTIVE) {
if (deactivateWorkflowRuns && data?.data.status === WorkflowStatus.DRAFT) {
void createNotice(
'success',
__('Automation is now deactivated!', 'mailpoet'),

View File

@@ -21,11 +21,6 @@ const tabConfig = [
title: __('Active', 'mailpoet'),
className: 'mailpoet-tab-active',
},
{
name: WorkflowStatus.INACTIVE,
title: __('Inactive', 'mailpoet'),
className: 'mailpoet-tab-inactive',
},
{
name: WorkflowStatus.DRAFT,
title: _x('Draft', 'noun', 'mailpoet'),

View File

@@ -1,6 +1,5 @@
export enum WorkflowStatus {
ACTIVE = 'active',
INACTIVE = 'inactive',
DRAFT = 'draft',
TRASH = 'trash',
DEACTIVATING = 'deactivating',

View File

@@ -249,12 +249,6 @@ class Reporter {
return $workflow->getStatus() === Workflow::STATUS_DRAFT;
}
);
$inactiveWorkflows = array_filter(
$workflows,
function(Workflow $workflow): bool {
return $workflow->getStatus() === Workflow::STATUS_INACTIVE;
}
);
$workflowsWithWordPressUserSubscribesTrigger = array_filter(
$activeWorkflows,
function(Workflow $workflow): bool {
@@ -288,7 +282,6 @@ class Reporter {
return [
'Automation > Number of active workflows' => $activeWorkflowCount,
'Automation > Number of draft workflows' => count($draftWorkflows),
'Automation > Number of inactive workflows' => count($inactiveWorkflows),
'Automation > Number of "WordPress user registers" active workflows' => count($workflowsWithWordPressUserSubscribesTrigger),
'Automation > Number of "Someone subscribes" active workflows ' => count($workflowsWithSomeoneSubscribesTrigger),
'Automation > Number of steps in shortest active workflow' => $minSteps,

View File

@@ -241,9 +241,9 @@ class StepHandler {
if ($workflow->getStatus() === Workflow::STATUS_DEACTIVATING) {
$activeRuns = $this->workflowRunStorage->getCountForWorkflow($workflow, WorkflowRun::STATUS_RUNNING);
// Set a deactivating Workflow to inactive once all workflow runs are finished.
// Set a deactivating Workflow to draft once all workflow runs are finished.
if ($activeRuns === 0) {
$workflow->setStatus(Workflow::STATUS_INACTIVE);
$workflow->setStatus(Workflow::STATUS_DRAFT);
$this->workflowStorage->updateWorkflow($workflow);
}
}

View File

@@ -9,13 +9,11 @@ use MailPoet\Automation\Engine\Utils\Json;
class Workflow {
public const STATUS_ACTIVE = 'active';
public const STATUS_DEACTIVATING = 'deactivating';
public const STATUS_INACTIVE = 'inactive';
public const STATUS_DRAFT = 'draft';
public const STATUS_TRASH = 'trash';
public const STATUS_ALL = [
self::STATUS_ACTIVE,
self::STATUS_DEACTIVATING,
self::STATUS_INACTIVE,
self::STATUS_DRAFT,
self::STATUS_TRASH,
];

View File

@@ -82,7 +82,6 @@ class SubscriberSubject implements Subject {
SubscriberEntity::STATUS_SUBSCRIBED => __('Subscribed', 'mailpoet'),
SubscriberEntity::STATUS_UNCONFIRMED => __('Unconfirmed', 'mailpoet'),
SubscriberEntity::STATUS_UNSUBSCRIBED => __('Unsubscribed', 'mailpoet'),
SubscriberEntity::STATUS_INACTIVE => __('Inactive', 'mailpoet'),
SubscriberEntity::STATUS_BOUNCED => __('Bounced', 'mailpoet'),
]
),

View File

@@ -98,7 +98,7 @@ class StepHandlerTest extends \MailPoetTest
}
}
public function testAnDeactivatingWorkflowGetsInactiveAfterLastRunIsExecuted() {
public function testAnDeactivatingWorkflowBecomesDraftAfterLastRunIsExecuted() {
$workflow = $this->createWorkflow();
$this->assertInstanceOf(Workflow::class, $workflow);
$workflowRun1 = $this->createWorkflowRun($workflow);
@@ -127,7 +127,7 @@ class StepHandlerTest extends \MailPoetTest
$updatedWorkflow = $this->workflowStorage->getWorkflow($workflow->getId());
/** @var WorkflowRun $updatedworkflowRun */
$updatedworkflowRun = $this->workflowRunStorage->getWorkflowRun($workflowRun1->getId());
$this->assertSame(Workflow::STATUS_INACTIVE, $updatedWorkflow->getStatus());
$this->assertSame(Workflow::STATUS_DRAFT, $updatedWorkflow->getStatus());
$this->assertSame(WorkflowRun::STATUS_COMPLETE, $updatedworkflowRun->getStatus());
}

View File

@@ -66,13 +66,13 @@ class WorkflowStorageTest extends \MailPoetTest
$subscriberTrigger = $this->diContainer->get(SomeoneSubscribesTrigger::class);
$trigger = new Step('id', Step::TYPE_TRIGGER, $subscriberTrigger->getKey(), [], []);
$workflow->setSteps(['id' => $trigger]);
$workflow->setStatus(Workflow::STATUS_INACTIVE);
$workflow->setStatus(Workflow::STATUS_DRAFT);
$this->testee->updateWorkflow($workflow);
$this->assertEmpty($this->testee->getActiveWorkflowsByTrigger($subscriberTrigger));
$workflow->setStatus(Workflow::STATUS_ACTIVE);
$this->testee->updateWorkflow($workflow);
$this->assertCount(1, $this->testee->getActiveWorkflowsByTrigger($subscriberTrigger));
$workflow->setStatus(Workflow::STATUS_INACTIVE);
$workflow->setStatus(Workflow::STATUS_DRAFT);
$this->testee->updateWorkflow($workflow);
$this->assertEmpty($this->testee->getActiveWorkflowsByTrigger($subscriberTrigger));
}