diff --git a/assets/css/admin.css b/assets/css/admin.css index cb011ea..8ee0123 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -133,7 +133,7 @@ align-items: center; display: flex; flex-wrap: wrap; - gap: 12px; + gap: 24px; margin-bottom: 8px; } @@ -170,17 +170,31 @@ background: #f0f0f1; border-radius: 3px; color: #50575e; - font-size: 11px; - letter-spacing: 0.5px; + font-size: 12px; + font-style: normal; + font-weight: 400; padding: 2px 8px; - text-transform: uppercase; + text-transform: lowercase; } .stellarwp-migration-card__description { color: #50575e; font-size: 12px; line-height: 1.5; + margin: 0 0 4px; +} + +.stellarwp-migration-card__details-link { + color: #2271b1; + display: inline-block; + font-size: 12px; margin: 0 0 16px; + text-decoration: none; +} + +.stellarwp-migration-card__details-link:hover { + color: #135e96; + text-decoration: underline; } .stellarwp-migration-card__separator { @@ -264,6 +278,18 @@ font-variant-numeric: tabular-nums; } +.stellarwp-migration-card__dot-separator { + color: #8c8f94; + font-size: 14px; + line-height: 1; +} + +.stellarwp-migration-card__total-items { + color: #646970; + font-size: 13px; + font-variant-numeric: tabular-nums; +} + /* Progress Bar */ .stellarwp-migration-progress { flex: 1; diff --git a/src/Admin/UI.php b/src/Admin/UI.php index ba39ba8..8a71377 100644 --- a/src/Admin/UI.php +++ b/src/Admin/UI.php @@ -200,7 +200,7 @@ private function get_migration_executions( string $migration_id ): array { * * @since 0.0.1 * - * @return array{tags: string[], show_completed: bool, show_non_applicable: bool} Parsed filters. + * @return array{tags: string[], show_completed: bool} Parsed filters. */ private function parse_filters(): array { $tags = $this->parse_tags_filter(); @@ -212,16 +212,15 @@ private function parse_filters(): array { * * @since 0.0.1 * - * @param array{tags: string[], show_completed: bool, show_non_applicable: bool} $filters Filters to apply. + * @param array{tags: string[], show_completed: bool} $filters Filters to apply. * - * @return array{tags: string[], show_completed: bool, show_non_applicable: bool} Filters to apply. + * @return array{tags: string[], show_completed: bool} Filters to apply. */ return apply_filters( "stellarwp_migrations_{$prefix}_filters", [ - 'tags' => $tags, - 'show_completed' => filter_input( INPUT_GET, 'show_completed', FILTER_SANITIZE_NUMBER_INT ) !== '0', - 'show_non_applicable' => ! empty( filter_input( INPUT_GET, 'show_non_applicable', FILTER_SANITIZE_NUMBER_INT ) ), + 'tags' => $tags, + 'show_completed' => filter_input( INPUT_GET, 'show_completed', FILTER_SANITIZE_NUMBER_INT ) !== '0', ] ); } @@ -268,20 +267,19 @@ private function parse_tags_filter(): array { * * @since 0.0.1 * - * @param array{tags: string[], show_completed: bool, show_non_applicable: bool} $filters Filters to apply. + * @param array{tags: string[], show_completed: bool} $filters Filters to apply. * * @return list Filtered migrations. */ private function get_filtered_migrations( array $filters ): array { - $show_completed = ! empty( $filters['show_completed'] ); - $show_non_applicable = ! empty( $filters['show_non_applicable'] ); - $filter_tags = ! empty( $filters['tags'] ) ? (array) $filters['tags'] : []; + $show_completed = ! empty( $filters['show_completed'] ); + $filter_tags = ! empty( $filters['tags'] ) ? (array) $filters['tags'] : []; $registry = Config::get_container()->get( Registry::class ); $migrations = $registry->filter( - static function ( Migration $migration ) use ( $show_completed, $show_non_applicable, $filter_tags ): bool { - if ( ! $show_non_applicable && $migration->get_status()->equals( Status::NOT_APPLICABLE() ) ) { + static function ( Migration $migration ) use ( $show_completed, $filter_tags ): bool { + if ( $migration->get_status()->equals( Status::NOT_APPLICABLE() ) ) { return false; } @@ -306,8 +304,8 @@ static function ( Migration $migration ) use ( $show_completed, $show_non_applic * * @since 0.0.1 * - * @param list $migrations Migrations to filter. - * @param array{tags: string[], show_completed: bool, show_non_applicable: bool} $filters Filters to apply. + * @param list $migrations Migrations to filter. + * @param array{tags: string[], show_completed: bool} $filters Filters to apply. * * @return list Filtered migrations. */ @@ -410,15 +408,14 @@ private function get_status_priority(): array { return apply_filters( "stellarwp_migrations_{$prefix}_status_priority", [ - Status::RUNNING()->getValue() => 1, - Status::FAILED()->getValue() => 2, - Status::PAUSED()->getValue() => 3, - Status::PENDING()->getValue() => 4, - Status::SCHEDULED()->getValue() => 5, - Status::CANCELED()->getValue() => 6, - Status::REVERTED()->getValue() => 7, - Status::COMPLETED()->getValue() => 8, - Status::NOT_APPLICABLE()->getValue() => 9, + Status::RUNNING()->getValue() => 1, + Status::FAILED()->getValue() => 2, + Status::PAUSED()->getValue() => 3, + Status::PENDING()->getValue() => 4, + Status::SCHEDULED()->getValue() => 5, + Status::CANCELED()->getValue() => 6, + Status::REVERTED()->getValue() => 7, + Status::COMPLETED()->getValue() => 8, ] ); } diff --git a/src/Enums/Status.php b/src/Enums/Status.php index b35506b..ec2100c 100644 --- a/src/Enums/Status.php +++ b/src/Enums/Status.php @@ -106,11 +106,11 @@ class Status extends Enum { public function get_label(): string { switch ( $this->getValue() ) { case self::PENDING: - return _x( 'Not started', 'Migration status', 'stellarwp-migrations' ); + return _x( 'Migration not started', 'Migration status', 'stellarwp-migrations' ); case self::RUNNING: return _x( 'Migration in progress', 'Migration status', 'stellarwp-migrations' ); case self::COMPLETED: - return _x( 'Completed', 'Migration status', 'stellarwp-migrations' ); + return _x( 'Completed successfully!', 'Migration status', 'stellarwp-migrations' ); case self::FAILED: return _x( 'Failed', 'Migration status', 'stellarwp-migrations' ); case self::NOT_APPLICABLE: @@ -122,7 +122,7 @@ public function get_label(): string { case self::SCHEDULED: return _x( 'Scheduled', 'Migration status', 'stellarwp-migrations' ); case self::REVERTED: - return _x( 'Reverted', 'Migration status', 'stellarwp-migrations' ); + return _x( 'Rolled back', 'Migration status', 'stellarwp-migrations' ); default: return _x( 'Unknown', 'Migration status', 'stellarwp-migrations' ); } diff --git a/src/views/components/migration-card.php b/src/views/components/migration-card.php index 4e265ec..bdccedf 100644 --- a/src/views/components/migration-card.php +++ b/src/views/components/migration-card.php @@ -15,7 +15,6 @@ use StellarWP\Migrations\Admin\Provider as Admin_Provider; use StellarWP\Migrations\Config; use StellarWP\Migrations\Contracts\Migration; -use StellarWP\Migrations\Enums\Status; use StellarWP\Migrations\Utilities\Migration_UI; if ( ! isset( $migration ) || ! $migration instanceof Migration ) { @@ -24,14 +23,11 @@ $migration_ui = new Migration_UI( $migration ); -$migration_id = $migration->get_id(); -$single_url = Admin_Provider::get_single_url( $migration_id ); -$migration_label = $migration->get_label(); -$description = $migration->get_description(); -$migration_tags = $migration->get_tags(); -$migration_status = $migration_ui->get_display_status(); -$status_value = $migration_status->getValue(); -$status_label = $migration_ui->get_display_status_label(); +$migration_id = $migration->get_id(); +$single_url = Admin_Provider::get_single_url( $migration_id ); +$migration_label = $migration->get_label(); +$description = $migration->get_description(); +$migration_tags = $migration->get_tags(); $template = Config::get_template_engine(); ?> @@ -48,42 +44,27 @@ +

-
- diff --git a/src/views/components/migration-status/completed.php b/src/views/components/migration-status/completed.php new file mode 100644 index 0000000..6e2959b --- /dev/null +++ b/src/views/components/migration-status/completed.php @@ -0,0 +1,48 @@ +get_display_status()->getValue(); +$status_label = $migration_ui->get_display_status_label(); + +$template = Config::get_template_engine(); +?> +
+ + + + + template( + 'components/progress-text', + [ + 'migration' => $migration, + 'migration_ui' => $migration_ui, + ] + ); + ?> +
diff --git a/src/views/components/migration-status/failed.php b/src/views/components/migration-status/failed.php new file mode 100644 index 0000000..0a6479b --- /dev/null +++ b/src/views/components/migration-status/failed.php @@ -0,0 +1,48 @@ +get_display_status()->getValue(); +$status_label = $migration_ui->get_display_status_label(); + +$template = Config::get_template_engine(); +?> +
+ + + + + template( + 'components/progress-text', + [ + 'migration' => $migration, + 'migration_ui' => $migration_ui, + ] + ); + ?> +
diff --git a/src/views/components/migration-status/pending.php b/src/views/components/migration-status/pending.php new file mode 100644 index 0000000..f2d524f --- /dev/null +++ b/src/views/components/migration-status/pending.php @@ -0,0 +1,49 @@ +get_display_status()->getValue(); +$status_label = $migration_ui->get_display_status_label(); + +?> +
+ + + + + · + + + get_total_items(); + printf( + /* translators: %s: total number of items */ + esc_html( _n( '%s total item', '%s total items', $total_items, 'stellarwp-migrations' ) ), + esc_html( number_format_i18n( $total_items ) ) + ); + ?> + +
diff --git a/src/views/components/migration-status/reverted.php b/src/views/components/migration-status/reverted.php new file mode 100644 index 0000000..d3b107a --- /dev/null +++ b/src/views/components/migration-status/reverted.php @@ -0,0 +1,48 @@ +get_display_status()->getValue(); +$status_label = $migration_ui->get_display_status_label(); + +$template = Config::get_template_engine(); +?> +
+ + + + + template( + 'components/progress-text', + [ + 'migration' => $migration, + 'migration_ui' => $migration_ui, + ] + ); + ?> +
diff --git a/src/views/components/migration-status/running.php b/src/views/components/migration-status/running.php new file mode 100644 index 0000000..c05ef71 --- /dev/null +++ b/src/views/components/migration-status/running.php @@ -0,0 +1,58 @@ +get_display_status()->getValue(); +$status_label = $migration_ui->get_display_status_label(); + +$template = Config::get_template_engine(); +?> +
+ + + + + template( + 'components/progress-text', + [ + 'migration' => $migration, + 'migration_ui' => $migration_ui, + ] + ); + ?> +
+ +template( + 'components/progress-bar', + [ + 'migration' => $migration, + 'migration_ui' => $migration_ui, + ] +); +?> diff --git a/src/views/components/migration-status/scheduled.php b/src/views/components/migration-status/scheduled.php new file mode 100644 index 0000000..6ce3ef0 --- /dev/null +++ b/src/views/components/migration-status/scheduled.php @@ -0,0 +1,48 @@ +get_display_status()->getValue(); +$status_label = $migration_ui->get_display_status_label(); + +$template = Config::get_template_engine(); +?> +
+ + + + + template( + 'components/progress-text', + [ + 'migration' => $migration, + 'migration_ui' => $migration_ui, + ] + ); + ?> +
diff --git a/src/views/components/progress-bar.php b/src/views/components/progress-bar.php index 16fe7c3..336cd2c 100644 --- a/src/views/components/progress-bar.php +++ b/src/views/components/progress-bar.php @@ -14,6 +14,7 @@ defined( 'ABSPATH' ) || exit; use StellarWP\Migrations\Contracts\Migration; +use StellarWP\Migrations\Enums\Status; use StellarWP\Migrations\Utilities\Migration_UI; if ( @@ -27,8 +28,16 @@ $latest_execution = $migration->get_latest_execution(); -$total_items = $latest_execution ? $latest_execution->get_items_total() : $migration->get_total_items(); -$items_processed = $latest_execution ? $latest_execution->get_items_processed() : 0; +if ( + ! $latest_execution + // Only show progress bar for running migrations. + || ! $latest_execution->get_status()->equals( Status::RUNNING() ) +) { + return; +} + +$total_items = $latest_execution->get_items_total(); +$items_processed = $latest_execution->get_items_processed(); $status_value = $migration_ui->get_display_status()->getValue(); // Calculate progress percentage. diff --git a/src/views/list.php b/src/views/list.php index 5082b24..57c0569 100644 --- a/src/views/list.php +++ b/src/views/list.php @@ -9,7 +9,7 @@ * * @var list $migrations List of migrations objects. * @var list $all_tags All available tags. - * @var array{tags: list, show_completed: bool, show_non_applicable: bool} $filters Current filter values. + * @var array{tags: list, show_completed: bool} $filters Current filter values. * @var string $rest_base_url REST API base URL. * @var array $additional_params Additional query parameters to preserve. */ @@ -62,7 +62,7 @@ class="stellarwp-migrations-select2" - + @@ -79,16 +79,6 @@ class="stellarwp-migrations-select2" /> - diff --git a/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_empty_list_when_no_migrations__0.snapshot.html b/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_empty_list_when_no_migrations__0.snapshot.html index 6d3c3ad..6c5100a 100644 --- a/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_empty_list_when_no_migrations__0.snapshot.html +++ b/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_empty_list_when_no_migrations__0.snapshot.html @@ -21,14 +21,6 @@ checked='checked' onchange="this.form.submit();" /> Show Completed - diff --git a/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_list_with_migrations__0.snapshot.html b/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_list_with_migrations__0.snapshot.html index b499326..3608eea 100644 --- a/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_list_with_migrations__0.snapshot.html +++ b/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_list_with_migrations__0.snapshot.html @@ -37,14 +37,6 @@ checked='checked' onchange="this.form.submit();" /> Show Completed - @@ -56,35 +48,27 @@

Simple Migration

+

This is a simple migration that runs a single batch.

+ + + View Details → + +
+
@@ -116,35 +101,27 @@

Multi Batch Migration

+

This migration runs multiple batches to complete.

+ + + View Details → + +
+
@@ -180,35 +158,27 @@

test

+

A migration with tags for testing tag-based filtering.

+ + + View Details → + +
+ diff --git a/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_list_with_single_migration__0.snapshot.html b/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_list_with_single_migration__0.snapshot.html index 8c3c063..ae3b95d 100644 --- a/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_list_with_single_migration__0.snapshot.html +++ b/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_list_with_single_migration__0.snapshot.html @@ -21,14 +21,6 @@ checked='checked' onchange="this.form.submit();" /> Show Completed - @@ -40,35 +32,27 @@

Simple Migration

+

This is a simple migration that runs a single batch.

+ + + View Details → + +
+ diff --git a/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_single_multi_batch_migration__0.snapshot.html b/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_single_multi_batch_migration__0.snapshot.html index 790ee25..ffc7fb5 100644 --- a/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_single_multi_batch_migration__0.snapshot.html +++ b/tests/wpunit/Admin/__snapshots__/UI_Test__it_should_render_single_multi_batch_migration__0.snapshot.html @@ -10,29 +10,14 @@

- Not started + Migration not started 0 / 3
-
-
-
-
-
-
+