<?php
/**
 * Button to see changes of a deployment item.
 *
 * @package EaLab\WP_Deployer
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Button to see changes of a deployment item.
 *
 * @param string $item_full_uuid The full UUID of the deployment item.
 * @param array  $context The build context.
 *
 * @return string Markup.
 */
function deploy_sync_content__deployment_item__diff_button( string $item_full_uuid, array $context ): string {
	$button_label = esc_html__( 'See changes', 'deploy-sync-content' );

	$link_to_merge = add_query_arg(
		array(
			'deployment_bundle' => $context['bundle_id'] ?? 'unknown_bundle',
			'form_context'      => $context['form_context'] ?? 'unknown_context',
			'tab'               => 'diff',
			'uuid'              => rawurlencode( $item_full_uuid ),
		),
		admin_url( DEPLOY_SYNC_CONTENT__BASIC_URI )
	);

	return '<a href="' . esc_attr( $link_to_merge ) . '" class="btn btn-primary">' . $button_label . '</a>';
}
