Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVA-157 Conditional Endpoint Disabling #2101

Merged
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
Expand Up @@ -483,33 +483,20 @@ public function get_endpoint_details() {
];

// Setup queue counts only on that endpoint type.
if (
static::$type !== 'queue'
|| ! isset( $this->trigger )
) {
/**
* Filters the integration endpoint details.
*
* @since TBD Migrated to Common from Event Automator
*
* @param array<string,array> $endpoint An array of the integration endpoint details.
* @param Abstract_REST_Endpoint $this An instance of the endpoint.
*/
return apply_filters( "tec_event_automator_{$api_id}_endpoint_details", $endpoint, $this );
if ( static::$type === 'queue' && isset( $this->trigger ) ) {
$endpoint_queue = (array) $this->trigger->get_queue();
pattihis marked this conversation as resolved.
Show resolved Hide resolved
$endpoint['count'] = empty( $endpoint_queue ) ? 0 : count( $endpoint_queue );
}

$endpoint_queue = (array) $this->trigger->get_queue();
$endpoint['count'] = empty( $endpoint_queue ) ? 0 : count( $endpoint_queue );

/**
* Filters the integation queue type endpoint details.
* Filters the integration endpoint details.
*
* @since TBD Migrated to Common from Event Automator
*
* @param array<string,array> $endpoint An array of the integration endpoint details.
* @param Abstract_REST_Endpoint $this An instance of the endpoint.
*/
return apply_filters( "tec_event_automator_{$api_id}_queue_endpoint_details", $endpoint, $this );
return apply_filters( "tec_event_automator_{$api_id}_endpoint_details", $endpoint, $this );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to deprecate the old filter in case of 3rd party usage? cc @jesseeproductions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being that the @since is TBD doesn't that mean this is a new filter. Not in production, yet?

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ class Action_Endpoints {
* @param Abstract_REST_Endpoint $this An instance of the endpoint.
*/
public function filter_details( $endpoint, $endpoint_obj ) {
if ( $endpoint_obj->get_id() !== 'create_events' ) {
return $endpoint;
if ( in_array( $endpoint_obj->get_id(), [ 'new_events', 'updated_events', 'canceled_events', 'create_events' ], true ) ) {
if ( ! class_exists( 'Tribe__Events__REST__V1__Validator__Base', false ) ) {
// Disable if Tribe__Events__REST__V1__Validator__Base class does not exist.
$endpoint['missing_dependency'] = true;
$endpoint['dependents'] = ['tec'];
pattihis marked this conversation as resolved.
Show resolved Hide resolved
pattihis marked this conversation as resolved.
Show resolved Hide resolved
pattihis marked this conversation as resolved.
Show resolved Hide resolved
}
} elseif ( in_array( $endpoint_obj->get_id(), [ 'attendees', 'updated_attendees', 'checkin', 'orders', 'refunded_orders' ], true ) ) {
if ( ! class_exists( 'Tribe__Tickets__REST__V1__Validator__Base', false ) ) {
// Disable if Tribe__Tickets__REST__V1__Validator__Base class does not exist.
$endpoint['missing_dependency'] = true;
$endpoint['dependents'] = ['et'];
pattihis marked this conversation as resolved.
Show resolved Hide resolved
pattihis marked this conversation as resolved.
Show resolved Hide resolved
pattihis marked this conversation as resolved.
Show resolved Hide resolved
}
}

if ( class_exists( 'Tribe__Events__REST__V1__Validator__Base', false ) ) {
return $endpoint;
}

// Disable if Tribe__Events__REST__V1__Validator__Base class does not exist.
$endpoint['missing_dependency'] = true;
$endpoint['dependents'] = $endpoint_obj->get_dependents();

return $endpoint;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,20 @@ class Action_Endpoints {
* @param Abstract_REST_Endpoint $this An instance of the endpoint.
*/
public function filter_details( $endpoint, $endpoint_obj ) {
if ( $endpoint_obj->get_id() !== 'create_events' ) {
return $endpoint;
if ( in_array( $endpoint_obj->get_id(), [ 'new_events', 'updated_events', 'canceled_events', 'create_events' ], true ) ) {
if ( ! class_exists( 'Tribe__Events__REST__V1__Validator__Base', false ) ) {
// Disable if Tribe__Events__REST__V1__Validator__Base class does not exist.
$endpoint['missing_dependency'] = true;
$endpoint['dependents'] = ['tec'];
pattihis marked this conversation as resolved.
Show resolved Hide resolved
pattihis marked this conversation as resolved.
Show resolved Hide resolved
pattihis marked this conversation as resolved.
Show resolved Hide resolved
}
} elseif ( in_array( $endpoint_obj->get_id(), [ 'attendees', 'updated_attendees', 'checkin', 'orders', 'refunded_orders' ], true ) ) {
if ( ! class_exists( 'Tribe__Tickets__REST__V1__Validator__Base', false ) ) {
// Disable if Tribe__Tickets__REST__V1__Validator__Base class does not exist.
$endpoint['missing_dependency'] = true;
$endpoint['dependents'] = ['et'];
pattihis marked this conversation as resolved.
Show resolved Hide resolved
pattihis marked this conversation as resolved.
Show resolved Hide resolved
pattihis marked this conversation as resolved.
Show resolved Hide resolved
}
}

if ( class_exists( 'Tribe__Events__REST__V1__Validator__Base', false ) ) {
return $endpoint;
}

// Disable if Tribe__Events__REST__V1__Validator__Base class does not exist.
$endpoint['missing_dependency'] = true;
$endpoint['dependents'] = $endpoint_obj->get_dependents();

return $endpoint;
}
}
4 changes: 2 additions & 2 deletions src/admin-views/dashboard/components/clear-button.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @var Url $url The URLs handler for the integration.
*/
// Only show for queue endpoints.
if ( $endpoint['type'] !== 'queue' || ! $endpoint['enabled'] ) {
if ( $endpoint['type'] !== 'queue' || ! $endpoint['enabled'] || $endpoint['missing_dependency'] ) {
return;
}

Expand All @@ -34,4 +34,4 @@ class="tec-settings-connection-endpoint-dashboard-details-action__button tec-set
>
<?php echo esc_html( $clear_label ); ?>
</button>
</div>
</div>
24 changes: 12 additions & 12 deletions src/admin-views/dashboard/endpoints/endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,24 @@ class="tec-automator-grid tec-automator-grid-row tec-automator-endpoint-dashboar
?>
<div class="tec-automator-grid-item tec-settings-connection-endpoint-dashboard-details__actions-wrap tec-common-integration-endpoint-details__actions-wrap">
<?php
$this->template( 'dashboard/components/clear-button', [
'endpoint' => $endpoint,
'manager' => $manager,
'url' => $url,
] );
$this->template( 'dashboard/components/status-button', [
'endpoint' => $endpoint,
'manager' => $manager,
'url' => $url,
] );

if ( $endpoint['missing_dependency'] ) {
$this->template( 'dashboard/components/missing-dependency', [
'endpoint' => $endpoint,
'manager' => $manager,
'url' => $url,
] );
} else {
pattihis marked this conversation as resolved.
Show resolved Hide resolved
$this->template( 'dashboard/components/clear-button', [
pattihis marked this conversation as resolved.
Show resolved Hide resolved
pattihis marked this conversation as resolved.
Show resolved Hide resolved
'endpoint' => $endpoint,
'manager' => $manager,
'url' => $url,
] );
pattihis marked this conversation as resolved.
Show resolved Hide resolved
$this->template( 'dashboard/components/status-button', [
pattihis marked this conversation as resolved.
Show resolved Hide resolved
pattihis marked this conversation as resolved.
Show resolved Hide resolved
'endpoint' => $endpoint,
'manager' => $manager,
'url' => $url,
] );
pattihis marked this conversation as resolved.
Show resolved Hide resolved
}
?>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions src/admin-views/zapier/dashboard/components/clear-button.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @var Url $url The URLs handler for the integration.
*/
// Only show for queue endpoints.
if ( $endpoint['type'] !== 'queue' || ! $endpoint['enabled'] ) {
if ( $endpoint['type'] !== 'queue' || ! $endpoint['enabled'] || $endpoint['missing_dependency'] ) {
return;
}

Expand All @@ -34,4 +34,4 @@ class="tec-settings-connection-endpoint-dashboard-details-action__button tec-set
>
<?php echo esc_html( $clear_label ); ?>
</button>
</div>
</div>
24 changes: 12 additions & 12 deletions src/admin-views/zapier/dashboard/endpoints/endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,24 @@ class="tec-automator-grid tec-automator-grid-row tec-automator-endpoint-dashboar
?>
<div class="tec-automator-grid-item tec-settings-connection-endpoint-dashboard-details__actions-wrap tec-common-zapier-details__actions-wrap">
<?php
$this->template( 'zapier/dashboard/components/clear-button', [
'endpoint' => $endpoint,
'manager' => $manager,
'url' => $url,
] );
$this->template( 'zapier/dashboard/components/status-button', [
'endpoint' => $endpoint,
'manager' => $manager,
'url' => $url,
] );

if ( $endpoint['missing_dependency'] ) {
$this->template( 'zapier/dashboard/components/missing-dependency', [
'endpoint' => $endpoint,
'manager' => $manager,
'url' => $url,
] );
} else {
pattihis marked this conversation as resolved.
Show resolved Hide resolved
$this->template( 'zapier/dashboard/components/clear-button', [
pattihis marked this conversation as resolved.
Show resolved Hide resolved
pattihis marked this conversation as resolved.
Show resolved Hide resolved
'endpoint' => $endpoint,
'manager' => $manager,
'url' => $url,
] );
pattihis marked this conversation as resolved.
Show resolved Hide resolved
$this->template( 'zapier/dashboard/components/status-button', [
pattihis marked this conversation as resolved.
Show resolved Hide resolved
pattihis marked this conversation as resolved.
Show resolved Hide resolved
'endpoint' => $endpoint,
'manager' => $manager,
'url' => $url,
] );
pattihis marked this conversation as resolved.
Show resolved Hide resolved
}
?>
</div>
</div>
</div>
Loading