Compare commits
283 Commits
Author | SHA1 | Date | |
---|---|---|---|
ec1eb8b54c | |||
78cc8743d5 | |||
89e75b3828 | |||
982d104ba0 | |||
2ce4461c63 | |||
146a55b921 | |||
7e883d3e5b | |||
7896efcd6c | |||
a1ef87ef78 | |||
d058f1741f | |||
ff0852fa39 | |||
5f07b68b07 | |||
0c2934a556 | |||
885b51a6cf | |||
6cb5ceca21 | |||
9a14ddb57c | |||
5c6f32488a | |||
4ec8f27d36 | |||
9554727370 | |||
394f9abd67 | |||
6ee45f0f54 | |||
2e9ae1ed0b | |||
74b12bd2d9 | |||
279adcfbcf | |||
64d655857b | |||
b2b5f3c22a | |||
588f3a9feb | |||
8c676b773d | |||
c76a0adb5e | |||
848fc51070 | |||
af1e09f46f | |||
f1abfe557a | |||
aa52ca804e | |||
273551fa36 | |||
17898b243a | |||
81ed12d454 | |||
2f78c99381 | |||
480c7d25e0 | |||
c1a6c5a215 | |||
8fadc87036 | |||
5176566882 | |||
b52b9990da | |||
8796599d89 | |||
9808245d30 | |||
12f2d1730f | |||
dac8c1e2f3 | |||
a3e1f8d8c6 | |||
2c28449b58 | |||
43197bf859 | |||
bd34c4e7ec | |||
511b8ad7ff | |||
a60562254c | |||
96368cbd3f | |||
e384e7dea3 | |||
86fbcd3a57 | |||
9730fb9272 | |||
a3f2ee8bbb | |||
a177b3b8da | |||
f369fdfa4a | |||
80a6e78d48 | |||
f65821256c | |||
dd10389c55 | |||
3dd6ef3da7 | |||
036d0a29ae | |||
d199e0b77e | |||
17ab79aa6f | |||
b10cd32449 | |||
f9001c1826 | |||
31050394b9 | |||
e9970f3cc8 | |||
516c460ace | |||
03d80290e6 | |||
d65b567858 | |||
0d10f4b1dd | |||
610d0204eb | |||
545a4adc66 | |||
38d8a1cd00 | |||
53201c7422 | |||
6f447e8a93 | |||
368a400fea | |||
902eeccea1 | |||
c8cf00a151 | |||
f41423e6a2 | |||
774485d5f2 | |||
8f4d62b080 | |||
8003a3e97f | |||
cf572985a7 | |||
c4966a9cc1 | |||
c6e6b13731 | |||
975041d211 | |||
ea16472ab1 | |||
713b0255f7 | |||
2aa63bbb8e | |||
f6708d9526 | |||
65b56271d4 | |||
c9c35d591b | |||
e9cfcb51ba | |||
dc5e5b4f8b | |||
ccb5369c57 | |||
bfe3ff17af | |||
756b0587bc | |||
af3d08ff36 | |||
a91913e633 | |||
736d8a8b12 | |||
9b5bdb2206 | |||
3ad606a767 | |||
e0cab11293 | |||
bffafdcd33 | |||
6dfeb7a100 | |||
a6431678ed | |||
cdcdfb135c | |||
7821c5767b | |||
6a5b7adc16 | |||
e58de01950 | |||
ae6e790879 | |||
d21b2fe21d | |||
6b8e8988b8 | |||
0db495eb1d | |||
6ad315b8de | |||
945ff65358 | |||
e0458ca444 | |||
5bd639e0be | |||
c78a050d86 | |||
e37a824d86 | |||
fe4d78992f | |||
1c380933e1 | |||
a8c3465133 | |||
edbfb957b1 | |||
161b8d8f34 | |||
96d9347cff | |||
dfb7133dbb | |||
a264b00200 | |||
100a301476 | |||
35c3ebfb20 | |||
e3db69282d | |||
45999f98b2 | |||
6f5c39e97c | |||
4644f3fe08 | |||
d951ebd351 | |||
a7bc4e7c70 | |||
a08553c9bc | |||
8161b83ded | |||
ad46d05c6b | |||
f231f3dc6d | |||
933b947f45 | |||
f6a5e0117c | |||
56c79dd66a | |||
25ba667cb1 | |||
1ac9c86a66 | |||
94a2e54c1e | |||
fbf4c853c1 | |||
5fba25d823 | |||
18efc02921 | |||
bdd803c517 | |||
382e232538 | |||
a2cddc761c | |||
6b4d2409cc | |||
da110bed80 | |||
363ee93c25 | |||
db0024dc58 | |||
1b59b95f52 | |||
2d0673a864 | |||
9f4b0d0ca1 | |||
97c1712fa6 | |||
455e3fbb90 | |||
3c718e3f68 | |||
63e797ba37 | |||
48340872f8 | |||
1b5d85d41a | |||
0595852d5a | |||
448e89d062 | |||
f92ee90e9b | |||
80f22c5b50 | |||
4b74d66529 | |||
ca72e11d9a | |||
5a0ec403f6 | |||
b6e7e39fb0 | |||
8c24d59f43 | |||
5ed0c3fb2d | |||
2151118183 | |||
4c65374a0c | |||
32cf2084b8 | |||
9dc834e14a | |||
3db11c443d | |||
421549d6ee | |||
a7277f3437 | |||
4d56911230 | |||
0f23dea7fc | |||
742e3e85e9 | |||
6eeb5bb1bf | |||
01eb59a295 | |||
8ddd42ea4c | |||
eb80adc2ed | |||
3103ef11d5 | |||
a1ead743fa | |||
c8d0291e41 | |||
bd44d77973 | |||
f872ab1819 | |||
55371ce7ee | |||
ba45d23307 | |||
f660bd9bd7 | |||
1332fb89e4 | |||
dc5254721e | |||
918a4d7c74 | |||
ec29c8fb49 | |||
43922a7c27 | |||
76b1166269 | |||
12c0605f92 | |||
0bbf1b96d5 | |||
b716b427a7 | |||
c1ac9f7922 | |||
3dd872e211 | |||
a09a9cdcbf | |||
2d835cdec1 | |||
28b91ed994 | |||
1e147c9dd5 | |||
6f89b47b30 | |||
8d5c07a317 | |||
9ff72b4d4c | |||
4fe5219b89 | |||
2dab7fdb0c | |||
5075982cd3 | |||
1a58166a0b | |||
ca0681b1a7 | |||
540b34c63f | |||
c8565b1197 | |||
75906820e5 | |||
2cacb5809d | |||
900faa2a71 | |||
c140eea734 | |||
5201c359d3 | |||
4e1b1b3c27 | |||
8af01c3bcb | |||
d94dabb8d6 | |||
63b1f1670b | |||
2d050b0ea5 | |||
686f702ec9 | |||
5754302154 | |||
e2ede3e568 | |||
f95824dea0 | |||
650a8704cd | |||
cd37f92592 | |||
6bf201b45e | |||
e178d6519c | |||
97d4a8e4f8 | |||
e5ce252587 | |||
b7cae6dac4 | |||
07d3b753b8 | |||
72ef0909f5 | |||
a5473bf882 | |||
c4e7ea4c8e | |||
ce462f1643 | |||
91936aff92 | |||
57858bbe9a | |||
42d9b1241e | |||
fc4a5315df | |||
e771bd53da | |||
291f46d732 | |||
e236d3312c | |||
794090291a | |||
380eec1ed6 | |||
7c283b7fda | |||
916080fa5a | |||
c10f80457d | |||
9773408c8b | |||
5ba5426281 | |||
098aebfaf9 | |||
75d79f19cc | |||
1b70e6d494 | |||
2c57251bae | |||
9bdb32c073 | |||
b74890137a | |||
57548b579f | |||
7aa1a5f4ba | |||
d60e399a3b | |||
da34614b5c | |||
a0d330fded | |||
f766661f8c | |||
82ddce42df | |||
bfe95676c3 | |||
789bb0b396 | |||
2620ef0b57 | |||
627962570e |
@ -71,13 +71,6 @@ anchors:
|
||||
- trunk
|
||||
- release
|
||||
|
||||
only_trunk_and_cot: &only_trunk_and_cot
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- trunk
|
||||
- /^cot-.*/
|
||||
|
||||
multisite_acceptance_config: &multisite_acceptance_config
|
||||
multisite: 1
|
||||
requires:
|
||||
@ -356,9 +349,6 @@ jobs:
|
||||
enable_cot_sync:
|
||||
type: integer
|
||||
default: 0
|
||||
allow_fail:
|
||||
type: integer
|
||||
default: 0
|
||||
environment:
|
||||
MYSQL_COMMAND: << parameters.mysql_command >>
|
||||
MYSQL_IMAGE_VERSION: << parameters.mysql_image_version >>
|
||||
@ -434,9 +424,6 @@ jobs:
|
||||
--xml
|
||||
-g circleci_split_group
|
||||
)
|
||||
if [[ << parameters.allow_fail >> == 1 ]]; then
|
||||
args+=(--no-exit)
|
||||
fi
|
||||
docker-compose run -e SKIP_DEPS=1 \
|
||||
-e CIRCLE_BRANCH=${CIRCLE_BRANCH} \
|
||||
-e CIRCLE_JOB=${CIRCLE_JOB} \
|
||||
@ -444,18 +431,13 @@ jobs:
|
||||
-e ENABLE_COT=<< parameters.enable_cot >> \
|
||||
-e ENABLE_COT_SYNC=<< parameters.enable_cot_sync >> \
|
||||
codeception_acceptance "${args[@]}"
|
||||
- when:
|
||||
condition:
|
||||
not:
|
||||
equal: [1, << parameters.allow_fail >>]
|
||||
steps:
|
||||
- run:
|
||||
name: Check exceptions
|
||||
command: |
|
||||
if [ "$(ls tests/_output/exceptions/*.html)" ]; then
|
||||
echo "There were some exceptions during the tests run"
|
||||
exit 1
|
||||
fi
|
||||
- run:
|
||||
name: Check exceptions
|
||||
command: |
|
||||
if [ "$(ls tests/_output/exceptions/*.html)" ]; then
|
||||
echo "There were some exceptions during the tests run"
|
||||
exit 1
|
||||
fi
|
||||
- store_artifacts:
|
||||
path: tests/_output
|
||||
- store_test_results:
|
||||
@ -522,9 +504,6 @@ jobs:
|
||||
woo_core_version:
|
||||
type: string
|
||||
default: ''
|
||||
allow_fail:
|
||||
type: integer
|
||||
default: 0
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: /home/circleci
|
||||
@ -558,9 +537,6 @@ jobs:
|
||||
if [[ -n '<< parameters.skip_group >>' ]]; then
|
||||
args+=(--skip-group << parameters.skip_group >>)
|
||||
fi
|
||||
if [[ << parameters.allow_fail >> == 1 ]]; then
|
||||
args+=(--no-exit)
|
||||
fi
|
||||
docker-compose run -e SKIP_DEPS=1 \
|
||||
-e CIRCLE_BRANCH=${CIRCLE_BRANCH} \
|
||||
-e CIRCLE_JOB=${CIRCLE_JOB} \
|
||||
@ -661,13 +637,11 @@ workflows:
|
||||
- qa_php
|
||||
- acceptance_tests:
|
||||
<<: *slack-fail-post-step
|
||||
<<: *only_trunk_and_cot
|
||||
name: acceptance_tests_woo_cot_sync
|
||||
group: woo
|
||||
enable_cot: 1
|
||||
enable_cot_sync: 1
|
||||
allow_fail: 1
|
||||
woo_core_version: woo-cot-beta # Temporarily force COT beta version
|
||||
woo_core_version: 7.1.0-rc.2 # Temporarily force COT beta version
|
||||
requires:
|
||||
- unit_tests
|
||||
- static_analysis_php8
|
||||
@ -675,13 +649,11 @@ workflows:
|
||||
- qa_php
|
||||
- acceptance_tests:
|
||||
<<: *slack-fail-post-step
|
||||
<<: *only_trunk_and_cot
|
||||
name: acceptance_tests_woo_cot_no_sync
|
||||
group: woo
|
||||
enable_cot: 1
|
||||
enable_cot_sync: 0
|
||||
allow_fail: 1
|
||||
woo_core_version: woo-cot-beta # Temporarily force COT beta version
|
||||
woo_core_version: 7.1.0-rc.2 # Temporarily force COT beta version
|
||||
requires:
|
||||
- unit_tests
|
||||
- static_analysis_php8
|
||||
@ -689,10 +661,9 @@ workflows:
|
||||
- qa_php
|
||||
- acceptance_tests:
|
||||
<<: *slack-fail-post-step
|
||||
<<: *only_trunk_and_cot
|
||||
name: acceptance_tests_woo_cot_off
|
||||
group: woo
|
||||
woo_core_version: woo-cot-beta # Temporarily force COT beta version
|
||||
woo_core_version: 7.1.0-rc.2 # Temporarily force COT beta version
|
||||
requires:
|
||||
- unit_tests
|
||||
- static_analysis_php8
|
||||
@ -713,12 +684,10 @@ workflows:
|
||||
- qa_php
|
||||
- integration_tests:
|
||||
<<: *slack-fail-post-step
|
||||
<<: *only_trunk_and_cot
|
||||
group: woo
|
||||
enable_cot: 1
|
||||
enable_cot_sync: 1
|
||||
allow_fail: 1
|
||||
woo_core_version: woo-cot-beta # Temporarily force COT beta version
|
||||
woo_core_version: 7.1.0-rc.2 # Temporarily force COT beta version
|
||||
name: integration_test_woo_cot_sync
|
||||
requires:
|
||||
- unit_tests
|
||||
@ -727,12 +696,10 @@ workflows:
|
||||
- qa_php
|
||||
- integration_tests:
|
||||
<<: *slack-fail-post-step
|
||||
<<: *only_trunk_and_cot
|
||||
group: woo
|
||||
enable_cot: 1
|
||||
enable_cot_sync: 0
|
||||
allow_fail: 1
|
||||
woo_core_version: woo-cot-beta # Temporarily force COT beta version
|
||||
woo_core_version: 7.1.0-rc.2 # Temporarily force COT beta version
|
||||
name: integration_test_woo_cot_no_sync
|
||||
requires:
|
||||
- unit_tests
|
||||
@ -741,9 +708,8 @@ workflows:
|
||||
- qa_php
|
||||
- integration_tests:
|
||||
<<: *slack-fail-post-step
|
||||
<<: *only_trunk_and_cot
|
||||
group: woo
|
||||
woo_core_version: woo-cot-beta # Temporarily force COT beta version
|
||||
woo_core_version: 7.1.0-rc.2 # Temporarily force COT beta version
|
||||
name: integration_test_woo_cot_off
|
||||
requires:
|
||||
- unit_tests
|
||||
|
@ -28,6 +28,7 @@ Class `\MailPoet\API\API` becomes available once MailPoet plugin is loaded by Wo
|
||||
- [Add List (addList)](api_methods/AddList.md)
|
||||
- [Add Subscriber (addSubscriber)](api_methods/AddSubscriber.md)
|
||||
- [Add Subscriber Field (addSubscriberField)](api_methods/AddSubscriberField.md)
|
||||
- [Delete List (deleteList)](api_methods/DeleteList.md)
|
||||
- [Get Lists (getLists)](api_methods/GetLists.md)
|
||||
- [Get Subscriber (getSubscriber)](api_methods/GetSubscriber.md)
|
||||
- [Get Subscribers (getSubscribers)](api_methods/GetSubscribers.md)
|
||||
@ -38,6 +39,7 @@ Class `\MailPoet\API\API` becomes available once MailPoet plugin is loaded by Wo
|
||||
- [Subscribe to Lists (subscribeToLists)](api_methods/SubscribeToLists.md)
|
||||
- [Unsubscribe from List (unsubscribeFromList)](api_methods/UnsubscribeFromList.md)
|
||||
- [Unsubscribe from Lists (unsubscribeFromLists)](api_methods/UnsubscribeFromLists.md)
|
||||
- [Update List (updateList)](api_methods/UpdateList.md)
|
||||
|
||||
### Usage examples
|
||||
|
||||
|
27
doc/api_methods/DeleteList.md
Normal file
27
doc/api_methods/DeleteList.md
Normal file
@ -0,0 +1,27 @@
|
||||
[back to list](../Readme.md)
|
||||
|
||||
# Delete List
|
||||
|
||||
## `bool deleteList(string $list_id)`
|
||||
|
||||
This method provides functionality for deleting a list that is of the type 'default'.
|
||||
|
||||
It returns a boolean value.
|
||||
|
||||
## Error handling
|
||||
|
||||
All expected errors from the API are exceptions of class `\MailPoet\API\MP\v1\APIException`.
|
||||
Code of the exception is populated to distinguish between different errors.
|
||||
|
||||
An exception of base class `\Exception` can be thrown when something unexpected happens.
|
||||
|
||||
Codes description:
|
||||
|
||||
| Code | Description |
|
||||
| ---- | --------------------------------------------------------------- |
|
||||
| 5 | List does not exist |
|
||||
| 18 | List id is empty |
|
||||
| 20 | List cannot be deleted because it’s used for an automatic email |
|
||||
| 21 | List cannot be deleted because it’s used for a form |
|
||||
| 22 | The list couldn’t be deleted from the database |
|
||||
| 23 | Only lists of the type 'default' can be deleted |
|
@ -18,8 +18,8 @@ This method returns a list of subscribers. To see the subscriber data structure,
|
||||
|
||||
Filter argument supports following array keys.
|
||||
|
||||
| Key | Type | Description |
|
||||
| -------------- | ------------ | ----------------------------------------------------------------------------------------------------------------- |
|
||||
| status | string | Specific status of subscribers. One of values: `unconfirmed`, `subscribed`, `unsubscribed`, `bounced`, `inactive` |
|
||||
| list_id | int | List id or dynamic segment id |
|
||||
| min_updated_at | DateTime\int | DateTime object or timestamp of the minimal last update of subscribers |
|
||||
| Key | Type | Description |
|
||||
| ------------ | ------------ | ----------------------------------------------------------------------------------------------------------------- |
|
||||
| status | string | Specific status of subscribers. One of values: `unconfirmed`, `subscribed`, `unsubscribed`, `bounced`, `inactive` |
|
||||
| listId | int | List id or dynamic segment id |
|
||||
| minUpdatedAt | DateTime\int | DateTime object or timestamp of the minimal last update of subscribers |
|
||||
|
39
doc/api_methods/UpdateList.md
Normal file
39
doc/api_methods/UpdateList.md
Normal file
@ -0,0 +1,39 @@
|
||||
[back to list](../Readme.md)
|
||||
|
||||
# Add Subscriber
|
||||
|
||||
## `array updateList(array $list)`
|
||||
|
||||
This method provides functionality for updating a list name or description. Only lists of type 'default' are supported.
|
||||
|
||||
It returns the updated list. See [Get Lists](GetLists.md) for a list data structure description.
|
||||
|
||||
## Arguments
|
||||
|
||||
### `$list` (required)
|
||||
|
||||
An associative array which contains list data.
|
||||
|
||||
| Property | Type | Limits | Description |
|
||||
| ---------------------- | ------------ | --------- | -------------------------- |
|
||||
| id (required) | string | 11 chars | A id of the list. |
|
||||
| name (required) | string | 90 chars | A name of the list. |
|
||||
| description (optional) | string\|null | 250 chars | A description of the list. |
|
||||
|
||||
## Error handling
|
||||
|
||||
All expected errors from the API are exceptions of class `\MailPoet\API\MP\v1\APIException`.
|
||||
Code of the exception is populated to distinguish between different errors.
|
||||
|
||||
An exception of base class `\Exception` can be thrown when something unexpected happens.
|
||||
|
||||
Codes description:
|
||||
|
||||
| Code | Description |
|
||||
| ---- | ----------------------------------------------- |
|
||||
| 5 | The list was not found by id |
|
||||
| 14 | Missing list name |
|
||||
| 15 | Trying to use a list name that is already used |
|
||||
| 18 | Missing list id |
|
||||
| 19 | The list couldn’t be updated in the database |
|
||||
| 23 | Only lists of the type 'default' can be updated |
|
@ -5,7 +5,6 @@
|
||||
"@babel/preset-env"
|
||||
],
|
||||
"plugins": [
|
||||
"babel-plugin-typescript-to-proptypes",
|
||||
[
|
||||
"@babel/plugin-transform-runtime",
|
||||
{
|
||||
|
@ -117,11 +117,45 @@ class RoboFile extends \Robo\Tasks {
|
||||
}
|
||||
|
||||
public function translationsBuild() {
|
||||
$exclude = implode(',', [
|
||||
'.mp_svn',
|
||||
'assets/css',
|
||||
'assets/img',
|
||||
'assets/js',
|
||||
'generated',
|
||||
'lang',
|
||||
'lib-3rd-party',
|
||||
'mailpoet-premium',
|
||||
'node_modules',
|
||||
'plugin_repository',
|
||||
'prefixer',
|
||||
'tasks',
|
||||
'temp',
|
||||
'tests',
|
||||
'tools',
|
||||
'vendor',
|
||||
'vendor-prefixed',
|
||||
]);
|
||||
|
||||
$headers = escapeshellarg(
|
||||
json_encode([
|
||||
'Report-Msgid-Bugs-To' => 'http://support.mailpoet.com/',
|
||||
'Last-Translator' => 'MailPoet i18n (https://www.transifex.com/organization/wysija)',
|
||||
'Language-Team' => 'MailPoet i18n <https://www.transifex.com/organization/wysija>',
|
||||
'Plural-Forms' => 'nplurals=2; plural=(n != 1);',
|
||||
])
|
||||
);
|
||||
|
||||
$this->collectionBuilder()
|
||||
->taskExec('mkdir -p ' . __DIR__ . '/lang')
|
||||
->taskExec(
|
||||
'php -d memory_limit=-1 tasks/makepot/grunt-makepot.php wp-plugin . lang/mailpoet.pot mailpoet .mp_svn,assets,lang,node_modules,plugin_repository,tasks,tests,vendor'
|
||||
)->run();
|
||||
|
||||
// HTML, HBS
|
||||
->taskExec("php -d memory_limit=-1 tasks/makepot/makepot-views.php . > lang/mailpoet.pot")
|
||||
|
||||
// PHP, JS/TS
|
||||
->taskExec("vendor/bin/wp i18n make-pot --merge --slug=mailpoet --domain=mailpoet --exclude=$exclude --headers=$headers . lang/mailpoet.pot")
|
||||
|
||||
->run();
|
||||
}
|
||||
|
||||
public function translationsGetPotFileFromBuild() {
|
||||
@ -351,6 +385,25 @@ class RoboFile extends \Robo\Tasks {
|
||||
$this->say("Validator metadata generated to: $validatorMetadataDir");
|
||||
}
|
||||
|
||||
public function migrationsNew() {
|
||||
$generator = new \MailPoet\Migrator\Repository();
|
||||
$result = $generator->create();
|
||||
$path = realpath($result['path']);
|
||||
$this->output->writeln('MAILPOET DATABASE MIGRATIONS');
|
||||
$this->output->writeln("============================\n");
|
||||
$this->output->writeln("New migration created ✔\n");
|
||||
$this->output->writeln(" Name: {$result['name']}");
|
||||
$this->output->writeln(" Path: $path");
|
||||
}
|
||||
|
||||
public function migrationsStatus() {
|
||||
return $this->taskExec('vendor/bin/wp mailpoet:migrations:status');
|
||||
}
|
||||
|
||||
public function migrationsRun() {
|
||||
return $this->taskExec('vendor/bin/wp mailpoet:migrations:run');
|
||||
}
|
||||
|
||||
public function qa() {
|
||||
$collection = $this->collectionBuilder();
|
||||
$collection->addCode([$this, 'qaPhp']);
|
||||
@ -1087,20 +1140,10 @@ class RoboFile extends \Robo\Tasks {
|
||||
}
|
||||
|
||||
public function downloadWooCommerceZip($tag = null) {
|
||||
if ($tag === 'woo-cot-beta') {
|
||||
$this->downloadWooCommerceCotZip();
|
||||
return;
|
||||
}
|
||||
$this->createWpOrgDownloader('woocommerce')
|
||||
->downloadPluginZip('woocommerce.zip', __DIR__ . '/tests/plugins/', $tag);
|
||||
}
|
||||
|
||||
public function downloadWooCommerceCotZip() {
|
||||
$cotBuildUrl = 'https://github.com/woocommerce/woocommerce/files/9706609/woocommerce.zip';
|
||||
file_put_contents(__DIR__ . '/tests/plugins/woocommerce.zip', file_get_contents($cotBuildUrl));
|
||||
file_put_contents(__DIR__ . '/tests/plugins/woocommerce.zip-info', $cotBuildUrl);
|
||||
}
|
||||
|
||||
public function generateData($generatorName = null, $threads = 1) {
|
||||
require_once __DIR__ . '/tests/DataGenerator/_bootstrap.php';
|
||||
$generator = new \MailPoet\Test\DataGenerator\DataGenerator(new \Codeception\Lib\Console\Output([]));
|
||||
|
@ -30,3 +30,31 @@
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
.mailpoet-automation-field__error {
|
||||
position: relative;
|
||||
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
background: right top/26px no-repeat url('../../img/icons/alert.svg');
|
||||
padding-right: 26px;
|
||||
}
|
||||
|
||||
select,
|
||||
input[type=number] {
|
||||
background-position-x: calc(100% - 26px);
|
||||
padding-right: 8px !important;
|
||||
}
|
||||
|
||||
.components-base-control__help,
|
||||
.mailpoet-automation-field-message {
|
||||
color: #d63638;
|
||||
}
|
||||
|
||||
.components-button.mailpoet-automation-button-sidebar-primary,
|
||||
.components-button.mailpoet-automation-button-sidebar-primary.has-text,
|
||||
.components-button.mailpoet-automation-button-sidebar-primary.has-icon {
|
||||
background: #d63638;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
.mailpoet-automation-is-onboarding {
|
||||
.notice {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.mailpoet-automation-listing-heading {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
@ -15,6 +21,21 @@
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.mailpoet-automation-listing-cell-name {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
||||
> a:only-child {
|
||||
bottom: 2px;
|
||||
display: flex;
|
||||
left: 0;
|
||||
padding: 16px 24px;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.mailpoet-filter-tab-panel {
|
||||
background-color: #fff;
|
||||
border: 1px solid #dcdcde;
|
||||
|
@ -0,0 +1,201 @@
|
||||
@mixin full-width {
|
||||
margin-left: -20px;
|
||||
padding-left: 104px;
|
||||
padding-right: 104px;
|
||||
width: calc(100% + 60px);
|
||||
|
||||
@media screen and (max-width: 782px) {
|
||||
margin-left: -10px;
|
||||
width: calc(100% + 34px);
|
||||
}
|
||||
}
|
||||
|
||||
.mailpoet-automation-section {
|
||||
@include full-width;
|
||||
}
|
||||
|
||||
.mailpoet-automation-white-background {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.mailpoet-automation-section-content {
|
||||
display: block;
|
||||
margin: auto;
|
||||
max-width: 1072px;
|
||||
padding: 65px 0;
|
||||
|
||||
h2 {
|
||||
font-size: 23px;
|
||||
font-weight: 400;
|
||||
line-height: 32px;
|
||||
margin: 0;
|
||||
padding: 0 0 8px;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 22px;
|
||||
margin: 0;
|
||||
padding: 0 0 40px;
|
||||
}
|
||||
}
|
||||
|
||||
.mailpoet-automation-section-hero {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
margin-top: -20px;
|
||||
|
||||
h1 {
|
||||
font-size: 32px;
|
||||
font-weight: 400;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
> div {
|
||||
width: 400px;
|
||||
}
|
||||
|
||||
img {
|
||||
margin-top: 16px;
|
||||
max-width: 100%;
|
||||
width: 532px;
|
||||
|
||||
@media screen and (min-width: 1305px) {
|
||||
height: 100%;
|
||||
margin-top: 0;
|
||||
max-height: 294px;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.mailpoet-automation-preheading {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
letter-spacing: .2px;
|
||||
line-height: 16px;
|
||||
margin-bottom: 32px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.mailpoet-section-templates {
|
||||
padding: 48px 0;
|
||||
|
||||
.components-button {
|
||||
display: block;
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
line-height: 25px;
|
||||
text-align: center;
|
||||
text-underline-offset: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.mailpoet-section-template-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 40px;
|
||||
|
||||
> li {
|
||||
flex-grow: 1;
|
||||
margin-right: 8px;
|
||||
max-width: 336px;
|
||||
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
button {
|
||||
background: #fff;
|
||||
border: 1px solid #dcdcde;
|
||||
border-radius: 0;
|
||||
color: #1d2327;
|
||||
cursor: pointer;
|
||||
padding: 24px;
|
||||
text-align: left;
|
||||
|
||||
h3 {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 24px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.mailpoet-section-build-list-button {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
color: #000;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
line-height: 24px;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mailpoet-section-build-your-own {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
|
||||
ol {
|
||||
list-style: decimal-leading-zero inside;
|
||||
margin: 0;
|
||||
max-width: 373px;
|
||||
padding: 0;
|
||||
|
||||
> li {
|
||||
border-bottom: 1px solid #dcdcde;
|
||||
display: grid;
|
||||
grid-gap: 16px;
|
||||
grid-template-columns: 16px auto;
|
||||
margin-bottom: 16px;
|
||||
padding-bottom: 16px;
|
||||
|
||||
&.open {
|
||||
p {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.mailpoet-section-build-list-button {
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
&:last-of-type {
|
||||
border: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.marker {
|
||||
color: #ff5301;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
p {
|
||||
display: none;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
height: auto;
|
||||
max-width: 400px;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
.mailpoet-option-button {
|
||||
display: flex;
|
||||
margin-top: 8px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.mailpoet-option-button-main {
|
||||
border-radius: 2px 0 0 2px;
|
||||
margin-right: 1px;
|
||||
}
|
||||
|
||||
.mailpoet-option-button-opener {
|
||||
background: var(--wp-admin-theme-color);
|
||||
border-radius: 0 2px 2px 0;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.mailpoet-option-button-opener svg {
|
||||
fill: white;
|
||||
}
|
||||
|
||||
.mailpoet-option-button-opener .is-opened svg {
|
||||
transform: scale(-1, -1);
|
||||
transform-origin: center 12.5px;
|
||||
}
|
@ -63,6 +63,11 @@ $form-line-height: 1.4;
|
||||
.mailpoet-has-font-size {
|
||||
line-height: $form-line-height;
|
||||
}
|
||||
|
||||
.mailpoet_submit {
|
||||
white-space: normal;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset fieldset styles in form for backward compatibility. */
|
||||
|
@ -13,13 +13,16 @@ ul.mailpoet-automation-templates {
|
||||
margin: auto;
|
||||
max-width: 982px;
|
||||
padding: 48px 0;
|
||||
}
|
||||
|
||||
.mailpoet-automation-template-list-item {
|
||||
button.components-button {
|
||||
background: #fff;
|
||||
border: 1px solid #dcdcde;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
padding: 24px 24px 26px;
|
||||
text-align: left;
|
||||
@ -37,6 +40,10 @@ ul.mailpoet-automation-templates {
|
||||
box-shadow: 0 3px 6px rgba(0, 0, 0, .15);
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
>* {
|
||||
width: 100%
|
||||
}
|
||||
}
|
||||
|
||||
h2 {
|
||||
@ -54,7 +61,7 @@ ul.mailpoet-automation-templates {
|
||||
margin: 8px 0 0;
|
||||
}
|
||||
|
||||
.mailpoet-automation-from-scratch {
|
||||
&.mailpoet-automation-from-scratch {
|
||||
button {
|
||||
align-content: center;
|
||||
border: 2px dashed #dcdcde;
|
||||
|
@ -4,11 +4,14 @@
|
||||
// automation components
|
||||
|
||||
@import './components-automation/statistics';
|
||||
@import './components-automation/option-button';
|
||||
|
||||
// automation listing
|
||||
|
||||
@import './components-automation-listing/sections';
|
||||
@import './components-automation-listing/listing';
|
||||
@import './components-automation-listing/header';
|
||||
@import './components-automation-listing/search';
|
||||
@import './components-automation-listing/cells/actions';
|
||||
@import './components-automation-listing/cells/status';
|
||||
@import './mailpoet-automation-templates';
|
||||
|
5
mailpoet/assets/img/icons/alert.svg
Normal file
5
mailpoet/assets/img/icons/alert.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M12 4.75C7.99594 4.75 4.75 7.99594 4.75 12C4.75 16.0041 7.99594 19.25 12 19.25C16.0041 19.25 19.25 16.0041 19.25 12C19.25 7.99594 16.0041 4.75 12 4.75ZM3.25 12C3.25 7.16751 7.16751 3.25 12 3.25C16.8325 3.25 20.75 7.16751 20.75 12C20.75 16.8325 16.8325 20.75 12 20.75C7.16751 20.75 3.25 16.8325 3.25 12Z" fill="#d63638"/>
|
||||
<path d="M13 7H11V13H13V7Z" fill="#d63638"/>
|
||||
<path d="M13 15H11V17H13V15Z" fill="#d63638"/>
|
||||
</svg>
|
After Width: | Height: | Size: 565 B |
@ -1,42 +1,58 @@
|
||||
import { useEffect } from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import { TopBarWithBeamer } from 'common/top_bar/top_bar';
|
||||
import { plusIcon } from 'common/button/icon/plus';
|
||||
import { Button, Flex, Popover, SlotFillProvider } from '@wordpress/components';
|
||||
import { Popover, SlotFillProvider } from '@wordpress/components';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import { initializeApi, useMutation } from './api';
|
||||
import { registerTranslations } from './i18n';
|
||||
import { createStore, storeName } from './listing/store';
|
||||
import { AutomationListing } from './listing';
|
||||
import { AutomationListing, AutomationListingHeader } from './listing';
|
||||
import { registerApiErrorHandler } from './listing/api-error-handler';
|
||||
import { Notices } from './listing/components/notices';
|
||||
import { WorkflowListingNotices } from './listing/workflow-listing-notices';
|
||||
import { Onboarding } from './onboarding';
|
||||
import { BuildYourOwnSection, HeroSection, TemplatesSection } from './sections';
|
||||
import {
|
||||
CreateEmptyWorkflowButton,
|
||||
CreateWorkflowFromTemplateButton,
|
||||
} from './testing';
|
||||
import { MailPoet } from '../mailpoet';
|
||||
|
||||
function Content(): JSX.Element {
|
||||
const count = useSelect((select) => select(storeName).getWorkflowCount());
|
||||
return count > 0 ? <AutomationListing /> : <Onboarding />;
|
||||
const content =
|
||||
count > 0 ? (
|
||||
<>
|
||||
<AutomationListingHeader />
|
||||
<AutomationListing />
|
||||
</>
|
||||
) : (
|
||||
<HeroSection />
|
||||
);
|
||||
|
||||
// Hide notices on onboarding screen
|
||||
useEffect(() => {
|
||||
const onboardingClass = 'mailpoet-automation-is-onboarding';
|
||||
const element = document.querySelector('body');
|
||||
if (count === 0 && !element.classList.contains(onboardingClass)) {
|
||||
element.classList.add(onboardingClass);
|
||||
}
|
||||
if (count > 0 && element.classList.contains(onboardingClass)) {
|
||||
element.classList.remove(onboardingClass);
|
||||
}
|
||||
}, [count]);
|
||||
return (
|
||||
<>
|
||||
{content}
|
||||
<TemplatesSection />
|
||||
<BuildYourOwnSection />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Workflows(): JSX.Element {
|
||||
return (
|
||||
<>
|
||||
<TopBarWithBeamer />
|
||||
<Flex className="mailpoet-automation-listing-heading">
|
||||
<h1 className="wp-heading-inline">Automations</h1>
|
||||
<Button
|
||||
href={MailPoet.urls.automationTemplates}
|
||||
icon={plusIcon}
|
||||
variant="primary"
|
||||
className="mailpoet-add-new-button"
|
||||
>
|
||||
New automation
|
||||
</Button>
|
||||
</Flex>
|
||||
<Notices />
|
||||
<Content />
|
||||
</>
|
||||
@ -126,6 +142,7 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
const root = document.getElementById('mailpoet_automation');
|
||||
if (root) {
|
||||
registerTranslations();
|
||||
registerApiErrorHandler();
|
||||
initializeApi();
|
||||
ReactDOM.render(<App />, root);
|
||||
|
@ -0,0 +1,44 @@
|
||||
import { Button, DropdownMenu } from '@wordpress/components';
|
||||
import { chevronDown } from '@wordpress/icons';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { Fragment } from '@wordpress/element';
|
||||
import { StepMoreControlsType } from '../../types/filters';
|
||||
|
||||
type OptionButtonPropType = {
|
||||
variant: Button.ButtonVariant;
|
||||
controls: StepMoreControlsType;
|
||||
title: string;
|
||||
onClick: () => void;
|
||||
};
|
||||
export function OptionButton({
|
||||
controls,
|
||||
title,
|
||||
onClick,
|
||||
variant,
|
||||
}: OptionButtonPropType): JSX.Element {
|
||||
const slots = Object.values(controls).filter((item) => item.slot);
|
||||
return (
|
||||
<div className="mailpoet-option-button">
|
||||
<Button
|
||||
variant={variant}
|
||||
className="mailpoet-option-button-main"
|
||||
onClick={onClick}
|
||||
>
|
||||
{title}
|
||||
</Button>
|
||||
{slots.length > 0 &&
|
||||
slots.map(({ key, slot }) => (
|
||||
<Fragment key={`slot-${key}`}>{slot}</Fragment>
|
||||
))}
|
||||
{Object.values(controls).length > 0 && (
|
||||
<DropdownMenu
|
||||
className="mailpoet-option-button-opener"
|
||||
label={__('More', 'mailpoet')}
|
||||
icon={chevronDown}
|
||||
controls={Object.values(controls).map((item) => item.control)}
|
||||
popoverProps={{ position: 'bottom left' }}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
@ -30,6 +30,7 @@ export const registerApiErrorHandler = (): void =>
|
||||
message ?? __('An unknown error occurred.', 'mailpoet'),
|
||||
{ explicitDismiss: true },
|
||||
);
|
||||
dispatch(storeName).setErrors({ steps: [] });
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import {
|
||||
Button,
|
||||
} from '@wordpress/components';
|
||||
import { useDispatch, useSelect } from '@wordpress/data';
|
||||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import { storeName } from '../../store';
|
||||
|
||||
export function TrashButton(): JSX.Element {
|
||||
@ -20,8 +21,8 @@ export function TrashButton(): JSX.Element {
|
||||
<>
|
||||
<ConfirmDialog
|
||||
isOpen={showConfirmDialog}
|
||||
title="Delete workflow"
|
||||
confirmButtonText="Yes, delete"
|
||||
title={__('Delete automation', 'mailpoet')}
|
||||
confirmButtonText={__('Yes, delete', 'mailpoet')}
|
||||
onConfirm={async () => {
|
||||
trash(() => {
|
||||
setShowConfirmDialog(false);
|
||||
@ -30,7 +31,12 @@ export function TrashButton(): JSX.Element {
|
||||
onCancel={() => setShowConfirmDialog(false)}
|
||||
__experimentalHideHeader={false}
|
||||
>
|
||||
You are about to delete the “{workflow.name}” workflow.
|
||||
{sprintf(
|
||||
__('You are about to delete the automation "%s".', 'mailpoet'),
|
||||
workflow.name,
|
||||
)}
|
||||
<br />
|
||||
{__(' This will stop it for all subscribers immediately.', 'mailpoet')}
|
||||
</ConfirmDialog>
|
||||
|
||||
<Button
|
||||
@ -38,7 +44,7 @@ export function TrashButton(): JSX.Element {
|
||||
isDestructive
|
||||
onClick={() => setShowConfirmDialog(true)}
|
||||
>
|
||||
Move to Trash
|
||||
{__('Move to Trash', 'mailpoet')}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { ComponentProps, ComponentType, Ref } from 'react';
|
||||
import {
|
||||
Dropdown as WpDropdown,
|
||||
Button,
|
||||
VisuallyHidden,
|
||||
__experimentalText as Text,
|
||||
Button,
|
||||
Dropdown as WpDropdown,
|
||||
VisuallyHidden,
|
||||
} from '@wordpress/components';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import { useRef } from '@wordpress/element';
|
||||
@ -38,7 +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 === WorkflowStatus.INACTIVE) {
|
||||
} else if (workflowStatus === WorkflowStatus.DEACTIVATING) {
|
||||
chipClass = 'mailpoet-automation-editor-chip-danger';
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ export function DocumentActions({ children }): JSX.Element {
|
||||
as="h1"
|
||||
>
|
||||
<VisuallyHidden as="span">
|
||||
{__('Editing workflow: ')}
|
||||
{__('Editing automation:', 'mailpoet')}
|
||||
</VisuallyHidden>
|
||||
{workflowName}
|
||||
</Text>
|
||||
@ -73,10 +73,12 @@ export function DocumentActions({ children }): JSX.Element {
|
||||
size="body"
|
||||
className={`edit-site-document-actions__secondary-item ${chipClass}`}
|
||||
>
|
||||
{workflowStatus === WorkflowStatus.ACTIVE && __('Active')}
|
||||
{workflowStatus === WorkflowStatus.INACTIVE &&
|
||||
__('Inactive')}
|
||||
{workflowStatus === WorkflowStatus.DRAFT && __('Draft')}
|
||||
{workflowStatus === WorkflowStatus.ACTIVE &&
|
||||
__('Active', 'mailpoet')}
|
||||
{workflowStatus === WorkflowStatus.DEACTIVATING &&
|
||||
__('Deactivating', 'mailpoet')}
|
||||
{workflowStatus === WorkflowStatus.DRAFT &&
|
||||
__('Draft', 'mailpoet')}
|
||||
</Text>
|
||||
</a>
|
||||
<Button
|
||||
@ -85,9 +87,9 @@ export function DocumentActions({ children }): JSX.Element {
|
||||
aria-expanded={isOpen}
|
||||
aria-haspopup="true"
|
||||
onClick={onToggle}
|
||||
label={__('Change workflow name')}
|
||||
label={__('Change automation name', 'mailpoet')}
|
||||
>
|
||||
{showIconLabels && __('Rename')}
|
||||
{showIconLabels && __('Rename', 'mailpoet')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
|
@ -12,7 +12,7 @@ import { __ } from '@wordpress/i18n';
|
||||
import { Chip } from '../chip';
|
||||
import { ColoredIcon } from '../icons';
|
||||
import {
|
||||
StepError as StepErrorType,
|
||||
StepErrors as StepErrorType,
|
||||
stepSidebarKey,
|
||||
storeName,
|
||||
} from '../../store';
|
||||
@ -151,11 +151,14 @@ export function Errors(): JSX.Element | null {
|
||||
<Composite
|
||||
state={compositeState}
|
||||
role="list"
|
||||
aria-label={__('Workflow errors', 'mailpoet')}
|
||||
aria-label={__('Automation errors', 'mailpoet')}
|
||||
className="mailpoet-automation-errors"
|
||||
>
|
||||
<div className="mailpoet-automation-errors-header">
|
||||
{__('The following steps are not fully set:', 'mailpoet')}
|
||||
{
|
||||
// translators: Label for a list of automation steps that are incomplete or have errors
|
||||
__('The following steps are not fully set:', 'mailpoet')
|
||||
}
|
||||
</div>
|
||||
{stepErrors.map((error) => (
|
||||
<StepError key={error.step_id} stepId={error.step_id} />
|
||||
|
@ -1,5 +1,10 @@
|
||||
import { useState } from 'react';
|
||||
import { Button, NavigableMenu, TextControl } from '@wordpress/components';
|
||||
import {
|
||||
Button,
|
||||
NavigableMenu,
|
||||
TextControl,
|
||||
Tooltip,
|
||||
} from '@wordpress/components';
|
||||
import { dispatch, useDispatch, useSelect } from '@wordpress/data';
|
||||
import { PinnedItems } from '@wordpress/interface';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
@ -9,43 +14,98 @@ import { InserterToggle } from './inserter_toggle';
|
||||
import { MoreMenu } from './more_menu';
|
||||
import { storeName } from '../../store';
|
||||
import { WorkflowStatus } from '../../../listing/workflow';
|
||||
import { DeactivateModal } from '../modals/deactivate-modal';
|
||||
import {
|
||||
DeactivateImmediatelyModal,
|
||||
DeactivateModal,
|
||||
} from '../modals/deactivate-modal';
|
||||
|
||||
// See:
|
||||
// https://github.com/WordPress/gutenberg/blob/9601a33e30ba41bac98579c8d822af63dd961488/packages/edit-post/src/components/header/index.js
|
||||
// https://github.com/WordPress/gutenberg/blob/0ee78b1bbe9c6f3e6df99f3b967132fa12bef77d/packages/edit-site/src/components/header/index.js
|
||||
|
||||
function ActivateButton({ onClick }): JSX.Element {
|
||||
const { errors } = useSelect(
|
||||
function ActivateButton({ onClick, label }): JSX.Element {
|
||||
const { errors, isDeactivating } = useSelect(
|
||||
(select) => ({
|
||||
errors: select(storeName).getErrors(),
|
||||
isDeactivating:
|
||||
select(storeName).getWorkflowData().status ===
|
||||
WorkflowStatus.DEACTIVATING,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
return (
|
||||
const button = (
|
||||
<Button
|
||||
variant="primary"
|
||||
className="editor-post-publish-button"
|
||||
onClick={onClick}
|
||||
disabled={!!errors}
|
||||
disabled={isDeactivating || !!errors}
|
||||
>
|
||||
{__('Activate', 'mailpoet')}
|
||||
{label}
|
||||
</Button>
|
||||
);
|
||||
|
||||
if (isDeactivating) {
|
||||
return (
|
||||
<Tooltip
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
// The following error seems to be a mismatch. It claims the 'delay' prop does not exist, but it does.
|
||||
delay={0}
|
||||
text={__(
|
||||
'Editing an active workflow is temporarily unavailable. We are working on introducing this functionality.',
|
||||
'mailpoet',
|
||||
)}
|
||||
>
|
||||
{button}
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
function UpdateButton(): JSX.Element {
|
||||
const { save } = useDispatch(storeName);
|
||||
|
||||
const { workflow } = useSelect(
|
||||
(select) => ({
|
||||
workflow: select(storeName).getWorkflowData(),
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
if (workflow.stats.totals.in_progress === 0) {
|
||||
return (
|
||||
<Button
|
||||
variant="primary"
|
||||
className="editor-post-publish-button"
|
||||
onClick={save}
|
||||
>
|
||||
{__('Update', 'mailpoet')}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Button
|
||||
variant="primary"
|
||||
className="editor-post-publish-button"
|
||||
onClick={save}
|
||||
<Tooltip
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
// The following error seems to be a mismatch. It claims the 'delay' prop does not exist, but it does.
|
||||
delay={0}
|
||||
text={__(
|
||||
'Editing an active workflow is temporarily unavailable. We are working on introducing this functionality.',
|
||||
'mailpoet',
|
||||
)}
|
||||
>
|
||||
{__('Update', 'mailpoet')}
|
||||
</Button>
|
||||
<Button
|
||||
variant="primary"
|
||||
className="editor-post-publish-button"
|
||||
onClick={save}
|
||||
disabled
|
||||
>
|
||||
{__('Update', 'mailpoet')}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
@ -99,6 +159,46 @@ function DeactivateButton(): JSX.Element {
|
||||
);
|
||||
}
|
||||
|
||||
function DeactivateNowButton(): JSX.Element {
|
||||
const [showDeactivateModal, setShowDeactivateModal] = useState(false);
|
||||
const [isBusy, setIsBusy] = useState(false);
|
||||
const { hasUsersInProgress } = useSelect(
|
||||
(select) => ({
|
||||
hasUsersInProgress:
|
||||
select(storeName).getWorkflowData().stats.totals.in_progress > 0,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
const deactivateOrShowModal = () => {
|
||||
if (hasUsersInProgress) {
|
||||
setShowDeactivateModal(true);
|
||||
return;
|
||||
}
|
||||
setIsBusy(true);
|
||||
void dispatch(storeName).deactivate();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{showDeactivateModal && (
|
||||
<DeactivateImmediatelyModal
|
||||
onClose={() => {
|
||||
setShowDeactivateModal(false);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
isBusy={isBusy}
|
||||
variant="tertiary"
|
||||
onClick={deactivateOrShowModal}
|
||||
>
|
||||
{__('Deactivate now', 'mailpoet')}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
type Props = {
|
||||
showInserterToggle: boolean;
|
||||
toggleActivatePanel: () => void;
|
||||
@ -152,10 +252,13 @@ export function Header({
|
||||
<div className="edit-site-header_end">
|
||||
<div className="edit-site-header__actions">
|
||||
<Errors />
|
||||
{workflowStatus !== WorkflowStatus.ACTIVE && (
|
||||
{workflowStatus === WorkflowStatus.DRAFT && (
|
||||
<>
|
||||
<SaveDraftButton />
|
||||
<ActivateButton onClick={toggleActivatePanel} />
|
||||
<ActivateButton
|
||||
onClick={toggleActivatePanel}
|
||||
label={__('Activate', 'mailpoet')}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{workflowStatus === WorkflowStatus.ACTIVE && (
|
||||
@ -164,6 +267,15 @@ export function Header({
|
||||
<UpdateButton />
|
||||
</>
|
||||
)}
|
||||
{workflowStatus === WorkflowStatus.DEACTIVATING && (
|
||||
<>
|
||||
<DeactivateNowButton />
|
||||
<ActivateButton
|
||||
onClick={toggleActivatePanel}
|
||||
label={__('Update & Activate', 'mailpoet')}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<PinnedItems.Slot scope={storeName} />
|
||||
<MoreMenu />
|
||||
</div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Button, ToolbarItem } from '@wordpress/components';
|
||||
import { useSelect, useDispatch } from '@wordpress/data';
|
||||
import { __, _x } from '@wordpress/i18n';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { plus } from '@wordpress/icons';
|
||||
import { storeName } from '../../store';
|
||||
|
||||
@ -28,13 +28,11 @@ export function InserterToggle(): JSX.Element {
|
||||
onMouseDown={(event) => event.preventDefault()}
|
||||
onClick={toggleInserterSidebar}
|
||||
icon={plus}
|
||||
label={_x(
|
||||
'Toggle step inserter',
|
||||
'Generic label for step inserter button',
|
||||
)}
|
||||
label={__('Toggle step inserter', 'mailpoet')}
|
||||
showTooltip={!showIconLabels}
|
||||
>
|
||||
{showIconLabels && (!isInserterOpened ? __('Add') : __('Close'))}
|
||||
{showIconLabels &&
|
||||
(!isInserterOpened ? __('Add', 'mailpoet') : __('Close', 'mailpoet'))}
|
||||
</ToolbarItem>
|
||||
);
|
||||
}
|
||||
|
@ -20,14 +20,14 @@ export function MoreMenu(): JSX.Element {
|
||||
>
|
||||
{() => (
|
||||
<>
|
||||
<MenuGroup label={_x('View', 'noun')}>
|
||||
<MenuGroup label={_x('View', 'noun', 'mailpoet')}>
|
||||
<PreferenceToggleMenuItem
|
||||
scope={storeName}
|
||||
name="fullscreenMode"
|
||||
label={__('Fullscreen mode')}
|
||||
info={__('Work without distraction')}
|
||||
messageActivated={__('Fullscreen mode activated')}
|
||||
messageDeactivated={__('Fullscreen mode deactivated')}
|
||||
label={__('Fullscreen mode', 'mailpoet')}
|
||||
info={__('Work without distraction', 'mailpoet')}
|
||||
messageActivated={__('Fullscreen mode activated', 'mailpoet')}
|
||||
messageDeactivated={__('Fullscreen mode deactivated', 'mailpoet')}
|
||||
shortcut={displayShortcut.secondary('f')}
|
||||
/>
|
||||
</MenuGroup>
|
||||
|
@ -13,7 +13,10 @@ export const InserterListboxGroup = forwardRef<HTMLDivElement, Props>(
|
||||
|
||||
useEffect(() => {
|
||||
if (shouldSpeak) {
|
||||
speak(__('Use left and right arrow keys to move through blocks'));
|
||||
speak(
|
||||
// translators: Moving through automation step list using keyboard
|
||||
__('Use left and right arrow keys to move through steps', 'mailpoet'),
|
||||
);
|
||||
}
|
||||
}, [shouldSpeak]);
|
||||
|
||||
|
@ -7,6 +7,7 @@ import { PremiumModal } from 'common/premium_modal';
|
||||
import { Inserter } from '../inserter';
|
||||
import { Item } from '../inserter/item';
|
||||
import { storeName } from '../../store';
|
||||
import { AddStepCallbackType } from '../../../types/filters';
|
||||
|
||||
export function InserterPopover(): JSX.Element | null {
|
||||
const popoverRef = useRef<HTMLDivElement>();
|
||||
@ -20,7 +21,7 @@ export function InserterPopover(): JSX.Element | null {
|
||||
const { setInserterPopover } = useDispatch(storeName);
|
||||
|
||||
const onInsert = useCallback((item: Item) => {
|
||||
const addStepCallback = Hooks.applyFilters(
|
||||
const addStepCallback: AddStepCallbackType = Hooks.applyFilters(
|
||||
'mailpoet.automation.workflow.add_step_callback',
|
||||
() => {
|
||||
setShowModal(true);
|
||||
|
@ -2,7 +2,7 @@ import { forwardRef, Fragment, useCallback, useMemo } from 'react';
|
||||
import { SearchControl } from '@wordpress/components';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import { useRef, useImperativeHandle, useState } from '@wordpress/element';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { __, _x } from '@wordpress/i18n';
|
||||
import { blockDefault, Icon } from '@wordpress/icons';
|
||||
import { Group } from './group';
|
||||
import { Item } from './item';
|
||||
@ -41,21 +41,26 @@ export const Inserter = forwardRef(({ onInsert }: Props, ref): JSX.Element => {
|
||||
{
|
||||
type: 'triggers',
|
||||
title: undefined,
|
||||
label: __('Triggers', 'mailpoet'),
|
||||
// translators: Label for a list of automation steps of type trigger
|
||||
label: _x('Triggers', 'automation steps', 'mailpoet'),
|
||||
items: steps.filter(({ group }) => group === 'triggers'),
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
type: 'actions',
|
||||
title: __('Actions', 'mailpoet'),
|
||||
label: __('Actions', 'mailpoet'),
|
||||
// translators: Label for a list of automation steps of type action
|
||||
title: _x('Actions', 'automation steps', 'mailpoet'),
|
||||
// translators: Label for a list of automation steps of type action
|
||||
label: _x('Actions', 'automation steps', 'mailpoet'),
|
||||
items: steps.filter(({ group }) => group === 'actions'),
|
||||
},
|
||||
{
|
||||
type: 'logical',
|
||||
title: __('Logical', 'mailpoet'),
|
||||
label: __('Logical', 'mailpoet'),
|
||||
// translators: Label for a list of logical automation steps (if/else, etc.)
|
||||
title: _x('Logical', 'automation steps', 'mailpoet'),
|
||||
// translators: Label for a list of logical automation steps (if/else, etc.)
|
||||
label: _x('Logical', 'automation steps', 'mailpoet'),
|
||||
items: steps.filter(({ group }) => group === 'logical'),
|
||||
},
|
||||
],
|
||||
@ -96,8 +101,8 @@ export const Inserter = forwardRef(({ onInsert }: Props, ref): JSX.Element => {
|
||||
setFilterValue(value);
|
||||
}}
|
||||
value={filterValue}
|
||||
label={__('Search for blocks and patterns')}
|
||||
placeholder={__('Search')}
|
||||
label={__('Search for automation steps', 'mailpoet')}
|
||||
placeholder={__('Search', 'mailpoet')}
|
||||
ref={searchRef}
|
||||
/>
|
||||
|
||||
@ -135,7 +140,7 @@ export const Inserter = forwardRef(({ onInsert }: Props, ref): JSX.Element => {
|
||||
className="block-editor-inserter__no-results-icon"
|
||||
icon={blockDefault}
|
||||
/>
|
||||
<p>{__('No results found.')}</p>
|
||||
<p>{__('No results found.', 'mailpoet')}</p>
|
||||
</div>
|
||||
)}
|
||||
</InserterListbox>
|
||||
|
@ -25,7 +25,7 @@ export function KeyboardShortcuts(): null {
|
||||
void registerShortcut({
|
||||
name: 'mailpoet/automation-editor/toggle-fullscreen',
|
||||
category: 'global',
|
||||
description: __('Toggle fullscreen mode.'),
|
||||
description: __('Toggle fullscreen mode.', 'mailpoet'),
|
||||
keyCombination: {
|
||||
modifier: 'secondary',
|
||||
character: 'f',
|
||||
@ -35,7 +35,7 @@ export function KeyboardShortcuts(): null {
|
||||
void registerShortcut({
|
||||
name: 'mailpoet/automation-editor/toggle-sidebar',
|
||||
category: 'global',
|
||||
description: __('Show or hide the settings sidebar.'),
|
||||
description: __('Show or hide the settings sidebar.', 'mailpoet'),
|
||||
keyCombination: {
|
||||
modifier: 'primaryShift',
|
||||
character: ',',
|
||||
|
@ -5,7 +5,50 @@ import { dispatch, useSelect } from '@wordpress/data';
|
||||
import { storeName } from '../../store';
|
||||
import { WorkflowStatus } from '../../../listing/workflow';
|
||||
|
||||
export function DeactivateModal({ onClose }): JSX.Element {
|
||||
type DeactivateImmediatelyModalProps = {
|
||||
onClose: () => void;
|
||||
};
|
||||
export function DeactivateImmediatelyModal({
|
||||
onClose,
|
||||
}: DeactivateImmediatelyModalProps): JSX.Element {
|
||||
const [isBusy, setIsBusy] = useState<boolean>(false);
|
||||
return (
|
||||
<Modal
|
||||
className="mailpoet-automatoin-deactivate-modal"
|
||||
title={__('Stop automatoin for all subscribers?', 'mailpoet')}
|
||||
onRequestClose={onClose}
|
||||
>
|
||||
<p>
|
||||
{__(
|
||||
'Are you sure you want to deactivate now? This would stop this automation for all subscribers immediately.',
|
||||
'mailpoet',
|
||||
)}
|
||||
</p>
|
||||
|
||||
<Button
|
||||
isBusy={isBusy}
|
||||
variant="primary"
|
||||
onClick={() => {
|
||||
setIsBusy(true);
|
||||
dispatch(storeName).deactivate(true);
|
||||
}}
|
||||
>
|
||||
{__('Deactivate now', 'mailpoet')}
|
||||
</Button>
|
||||
|
||||
<Button disabled={isBusy} variant="tertiary" onClick={onClose}>
|
||||
{__('Cancel', 'mailpoet')}
|
||||
</Button>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
type DeactivateModalProps = {
|
||||
onClose: () => void;
|
||||
};
|
||||
export function DeactivateModal({
|
||||
onClose,
|
||||
}: DeactivateModalProps): JSX.Element {
|
||||
const { workflowName } = useSelect(
|
||||
(select) => ({
|
||||
workflowName: select(storeName).getWorkflowData().name,
|
||||
@ -13,7 +56,7 @@ export function DeactivateModal({ onClose }): JSX.Element {
|
||||
[],
|
||||
);
|
||||
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.
|
||||
@ -64,7 +107,7 @@ export function DeactivateModal({ onClose }): JSX.Element {
|
||||
<li>
|
||||
<label
|
||||
className={
|
||||
selected === WorkflowStatus.INACTIVE
|
||||
selected === WorkflowStatus.DRAFT
|
||||
? 'mailpoet-automation-option active'
|
||||
: 'mailpoet-automation-option'
|
||||
}
|
||||
@ -74,8 +117,8 @@ export function DeactivateModal({ onClose }): JSX.Element {
|
||||
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>
|
||||
@ -96,12 +139,9 @@ export function DeactivateModal({ onClose }): JSX.Element {
|
||||
variant="primary"
|
||||
onClick={() => {
|
||||
setIsBusy(true);
|
||||
if (selected === WorkflowStatus.DEACTIVATING) {
|
||||
// @ToDo Use the correct method provided in MAILPOET-4731
|
||||
dispatch(storeName).deactivate();
|
||||
return;
|
||||
}
|
||||
dispatch(storeName).deactivate();
|
||||
dispatch(storeName).deactivate(
|
||||
selected !== WorkflowStatus.DEACTIVATING,
|
||||
);
|
||||
}}
|
||||
>
|
||||
{__('Deactivate automation', 'mailpoet')}
|
||||
|
@ -84,7 +84,7 @@ function PostStep({ onClose }): JSX.Element {
|
||||
{sprintf(__('"%s" is now live.', 'mailpoet'), workflow.name)}
|
||||
</div>
|
||||
<p>
|
||||
<strong>{__("What's next?", 'mailpoet')}</strong>
|
||||
<strong>{__('What’s next?', 'mailpoet')}</strong>
|
||||
</p>
|
||||
<p>
|
||||
{__(
|
||||
|
@ -0,0 +1,24 @@
|
||||
import { PanelBody as WpPanelBody } from '@wordpress/components';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
type Props = WpPanelBody.Props & {
|
||||
hasErrors?: boolean;
|
||||
};
|
||||
|
||||
export function PanelBody({ hasErrors = false, ...props }: Props): JSX.Element {
|
||||
const [isOpened, setIsOpened] = useState(props.initialOpen);
|
||||
|
||||
useEffect(() => {
|
||||
if (hasErrors) {
|
||||
setIsOpened(true);
|
||||
}
|
||||
}, [hasErrors]);
|
||||
|
||||
return (
|
||||
<WpPanelBody
|
||||
opened={isOpened}
|
||||
onToggle={() => setIsOpened((prevState) => !prevState)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import { Dropdown, TextControl } from '@wordpress/components';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { edit, Icon } from '@wordpress/icons';
|
||||
import { PlainBodyTitle } from './plain-body-title';
|
||||
import { TitleActionButton } from './title-action-button';
|
||||
@ -25,7 +26,7 @@ export function StepName({
|
||||
<TitleActionButton
|
||||
onClick={onToggle}
|
||||
aria-expanded={isOpen}
|
||||
aria-label="Edit step name"
|
||||
aria-label={__('Edit step name', 'mailpoet')}
|
||||
>
|
||||
<Icon icon={edit} size={16} />
|
||||
</TitleActionButton>
|
||||
@ -33,13 +34,15 @@ export function StepName({
|
||||
)}
|
||||
renderContent={() => (
|
||||
<TextControl
|
||||
label="Step name"
|
||||
label={__('Step name', 'mailpoet')}
|
||||
className="mailpoet-step-name-input"
|
||||
placeholder={defaultName}
|
||||
value={currentName}
|
||||
onChange={update}
|
||||
help="Give the automation step a name that indicates its purpose. E.g
|
||||
“Abandoned cart recovery”. This name will be displayed only to you and not to the clients."
|
||||
help={__(
|
||||
'Give the automation step a name that indicates its purpose. E.g "Abandoned cart recovery". This name will be displayed only to you and not to the clients.',
|
||||
'mailpoet',
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Button } from '@wordpress/components';
|
||||
import { useDispatch } from '@wordpress/data';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { stepSidebarKey, storeName, workflowSidebarKey } from '../../store';
|
||||
|
||||
// See:
|
||||
@ -17,13 +18,13 @@ export function Header({ sidebarKey }: Props): JSX.Element {
|
||||
|
||||
const [workflowAriaLabel, workflowActiveClass] =
|
||||
sidebarKey === workflowSidebarKey
|
||||
? ['Workflow (selected)', 'is-active']
|
||||
: ['Workflow', ''];
|
||||
? [__('Automation (selected)', 'mailpoet'), 'is-active']
|
||||
: [__('Automation', 'mailpoet'), ''];
|
||||
|
||||
const [stepAriaLabel, stepActiveClass] =
|
||||
sidebarKey === stepSidebarKey
|
||||
? ['Step (selected)', 'is-active']
|
||||
: ['Step', ''];
|
||||
? [__('Step (selected)', 'mailpoet'), 'is-active']
|
||||
: [__('Step', 'mailpoet'), ''];
|
||||
|
||||
return (
|
||||
<ul>
|
||||
@ -32,9 +33,9 @@ export function Header({ sidebarKey }: Props): JSX.Element {
|
||||
onClick={openWorkflowSettings}
|
||||
className={`edit-site-sidebar__panel-tab ${workflowActiveClass}`}
|
||||
aria-label={workflowAriaLabel}
|
||||
data-label="Workflow"
|
||||
data-label={__('Automation', 'mailpoet')}
|
||||
>
|
||||
Workflow
|
||||
{__('Automation', 'mailpoet')}
|
||||
</Button>
|
||||
</li>
|
||||
<li>
|
||||
@ -42,9 +43,9 @@ export function Header({ sidebarKey }: Props): JSX.Element {
|
||||
onClick={openStepSettings}
|
||||
className={`edit-site-sidebar__panel-tab ${stepActiveClass}`}
|
||||
aria-label={stepAriaLabel}
|
||||
data-label="Workflow"
|
||||
data-label={__('Step', 'mailpoet')}
|
||||
>
|
||||
Step
|
||||
{__('Step', 'mailpoet')}
|
||||
</Button>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -47,13 +47,13 @@ export function Sidebar(props: Props): JSX.Element {
|
||||
<ComplementaryArea
|
||||
identifier={sidebarKey}
|
||||
header={<Header sidebarKey={sidebarKey} />}
|
||||
closeLabel={__('Close settings')}
|
||||
closeLabel={__('Close settings', 'mailpoet')}
|
||||
headerClassName="edit-site-sidebar__panel-tabs"
|
||||
title={__('Settings')}
|
||||
title={__('Settings', 'mailpoet')}
|
||||
icon={cog}
|
||||
className="edit-site-sidebar mailpoet-automation-sidebar"
|
||||
panelClassName="edit-site-sidebar"
|
||||
smallScreenTitle={workflowName || __('(no title)')}
|
||||
smallScreenTitle={workflowName || __('(no title)', 'mailpoet')}
|
||||
scope={storeName}
|
||||
toggleShortcut={keyboardShortcut}
|
||||
isActiveByDefault={sidebarActiveByDefault}
|
||||
|
@ -30,22 +30,11 @@ export function StepSidebar(): JSX.Element {
|
||||
icon={selectedStepType.icon}
|
||||
/>
|
||||
|
||||
<Edit />
|
||||
|
||||
<PanelBody title="Debug info" initialOpen={false}>
|
||||
<div>
|
||||
<strong>ID:</strong> {selectedStep.id}
|
||||
</div>
|
||||
<div>
|
||||
<strong>Type:</strong> {selectedStep.type}
|
||||
</div>
|
||||
<div>
|
||||
<strong>Key:</strong> {selectedStep.key}
|
||||
</div>
|
||||
<div>
|
||||
<strong>Args:</strong> {JSON.stringify(selectedStep.args)}
|
||||
</div>
|
||||
</PanelBody>
|
||||
<Edit
|
||||
// Force sidebar remount to avoid different steps mixing their data.
|
||||
// This can happen e.g. when having "useState" or "useRef" internally.
|
||||
key={selectedStep.id}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { PanelBody, PanelRow } from '@wordpress/components';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { storeName } from '../../../store';
|
||||
import { TrashButton } from '../../actions/trash-button';
|
||||
|
||||
@ -18,7 +19,7 @@ export function WorkflowSidebar(): JSX.Element {
|
||||
};
|
||||
|
||||
return (
|
||||
<PanelBody title="Automation details" initialOpen>
|
||||
<PanelBody title={__('Automation details', 'mailpoet')} initialOpen>
|
||||
<PanelRow>
|
||||
<strong>Date added</strong>{' '}
|
||||
{new Date(Date.parse(workflowData.created_at)).toLocaleDateString(
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
export function EmptyWorkflow(): JSX.Element {
|
||||
return (
|
||||
<div className="mailpoet-automation-editor-empty-workflow">
|
||||
No workflow data.
|
||||
{__('No automation data.', 'mailpoet')}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -16,6 +16,10 @@ import { InserterPopover } from '../inserter-popover';
|
||||
import { storeName } from '../../store';
|
||||
import { AddTrigger } from './add-trigger';
|
||||
import { Statistics } from './statistics';
|
||||
import {
|
||||
RenderStepSeparatorType,
|
||||
RenderStepType,
|
||||
} from '../../../types/filters';
|
||||
|
||||
export function Workflow(): JSX.Element {
|
||||
const { workflowData, selectedStep } = useSelect(
|
||||
@ -50,7 +54,7 @@ export function Workflow(): JSX.Element {
|
||||
}, [stepMap]);
|
||||
|
||||
const renderStep = useMemo(
|
||||
() =>
|
||||
(): RenderStepType =>
|
||||
Hooks.applyFilters(
|
||||
'mailpoet.automation.workflow.render_step',
|
||||
(stepData: StepData) =>
|
||||
@ -67,7 +71,7 @@ export function Workflow(): JSX.Element {
|
||||
);
|
||||
|
||||
const renderSeparator = useMemo(
|
||||
() =>
|
||||
(): RenderStepSeparatorType =>
|
||||
Hooks.applyFilters(
|
||||
'mailpoet.automation.workflow.render_step_separator',
|
||||
(previousStepData: StepData) => (
|
||||
@ -86,7 +90,7 @@ export function Workflow(): JSX.Element {
|
||||
<Composite
|
||||
state={compositeState}
|
||||
role="tree"
|
||||
aria-label={__('Workflow', 'mailpoet')}
|
||||
aria-label={__('Automation', 'mailpoet')}
|
||||
aria-orientation="vertical"
|
||||
className="mailpoet-automation-editor-workflow"
|
||||
>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { _x } from '@wordpress/i18n';
|
||||
import { storeName } from '../../store';
|
||||
import { Statistics as BaseStatistics } from '../../../components/statistics';
|
||||
|
||||
@ -17,17 +17,20 @@ export function Statistics(): JSX.Element {
|
||||
items={[
|
||||
{
|
||||
key: 'entered',
|
||||
label: __('Total Entered', 'mailpoet'),
|
||||
// translators: Total number of subscribers who entered an automation
|
||||
label: _x('Total Entered', 'automation stats', 'mailpoet'),
|
||||
value: workflow.stats.totals.entered,
|
||||
},
|
||||
{
|
||||
key: 'processing',
|
||||
label: __('Total Processing', 'mailpoet'),
|
||||
// translators: Total number of subscribers who are being processed in an automation
|
||||
label: _x('Total Processing', 'automation stats', 'mailpoet'),
|
||||
value: workflow.stats.totals.in_progress,
|
||||
},
|
||||
{
|
||||
key: 'exited',
|
||||
label: __('Total Exited', 'mailpoet'),
|
||||
// translators: Total number of subscribers who exited an automation, no matter the result
|
||||
label: _x('Total Exited', 'automation stats', 'mailpoet'),
|
||||
value: workflow.stats.totals.exited,
|
||||
},
|
||||
]}
|
||||
|
@ -1,59 +1,77 @@
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useState, Fragment } from 'react';
|
||||
import { DropdownMenu } from '@wordpress/components';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import { moreVertical, trash } from '@wordpress/icons';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { Hooks } from 'wp-js-hooks';
|
||||
import { PremiumModal } from 'common/premium_modal';
|
||||
import { Step as StepData } from './types';
|
||||
import { storeName } from '../../store';
|
||||
import { StepMoreControlsType } from '../../../types/filters';
|
||||
|
||||
type Props = {
|
||||
step: StepData;
|
||||
};
|
||||
|
||||
export function StepMoreMenu({ step }: Props): JSX.Element {
|
||||
const { stepType } = useSelect(
|
||||
(select) => ({
|
||||
stepType: select(storeName).getStepType(step.key),
|
||||
}),
|
||||
[step],
|
||||
);
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
|
||||
const onDelete = useCallback((stepData: StepData) => {
|
||||
const deleteStepCallback = Hooks.applyFilters(
|
||||
'mailpoet.automation.workflow.delete_step_callback',
|
||||
() => {
|
||||
setShowModal(true);
|
||||
const moreControls: StepMoreControlsType = Hooks.applyFilters(
|
||||
'mailpoet.automation.workflow.step.more-controls',
|
||||
{
|
||||
delete: {
|
||||
key: 'delete',
|
||||
control: {
|
||||
title: __('Delete step', 'mailpoet'),
|
||||
icon: trash,
|
||||
onClick: () => setShowModal(true),
|
||||
},
|
||||
slot: () => {
|
||||
if (!showModal) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
<PremiumModal
|
||||
onRequestClose={() => {
|
||||
setShowModal(false);
|
||||
}}
|
||||
tracking={{
|
||||
utm_medium: 'upsell_modal',
|
||||
utm_campaign: 'remove_automation_step',
|
||||
}}
|
||||
>
|
||||
{__('You cannot remove a step from the automation.', 'mailpoet')}
|
||||
</PremiumModal>
|
||||
);
|
||||
},
|
||||
},
|
||||
);
|
||||
deleteStepCallback(stepData);
|
||||
}, []);
|
||||
},
|
||||
step,
|
||||
stepType,
|
||||
);
|
||||
|
||||
const slots = Object.values(moreControls).filter(
|
||||
(item) => item.slot !== undefined,
|
||||
);
|
||||
const controls = Object.values(moreControls).map((item) => item.control);
|
||||
return (
|
||||
<>
|
||||
<div className="mailpoet-automation-step-more-menu">
|
||||
<DropdownMenu
|
||||
label={__('More', 'mailpoet')}
|
||||
icon={moreVertical}
|
||||
controls={[
|
||||
{
|
||||
title: __('Delete step', 'mailpoet'),
|
||||
icon: trash,
|
||||
onClick: () => onDelete(step),
|
||||
},
|
||||
]}
|
||||
popoverProps={{ position: 'bottom right' }}
|
||||
toggleProps={{ isSmall: true }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{showModal && (
|
||||
<PremiumModal
|
||||
onRequestClose={() => {
|
||||
setShowModal(false);
|
||||
}}
|
||||
tracking={{
|
||||
utm_medium: 'upsell_modal',
|
||||
utm_campaign: 'remove_automation_step',
|
||||
}}
|
||||
>
|
||||
{__('You cannot remove a new step from the automation.', 'mailpoet')}
|
||||
</PremiumModal>
|
||||
)}
|
||||
</>
|
||||
<div className="mailpoet-automation-step-more-menu">
|
||||
{slots.map(({ key, slot }) => (
|
||||
<Fragment key={key}>{slot()}</Fragment>
|
||||
))}
|
||||
<DropdownMenu
|
||||
label={__('More', 'mailpoet')}
|
||||
icon={moreVertical}
|
||||
popoverProps={{ position: 'bottom right' }}
|
||||
toggleProps={{ isSmall: true }}
|
||||
controls={Object.values(controls)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import { useContext } from 'react';
|
||||
import { __unstableCompositeItem as CompositeItem } from '@wordpress/components';
|
||||
import { useDispatch, useRegistry, useSelect } from '@wordpress/data';
|
||||
import { blockMeta } from '@wordpress/icons';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { __, _x } from '@wordpress/i18n';
|
||||
import { WorkflowCompositeContext } from './context';
|
||||
import { StepMoreMenu } from './step-more-menu';
|
||||
import { Step as StepData } from './types';
|
||||
@ -90,7 +90,7 @@ export function Step({ step, isSelected }: Props): JSX.Element {
|
||||
>
|
||||
{step.type !== 'trigger'
|
||||
? stepTypeData.title
|
||||
: __('Trigger', 'mailpoet')}
|
||||
: _x('Trigger', 'noun', 'mailpoet')}
|
||||
</label>
|
||||
<div className="mailpoet-automation-editor-step-subtitle">
|
||||
{step.type !== 'trigger'
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { WorkflowStatus } from '../../../listing/workflow';
|
||||
|
||||
export type NextStep = {
|
||||
id: string;
|
||||
};
|
||||
@ -13,7 +15,7 @@ export type Step = {
|
||||
export type Workflow = {
|
||||
id: number;
|
||||
name: string;
|
||||
status: 'active' | 'inactive' | 'draft' | 'trash';
|
||||
status: WorkflowStatus;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
activated_at: string;
|
||||
|
@ -1,15 +1,22 @@
|
||||
import classnames from 'classnames';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Button, Icon, Popover, SlotFillProvider } from '@wordpress/components';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import { store as noticesStore } from '@wordpress/notices';
|
||||
import {
|
||||
dispatch,
|
||||
select as globalSelect,
|
||||
StoreDescriptor,
|
||||
useSelect,
|
||||
} from '@wordpress/data';
|
||||
import { wordpress } from '@wordpress/icons';
|
||||
import {
|
||||
ComplementaryArea,
|
||||
InterfaceSkeleton,
|
||||
FullscreenMode,
|
||||
InterfaceSkeleton,
|
||||
} from '@wordpress/interface';
|
||||
import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { addQueryArgs } from '@wordpress/url';
|
||||
import { Header } from './components/header';
|
||||
import { InserterSidebar } from './components/inserter-sidebar';
|
||||
@ -25,6 +32,8 @@ import { MailPoet } from '../../mailpoet';
|
||||
import { LISTING_NOTICE_PARAMETERS } from '../listing/workflow-listing-notices';
|
||||
import { registerApiErrorHandler } from './api-error-handler';
|
||||
import { ActivatePanel } from './components/panel/activate-panel';
|
||||
import { registerTranslations } from '../i18n';
|
||||
import { WorkflowStatus } from '../listing/workflow';
|
||||
|
||||
// See:
|
||||
// https://github.com/WordPress/gutenberg/blob/9601a33e30ba41bac98579c8d822af63dd961488/packages/edit-post/src/components/layout/index.js
|
||||
@ -33,6 +42,36 @@ import { ActivatePanel } from './components/panel/activate-panel';
|
||||
// disable inserter sidebar until we implement drag & drop
|
||||
const showInserterSidebar = false;
|
||||
|
||||
/**
|
||||
* Show temporary message that active workflows cant be updated
|
||||
*
|
||||
* see MAILPOET-4744
|
||||
*/
|
||||
function updatingActiveWorkflowNotPossible() {
|
||||
const workflow = globalSelect(storeName).getWorkflowData();
|
||||
if (
|
||||
![WorkflowStatus.ACTIVE, WorkflowStatus.DEACTIVATING].includes(
|
||||
workflow.status,
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (workflow.stats.totals.in_progress === 0) {
|
||||
return;
|
||||
}
|
||||
const { createNotice } = dispatch(noticesStore as StoreDescriptor);
|
||||
void createNotice(
|
||||
'success',
|
||||
__(
|
||||
'Editing an active workflow is temporarily unavailable. We are working on introducing this functionality.',
|
||||
'mailpoet',
|
||||
),
|
||||
{
|
||||
type: 'snackbar',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function Editor(): JSX.Element {
|
||||
const {
|
||||
isFullscreenActive,
|
||||
@ -51,7 +90,15 @@ function Editor(): JSX.Element {
|
||||
[],
|
||||
);
|
||||
const [showActivatePanel, setShowActivatePanel] = useState(false);
|
||||
const [isBooting, setIsBooting] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isBooting) {
|
||||
return;
|
||||
}
|
||||
updatingActiveWorkflowNotPossible();
|
||||
setIsBooting(false);
|
||||
}, [isBooting]);
|
||||
const className = classnames('interface-interface-skeleton', {
|
||||
'is-sidebar-opened': isSidebarOpened,
|
||||
'show-icon-labels': showIconLabels,
|
||||
@ -117,6 +164,7 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
const root = document.getElementById('mailpoet_automation_editor');
|
||||
if (root) {
|
||||
registerTranslations();
|
||||
registerApiErrorHandler();
|
||||
initializeApi();
|
||||
initializeCoreIntegration();
|
||||
|
@ -65,6 +65,17 @@ export function* save() {
|
||||
data: { ...workflow },
|
||||
});
|
||||
|
||||
const { createNotice } = dispatch(noticesStore as StoreDescriptor);
|
||||
if (data?.data) {
|
||||
void createNotice(
|
||||
'success',
|
||||
__('The automation has been saved.', 'mailpoet'),
|
||||
{
|
||||
type: 'snackbar',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'SAVE',
|
||||
workflow: data?.data ?? workflow,
|
||||
@ -78,7 +89,7 @@ export function* activate() {
|
||||
method: 'PUT',
|
||||
data: {
|
||||
...workflow,
|
||||
status: 'active',
|
||||
status: WorkflowStatus.ACTIVE,
|
||||
},
|
||||
});
|
||||
|
||||
@ -99,20 +110,21 @@ export function* activate() {
|
||||
} as const;
|
||||
}
|
||||
|
||||
// @ToDo: Decide on best naming once MAILPOET-4731 decides about the "deactivating" status name
|
||||
export function* deactivate() {
|
||||
export function* deactivate(deactivateWorkflowRuns = true) {
|
||||
const workflow = select(storeName).getWorkflowData();
|
||||
const data = yield apiFetch({
|
||||
path: `/workflows/${workflow.id}`,
|
||||
method: 'PUT',
|
||||
data: {
|
||||
...workflow,
|
||||
status: 'inactive',
|
||||
status: deactivateWorkflowRuns
|
||||
? WorkflowStatus.DRAFT
|
||||
: WorkflowStatus.DEACTIVATING,
|
||||
},
|
||||
});
|
||||
|
||||
const { createNotice } = dispatch(noticesStore as StoreDescriptor);
|
||||
if (data?.data.status === WorkflowStatus.INACTIVE) {
|
||||
if (deactivateWorkflowRuns && data?.data.status === WorkflowStatus.DRAFT) {
|
||||
void createNotice(
|
||||
'success',
|
||||
__('Automation is now deactivated!', 'mailpoet'),
|
||||
@ -121,6 +133,21 @@ export function* deactivate() {
|
||||
},
|
||||
);
|
||||
}
|
||||
if (
|
||||
!deactivateWorkflowRuns &&
|
||||
data?.data.status === WorkflowStatus.DEACTIVATING
|
||||
) {
|
||||
void createNotice(
|
||||
'success',
|
||||
__(
|
||||
'Automation is deactivated. But recent users are still going through the flow.',
|
||||
'mailpoet',
|
||||
),
|
||||
{
|
||||
type: 'snackbar',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'DEACTIVATE',
|
||||
@ -135,13 +162,13 @@ export function* trash(onTrashed: () => void = undefined) {
|
||||
method: 'PUT',
|
||||
data: {
|
||||
...workflow,
|
||||
status: 'trash',
|
||||
status: WorkflowStatus.TRASH,
|
||||
},
|
||||
});
|
||||
|
||||
onTrashed?.();
|
||||
|
||||
if (data?.status === 'trash') {
|
||||
if (data?.status === WorkflowStatus.TRASH) {
|
||||
window.location.href = addQueryArgs(MailPoet.urls.automationListing, {
|
||||
[LISTING_NOTICE_PARAMETERS.workflowDeleted]: workflow.id,
|
||||
});
|
||||
|
@ -67,10 +67,12 @@ export function reducer(state: State, action: Action): State {
|
||||
? action.value(prevArgs[action.name] ?? undefined)
|
||||
: action.value;
|
||||
|
||||
const args = {
|
||||
...prevArgs,
|
||||
[action.name]: value,
|
||||
};
|
||||
const args =
|
||||
value === undefined
|
||||
? Object.fromEntries(
|
||||
Object.entries(prevArgs).filter(([name]) => name !== action.name),
|
||||
)
|
||||
: { ...prevArgs, [action.name]: value };
|
||||
|
||||
const step = { ...state.workflowData.steps[action.stepId], args };
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { createRegistrySelector } from '@wordpress/data';
|
||||
import { store as interfaceStore } from '@wordpress/interface';
|
||||
import { store as preferencesStore } from '@wordpress/preferences';
|
||||
import { storeName } from './constants';
|
||||
import { Context, Errors, Feature, State, StepError, StepType } from './types';
|
||||
import { Context, Errors, Feature, State, StepErrors, StepType } from './types';
|
||||
import { Item } from '../components/inserter/item';
|
||||
import { Step, Workflow } from '../components/workflow/types';
|
||||
|
||||
@ -78,6 +78,6 @@ export function getErrors(state: State): Errors | undefined {
|
||||
return state.errors;
|
||||
}
|
||||
|
||||
export function getStepError(state: State, id: string): StepError | undefined {
|
||||
export function getStepError(state: State, id: string): StepErrors | undefined {
|
||||
return state.errors?.steps[id] ?? undefined;
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
import {
|
||||
createReduxStore,
|
||||
register,
|
||||
StoreConfig,
|
||||
StoreDescriptor,
|
||||
} from '@wordpress/data';
|
||||
import { createReduxStore, register, StoreDescriptor } from '@wordpress/data';
|
||||
import { controls } from '@wordpress/data-controls';
|
||||
import { Hooks } from 'wp-js-hooks';
|
||||
import * as actions from './actions';
|
||||
@ -13,6 +8,7 @@ import { reducer } from './reducer';
|
||||
import * as selectors from './selectors';
|
||||
import { State } from './types';
|
||||
import { OmitFirstArgs } from '../../../types';
|
||||
import { EditorStoreConfigType } from '../../types/filters';
|
||||
|
||||
type StoreType = Omit<StoreDescriptor, 'name'> & {
|
||||
name: typeof storeName;
|
||||
@ -28,8 +24,8 @@ export const createStore = (): StoreType => {
|
||||
selectors,
|
||||
reducer,
|
||||
initialState: getInitialState(),
|
||||
} as StoreConfig<State>,
|
||||
) as StoreConfig<State>;
|
||||
} as EditorStoreConfigType,
|
||||
) as EditorStoreConfigType;
|
||||
|
||||
const store = createReduxStore<State>(storeName, storeConfig) as StoreType;
|
||||
register(store);
|
||||
|
@ -32,15 +32,17 @@ export type StepType = {
|
||||
edit: ComponentType;
|
||||
foreground: string;
|
||||
background: string;
|
||||
createStep?: (step: Step, state: State) => Step;
|
||||
};
|
||||
|
||||
export type StepError = {
|
||||
export type StepErrors = {
|
||||
step_id: string;
|
||||
message: string;
|
||||
fields: Record<string, string>;
|
||||
};
|
||||
|
||||
export type Errors = {
|
||||
steps: Record<string, StepError>;
|
||||
steps: Record<string, StepErrors>;
|
||||
};
|
||||
|
||||
export type State = {
|
||||
|
14
mailpoet/assets/js/src/automation/i18n.tsx
Normal file
14
mailpoet/assets/js/src/automation/i18n.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import { getLocaleData, setLocaleData } from '@wordpress/i18n';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
wp: {
|
||||
i18n: { getLocaleData: typeof getLocaleData };
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// We are using "@wordpress/i18n" from our bundle while WordPress initializes
|
||||
// translation data on the core one — we need to pass the data to our code.
|
||||
export const registerTranslations = () =>
|
||||
setLocaleData(window.wp.i18n.getLocaleData('mailpoet'), 'mailpoet');
|
@ -12,25 +12,42 @@ import { storeName } from '../../../../editor/store';
|
||||
import { DelayTypeOptions } from './types/delayTypes';
|
||||
|
||||
export function Edit(): JSX.Element {
|
||||
const { selectedStep } = useSelect(
|
||||
const { selectedStep, errors } = useSelect(
|
||||
(select) => ({
|
||||
selectedStep: select(storeName).getSelectedStep(),
|
||||
errors: select(storeName).getStepError(
|
||||
select(storeName).getSelectedStep().id,
|
||||
),
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
const errorFields = errors?.fields ?? {};
|
||||
const delayErrorMessage = errorFields?.delay ?? '';
|
||||
const delayTypeErrorMessage = errorFields?.delay_type ?? '';
|
||||
const delayValueInputId = `delay-number-${selectedStep.id}`;
|
||||
return (
|
||||
<PanelBody opened>
|
||||
<label htmlFor={delayValueInputId}>
|
||||
<PlainBodyTitle title={__('Wait for', 'mailpoet')} />
|
||||
<PlainBodyTitle
|
||||
title={
|
||||
// translators: A label for a wait delay time selection form field - time unit follows
|
||||
__('Wait for', 'mailpoet')
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<Flex align="top">
|
||||
<FlexItem style={{ flex: '1 1 0' }}>
|
||||
<FlexItem
|
||||
style={{ flex: '1 1 0' }}
|
||||
className={
|
||||
delayErrorMessage ? 'mailpoet-automation-field__error' : ''
|
||||
}
|
||||
>
|
||||
<TextControl
|
||||
id={delayValueInputId}
|
||||
help={delayErrorMessage}
|
||||
type="number"
|
||||
placeholder="Number"
|
||||
placeholder={__('Number', 'mailpoet')}
|
||||
value={(selectedStep.args.delay as string) ?? ''}
|
||||
onChange={(rawValue) => {
|
||||
const value: number =
|
||||
@ -45,9 +62,15 @@ export function Edit(): JSX.Element {
|
||||
}}
|
||||
/>
|
||||
</FlexItem>
|
||||
<FlexItem style={{ flex: '1 1 0' }}>
|
||||
<FlexItem
|
||||
style={{ flex: '1 1 0' }}
|
||||
className={
|
||||
delayTypeErrorMessage ? 'mailpoet-automation-field__error' : ''
|
||||
}
|
||||
>
|
||||
<SelectControl
|
||||
label=""
|
||||
help={delayTypeErrorMessage}
|
||||
value={(selectedStep.args.delay_type as string) ?? 'HOURS'}
|
||||
options={DelayTypeOptions}
|
||||
onChange={(value) =>
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { __, _x } from '@wordpress/i18n';
|
||||
import { Icon } from './icon';
|
||||
import { Edit } from './edit';
|
||||
import { StepType } from '../../../../editor/store/types';
|
||||
@ -14,13 +15,16 @@ const getDelayInformation = (delayTypeValue: string, value: number): string =>
|
||||
export const step: StepType = {
|
||||
key: 'core:delay',
|
||||
group: 'actions',
|
||||
title: 'Delay',
|
||||
title: _x('Delay', 'noun', 'mailpoet'),
|
||||
foreground: '#7F54B3',
|
||||
background: '#f7edf7',
|
||||
description: 'Wait some time before proceeding with the steps below',
|
||||
description: __(
|
||||
'Wait some time before proceeding with the steps below',
|
||||
'mailpoet',
|
||||
),
|
||||
subtitle: (data): string => {
|
||||
if (!data.args.delay || !data.args.delay_type) {
|
||||
return 'Not set up yet.';
|
||||
return __('Not set up yet.', 'mailpoet');
|
||||
}
|
||||
|
||||
return getDelayInformation(
|
||||
|
@ -1,25 +1,44 @@
|
||||
import { SelectControl } from '@wordpress/components';
|
||||
import { __, _n, sprintf } from '@wordpress/i18n';
|
||||
|
||||
export type DelayTypes = SelectControl.Option & {
|
||||
subtitle: (value: number) => string;
|
||||
};
|
||||
export const DelayTypeOptions: DelayTypes[] = [
|
||||
{
|
||||
label: 'Hours',
|
||||
label: __('Minutes', 'mailpoet'),
|
||||
subtitle: (value: number) =>
|
||||
`Wait for ${value} ${value === 1 ? 'hour' : 'hours'}`,
|
||||
sprintf(
|
||||
_n('Wait for %d minute', 'Wait for %d minutes', value, 'mailpoet'),
|
||||
value,
|
||||
),
|
||||
value: 'MINUTES',
|
||||
},
|
||||
{
|
||||
label: __('Hours', 'mailpoet'),
|
||||
subtitle: (value: number) =>
|
||||
sprintf(
|
||||
_n('Wait for %d hour', 'Wait for %d hours', value, 'mailpoet'),
|
||||
value,
|
||||
),
|
||||
value: 'HOURS',
|
||||
},
|
||||
{
|
||||
label: 'Days',
|
||||
label: __('Days', 'mailpoet'),
|
||||
subtitle: (value: number) =>
|
||||
`Wait for ${value} ${value === 1 ? 'day' : 'days'}`,
|
||||
sprintf(
|
||||
_n('Wait for %d day', 'Wait for %d days', value, 'mailpoet'),
|
||||
value,
|
||||
),
|
||||
value: 'DAYS',
|
||||
},
|
||||
{
|
||||
label: 'Weeks',
|
||||
label: __('Weeks', 'mailpoet'),
|
||||
subtitle: (value: number) =>
|
||||
`Wait for ${value} ${value === 1 ? 'week' : 'weeks'}`,
|
||||
sprintf(
|
||||
_n('Wait for %d week', 'Wait for %d weeks', value, 'mailpoet'),
|
||||
value,
|
||||
),
|
||||
value: 'WEEKS',
|
||||
},
|
||||
];
|
||||
|
@ -2,9 +2,11 @@ import { registerStepType } from '../../editor/store';
|
||||
import { step as SendEmailStep } from './steps/send_email';
|
||||
import { step as SomeoneSubscribesTrigger } from './steps/someone-subscribes';
|
||||
import { step as WpUserRegisteredTrigger } from './steps/wp-user-registered';
|
||||
import { registerStepControls } from './step-controls';
|
||||
|
||||
export const initialize = (): void => {
|
||||
registerStepType(SendEmailStep);
|
||||
registerStepType(WpUserRegisteredTrigger);
|
||||
registerStepType(SomeoneSubscribesTrigger);
|
||||
registerStepControls();
|
||||
};
|
||||
|
@ -0,0 +1,47 @@
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { chartBar } from '@wordpress/icons';
|
||||
import { Hooks } from 'wp-js-hooks';
|
||||
import { MoreControlType, StepMoreControlsType } from '../../../types/filters';
|
||||
import { StepType } from '../../../editor/store';
|
||||
import { Step } from '../../../editor/components/workflow/types';
|
||||
|
||||
const emailStatisticsControl = (step: Step): MoreControlType => {
|
||||
const hasEmail = step.args?.email_id > 0;
|
||||
return {
|
||||
key: 'statistics',
|
||||
control: {
|
||||
icon: chartBar,
|
||||
title: __('Email statistics', 'mailpoet'),
|
||||
isDisabled: !hasEmail,
|
||||
onClick: () => {
|
||||
window.open(
|
||||
`admin.php?page=mailpoet-newsletters#/stats/${
|
||||
step.args.email_id as string
|
||||
}`,
|
||||
'_blank',
|
||||
);
|
||||
},
|
||||
},
|
||||
slot: () => null,
|
||||
};
|
||||
};
|
||||
|
||||
export function registerStepControls() {
|
||||
Hooks.addFilter(
|
||||
'mailpoet.automation.workflow.step.more-controls',
|
||||
'mailpoet',
|
||||
(
|
||||
controls: StepMoreControlsType,
|
||||
step: Step,
|
||||
stepType: StepType,
|
||||
): StepMoreControlsType => {
|
||||
if (stepType.key === 'mailpoet:send-email') {
|
||||
return {
|
||||
statistics: emailStatisticsControl(step),
|
||||
...controls,
|
||||
};
|
||||
}
|
||||
return controls;
|
||||
},
|
||||
);
|
||||
}
|
@ -1,25 +1,52 @@
|
||||
import { dispatch, useSelect } from '@wordpress/data';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { plus } from '@wordpress/icons';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { Button } from '../../../components/button';
|
||||
import { storeName } from '../../../../../editor/store';
|
||||
import { MailPoet } from '../../../../../../mailpoet';
|
||||
|
||||
const emailPreviewLinkCache = {};
|
||||
const retrievePreviewLink = async (emailId) => {
|
||||
if (
|
||||
emailPreviewLinkCache[emailId] &&
|
||||
emailPreviewLinkCache[emailId].length > 0
|
||||
) {
|
||||
return emailPreviewLinkCache[emailId];
|
||||
}
|
||||
const response = await MailPoet.Ajax.post({
|
||||
api_version: window.mailpoet_api_version,
|
||||
endpoint: 'newsletters',
|
||||
action: 'get',
|
||||
data: {
|
||||
id: emailId,
|
||||
},
|
||||
});
|
||||
emailPreviewLinkCache[emailId] = response?.meta?.preview_url ?? '';
|
||||
return emailPreviewLinkCache[emailId];
|
||||
};
|
||||
|
||||
export function EditNewsletter(): JSX.Element {
|
||||
const [redirectToTemplateSelection, setRedirectToTemplateSelection] =
|
||||
useState(false);
|
||||
const [fetchingPreviewLink, setFetchingPreviewLink] = useState(false);
|
||||
|
||||
const { selectedStep, workflowId, workflowSaved } = useSelect(
|
||||
const { selectedStep, workflowId, workflowSaved, errors } = useSelect(
|
||||
(select) => ({
|
||||
selectedStep: select(storeName).getSelectedStep(),
|
||||
workflowId: select(storeName).getWorkflowData().id,
|
||||
workflowSaved: select(storeName).getWorkflowSaved(),
|
||||
errors: select(storeName).getStepError(
|
||||
select(storeName).getSelectedStep().id,
|
||||
),
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
const emailId = selectedStep?.args?.email_id as number | undefined;
|
||||
const workflowStepId = selectedStep.id;
|
||||
const errorFields = errors?.fields ?? {};
|
||||
const emailIdError = errorFields?.email_id ?? '';
|
||||
|
||||
const createEmail = useCallback(async () => {
|
||||
setRedirectToTemplateSelection(true);
|
||||
@ -56,16 +83,26 @@ export function EditNewsletter(): JSX.Element {
|
||||
|
||||
if (!emailId || redirectToTemplateSelection) {
|
||||
return (
|
||||
<Button
|
||||
variant="sidebar-primary"
|
||||
centered
|
||||
icon={plus}
|
||||
onClick={createEmail}
|
||||
isBusy={redirectToTemplateSelection}
|
||||
disabled={redirectToTemplateSelection}
|
||||
>
|
||||
Design email
|
||||
</Button>
|
||||
<div className={emailIdError ? 'mailpoet-automation-field__error' : ''}>
|
||||
<Button
|
||||
variant="sidebar-primary"
|
||||
centered
|
||||
icon={plus}
|
||||
onClick={createEmail}
|
||||
isBusy={redirectToTemplateSelection}
|
||||
disabled={redirectToTemplateSelection}
|
||||
>
|
||||
{__('Design email', 'mailpoet')}
|
||||
</Button>
|
||||
{emailIdError && (
|
||||
<span className="mailpoet-automation-field-message">
|
||||
{__(
|
||||
'You need to design an email before you can activate the automation',
|
||||
'mailpoet',
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -78,10 +115,21 @@ export function EditNewsletter(): JSX.Element {
|
||||
selectedStep.args.email_id as string
|
||||
}`}
|
||||
>
|
||||
Edit content
|
||||
{__('Edit content', 'mailpoet')}
|
||||
</Button>
|
||||
<Button variant="secondary" centered>
|
||||
Preview
|
||||
<Button
|
||||
variant="secondary"
|
||||
centered
|
||||
isBusy={fetchingPreviewLink}
|
||||
disabled={fetchingPreviewLink}
|
||||
onClick={async () => {
|
||||
setFetchingPreviewLink(true);
|
||||
const link = await retrievePreviewLink(emailId);
|
||||
window.open(link as string, '_blank');
|
||||
setFetchingPreviewLink(false);
|
||||
}}
|
||||
>
|
||||
{__('Preview', 'mailpoet')}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { ComponentProps } from 'react';
|
||||
import { PanelBody, TextareaControl, TextControl } from '@wordpress/components';
|
||||
import { dispatch, useSelect } from '@wordpress/data';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { ShortcodeHelpText } from './shortcode_help_text';
|
||||
import { PlainBodyTitle } from '../../../../../editor/components/panel';
|
||||
import { storeName } from '../../../../../editor/store';
|
||||
@ -31,14 +32,21 @@ function SingleLineTextareaControl(
|
||||
}
|
||||
|
||||
export function EmailPanel(): JSX.Element {
|
||||
const { selectedStep, selectedStepType } = useSelect(
|
||||
const { selectedStep, selectedStepType, errors } = useSelect(
|
||||
(select) => ({
|
||||
selectedStep: select(storeName).getSelectedStep(),
|
||||
selectedStepType: select(storeName).getSelectedStepType(),
|
||||
errors: select(storeName).getStepError(
|
||||
select(storeName).getSelectedStep().id,
|
||||
),
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
const errorFields = errors?.fields ?? {};
|
||||
const senderNameErrorMessage = errorFields?.sender_name ?? '';
|
||||
const senderAddressErrorMessage = errorFields?.sender_address ?? '';
|
||||
const subjectErrorMessage = errorFields?.subject ?? '';
|
||||
return (
|
||||
<PanelBody opened>
|
||||
<StepName
|
||||
@ -49,8 +57,15 @@ export function EmailPanel(): JSX.Element {
|
||||
}}
|
||||
/>
|
||||
<TextControl
|
||||
label="“From” name"
|
||||
placeholder="John Doe"
|
||||
className={
|
||||
senderNameErrorMessage ? 'mailpoet-automation-field__error' : ''
|
||||
}
|
||||
help={senderNameErrorMessage}
|
||||
label={__('"From" name', 'mailpoet')}
|
||||
placeholder={
|
||||
// translators: A placeholder for a person's name
|
||||
__('John Doe', 'mailpoet')
|
||||
}
|
||||
value={(selectedStep.args.sender_name as string) ?? ''}
|
||||
onChange={(value) =>
|
||||
dispatch(storeName).updateStepArgs(
|
||||
@ -61,9 +76,16 @@ export function EmailPanel(): JSX.Element {
|
||||
}
|
||||
/>
|
||||
<TextControl
|
||||
className={
|
||||
senderAddressErrorMessage ? 'mailpoet-automation-field__error' : ''
|
||||
}
|
||||
help={senderAddressErrorMessage}
|
||||
type="email"
|
||||
label="“From” email address"
|
||||
placeholder="you@domain.com"
|
||||
label={__('"From" email address', 'mailpoet')}
|
||||
placeholder={
|
||||
// translators: A placeholder for an email
|
||||
__('you@domain.com', 'mailpoet')
|
||||
}
|
||||
value={(selectedStep.args.sender_address as string) ?? ''}
|
||||
onChange={(value) =>
|
||||
dispatch(storeName).updateStepArgs(
|
||||
@ -74,17 +96,25 @@ export function EmailPanel(): JSX.Element {
|
||||
}
|
||||
/>
|
||||
<SingleLineTextareaControl
|
||||
label="Subject"
|
||||
placeholder="Type in subject…"
|
||||
className={
|
||||
subjectErrorMessage ? 'mailpoet-automation-field__error' : ''
|
||||
}
|
||||
label={__('Subject', 'mailpoet')}
|
||||
placeholder={__('Type in subject…', 'mailpoet')}
|
||||
value={(selectedStep.args.subject as string) ?? ''}
|
||||
onChange={(value) =>
|
||||
dispatch(storeName).updateStepArgs(selectedStep.id, 'subject', value)
|
||||
}
|
||||
help={<ShortcodeHelpText />}
|
||||
help={
|
||||
<>
|
||||
{`${subjectErrorMessage} `}
|
||||
<ShortcodeHelpText />
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<SingleLineTextareaControl
|
||||
label="Preheader"
|
||||
placeholder="Type in preheader…"
|
||||
label={__('Preheader', 'mailpoet')}
|
||||
placeholder={__('Type in preheader…', 'mailpoet')}
|
||||
value={(selectedStep.args.preheader as string) ?? ''}
|
||||
onChange={(value) =>
|
||||
dispatch(storeName).updateStepArgs(
|
||||
@ -97,7 +127,7 @@ export function EmailPanel(): JSX.Element {
|
||||
/>
|
||||
|
||||
<div className="mailpoet-automation-email-content-separator" />
|
||||
<PlainBodyTitle title="Email" />
|
||||
<PlainBodyTitle title={__('Email', 'mailpoet')} />
|
||||
<EditNewsletter />
|
||||
</PanelBody>
|
||||
);
|
||||
|
@ -1,27 +1,36 @@
|
||||
import { PanelBody, ToggleControl } from '@wordpress/components';
|
||||
import { dispatch, useSelect } from '@wordpress/data';
|
||||
import { useState } from 'react';
|
||||
import { ToggleControl } from '@wordpress/components';
|
||||
import { useDispatch, useSelect } from '@wordpress/data';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { PremiumModal } from 'common/premium_modal';
|
||||
import { Hooks } from 'wp-js-hooks';
|
||||
import { storeName } from '../../../../../editor/store';
|
||||
import { GoogleAnalyticsPanelBodyType } from '../../../types/filters';
|
||||
import { PanelBody } from '../../../../../editor/components/panel/panel-body';
|
||||
|
||||
export function GoogleAnalyticsPanel(): JSX.Element {
|
||||
const { selectedStep } = useSelect(
|
||||
(select) => ({ selectedStep: select(storeName).getSelectedStep() }),
|
||||
const { selectedStep, errors } = useSelect(
|
||||
(select) => ({
|
||||
selectedStep: select(storeName).getSelectedStep(),
|
||||
errors: select(storeName).getStepError(
|
||||
select(storeName).getSelectedStep().id,
|
||||
)?.fields?.ga_campaign,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
const enabled = typeof selectedStep.args?.ga_campaign !== 'undefined';
|
||||
const panelBody = Hooks.applyFilters(
|
||||
const { updateStepArgs } = useDispatch(storeName);
|
||||
|
||||
const hasValue = typeof selectedStep.args?.ga_campaign !== 'undefined';
|
||||
const [enabled, setEnabled] = useState(hasValue);
|
||||
|
||||
const panelBody: GoogleAnalyticsPanelBodyType = Hooks.applyFilters(
|
||||
'mailpoet.automation.send_email.google_analytics_panel',
|
||||
<PremiumModal
|
||||
onRequestClose={() =>
|
||||
dispatch(storeName).updateStepArgs(
|
||||
selectedStep.id,
|
||||
'ga_campaign',
|
||||
undefined,
|
||||
)
|
||||
}
|
||||
onRequestClose={() => {
|
||||
setEnabled(false);
|
||||
updateStepArgs(selectedStep.id, 'ga_campaign', undefined);
|
||||
}}
|
||||
>
|
||||
{__(
|
||||
'Google Analytics tracking is not available in the free version of the MailPoet plugin.',
|
||||
@ -31,17 +40,20 @@ export function GoogleAnalyticsPanel(): JSX.Element {
|
||||
);
|
||||
|
||||
return (
|
||||
<PanelBody title="Google analytics" initialOpen={false}>
|
||||
<PanelBody
|
||||
title={__('Google Analytics', 'mailpoet')}
|
||||
initialOpen={false}
|
||||
hasErrors={!!errors}
|
||||
>
|
||||
<ToggleControl
|
||||
label="Enable custom GA tracking"
|
||||
label={__('Enable custom GA tracking', 'mailpoet')}
|
||||
checked={enabled}
|
||||
onChange={(value) =>
|
||||
dispatch(storeName).updateStepArgs(
|
||||
selectedStep.id,
|
||||
'ga_campaign',
|
||||
value ? '' : undefined,
|
||||
)
|
||||
}
|
||||
onChange={(value) => {
|
||||
setEnabled(value);
|
||||
if (!value) {
|
||||
updateStepArgs(selectedStep.id, 'ga_campaign', undefined);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
{enabled && panelBody}
|
||||
|
@ -1,67 +1,113 @@
|
||||
import { PanelBody, TextControl, ToggleControl } from '@wordpress/components';
|
||||
import { dispatch, useSelect } from '@wordpress/data';
|
||||
import { useRef, useState } from 'react';
|
||||
import { TextControl, ToggleControl } from '@wordpress/components';
|
||||
import { useDispatch, useSelect } from '@wordpress/data';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { storeName } from '../../../../../editor/store';
|
||||
import { PanelBody } from '../../../../../editor/components/panel/panel-body';
|
||||
|
||||
type ReplyToArgs = {
|
||||
reply_to_name?: string;
|
||||
reply_to_address?: string;
|
||||
};
|
||||
|
||||
export function ReplyToPanel(): JSX.Element {
|
||||
const { selectedStep } = useSelect(
|
||||
const { context, selectedStep, errors } = useSelect(
|
||||
(select) => ({
|
||||
context: select(storeName).getContext(),
|
||||
selectedStep: select(storeName).getSelectedStep(),
|
||||
errors: select(storeName).getStepError(
|
||||
select(storeName).getSelectedStep().id,
|
||||
),
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
const replyToName = selectedStep.args.reply_to_name as string | undefined;
|
||||
const replyToAddress = selectedStep.args.reply_to_address as
|
||||
| string
|
||||
| undefined;
|
||||
const { updateStepArgs } = useDispatch(storeName);
|
||||
|
||||
const enabled =
|
||||
typeof replyToName !== 'undefined' || typeof replyToAddress !== 'undefined';
|
||||
const args = selectedStep.args as ReplyToArgs;
|
||||
const hasValue = !!args.reply_to_name || !!args.reply_to_address;
|
||||
const [expanded, setExpanded] = useState(hasValue);
|
||||
const prevValue = useRef<{ name?: string; address?: string }>();
|
||||
|
||||
// defaults
|
||||
const argsContext =
|
||||
context.steps['mailpoet:send-email']?.args_schema?.properties ?? {};
|
||||
const defaultName = argsContext.reply_to_name?.default;
|
||||
const defaultAddress = argsContext.reply_to_address?.default;
|
||||
|
||||
const errorFields = errors?.fields ?? {};
|
||||
const replyToNameError = errorFields?.reply_to_name ?? '';
|
||||
const replyToAddressError = errorFields?.reply_to_address ?? '';
|
||||
return (
|
||||
<PanelBody title="Reply to" initialOpen={false}>
|
||||
<PanelBody
|
||||
title={__('Reply to', 'mailpoet')}
|
||||
initialOpen={false}
|
||||
hasErrors={!!replyToNameError || !!replyToAddressError}
|
||||
>
|
||||
<ToggleControl
|
||||
label="Use different email address for getting replies to the email"
|
||||
checked={enabled}
|
||||
label={__(
|
||||
'Use different email address for getting replies to the email',
|
||||
'mailpoet',
|
||||
)}
|
||||
checked={expanded}
|
||||
onChange={(value) => {
|
||||
dispatch(storeName).updateStepArgs(
|
||||
selectedStep.id,
|
||||
'reply_to_name',
|
||||
value ? '' : undefined,
|
||||
);
|
||||
dispatch(storeName).updateStepArgs(
|
||||
selectedStep.id,
|
||||
'reply_to_address',
|
||||
value ? '' : undefined,
|
||||
);
|
||||
setExpanded(value);
|
||||
const stepId = selectedStep.id;
|
||||
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);
|
||||
} 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);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
{enabled && (
|
||||
{expanded && (
|
||||
<>
|
||||
<TextControl
|
||||
label="“Reply to” name"
|
||||
placeholder="John Doe"
|
||||
value={replyToName ?? ''}
|
||||
className={
|
||||
replyToNameError ? 'mailpoet-automation-field__error' : ''
|
||||
}
|
||||
help={replyToNameError}
|
||||
label={__('"Reply to" name', 'mailpoet')}
|
||||
placeholder={
|
||||
// translators: A placeholder for a person's name
|
||||
__('John Doe', 'mailpoet')
|
||||
}
|
||||
value={args.reply_to_name ?? ''}
|
||||
onChange={(value) =>
|
||||
dispatch(storeName).updateStepArgs(
|
||||
updateStepArgs(
|
||||
selectedStep.id,
|
||||
'reply_to_name',
|
||||
value,
|
||||
value || undefined,
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
<TextControl
|
||||
className={
|
||||
replyToAddressError ? 'mailpoet-automation-field__error' : ''
|
||||
}
|
||||
help={replyToAddressError}
|
||||
type="email"
|
||||
label="“Reply to” email address"
|
||||
placeholder="you@domain.com"
|
||||
value={replyToAddress ?? ''}
|
||||
label={__('"Reply to" email address', 'mailpoet')}
|
||||
placeholder={
|
||||
// translators: A placeholder for an email
|
||||
__('you@domain.com', 'mailpoet')
|
||||
}
|
||||
value={args.reply_to_address ?? ''}
|
||||
onChange={(value) =>
|
||||
dispatch(storeName).updateStepArgs(
|
||||
updateStepArgs(
|
||||
selectedStep.id,
|
||||
'reply_to_address',
|
||||
value,
|
||||
value || undefined,
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
export function ShortcodeHelpText(): JSX.Element {
|
||||
return (
|
||||
<span className="mailpoet-shortcode-selector">
|
||||
@ -8,7 +10,7 @@ export function ShortcodeHelpText(): JSX.Element {
|
||||
rel="noopener noreferrer"
|
||||
data-beacon-article="59d662ef042863379ddc6faa"
|
||||
>
|
||||
MailPoet shortcodes
|
||||
{__('MailPoet shortcodes', 'mailpoet')}
|
||||
</a>
|
||||
</span>
|
||||
);
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { ComponentProps, ComponentType, useEffect, useState } from 'react';
|
||||
import { Spinner as WpSpinner } from '@wordpress/components';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { MailPoetAjax } from '../../../../../../ajax';
|
||||
|
||||
// @types/wordpress__components don't define "className", which is supported
|
||||
@ -39,7 +40,7 @@ export function Thumbnail({ emailId }: Props): JSX.Element {
|
||||
<img
|
||||
className="mailpoet-automation-thumbnail-image"
|
||||
src={thumbnailUrl}
|
||||
alt="Email thumbnail"
|
||||
alt={__('Email thumbnail', 'mailpoet')}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
|
@ -1,15 +1,25 @@
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { Hooks } from 'wp-js-hooks';
|
||||
import { Icon } from './icon';
|
||||
import { Edit } from './edit';
|
||||
import { StepType } from '../../../../editor/store/types';
|
||||
import { State, StepType } from '../../../../editor/store/types';
|
||||
import { Step } from '../../../../editor/components/workflow/types';
|
||||
|
||||
export const step: StepType = {
|
||||
key: 'mailpoet:send-email',
|
||||
group: 'actions',
|
||||
title: 'Send email',
|
||||
description: 'An email will be sent to subscriber',
|
||||
subtitle: (data) => (data.args.name as string) ?? 'Send email',
|
||||
title: __('Send email', 'mailpoet'),
|
||||
description: __('An email will be sent to subscriber', 'mailpoet'),
|
||||
subtitle: (data) =>
|
||||
(data.args.name as string) ?? __('Send email', 'mailpoet'),
|
||||
foreground: '#996800',
|
||||
background: '#FCF9E8',
|
||||
icon: Icon,
|
||||
edit: Edit,
|
||||
createStep: (stepData: Step, state: State) =>
|
||||
Hooks.applyFilters(
|
||||
'mailpoet.automation.send_email.create_step',
|
||||
stepData,
|
||||
state.workflowData.id,
|
||||
),
|
||||
} as const;
|
||||
|
@ -30,7 +30,7 @@ export function ListPanel(): JSX.Element {
|
||||
|
||||
<FormTokenField
|
||||
label={__(
|
||||
'When someone subscribers to the following list(s):',
|
||||
'When someone subscribes to the following lists:',
|
||||
'mailpoet',
|
||||
)}
|
||||
placeholder={__('Any list', 'mailpoet')}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { __, _x } from '@wordpress/i18n';
|
||||
import { commentAuthorAvatar } from '@wordpress/icons';
|
||||
import { StepType } from '../../../../editor/store';
|
||||
import { Edit } from './edit';
|
||||
@ -13,7 +13,7 @@ export const step: StepType = {
|
||||
'Starts the automation when a new subscriber is added to MailPoet.',
|
||||
'mailpoet',
|
||||
),
|
||||
subtitle: () => __('Trigger', 'mailpoet'),
|
||||
subtitle: () => _x('Trigger', 'noun', 'mailpoet'),
|
||||
icon: () => (
|
||||
<div style={{ width: '100%', height: '100%', scale: '1.4' }}>
|
||||
{commentAuthorAvatar}
|
||||
|
@ -1,11 +1,31 @@
|
||||
import { PanelBody } from '@wordpress/components';
|
||||
import { dispatch, useSelect } from '@wordpress/data';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import ReactStringReplace from 'react-string-replace';
|
||||
import { storeName } from '../../../../../editor/store';
|
||||
import { PlainBodyTitle } from '../../../../../editor/components/panel';
|
||||
import { userRoles } from './role';
|
||||
import { FormTokenField } from '../../../components/form-token-field';
|
||||
|
||||
function SettingsInfoText(): JSX.Element {
|
||||
return (
|
||||
<p>
|
||||
{ReactStringReplace(
|
||||
__(
|
||||
'[link]Subscribe in registration form[/link] setting must be enabled.',
|
||||
'mailpoet',
|
||||
),
|
||||
/\[link\](.*?)\[\/link\]/g,
|
||||
(match) => (
|
||||
<a href="admin.php?page=mailpoet-settings#/basics" target="_blank">
|
||||
{match}
|
||||
</a>
|
||||
),
|
||||
)}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
export function RolePanel(): JSX.Element {
|
||||
const { selectedStep } = useSelect(
|
||||
(select) => ({
|
||||
@ -20,9 +40,11 @@ export function RolePanel(): JSX.Element {
|
||||
const selected = userRoles.filter((role): boolean =>
|
||||
rawSelected.includes(role.id as string),
|
||||
);
|
||||
|
||||
return (
|
||||
<PanelBody opened>
|
||||
<PlainBodyTitle title={__('Trigger settings', 'mailpoet')} />
|
||||
<SettingsInfoText />
|
||||
<FormTokenField
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { __, _x } from '@wordpress/i18n';
|
||||
import { wordpress } from '@wordpress/icons';
|
||||
import { StepType } from '../../../../editor/store';
|
||||
import { Edit } from './edit';
|
||||
@ -13,7 +13,7 @@ export const step: StepType = {
|
||||
'Starts the automation when a new user registered in WordPress.',
|
||||
'mailpoet',
|
||||
),
|
||||
subtitle: () => __('Trigger', 'mailpoet'),
|
||||
subtitle: () => _x('Trigger', 'noun', 'mailpoet'),
|
||||
icon: () => (
|
||||
<div style={{ width: '100%', height: '100%', scale: '1.12' }}>
|
||||
{wordpress}
|
||||
|
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* The types in this file document the expected return types of specific
|
||||
* filters.
|
||||
*/
|
||||
import { Step } from '../../../editor/components/workflow/types';
|
||||
|
||||
// mailpoet.automation.send_email.create_step
|
||||
export type SendEmailCreateStepType = (step: Step, workflowId: number) => Step;
|
||||
|
||||
// mailpoet.automation.send_email.google_analytics_panel
|
||||
export type GoogleAnalyticsPanelBodyType = JSX.Element;
|
@ -1,4 +1,4 @@
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { _x } from '@wordpress/i18n';
|
||||
import { Workflow } from '../../workflow';
|
||||
import { Statistics } from '../../../components/statistics';
|
||||
|
||||
@ -13,17 +13,20 @@ export function Subscribers({ workflow }: Props): JSX.Element {
|
||||
items={[
|
||||
{
|
||||
key: 'entered',
|
||||
label: __('Entered', 'mailpoet'),
|
||||
// translators: Total number of subscribers who entered an automation
|
||||
label: _x('Entered', 'automation stats', 'mailpoet'),
|
||||
value: workflow.stats.totals.entered,
|
||||
},
|
||||
{
|
||||
key: 'processing',
|
||||
label: __('Processing', 'mailpoet'),
|
||||
// translators: Total number of subscribers who are being processed in an automation
|
||||
label: _x('Processing', 'automation stats', 'mailpoet'),
|
||||
value: workflow.stats.totals.in_progress,
|
||||
},
|
||||
{
|
||||
key: 'exited',
|
||||
label: __('Exited', 'mailpoet'),
|
||||
// translators: Total number of subscribers who exited an automation, no matter the result
|
||||
label: _x('Exited', 'automation stats', 'mailpoet'),
|
||||
value: workflow.stats.totals.exited,
|
||||
},
|
||||
]}
|
||||
|
@ -31,7 +31,7 @@ export const useDeleteButton = (workflow: Workflow): Item | undefined => {
|
||||
onCancel={() => setShowDialog(false)}
|
||||
>
|
||||
{sprintf(
|
||||
// translators: %s is the workflow name
|
||||
// translators: %s is the automation name
|
||||
__(
|
||||
'Are you sure you want to permanently delete "%s" and all associated data? This cannot be undone!',
|
||||
'mailpoet',
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';
|
||||
import { useDispatch } from '@wordpress/data';
|
||||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import { __, _x, sprintf } from '@wordpress/i18n';
|
||||
import { Item } from './item';
|
||||
import { storeName } from '../../store';
|
||||
import { Workflow, WorkflowStatus } from '../../workflow';
|
||||
@ -17,23 +17,23 @@ export const useTrashButton = (workflow: Workflow): Item | undefined => {
|
||||
return {
|
||||
key: 'trash',
|
||||
control: {
|
||||
title: __('Trash', 'mailpoet'),
|
||||
title: _x('Trash', 'verb', 'mailpoet'),
|
||||
icon: null,
|
||||
onClick: () => setShowDialog(true),
|
||||
},
|
||||
slot: (
|
||||
<ConfirmDialog
|
||||
isOpen={showDialog}
|
||||
title={__('Trash workflow', 'mailpoet')}
|
||||
title={__('Trash automation', 'mailpoet')}
|
||||
confirmButtonText={__('Yes, move to trash', 'mailpoet')}
|
||||
__experimentalHideHeader={false}
|
||||
onConfirm={() => trashWorkflow(workflow)}
|
||||
onCancel={() => setShowDialog(false)}
|
||||
>
|
||||
{sprintf(
|
||||
// translators: %s is the workflow name
|
||||
// translators: %s is the automation name
|
||||
__(
|
||||
'Are you sure you want to move the workflow "%s" to the Trash?',
|
||||
'Are you sure you want to move the automation "%s" to the Trash?',
|
||||
'mailpoet',
|
||||
),
|
||||
workflow.name,
|
||||
|
@ -1,48 +1,65 @@
|
||||
import { Search, TableCard } from '@woocommerce/components/build';
|
||||
import { TabPanel } from '@wordpress/components';
|
||||
import { TableCard } from '@woocommerce/components/build';
|
||||
import { Button, Flex, TabPanel } from '@wordpress/components';
|
||||
import { useDispatch, useSelect } from '@wordpress/data';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { __, _x } from '@wordpress/i18n';
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo } from 'react';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
import { plusIcon } from 'common/button/icon/plus';
|
||||
import { getRow } from './get-row';
|
||||
import { storeName } from './store/constants';
|
||||
import { storeName } from './store';
|
||||
import { Workflow, WorkflowStatus } from './workflow';
|
||||
import { MailPoet } from '../../mailpoet';
|
||||
|
||||
const tabConfig = [
|
||||
{
|
||||
name: 'all',
|
||||
title: 'All',
|
||||
title: __('All', 'mailpoet'),
|
||||
className: 'mailpoet-tab-all',
|
||||
},
|
||||
{
|
||||
name: WorkflowStatus.ACTIVE,
|
||||
title: 'Active',
|
||||
title: __('Active', 'mailpoet'),
|
||||
className: 'mailpoet-tab-active',
|
||||
},
|
||||
{
|
||||
name: WorkflowStatus.INACTIVE,
|
||||
title: 'Inactive',
|
||||
className: 'mailpoet-tab-inactive',
|
||||
},
|
||||
{
|
||||
name: WorkflowStatus.DRAFT,
|
||||
title: 'Draft',
|
||||
title: _x('Draft', 'noun', 'mailpoet'),
|
||||
className: 'mailpoet-tab-draft',
|
||||
},
|
||||
{
|
||||
name: WorkflowStatus.TRASH,
|
||||
title: 'Trash',
|
||||
title: _x('Trash', 'noun', 'mailpoet'),
|
||||
className: 'mailpoet-tab-trash',
|
||||
},
|
||||
] as const;
|
||||
|
||||
const tableHeaders = [
|
||||
{ key: 'name', label: __('Name', 'mailpoet') },
|
||||
{
|
||||
key: 'name',
|
||||
label: __('Name', 'mailpoet'),
|
||||
cellClassName: 'mailpoet-automation-listing-cell-name',
|
||||
},
|
||||
{ key: 'subscribers', label: __('Subscribers', 'mailpoet') },
|
||||
{ key: 'status', label: __('Status', 'mailpoet') },
|
||||
{ key: 'actions' },
|
||||
] as const;
|
||||
|
||||
export function AutomationListingHeader(): JSX.Element {
|
||||
return (
|
||||
<Flex className="mailpoet-automation-listing-heading">
|
||||
<h1 className="wp-heading-inline">{__('Automations', 'mailpoet')}</h1>
|
||||
<Button
|
||||
href={MailPoet.urls.automationTemplates}
|
||||
icon={plusIcon}
|
||||
variant="primary"
|
||||
className="mailpoet-add-new-button"
|
||||
>
|
||||
{__('New automation', 'mailpoet')}
|
||||
</Button>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
|
||||
export function AutomationListing(): JSX.Element {
|
||||
const history = useHistory();
|
||||
const location = useLocation();
|
||||
@ -142,19 +159,7 @@ export function AutomationListing(): JSX.Element {
|
||||
}}
|
||||
totalRows={filteredWorkflows.length}
|
||||
query={Object.fromEntries(pageSearch)}
|
||||
hasSearch
|
||||
showMenu={false}
|
||||
actions={[
|
||||
<Search
|
||||
className="mailpoet-automation-listing-search"
|
||||
allowFreeTextSearch
|
||||
inlineTags
|
||||
key="search"
|
||||
type="custom"
|
||||
disabled={!workflows}
|
||||
autocompleter={{}}
|
||||
/>,
|
||||
]}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
@ -32,7 +32,7 @@ export function* duplicateWorkflow(workflow: Workflow) {
|
||||
});
|
||||
|
||||
void createSuccessNotice(
|
||||
// translators: %s is the workflow name
|
||||
// translators: %s is the automation name
|
||||
sprintf(__('Automation "%s" was duplicated.', 'mailpoet'), workflow.name),
|
||||
);
|
||||
|
||||
@ -83,7 +83,11 @@ export function* restoreWorkflow(workflow: Workflow, status: WorkflowStatus) {
|
||||
void createSuccessNotice(message, {
|
||||
__unstableHTML: (
|
||||
<p>
|
||||
{message} <EditWorkflow workflow={workflow} label="Edit Workflow" />
|
||||
{message}{' '}
|
||||
<EditWorkflow
|
||||
workflow={workflow}
|
||||
label={__('Edit automation', 'mailpoet')}
|
||||
/>
|
||||
</p>
|
||||
),
|
||||
});
|
||||
|
@ -47,7 +47,7 @@ export function WorkflowListingNotices(): JSX.Element {
|
||||
if (workflowDeleted) {
|
||||
return (
|
||||
<Notice type="success" closable timeout={false}>
|
||||
<p>{__('1 workflow moved to the Trash.', 'mailpoet')}</p>
|
||||
<p>{__('1 automation moved to the Trash.', 'mailpoet')}</p>
|
||||
</Notice>
|
||||
);
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
export enum WorkflowStatus {
|
||||
ACTIVE = 'active',
|
||||
INACTIVE = 'inactive',
|
||||
DRAFT = 'draft',
|
||||
TRASH = 'trash',
|
||||
// @ToDo: Needs to be aligned with MAILPOET-4731
|
||||
DEACTIVATING = 'deactivating',
|
||||
}
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
export function Onboarding(): JSX.Element {
|
||||
return (
|
||||
<div className="mailpoet-automation onboarding">
|
||||
<img src="" alt="" />
|
||||
<h1>{__('Scale your business with advanced automations', 'mailpoet')}</h1>
|
||||
<p>
|
||||
{__(
|
||||
'Automated workflow allows you to set up a chain of interactions with your subscribers with less efforts. You control all the flow with a visual scheme and a set of goals. Try it!',
|
||||
'mailpoet',
|
||||
)}
|
||||
</p>
|
||||
<a href="#" className="button secondary">
|
||||
{__('Learn more', 'mailpoet')}
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
import { useState } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { MailPoet } from '../../mailpoet';
|
||||
|
||||
export function BuildYourOwnSection(): JSX.Element {
|
||||
const [itemOpen, setItemOpen] = useState('start-with-a-trigger');
|
||||
const list: { slug: string; title: string; text: string; image: string }[] = [
|
||||
{
|
||||
slug: 'start-with-a-trigger',
|
||||
title: __('Start with a trigger', 'mailpoet'),
|
||||
text: __(
|
||||
'Deliver relevant messages to your customers based on who they are and how they interact with your business.',
|
||||
'mailpoet',
|
||||
),
|
||||
image: `${MailPoet.cdnUrl}automation/sections/start-with-a-trigger.png`,
|
||||
},
|
||||
{
|
||||
slug: 'customize-your-workflow',
|
||||
title: __('Customize your automation', 'mailpoet'),
|
||||
text: __(
|
||||
'Choose steps and create a custom journey to best suit your needs.',
|
||||
'mailpoet',
|
||||
),
|
||||
image: `${MailPoet.cdnUrl}automation/sections/customize-your-workflow.png`,
|
||||
},
|
||||
{
|
||||
slug: 'design-your-email',
|
||||
title: __('Design your email', 'mailpoet'),
|
||||
text: __(
|
||||
'Modify one of our pre-made email templates or create your own design.',
|
||||
'mailpoet',
|
||||
),
|
||||
image: `${MailPoet.cdnUrl}automation/sections/design-your-email.png`,
|
||||
},
|
||||
{
|
||||
slug: 'start-engaging',
|
||||
title: __('Start engaging', 'mailpoet'),
|
||||
text: __(
|
||||
'Activate the automation and start engaging with your customers as they interact with your business.',
|
||||
'mailpoet',
|
||||
),
|
||||
image: `${MailPoet.cdnUrl}automation/sections/start-engaging.png`,
|
||||
},
|
||||
];
|
||||
|
||||
const selectedItem = list.filter((item) => item.slug === itemOpen)[0];
|
||||
|
||||
return (
|
||||
<section className="mailpoet-automation-section mailpoet-automation-white-background">
|
||||
<div className="mailpoet-automation-section-content mailpoet-section-build-your-own">
|
||||
<div>
|
||||
<h2>{__('Build your own automations', 'mailpoet')}</h2>
|
||||
<p>
|
||||
{__(
|
||||
'Create customized email sequences with our new automation editor.',
|
||||
'mailpoet',
|
||||
)}
|
||||
</p>
|
||||
<ol>
|
||||
{list.map((item, index) => (
|
||||
<li
|
||||
key={item.slug}
|
||||
className={itemOpen === item.slug ? 'open' : ''}
|
||||
>
|
||||
<div className="marker">
|
||||
{index < 10 ? `0${index + 1}` : index + 1}
|
||||
</div>
|
||||
<div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setItemOpen(item.slug)}
|
||||
className="mailpoet-section-build-list-button"
|
||||
>
|
||||
{item.title}
|
||||
</button>
|
||||
<p>{item.text}</p>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</div>
|
||||
<img src={selectedItem.image} alt={selectedItem.title} />
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
43
mailpoet/assets/js/src/automation/sections/hero-section.tsx
Normal file
43
mailpoet/assets/js/src/automation/sections/hero-section.tsx
Normal file
@ -0,0 +1,43 @@
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { Hooks } from '../../hooks';
|
||||
import { OptionButton } from '../components/option-button';
|
||||
import { MailPoet } from '../../mailpoet';
|
||||
import { StepMoreControlsType } from '../types/filters';
|
||||
|
||||
export function HeroSection(): JSX.Element {
|
||||
const buttonControls: StepMoreControlsType = Hooks.applyFilters(
|
||||
'mailpoet.automation.hero.actions',
|
||||
{},
|
||||
);
|
||||
return (
|
||||
<section className="mailpoet-automation-section mailpoet-automation-white-background">
|
||||
<div className="mailpoet-automation-section-content mailpoet-automation-section-hero">
|
||||
<div>
|
||||
<span className="mailpoet-automation-preheading">
|
||||
{__('Automations', 'mailpoet')}
|
||||
</span>
|
||||
<h1>{__('Better engagement begins with automation', 'mailpoet')}</h1>
|
||||
<p>
|
||||
{__(
|
||||
'Send emails that inform, reward, and engage your audience through powerful segmenting, scheduling, and design tools.',
|
||||
'mailpoet',
|
||||
)}
|
||||
</p>
|
||||
|
||||
<OptionButton
|
||||
variant="primary"
|
||||
onClick={() => {
|
||||
window.location.href = MailPoet.urls.automationTemplates;
|
||||
}}
|
||||
title={__('Start with a template', 'mailpoet')}
|
||||
controls={buttonControls}
|
||||
/>
|
||||
</div>
|
||||
<img
|
||||
src={`${MailPoet.cdnUrl}automation/sections/hero.png`}
|
||||
alt={__('Welcome', 'mailpoet')}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
3
mailpoet/assets/js/src/automation/sections/index.tsx
Normal file
3
mailpoet/assets/js/src/automation/sections/index.tsx
Normal file
@ -0,0 +1,3 @@
|
||||
export { HeroSection } from './hero-section';
|
||||
export { TemplatesSection } from './templates-section';
|
||||
export { BuildYourOwnSection } from './build-your-own-section';
|
@ -0,0 +1,35 @@
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { Button } from '@wordpress/components';
|
||||
import { MailPoet } from '../../mailpoet';
|
||||
import { workflowTemplates } from '../templates/config';
|
||||
import { TemplateListItem } from '../templates/components/template-list-item';
|
||||
|
||||
export function TemplatesSection(): JSX.Element {
|
||||
const templates = workflowTemplates.slice(0, 3);
|
||||
|
||||
return (
|
||||
<section className="mailpoet-automation-section">
|
||||
<div className="mailpoet-automation-section-content mailpoet-section-templates">
|
||||
<h2>{__('Explore essentials', 'mailpoet')}</h2>
|
||||
<p>
|
||||
{__(
|
||||
'Choose from our list of pre-made templates and make it your own.',
|
||||
'mailpoet',
|
||||
)}
|
||||
</p>
|
||||
<ul className="mailpoet-section-template-list">
|
||||
{templates.map((template) => (
|
||||
<TemplateListItem
|
||||
key={template.slug}
|
||||
template={template}
|
||||
heading="h3"
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
<Button variant="link" href={MailPoet.urls.automationTemplates}>
|
||||
{__('Browse all templates →', 'mailpoet')}
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
@ -5,6 +5,7 @@ import { Hooks } from 'wp-js-hooks';
|
||||
import { Icon, plusCircleFilled } from '@wordpress/icons';
|
||||
import { PremiumModal } from '../../../common/premium_modal';
|
||||
import { Notice } from '../../../notices/notice';
|
||||
import { FromScratchHookType } from '../../types/filters';
|
||||
|
||||
type FromScratchPremiumModalProps = {
|
||||
showModal: boolean;
|
||||
@ -34,7 +35,7 @@ function FromScratchPremiumModal({
|
||||
}
|
||||
|
||||
function fromScratchHook(callback: () => void, errorHandler: Dispatch<string>) {
|
||||
const fromScratchCallback = Hooks.applyFilters(
|
||||
const fromScratchCallback: FromScratchHookType = Hooks.applyFilters(
|
||||
'mailpoet.automation.templates.from_scratch_button',
|
||||
() => {
|
||||
callback();
|
||||
|
@ -8,9 +8,11 @@ import { Notice } from '../../../notices/notice';
|
||||
|
||||
type TemplateListItemProps = {
|
||||
template: WorkflowTemplate;
|
||||
heading?: 'h2' | 'h3';
|
||||
};
|
||||
export function TemplateListItem({
|
||||
template,
|
||||
heading,
|
||||
}: TemplateListItemProps): JSX.Element {
|
||||
const [createWorkflowFromTemplate, { loading, error, data }] = useMutation(
|
||||
'workflows/create-from-template',
|
||||
@ -35,12 +37,13 @@ export function TemplateListItem({
|
||||
<p>
|
||||
{error.data
|
||||
? error.data.message
|
||||
: __('Could not create workflow.', 'mailpoet')}
|
||||
: __('Could not create automation.', 'mailpoet')}
|
||||
</p>
|
||||
</Notice>
|
||||
);
|
||||
}
|
||||
|
||||
const headingTag = heading ?? 'h2';
|
||||
return (
|
||||
<li className="mailpoet-automation-template-list-item">
|
||||
{notice}
|
||||
@ -50,7 +53,9 @@ export function TemplateListItem({
|
||||
void createWorkflowFromTemplate();
|
||||
}}
|
||||
>
|
||||
<h2>{template.name} →</h2>
|
||||
{headingTag === 'h3' && <h3>{template.name} →</h3>}
|
||||
{headingTag === 'h2' && <h2>{template.name} →</h2>}
|
||||
|
||||
<p>{template.description}</p>
|
||||
</Button>
|
||||
</li>
|
||||
|
@ -4,6 +4,7 @@ import { Flex } from '@wordpress/components';
|
||||
import { workflowTemplates } from './config';
|
||||
import { TemplateListItem } from './components/template-list-item';
|
||||
import { initializeApi } from '../api';
|
||||
import { registerTranslations } from '../i18n';
|
||||
import { TopBarWithBeamer } from '../../common/top_bar/top_bar';
|
||||
import {
|
||||
FromScratchButton,
|
||||
@ -37,6 +38,7 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
return;
|
||||
}
|
||||
|
||||
registerTranslations();
|
||||
initializeApi();
|
||||
ReactDOM.render(<Templates />, root);
|
||||
});
|
||||
|
40
mailpoet/assets/js/src/automation/types/filters.ts
Normal file
40
mailpoet/assets/js/src/automation/types/filters.ts
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* The types in this file document the expected return types of specific
|
||||
* filters.
|
||||
*/
|
||||
|
||||
import { Dispatch } from 'react';
|
||||
import { DropdownMenu } from '@wordpress/components';
|
||||
import { StoreConfig } from '@wordpress/data';
|
||||
import { Item } from '../editor/components/inserter/item';
|
||||
import { Step } from '../editor/components/workflow/types';
|
||||
import { State } from '../editor/store/types';
|
||||
|
||||
export type MoreControlType = {
|
||||
key: string;
|
||||
control: DropdownMenu.Control;
|
||||
slot: () => JSX.Element | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* APPLICATION HOOKS
|
||||
*/
|
||||
|
||||
// mailpoet.automation.workflow.step.more-controls
|
||||
// mailpoet.automation.hero.actions
|
||||
export type StepMoreControlsType = Record<string, MoreControlType>;
|
||||
|
||||
// mailpoet.automation.workflow.add_step_callback
|
||||
export type AddStepCallbackType = (item?: Item) => void;
|
||||
|
||||
// mailpoet.automation.workflow.render_step
|
||||
export type RenderStepType = (step: Step) => JSX.Element;
|
||||
|
||||
// mailpoet.automation.workflow.render_step_separator
|
||||
export type RenderStepSeparatorType = (step: Step) => JSX.Element;
|
||||
|
||||
// mailpoet.automation.editor.create_store
|
||||
export type EditorStoreConfigType = StoreConfig<State>;
|
||||
|
||||
// mailpoet.automation.templates.from_scratch_button
|
||||
export type FromScratchHookType = (errorHandler: Dispatch<string>) => void;
|
@ -1,6 +1,4 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { noop } from 'lodash';
|
||||
import { MailPoet } from 'mailpoet';
|
||||
import { Modal } from 'common/modal/modal';
|
||||
import {
|
||||
@ -99,7 +97,7 @@ function AuthorizeSenderDomainModal({
|
||||
if (res.data.ok) {
|
||||
// record verified, close the modal
|
||||
setErrorMessage('');
|
||||
setVerifiedSenderDomain(senderDomain);
|
||||
setVerifiedSenderDomain?.(senderDomain);
|
||||
onRequestClose();
|
||||
}
|
||||
} catch (e) {
|
||||
@ -185,14 +183,4 @@ function AuthorizeSenderDomainModal({
|
||||
);
|
||||
}
|
||||
|
||||
AuthorizeSenderDomainModal.propTypes = {
|
||||
senderDomain: PropTypes.string.isRequired,
|
||||
useModal: PropTypes.bool,
|
||||
};
|
||||
|
||||
AuthorizeSenderDomainModal.defaultProps = {
|
||||
setVerifiedSenderDomain: noop,
|
||||
useModal: true,
|
||||
};
|
||||
|
||||
export { AuthorizeSenderDomainModal };
|
||||
|
@ -1,7 +1,5 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import ReactStringReplace from 'react-string-replace';
|
||||
import PropTypes from 'prop-types';
|
||||
import { noop } from 'lodash';
|
||||
import moment from 'moment';
|
||||
import { MailPoet } from 'mailpoet';
|
||||
import { Modal } from 'common/modal/modal';
|
||||
@ -117,7 +115,7 @@ function AuthorizeSenderEmailModal({
|
||||
setCreateEmailApiResponse(null);
|
||||
setShowLoader(false);
|
||||
setConfirmEmailApiResponse(true);
|
||||
setAuthorizedAddress(senderEmailAddress);
|
||||
setAuthorizedAddress?.(senderEmailAddress);
|
||||
removeUnauthorizedEmailNotices();
|
||||
})
|
||||
.catch(() => {
|
||||
@ -238,14 +236,4 @@ function AuthorizeSenderEmailModal({
|
||||
);
|
||||
}
|
||||
|
||||
AuthorizeSenderEmailModal.propTypes = {
|
||||
senderEmail: PropTypes.string.isRequired,
|
||||
useModal: PropTypes.bool,
|
||||
};
|
||||
|
||||
AuthorizeSenderEmailModal.defaultProps = {
|
||||
setAuthorizedAddress: noop,
|
||||
useModal: true,
|
||||
};
|
||||
|
||||
export { AuthorizeSenderEmailModal };
|
||||
|
@ -6,13 +6,13 @@ type Event = {
|
||||
name: string;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
export type TokenFieldProps = {
|
||||
id?: string;
|
||||
label?: string;
|
||||
name?: string;
|
||||
placeholder?: string;
|
||||
onChange: (event: Event) => void;
|
||||
selectedValues?: FormTokenField.Value[];
|
||||
selectedValues?: FormTokenField.Value[] | [];
|
||||
suggestedValues?: readonly string[];
|
||||
};
|
||||
|
||||
@ -24,7 +24,7 @@ export function TokenField({
|
||||
selectedValues,
|
||||
suggestedValues,
|
||||
onChange,
|
||||
}: Props) {
|
||||
}: TokenFieldProps) {
|
||||
const args = {
|
||||
id,
|
||||
label,
|
||||
|
@ -99,6 +99,7 @@ function SetFromAddressModal({ onRequestClose, setAuthorizedAddress }: Props) {
|
||||
>
|
||||
{showAuthorizedEmailModal && (
|
||||
<AuthorizeSenderEmailModal
|
||||
useModal
|
||||
senderEmail={address}
|
||||
onRequestClose={() => {
|
||||
setShowAuthorizedEmailModal(false);
|
||||
|
@ -1,7 +1,16 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { TokenField } from 'common/form/tokenField/tokenField';
|
||||
import { TokenFieldProps, TokenField } from 'common/form/tokenField/tokenField';
|
||||
import { FormTokenItem } from '../../automation/integrations/mailpoet/components/form-token-field';
|
||||
|
||||
function getItems(endpoint: string) {
|
||||
interface TokenFormFieldProps {
|
||||
onValueChange: TokenFieldProps['onChange'];
|
||||
item?: Record<string, FormTokenItem[]>;
|
||||
field: Omit<TokenFieldProps, 'id' | 'onChange' | 'selectedValues'> & {
|
||||
endpoint: string;
|
||||
getName: (item: FormTokenItem) => string;
|
||||
};
|
||||
}
|
||||
|
||||
function getItems(endpoint: string): FormTokenItem[] {
|
||||
let items = [];
|
||||
if (typeof window[`mailpoet_${endpoint}`] !== 'undefined') {
|
||||
items = window[`mailpoet_${endpoint}`];
|
||||
@ -10,12 +19,15 @@ function getItems(endpoint: string) {
|
||||
return items;
|
||||
}
|
||||
|
||||
function FormFieldTokenField(props) {
|
||||
const selectedValues = Array.isArray(props.item[props.field.name])
|
||||
? props.item[props.field.name].map((item) => props.field.getName(item))
|
||||
function FormFieldTokenField(props: TokenFormFieldProps) {
|
||||
const selectedValues: TokenFieldProps['selectedValues'] = Array.isArray(
|
||||
props.item[props.field.name],
|
||||
)
|
||||
? props.field.name &&
|
||||
props.item[props.field.name].map((item) => props.field.getName(item))
|
||||
: [];
|
||||
|
||||
let suggestedValues = [];
|
||||
let suggestedValues: readonly string[] = [];
|
||||
if (props.field.endpoint) {
|
||||
const items = getItems(String(props.field.endpoint));
|
||||
suggestedValues = items.map((item) => props.field.getName(item));
|
||||
@ -35,16 +47,4 @@ function FormFieldTokenField(props) {
|
||||
);
|
||||
}
|
||||
|
||||
FormFieldTokenField.propTypes = {
|
||||
onValueChange: PropTypes.func,
|
||||
item: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
||||
field: PropTypes.shape({
|
||||
name: PropTypes.string,
|
||||
label: PropTypes.string,
|
||||
suggestedValues: PropTypes.arrayOf(PropTypes.string),
|
||||
placeholder: PropTypes.string,
|
||||
getName: PropTypes.func,
|
||||
}).isRequired,
|
||||
};
|
||||
|
||||
export { FormFieldTokenField };
|
||||
|
@ -12,7 +12,23 @@ import { partial } from 'lodash';
|
||||
import PropTypes from 'prop-types';
|
||||
import { ColorGradientSettings } from '../components/color_gradient_settings';
|
||||
|
||||
function InputStylesSettings({ styles, onChange }) {
|
||||
type InputStyles = {
|
||||
fullWidth: boolean;
|
||||
inheritFromTheme: boolean;
|
||||
bold: boolean;
|
||||
backgroundColor: string;
|
||||
borderSize: number;
|
||||
borderRadius: number;
|
||||
borderColor: string;
|
||||
fontColor: string;
|
||||
};
|
||||
|
||||
type InputStylesSettingsProps = {
|
||||
styles: InputStyles;
|
||||
onChange: (styles: InputStyles) => void;
|
||||
};
|
||||
|
||||
function InputStylesSettings({ styles, onChange }: InputStylesSettingsProps) {
|
||||
const localStylesRef = useRef(styles);
|
||||
const localStyles = localStylesRef.current;
|
||||
|
||||
@ -132,6 +148,10 @@ function InputStylesSettings({ styles, onChange }) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since removal of propTypes for InputStylesSettings
|
||||
* Remove when TextInputEdit is converted to tsx
|
||||
*/
|
||||
export const inputStylesPropTypes = PropTypes.shape({
|
||||
fullWidth: PropTypes.bool.isRequired,
|
||||
inheritFromTheme: PropTypes.bool.isRequired,
|
||||
@ -142,9 +162,4 @@ export const inputStylesPropTypes = PropTypes.shape({
|
||||
borderColor: PropTypes.string,
|
||||
});
|
||||
|
||||
InputStylesSettings.propTypes = {
|
||||
styles: inputStylesPropTypes.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export { InputStylesSettings };
|
||||
|
@ -220,9 +220,9 @@ export function PlacementSettings({
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="form-editor-sidebar-heading">
|
||||
<p className="form-editor-sidebar-heading">
|
||||
{MailPoet.I18n.t('displayOnCategories')}
|
||||
</h3>
|
||||
</p>
|
||||
<div className="form-editor-placement-selection">
|
||||
<Selection
|
||||
dropDownParent={
|
||||
@ -278,9 +278,9 @@ export function PlacementSettings({
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="form-editor-sidebar-heading">
|
||||
<p className="form-editor-sidebar-heading">
|
||||
{MailPoet.I18n.t('displayOnTags')}
|
||||
</h3>
|
||||
</p>
|
||||
<div className="form-editor-placement-selection">
|
||||
<Selection
|
||||
dropDownParent={
|
||||
|
@ -6,7 +6,6 @@ import {
|
||||
SelectControl,
|
||||
} from '@wordpress/components';
|
||||
import { MailPoet } from 'mailpoet';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useDispatch, useSelect } from '@wordpress/data';
|
||||
import { partial } from 'lodash';
|
||||
import { HorizontalAlignment } from 'common/styles';
|
||||
@ -18,7 +17,12 @@ import { CloseButtonsSettings } from 'form_editor/components/close_button_settin
|
||||
import { formStyles as defaultFormStyles } from 'form_editor/store/defaults';
|
||||
import { FontFamilySettings } from '../font_family_settings';
|
||||
|
||||
function StylesSettingsPanel({ onToggle, isOpened }) {
|
||||
type StylesSettingsPanelProps = {
|
||||
onToggle: PanelBody.Props['onToggle'];
|
||||
isOpened: boolean;
|
||||
};
|
||||
|
||||
function StylesSettingsPanel({ onToggle, isOpened }: StylesSettingsPanelProps) {
|
||||
const { changeFormSettings } = useDispatch('mailpoet-form-editor');
|
||||
const settings = useSelect(
|
||||
(select) => select('mailpoet-form-editor').getFormSettings(),
|
||||
@ -165,9 +169,4 @@ function StylesSettingsPanel({ onToggle, isOpened }) {
|
||||
);
|
||||
}
|
||||
|
||||
StylesSettingsPanel.propTypes = {
|
||||
onToggle: PropTypes.func.isRequired,
|
||||
isOpened: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
export { StylesSettingsPanel };
|
||||
|
2
mailpoet/assets/js/src/global.d.ts
vendored
2
mailpoet/assets/js/src/global.d.ts
vendored
@ -136,8 +136,10 @@ interface Window {
|
||||
mailpoet_email_editor_tutorial_seen: number;
|
||||
mailpoet_email_editor_tutorial_url: string;
|
||||
mailpoet_deactivate_subscriber_after_inactive_days: string;
|
||||
mailpoet_current_site_title?: string;
|
||||
mailpoet_tags?: {
|
||||
id: number;
|
||||
name: string;
|
||||
}[];
|
||||
mailpoet_cdn_url: string;
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ export const MailPoet = {
|
||||
deactivateSubscriberAfterInactiveDays:
|
||||
window.mailpoet_deactivate_subscriber_after_inactive_days,
|
||||
tags: window.mailpoet_tags,
|
||||
cdnUrl: window.mailpoet_cdn_url,
|
||||
} as const;
|
||||
|
||||
declare global {
|
||||
|
@ -22,6 +22,6 @@
|
||||
}
|
||||
},
|
||||
"parent": ["woocommerce/checkout-contact-information-block"],
|
||||
"editorScript": "file:../../../dist/js/marketing_optin_block/marketing-optin-block.js",
|
||||
"editorStyle": "file:../../../dist/js/marketing_optin_block/marketing-optin-block.css"
|
||||
"editorScript": "file:./marketing-optin-block.js",
|
||||
"editorStyle": "file:./marketing-optin-block.css"
|
||||
}
|
||||
|
@ -21,11 +21,14 @@ function EmptyState(): JSX.Element {
|
||||
return (
|
||||
<Placeholder
|
||||
icon={<Icon icon={megaphone} />}
|
||||
label={__('marketing-opt-in-label', 'mailpoet')}
|
||||
label={__('Marketing opt-in', 'mailpoet')}
|
||||
className="wp-block-mailpoet-newsletter-block-placeholder"
|
||||
>
|
||||
<span className="wp-block-mailpoet-newsletter-block-placeholder__description">
|
||||
{__('marketing-opt-in-not-shown', 'mailpoet')}
|
||||
{__(
|
||||
'MailPoet marketing opt-in would be shown here if enabled. You can enable from the settings page.',
|
||||
'mailpoet',
|
||||
)}
|
||||
</span>
|
||||
<Button
|
||||
isPrimary
|
||||
@ -34,7 +37,7 @@ function EmptyState(): JSX.Element {
|
||||
rel="noopener noreferrer"
|
||||
className="wp-block-mailpoet-newsletter-block-placeholder__button"
|
||||
>
|
||||
{__('marketing-opt-in-enable', 'mailpoet')}
|
||||
{__('Enable opt-in for Checkout', 'mailpoet')}
|
||||
</Button>
|
||||
</Placeholder>
|
||||
);
|
||||
|
@ -6,6 +6,7 @@ import { MailPoet } from 'mailpoet';
|
||||
import { Selection } from 'form/fields/selection.jsx';
|
||||
import { FormFieldText } from 'form/fields/text.jsx';
|
||||
import { timeDelayValues } from 'newsletters/scheduling/common.jsx';
|
||||
import { Grid } from 'common/grid';
|
||||
|
||||
const defaultAfterTimeType = 'immediate';
|
||||
const defaultAfterTimeNumber = 1;
|
||||
@ -142,10 +143,15 @@ class EventScheduling extends Component {
|
||||
const { event } = this.props;
|
||||
return (
|
||||
<>
|
||||
<div className="mailpoet-grid-column mailpoet-flex">
|
||||
<h4> {MailPoet.I18n.t('whenToSendMail')} </h4>
|
||||
|
||||
<Grid.CenteredRow className="mailpoet-re-engagement-scheduling">
|
||||
{this.displayAfterTimeNumberField()}
|
||||
{this.displayAfterTimeTypeOptions()}
|
||||
</div>
|
||||
|
||||
{event.afterDelayText && <p>{event.afterDelayText}</p>}
|
||||
</Grid.CenteredRow>
|
||||
|
||||
<div className="mailpoet-form-errors" />
|
||||
<div className="mailpoet-gap" />
|
||||
{event.schedulingReadMoreLink && (
|
||||
@ -175,6 +181,7 @@ EventScheduling.propTypes = {
|
||||
onValueChange: PropTypes.func,
|
||||
event: PropTypes.shape({
|
||||
defaultAfterTimeType: PropTypes.string,
|
||||
afterDelayText: PropTypes.string,
|
||||
timeDelayValues: PropTypes.objectOf(
|
||||
PropTypes.shape({
|
||||
text: PropTypes.string,
|
||||
|
@ -77,7 +77,9 @@ class NewsletterNotificationComponent extends Component {
|
||||
/>
|
||||
|
||||
<Grid.Column align="center" className="mailpoet-schedule-email">
|
||||
<Heading level={4}>{MailPoet.I18n.t('selectFrequency')}</Heading>
|
||||
<Heading level={4}>
|
||||
{MailPoet.I18n.t('selectEventToSendPostNotificationEmail')}
|
||||
</Heading>
|
||||
|
||||
<NotificationScheduling
|
||||
item={this.state}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import _ from 'underscore';
|
||||
import { Component } from 'react';
|
||||
import { MailPoet } from 'mailpoet';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormFieldSelect as Select } from 'form/fields/select.jsx';
|
||||
import {
|
||||
@ -9,6 +10,7 @@ import {
|
||||
monthDayValues,
|
||||
nthWeekDayValues,
|
||||
} from 'newsletters/scheduling/common.jsx';
|
||||
import { Grid } from 'common/grid';
|
||||
|
||||
const intervalField = {
|
||||
name: 'intervalType',
|
||||
@ -123,12 +125,21 @@ class NotificationScheduling extends Component {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Select
|
||||
field={intervalField}
|
||||
item={this.getCurrentValue()}
|
||||
onValueChange={this.handleIntervalChange}
|
||||
automationId="newsletter_interval_type"
|
||||
/>
|
||||
<Grid.CenteredRow>
|
||||
<Select
|
||||
field={intervalField}
|
||||
item={this.getCurrentValue()}
|
||||
onValueChange={this.handleIntervalChange}
|
||||
automationId="newsletter_interval_type"
|
||||
/>
|
||||
{value.intervalType === 'immediately' && (
|
||||
<div>
|
||||
<p>
|
||||
{MailPoet.I18n.t('postNotificationNewsletterAfterValueText')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</Grid.CenteredRow>
|
||||
<div className="mailpoet-gap" />
|
||||
|
||||
<div className="mailpoet-grid-column mailpoet-flex">
|
||||
|
@ -9,6 +9,7 @@ export function EmailContent() {
|
||||
|
||||
if (!enabled) return null;
|
||||
const descriptionLines = t('emailContentDescription')
|
||||
.replace('[current_site_title]', window.mailpoet_current_site_title || '')
|
||||
.split('<br />')
|
||||
.filter((x) => x);
|
||||
return (
|
||||
|
@ -11,9 +11,12 @@ export * as ReactTooltip from 'react-tooltip';
|
||||
export * as ReactStringReplace from 'react-string-replace';
|
||||
export * as Slugify from 'slugify';
|
||||
export { TextControl as WordpressComponentsTextControl } from '@wordpress/components';
|
||||
export { __experimentalConfirmDialog as WordpressComponentsConfirmDialog } from '@wordpress/components';
|
||||
export { MenuItem as WordpressComponentsMenuItem } from '@wordpress/components';
|
||||
export * as WordPressData from '@wordpress/data';
|
||||
export * as WordPressUrl from '@wordpress/url';
|
||||
export * as WordPressI18n from '@wordpress/i18n';
|
||||
export * as WordPressIcons from '@wordpress/icons';
|
||||
|
||||
// assets
|
||||
export * as Automation from 'automation';
|
||||
|
@ -6,13 +6,24 @@ import { Button } from 'common/button/button';
|
||||
import { Heading } from 'common/typography/heading/heading';
|
||||
import { YesNo } from 'common/form/yesno/yesno';
|
||||
|
||||
const isNullOrUndefined = (value) => value === null || value === undefined;
|
||||
|
||||
function WelcomeWizardUsageTrackingStep({ loading, submitForm }) {
|
||||
const [state, setState] = useState({
|
||||
tracking: undefined,
|
||||
libs3rdParty: undefined,
|
||||
});
|
||||
const [submitted, setSubmitted] = useState(false);
|
||||
|
||||
function submit(event) {
|
||||
event.preventDefault();
|
||||
setSubmitted(true);
|
||||
if (
|
||||
isNullOrUndefined(state.libs3rdParty) ||
|
||||
isNullOrUndefined(state.tracking)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
submitForm(state.tracking, state.libs3rdParty);
|
||||
return false;
|
||||
@ -30,6 +41,7 @@ function WelcomeWizardUsageTrackingStep({ loading, submitForm }) {
|
||||
<div className="mailpoet-wizard-woocommerce-option">
|
||||
<div className="mailpoet-wizard-woocommerce-toggle">
|
||||
<YesNo
|
||||
showError={submitted && isNullOrUndefined(state.libs3rdParty)}
|
||||
onCheck={(value) => {
|
||||
const newState = {
|
||||
libs3rdParty: value,
|
||||
@ -79,6 +91,7 @@ function WelcomeWizardUsageTrackingStep({ loading, submitForm }) {
|
||||
<div className="mailpoet-wizard-woocommerce-option">
|
||||
<div className="mailpoet-wizard-woocommerce-toggle">
|
||||
<YesNo
|
||||
showError={submitted && isNullOrUndefined(state.tracking)}
|
||||
onCheck={(value) => {
|
||||
const newState = {
|
||||
tracking: value,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user