Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global yoastIndexingData */
import PropTypes from "prop-types";
import { __ } from "@wordpress/i18n";
import { Transition } from "@headlessui/react";
Expand Down Expand Up @@ -31,6 +32,11 @@ export function ConfigurationIndexation( { indexingStateCallback, indexingState,
{ __( "Start SEO data optimization", "wordpress-seo" ) }
</button>;
}

// If the 'start indexation' button should be hidden, set the indexingState tot already_done.
// eslint-disable-next-line no-negated-condition
indexingState = ( ! yoastIndexingData.shouldShowIndexingButton ) ? "already_done" : indexingState;
Comment thread
FAMarfuaty marked this conversation as resolved.
Outdated

return <Indexation
preIndexingActions={ window.yoast.indexing.preIndexingActions }
indexingActions={ window.yoast.indexing.indexingActions }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export class Indexation extends Component {
this.settings = yoastIndexingData;

this.state = {
state: STATE.IDLE,
// If the 'start indexation' button should be hidden, set STATE tot DONE.
state: ( this.settings.shouldShowIndexingButton ) ? STATE.IDLE : STATE.COMPLETED,
processed: 0,
error: null,
amount: parseInt( this.settings.amount, 10 ),
Expand Down
22 changes: 17 additions & 5 deletions src/integrations/admin/first-time-configuration-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use WPSEO_Shortlinker;
use WPSEO_Utils;
use Yoast\WP\SEO\Conditionals\Admin_Conditional;
use Yoast\WP\SEO\Helpers\Indexing_Helper;
use Yoast\WP\SEO\Context\Meta_Tags_Context;
use Yoast\WP\SEO\Helpers\Options_Helper;
use Yoast\WP\SEO\Helpers\Product_Helper;
Expand Down Expand Up @@ -41,6 +42,13 @@ class First_Time_Configuration_Integration implements Integration_Interface {
*/
private $shortlinker;

/**
* Represents the indexing helper.
*
* @var Indexing_Helper
*/
protected $indexing_helper;

/**
* The options' helper.
*
Expand Down Expand Up @@ -82,6 +90,7 @@ public static function get_conditionals() {
* @param WPSEO_Admin_Asset_Manager $admin_asset_manager The admin asset manager.
* @param WPSEO_Addon_Manager $addon_manager The addon manager.
* @param WPSEO_Shortlinker $shortlinker The shortlinker.
* @param Indexing_Helper $indexing_helper The indexing helper.
* @param Options_Helper $options_helper The options helper.
* @param Social_Profiles_Helper $social_profiles_helper The social profile helper.
* @param Product_Helper $product_helper The product helper.
Expand All @@ -91,6 +100,7 @@ public function __construct(
WPSEO_Admin_Asset_Manager $admin_asset_manager,
WPSEO_Addon_Manager $addon_manager,
WPSEO_Shortlinker $shortlinker,
Indexing_Helper $indexing_helper,
Options_Helper $options_helper,
Social_Profiles_Helper $social_profiles_helper,
Product_Helper $product_helper,
Expand All @@ -99,6 +109,7 @@ public function __construct(
$this->admin_asset_manager = $admin_asset_manager;
$this->addon_manager = $addon_manager;
$this->shortlinker = $shortlinker;
$this->indexing_helper = $indexing_helper;
$this->options_helper = $options_helper;
$this->social_profiles_helper = $social_profiles_helper;
$this->product_helper = $product_helper;
Expand Down Expand Up @@ -144,15 +155,16 @@ public function enqueue_assets() {
$this->admin_asset_manager->enqueue_style( 'monorepo' );

$data = [
'disabled' => ! \YoastSEO()->helpers->indexable->should_index_indexables(),
'amount' => \YoastSEO()->helpers->indexing->get_filtered_unindexed_count(),
'firstTime' => ( \YoastSEO()->helpers->indexing->is_initial_indexing() === true ),
'errorMessage' => '',
'restApi' => [
'disabled' => ! \YoastSEO()->helpers->indexable->should_index_indexables(),
'amount' => \YoastSEO()->helpers->indexing->get_filtered_unindexed_count(),
'firstTime' => ( \YoastSEO()->helpers->indexing->is_initial_indexing() === true ),
'errorMessage' => '',
'restApi' => [
'root' => \esc_url_raw( \rest_url() ),
'indexing_endpoints' => $this->get_endpoints(),
'nonce' => \wp_create_nonce( 'wp_rest' ),
],
'shouldShowIndexingButton' => $this->indexing_helper->should_show_optimization_button(),
];

/**
Expand Down