Skip to content
34 changes: 30 additions & 4 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
align-items: center;
display: flex;
flex-wrap: wrap;
gap: 12px;
gap: 24px;
margin-bottom: 8px;
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
43 changes: 20 additions & 23 deletions src/Admin/UI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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',
]
);
}
Expand Down Expand Up @@ -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<Migration> 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;
}

Expand All @@ -306,8 +304,8 @@ static function ( Migration $migration ) use ( $show_completed, $show_non_applic
*
* @since 0.0.1
*
* @param list<Migration> $migrations Migrations to filter.
* @param array{tags: string[], show_completed: bool, show_non_applicable: bool} $filters Filters to apply.
* @param list<Migration> $migrations Migrations to filter.
* @param array{tags: string[], show_completed: bool} $filters Filters to apply.
*
* @return list<Migration> Filtered migrations.
*/
Expand Down Expand Up @@ -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,
]
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Enums/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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' );
}
Expand Down
58 changes: 20 additions & 38 deletions src/views/components/migration-card.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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();
?>
Expand All @@ -48,42 +44,27 @@
</div>
<?php endif; ?>
</div>

<p class="stellarwp-migration-card__description">
<?php echo esc_html( $description ); ?>
</p>
<hr class="stellarwp-migration-card__separator" />
<div class="stellarwp-migration-card__footer">
<div class="stellarwp-migration-card__status">
<span class="stellarwp-migration-card__status-label stellarwp-migration-card__status-label--<?php echo esc_attr( $status_value ); ?>">
<?php echo esc_html( $status_label ); ?>
</span>

<?php if ( ! $migration_status->equals( Status::NOT_APPLICABLE() ) ) : ?>
<?php
$template->template(
'components/progress-text',
[
'migration' => $migration,
'migration_ui' => $migration_ui,
]
);
?>
<?php endif; ?>
</div>
<a href="<?php echo esc_url( $single_url ); ?>" class="stellarwp-migration-card__details-link">
<?php esc_html_e( 'View Details', 'stellarwp-migrations' ); ?> &rarr;
</a>

<?php if ( ! $migration_status->equals( Status::NOT_APPLICABLE() ) ) : ?>
<?php
$template->template(
'components/progress-bar',
[
'migration' => $migration,
'migration_ui' => $migration_ui,
]
);
?>
<?php endif; ?>
<hr class="stellarwp-migration-card__separator" />

<div class="stellarwp-migration-card__footer">
<?php
$template->template(
'components/migration-status/' . $migration_ui->get_display_status()->getValue(),
[
'migration' => $migration,
'migration_ui' => $migration_ui,
]
);

$template->template(
'components/migration-actions',
[
Expand All @@ -93,5 +74,6 @@
);
?>
</div>

<div class="stellarwp-migration-card__message" style="display: none;"></div>
</div>
48 changes: 48 additions & 0 deletions src/views/components/migration-status/completed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* Migration Status Template — Completed.
*
* @since 0.0.1
* @version 0.0.1
*
* @package StellarWP\Migrations
*
* @var StellarWP\Migrations\Contracts\Migration $migration Migration object.
* @var StellarWP\Migrations\Utilities\Migration_UI $migration_ui UI helper object.
*/

defined( 'ABSPATH' ) || exit;

use StellarWP\Migrations\Config;
use StellarWP\Migrations\Contracts\Migration;
use StellarWP\Migrations\Utilities\Migration_UI;

if (
! isset( $migration )
|| ! isset( $migration_ui )
|| ! $migration instanceof Migration
|| ! $migration_ui instanceof Migration_UI
) {
return;
}

$status_value = $migration_ui->get_display_status()->getValue();
$status_label = $migration_ui->get_display_status_label();

$template = Config::get_template_engine();
?>
<div class="stellarwp-migration-card__status">
<span class="stellarwp-migration-card__status-label stellarwp-migration-card__status-label--<?php echo esc_attr( $status_value ); ?>">
<?php echo esc_html( $status_label ); ?>
</span>

<?php
$template->template(
'components/progress-text',
[
'migration' => $migration,
'migration_ui' => $migration_ui,
]
);
?>
</div>
48 changes: 48 additions & 0 deletions src/views/components/migration-status/failed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* Migration Status Template — Failed.
*
* @since 0.0.1
* @version 0.0.1
*
* @package StellarWP\Migrations
*
* @var StellarWP\Migrations\Contracts\Migration $migration Migration object.
* @var StellarWP\Migrations\Utilities\Migration_UI $migration_ui UI helper object.
*/

defined( 'ABSPATH' ) || exit;

use StellarWP\Migrations\Config;
use StellarWP\Migrations\Contracts\Migration;
use StellarWP\Migrations\Utilities\Migration_UI;

if (
! isset( $migration )
|| ! isset( $migration_ui )
|| ! $migration instanceof Migration
|| ! $migration_ui instanceof Migration_UI
) {
return;
}

$status_value = $migration_ui->get_display_status()->getValue();
$status_label = $migration_ui->get_display_status_label();

$template = Config::get_template_engine();
?>
<div class="stellarwp-migration-card__status">
<span class="stellarwp-migration-card__status-label stellarwp-migration-card__status-label--<?php echo esc_attr( $status_value ); ?>">
<?php echo esc_html( $status_label ); ?>
</span>

<?php
$template->template(
'components/progress-text',
[
'migration' => $migration,
'migration_ui' => $migration_ui,
]
);
?>
</div>
Loading
Loading