Enhance check-in and check-out blocks with meta and post types#645
Enhance check-in and check-out blocks with meta and post types#645
Conversation
|
Caution Review failedThe pull request is closed. Warning CodeRabbit GitHub Action detectedThe repository is using both CodeRabbit Pro and CodeRabbit Open Source (via GitHub Actions), which is not recommended as it may lead to duplicate comments and extra noise. Please remove the CodeRabbit GitHub Action. Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds editor metadata and example payloads to checkin/checkout block manifests; replaces unconditional block-variation registration with i18n-enabled, post-type-gated registration that retries until the editor post type is available; updates built checkin assets to include wp-i18n; renames a PHP global for content model JSON paths. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant DOM as domReady
participant Data as wp.data (core/editor)
participant Blocks as wp.blocks.registerBlockVariation
Note over DOM,Blocks: Variation registration gated to "accommodation" post type
DOM->>Data: getCurrentPostType() / getEditedPostAttribute('slug') (for templates)
alt supported (accommodation / template slug contains accommodation)
DOM->>Blocks: registerBlockVariation(variationPayload)
Blocks-->>DOM: success
else not ready/unsupported
DOM->>DOM: start interval (every 100ms) + 5s timeout
loop until success or timeout
DOM->>Data: getCurrentPostType()
alt supported now
DOM->>Blocks: registerBlockVariation(variationPayload)
Blocks-->>DOM: success (stop interval)
else
DOM-->>DOM: wait 100ms
end
end
end
Note over Blocks: variationPayload includes i18n labels and nested `lsx-tour-operator/icons` and post-meta-bound paragraph
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
Suggested labels[Type] Enhancement, [Component] Block Inserter, Tour Operator, 2.1.0 Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (4 warnings)
✅ Passed checks (1 passed)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Uplevel your code reviews with CodeRabbit ProCodeRabbit ProIf you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects. |
There was a problem hiding this comment.
Files selected (2)
- src/blocks/checkin-time/index.js (1)
- src/blocks/checkout-time/index.js (1)
Files ignored due to filter (4)
- build/blocks/checkin-time/block.json
- build/blocks/checkout-time/block.json
- src/blocks/checkin-time/block.json
- src/blocks/checkout-time/block.json
Files not summarized due to errors (2)
- src/blocks/checkout-time/index.js (nothing obtained from openai)
- src/blocks/checkin-time/index.js (nothing obtained from openai)
Files not reviewed due to errors (2)
- src/blocks/checkin-time/index.js (no response)
- src/blocks/checkout-time/index.js (no response)
Review comments generated (0)
- Review: 0
- LGTM: 0
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/blocks/checkout-time/index.js (1)
132-143: Consider extracting the polling mechanism into a shared utility.The polling logic (100ms interval, 5s timeout) is duplicated between the check-in and check-out time blocks. While the current implementation works correctly, extracting this into a shared utility function would improve maintainability and ensure consistent behaviour across both blocks.
Example shared utility:
// In a shared utilities file export const registerBlockVariationWhenReady = ( checkFn, options = { interval: 100, timeout: 5000 } ) => { if (checkFn()) return; const interval = setInterval(() => { if (checkFn()) clearInterval(interval); }, options.interval); setTimeout(() => clearInterval(interval), options.timeout); };
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
build/blocks/checkin-time/block.jsonis excluded by!build/**build/blocks/checkin-time/index.asset.phpis excluded by!build/**build/blocks/checkin-time/index.jsis excluded by!build/**build/blocks/checkout-time/block.jsonis excluded by!build/**build/blocks/checkout-time/index.asset.phpis excluded by!build/**build/blocks/checkout-time/index.jsis excluded by!build/**
📒 Files selected for processing (4)
src/blocks/checkin-time/block.json(1 hunks)src/blocks/checkin-time/index.js(1 hunks)src/blocks/checkout-time/block.json(1 hunks)src/blocks/checkout-time/index.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (14)
src/**/block.json
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/**/block.json: Prefer block.json with server-side registration for blocks (avoid ad‑hoc registration)
Use the block namespacelsx-toin block names
Files:
src/blocks/checkout-time/block.jsonsrc/blocks/checkin-time/block.json
**/block.json
📄 CodeRabbit inference engine (.github/instructions/accessibility.instructions.md)
**/block.json: Provide meaningful block titles, descriptions, and keywords in block.json
Include editor-specific accessibility guidance in block descriptions (block.json)
Include accessibility considerations in block registration (e.g., supports, attributes)
**/block.json: In block.json, include required fields: name, title, description, category, keywords, and supports
Ensure accessible metadata in block.json: use clear, descriptive title and description
Provide reasonable default values for attributes in block.json
Use usesInnerBlocks in block.json only when the block actually contains InnerBlocks
Define block variations in block.json to provide common starting points
Ensure i18n and RTL safety for user-facing strings in block.json (including variations)
Files:
src/blocks/checkout-time/block.jsonsrc/blocks/checkin-time/block.json
{assets,src}/**/*
📄 CodeRabbit inference engine (.github/instructions/block-theme-structure.instructions.md)
Keep SCSS/JS/images source assets in assets/ or src/
Files:
src/blocks/checkout-time/block.jsonsrc/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.jssrc/blocks/checkin-time/block.json
src/**/*.{js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use @wordpress/eslint-plugin for JavaScript linting
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
src/**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/**/*.{js,jsx,ts,tsx}: Use useBlockProps() in block edit/save components when applicable
Use the text domaintour-operatorfor JS i18n calls
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{js,ts}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts}: Use const or let instead of var for variable declarations
Use default parameters for function arguments where appropriate
Use @wordpress/api-fetch (optionally with addQueryArgs) for REST API requests
Register blocks via registerBlockType using block metadata (imported from block.json), and localize title/description/keywords
Use wp.media for media selection in custom components/utilities when needed
Create and register custom data stores with @wordpress/data (createReduxStore + register), and structure actions/selectors clearly
Initialize frontend interactivity after DOMContentLoaded and implement ARIA attributes for toggles (aria-controls, aria-expanded)
Handle AJAX form submissions with fetch, proper loading states, and user notices; restore UI state in finally
Implement accessibility utilities like focus trapping and polite screen reader announcements for dynamic content
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts,jsx,tsx}: Prefer arrow functions for callbacks and inline handlers
Use object/array destructuring for cleaner code
Use template literals for string interpolation
Use async/await for promise handling with try/catch for errors
Use WordPress i18n APIs (__/_n/sprintf) with a consistent textdomain for all user-facing strings; include translator comments where needed
Use @wordpress/data dispatch/select for interacting with WP data stores (e.g., core/notices, core/editor)
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/js-ts.instructions.md)
**/*.{ts,tsx,js,jsx}: Debounce user inputs to prevent excessive processing
Avoid blocking the UI thread (prefer async/non-blocking operations)
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{js,mjs,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/performance.instructions.md)
Defer non-critical JavaScript and avoid synchronous blocking operations
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/review.instructions.md)
Internationalize user‑facing strings using WordPress i18n APIs
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{css,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Minimize CSS/JS payload size
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Lazy-load code and resources where possible
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{js,ts,tsx,jsx}
⚙️ CodeRabbit configuration file
**/*.{js,ts,tsx,jsx}: Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards and @wordpress/eslint-plugin rules.
- Ensure the code is well-documented with proper JSDoc comments.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features.
- Follow WordPress JavaScript coding standards and use WordPress script localization.
- Use WordPress script dependencies and enqueue properly.
- Ensure React/JSX best practices for blocks and modern JavaScript/TypeScript patterns.
- Implement proper error handling and loading states.
- Use WordPress components and design system where applicable.
- For Tour Operator: Focus on tour booking interfaces, search functionality, and tour display components.
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
src/blocks/**/*.{js,jsx,ts,tsx}
⚙️ CodeRabbit configuration file
src/blocks/**/*.{js,jsx,ts,tsx}: - Follow WordPress JavaScript coding standards and @wordpress/scripts configuration.
- Use WordPress components from @wordpress/components and design system.
- Implement proper React/JSX patterns for WordPress blocks.
- Ensure proper WordPress script dependencies and localization.
- Use WordPress data store patterns with @wordpress/data.
- Implement proper error boundaries and loading states.
- Follow modern JavaScript/TypeScript patterns with proper typing.
- Ensure accessibility in interactive block components.
- Use WordPress block editor APIs correctly (useBlockProps, InspectorControls, etc.).
- Implement proper block validation and save/edit functionality.
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
🧬 Code graph analysis (2)
src/blocks/checkout-time/index.js (1)
src/blocks/checkin-time/index.js (3)
wp(14-14)supportedPostTypes(17-17)checkAndRegister(20-130)
src/blocks/checkin-time/index.js (1)
src/blocks/checkout-time/index.js (3)
wp(14-14)supportedPostTypes(17-17)checkAndRegister(20-130)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: review
🔇 Additional comments (6)
src/blocks/checkin-time/block.json (2)
4-4: LGTM! Metadata enhancements align with requirements.The additions of
textdomain,description,icon,keywords, andexampleproperly enhance the block's discoverability and provide a clear inserter preview. These changes fulfill the block.json requirements from issue #644.Also applies to: 9-15, 16-43
5-5: Align block namespace or update guideline
All blocks currently uselsx-tour-operator/...but the coding guideline prescribeslsx-to/.... Renaming every block tolsx-tois a breaking change; alternatively, revise the guideline tolsx-tour-operator. Confirm which namespace should be standard.src/blocks/checkout-time/index.js (2)
1-9: LGTM! JSDoc and imports are correct.The file header accurately describes the Check Out Time block variation, and the i18n import is properly included for translatable strings.
Also applies to: 11-11
20-130: Well-implemented post-type gating and registration logic.The conditional registration based on post type is correctly implemented with proper editor state checking and fallback handling.
src/blocks/checkout-time/block.json (1)
4-4: LGTM! Metadata enhancements properly implemented.The checkout time block.json includes all required metadata fields with appropriate content. The example preview with "3:00 PM" effectively demonstrates the block's purpose in the inserter.
Also applies to: 9-15, 16-43
src/blocks/checkin-time/index.js (1)
20-130: LGTM! Registration logic is correctly implemented.The post-type gating and conditional registration logic properly restricts the block variation to accommodation post types, fulfilling the requirements from issue #644.
|
@tibiii please assign project details to both issues and PRs, make sure the meta is filled in properly. Also, process the coderabbit and copilot code review feedback. |
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the Check In Time and Check Out Time block variations by adding post-type-specific registration, improved metadata, and better visual consistency. The blocks now only appear when editing accommodation posts and feature enriched configuration for better discoverability.
Key changes:
- Added post-type-specific registration logic that restricts blocks to accommodation post types
- Enhanced block metadata with descriptions, keywords, and detailed examples for better editor experience
- Replaced static image icons with custom icon components for improved maintainability
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/blocks/checkout-time/index.js | Added post-type checking logic and switched from static image to custom icon component |
| src/blocks/checkout-time/block.json | Added metadata fields including description, keywords, and example configuration |
| src/blocks/checkin-time/index.js | Added post-type checking logic and switched from static image to custom icon component |
| src/blocks/checkin-time/block.json | Added metadata fields including description, keywords, and example configuration |
| build/blocks/checkout-time/index.js | Compiled build output with new webpack bundling structure |
| build/blocks/checkout-time/index.asset.php | Updated asset dependencies and version hash |
| build/blocks/checkout-time/block.json | Build copy of updated block configuration |
| build/blocks/checkin-time/index.js | Compiled build output with new webpack bundling structure |
| build/blocks/checkin-time/index.asset.php | Updated asset dependencies and version hash |
| build/blocks/checkin-time/block.json | Build copy of updated block configuration |
There was a problem hiding this comment.
Files selected (1)
- src/blocks/checkin-time/index.js (1)
Files not summarized due to errors (1)
- src/blocks/checkin-time/index.js (nothing obtained from openai)
Files not reviewed due to errors (1)
- src/blocks/checkin-time/index.js (no response)
Review comments generated (0)
- Review: 0
- LGTM: 0
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
build/blocks/checkin-time/index.asset.php(1 hunks)build/blocks/checkin-time/index.js(1 hunks)src/blocks/checkin-time/index.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
**/*.php
📄 CodeRabbit inference engine (.github/instructions/coding-standards.instructions.md)
**/*.php: PHP classes must use the Tour_Operator_ prefix with Pascal_Case
PHP functions must use the tour_operator_ prefix with snake_case
Variables should use snake_case (e.g., $tour_data, $destination_info)
Constants must use UPPER_SNAKE_CASE (e.g., TOUR_OPERATOR_VERSION)
Always sanitize input data (e.g., sanitize_text_field)
Validate all data before processing (e.g., type checks, ranges)
Escape all output (e.g., esc_html, wp_kses_post)
Use nonces for form submissions (e.g., wp_nonce_field)
Use $wpdb->prepare() for all SQL queries
Prefix all custom tables with $wpdb->prefix
Prefer WordPress database helper functions when possible
Prefix all hooks (actions/filters) with tour_operator_
Document all hooks with proper DocBlocks
Provide examples in hook documentation DocBlocks
One class per PHP file
All functions must have DocBlocks
Use @SInCE tags for version tracking in DocBlocks
Include @param and @return tags in DocBlocks
Use transients for temporary cached data
Minimize database queriesUse wp_enqueue_block_style and wp_register_style with proper dependencies when adding styles in WordPress
**/*.php: Use proper WordPress file headers with plugin/theme information
Use kebab-case for file names
Use snake_case for PHP function names
Prefix all functions, classes, and constants to avoid conflicts
Escape all output using appropriate WordPress functions (esc_html, esc_attr, esc_url, wp_kses_post)
Sanitize input immediately on receipt (e.g., sanitize_text_field, sanitize_email, esc_url_raw)
Use nonces for all forms and AJAX requests and verify with wp_verify_nonce
Check user capabilities (current_user_can) before privileged actions
Always use $wpdb->prepare for custom SQL queries
Prefer WordPress API functions (e.g., get_posts) over direct SQL queries
Internationalize strings using __, _e, _x, _n with a consistent text domain
For JavaScript strings, pass data via wp_localize_script and include nonces where needed
Use WordPress error handling: check is_wp_error, log...
Files:
build/blocks/checkin-time/index.asset.php
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/review.instructions.md)
Internationalize user‑facing strings using WordPress i18n APIs
Files:
build/blocks/checkin-time/index.asset.phpsrc/blocks/checkin-time/index.jsbuild/blocks/checkin-time/index.js
**/*.{php,html,jsx,tsx}
📄 CodeRabbit inference engine (.github/instructions/review.instructions.md)
Do not use inline CSS (no style attributes or inline style props)
Files:
build/blocks/checkin-time/index.asset.php
src/**/*.{js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use @wordpress/eslint-plugin for JavaScript linting
Files:
src/blocks/checkin-time/index.js
src/**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/**/*.{js,jsx,ts,tsx}: Use useBlockProps() in block edit/save components when applicable
Use the text domaintour-operatorfor JS i18n calls
Files:
src/blocks/checkin-time/index.js
{assets,src}/**/*
📄 CodeRabbit inference engine (.github/instructions/block-theme-structure.instructions.md)
Keep SCSS/JS/images source assets in assets/ or src/
Files:
src/blocks/checkin-time/index.js
**/*.{js,ts}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts}: Use const or let instead of var for variable declarations
Use default parameters for function arguments where appropriate
Use @wordpress/api-fetch (optionally with addQueryArgs) for REST API requests
Register blocks via registerBlockType using block metadata (imported from block.json), and localize title/description/keywords
Use wp.media for media selection in custom components/utilities when needed
Create and register custom data stores with @wordpress/data (createReduxStore + register), and structure actions/selectors clearly
Initialize frontend interactivity after DOMContentLoaded and implement ARIA attributes for toggles (aria-controls, aria-expanded)
Handle AJAX form submissions with fetch, proper loading states, and user notices; restore UI state in finally
Implement accessibility utilities like focus trapping and polite screen reader announcements for dynamic content
Files:
src/blocks/checkin-time/index.jsbuild/blocks/checkin-time/index.js
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts,jsx,tsx}: Prefer arrow functions for callbacks and inline handlers
Use object/array destructuring for cleaner code
Use template literals for string interpolation
Use async/await for promise handling with try/catch for errors
Use WordPress i18n APIs (__/_n/sprintf) with a consistent textdomain for all user-facing strings; include translator comments where needed
Use @wordpress/data dispatch/select for interacting with WP data stores (e.g., core/notices, core/editor)
Files:
src/blocks/checkin-time/index.jsbuild/blocks/checkin-time/index.js
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/js-ts.instructions.md)
**/*.{ts,tsx,js,jsx}: Debounce user inputs to prevent excessive processing
Avoid blocking the UI thread (prefer async/non-blocking operations)
Files:
src/blocks/checkin-time/index.jsbuild/blocks/checkin-time/index.js
**/*.{js,mjs,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/performance.instructions.md)
Defer non-critical JavaScript and avoid synchronous blocking operations
Files:
src/blocks/checkin-time/index.jsbuild/blocks/checkin-time/index.js
**/*.{css,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Minimize CSS/JS payload size
Files:
src/blocks/checkin-time/index.jsbuild/blocks/checkin-time/index.js
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Lazy-load code and resources where possible
Files:
src/blocks/checkin-time/index.jsbuild/blocks/checkin-time/index.js
🔇 Additional comments (1)
build/blocks/checkin-time/index.asset.php (1)
1-1: LGTM! Dependency and version updated correctly.The addition of the
wp-i18ndependency aligns with the internationalization work in the source block (where__is now used for translated strings), and the version hash has been properly updated to reflect the build change.Note: This is a generated build artifact. Ensure your build process consistently regenerates this file when source dependencies change.
There was a problem hiding this comment.
Files selected (2)
- src/blocks/checkin-time/index.js (1)
- src/blocks/checkout-time/index.js (1)
Files not summarized due to errors (2)
- src/blocks/checkout-time/index.js (nothing obtained from openai)
- src/blocks/checkin-time/index.js (nothing obtained from openai)
Files not reviewed due to errors (2)
- src/blocks/checkin-time/index.js (no response)
- src/blocks/checkout-time/index.js (no response)
Review comments generated (0)
- Review: 0
- LGTM: 0
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/blocks/checkin-time/index.js (1)
16-118: Localise the variation label everywhere.
metadata.nameand the preview text are still hard-coded, so the list view and inserter preview stay in English. Please reuse the translated label for these fields as well.- wp.blocks.registerBlockVariation('core/group', { + const variationLabel = __( 'Check in time', 'tour-operator' ); + + wp.blocks.registerBlockVariation('core/group', { name: 'lsx-tour-operator/checkin-time', - title: __('Check in time', 'tour-operator'), + title: variationLabel, @@ attributes: { metadata: { - name: 'Check in time', + name: variationLabel, }, @@ example: { attributes: { metadata: { - name: 'Check in time', + name: variationLabel, }, }, innerBlocks: [ [ 'core/group', {}, [ [ 'core/heading', { - content: 'Check in time', + content: variationLabel, level: 3, },As per coding guidelines.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
build/blocks/checkin-time/index.asset.phpis excluded by!build/**build/blocks/checkin-time/index.jsis excluded by!build/**build/blocks/checkout-time/index.asset.phpis excluded by!build/**build/blocks/checkout-time/index.jsis excluded by!build/**
📒 Files selected for processing (2)
src/blocks/checkin-time/index.js(1 hunks)src/blocks/checkout-time/index.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
src/**/*.{js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use @wordpress/eslint-plugin for JavaScript linting
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
src/**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/**/*.{js,jsx,ts,tsx}: Use useBlockProps() in block edit/save components when applicable
Use the text domaintour-operatorfor JS i18n calls
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
{assets,src}/**/*
📄 CodeRabbit inference engine (.github/instructions/block-theme-structure.instructions.md)
Keep SCSS/JS/images source assets in assets/ or src/
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{js,ts}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts}: Use const or let instead of var for variable declarations
Use default parameters for function arguments where appropriate
Use @wordpress/api-fetch (optionally with addQueryArgs) for REST API requests
Register blocks via registerBlockType using block metadata (imported from block.json), and localize title/description/keywords
Use wp.media for media selection in custom components/utilities when needed
Create and register custom data stores with @wordpress/data (createReduxStore + register), and structure actions/selectors clearly
Initialize frontend interactivity after DOMContentLoaded and implement ARIA attributes for toggles (aria-controls, aria-expanded)
Handle AJAX form submissions with fetch, proper loading states, and user notices; restore UI state in finally
Implement accessibility utilities like focus trapping and polite screen reader announcements for dynamic content
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts,jsx,tsx}: Prefer arrow functions for callbacks and inline handlers
Use object/array destructuring for cleaner code
Use template literals for string interpolation
Use async/await for promise handling with try/catch for errors
Use WordPress i18n APIs (__/_n/sprintf) with a consistent textdomain for all user-facing strings; include translator comments where needed
Use @wordpress/data dispatch/select for interacting with WP data stores (e.g., core/notices, core/editor)
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/js-ts.instructions.md)
**/*.{ts,tsx,js,jsx}: Debounce user inputs to prevent excessive processing
Avoid blocking the UI thread (prefer async/non-blocking operations)
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{js,mjs,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/performance.instructions.md)
Defer non-critical JavaScript and avoid synchronous blocking operations
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/review.instructions.md)
Internationalize user‑facing strings using WordPress i18n APIs
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{css,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Minimize CSS/JS payload size
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Lazy-load code and resources where possible
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
**/*.{js,ts,tsx,jsx}
⚙️ CodeRabbit configuration file
**/*.{js,ts,tsx,jsx}: Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards and @wordpress/eslint-plugin rules.
- Ensure the code is well-documented with proper JSDoc comments.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features.
- Follow WordPress JavaScript coding standards and use WordPress script localization.
- Use WordPress script dependencies and enqueue properly.
- Ensure React/JSX best practices for blocks and modern JavaScript/TypeScript patterns.
- Implement proper error handling and loading states.
- Use WordPress components and design system where applicable.
- For Tour Operator: Focus on tour booking interfaces, search functionality, and tour display components.
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
src/blocks/**/*.{js,jsx,ts,tsx}
⚙️ CodeRabbit configuration file
src/blocks/**/*.{js,jsx,ts,tsx}: - Follow WordPress JavaScript coding standards and @wordpress/scripts configuration.
- Use WordPress components from @wordpress/components and design system.
- Implement proper React/JSX patterns for WordPress blocks.
- Ensure proper WordPress script dependencies and localization.
- Use WordPress data store patterns with @wordpress/data.
- Implement proper error boundaries and loading states.
- Follow modern JavaScript/TypeScript patterns with proper typing.
- Ensure accessibility in interactive block components.
- Use WordPress block editor APIs correctly (useBlockProps, InspectorControls, etc.).
- Implement proper block validation and save/edit functionality.
Files:
src/blocks/checkout-time/index.jssrc/blocks/checkin-time/index.js
🧬 Code graph analysis (2)
src/blocks/checkout-time/index.js (1)
src/blocks/checkin-time/index.js (5)
wp(129-129)supportedPostTypes(132-132)registered(133-133)checkAndRegister(136-154)interval(159-163)
src/blocks/checkin-time/index.js (2)
src/blocks/checkout-time/index.js (5)
wp(129-129)supportedPostTypes(132-132)registered(133-133)checkAndRegister(136-154)interval(159-163)build/blocks/checkin-time/index.js (5)
wp(175-177)supportedPostTypes(180-180)registered(181-181)checkAndRegister(184-198)interval(203-207)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: review
- GitHub Check: Summary
| name: "lsx-tour-operator/checkout-time", | ||
| title: __("Check out time", "tour-operator"), | ||
| icon: "clock", | ||
| category: "lsx-tour-operator", | ||
| isActive: (blockAttributes, variationAttributes) => { | ||
| return blockAttributes.metadata?.name === variationAttributes.metadata?.name; | ||
| }, | ||
| }, | ||
| innerBlocks: [ | ||
| [ | ||
| 'core/group', | ||
| { | ||
| layout: { | ||
| type: 'flex', | ||
| flexWrap: 'nowrap', | ||
| verticalAlignment: 'top', | ||
| }, | ||
| attributes: { | ||
| metadata: { | ||
| name: "Check out time", | ||
| }, | ||
| className: "lsx-checkout-time-wrapper", | ||
| layout: { | ||
| type: "flex", | ||
| flexWrap: "nowrap", | ||
| }, | ||
| }, | ||
| innerBlocks: [ | ||
| [ | ||
| [ | ||
| 'core/image', | ||
| { | ||
| id: 122720, | ||
| width: '20px', | ||
| sizeSlug: 'large', | ||
| linkDestination: 'none', | ||
| url: | ||
| lsxToEditor.assetsUrl + | ||
| 'blocks/check-in-check-out-time.svg', | ||
| alt: '', | ||
| className: 'wp-image-122720', | ||
| "core/group", | ||
| { | ||
| layout: { | ||
| type: "flex", | ||
| flexWrap: "nowrap", | ||
| verticalAlignment: "middle", | ||
| }, | ||
| ], | ||
| }, | ||
| [ | ||
| 'core/paragraph', | ||
| { | ||
| content: '<strong>Check out time:</strong>', | ||
| }, | ||
| [ | ||
| "lsx-tour-operator/icons", | ||
| { | ||
| iconType: "solid", | ||
| iconName: "checkInAccommodationIcon", | ||
| }, | ||
| ], | ||
| [ | ||
| "core/paragraph", | ||
| { | ||
| content: __( | ||
| 'Check out time:', | ||
| 'tour-operator' | ||
| ), | ||
| }, | ||
| ], | ||
| ], | ||
| ], | ||
| ], | ||
| [ | ||
| 'core/group', | ||
| { | ||
| layout: { | ||
| type: 'flex', | ||
| flexWrap: 'nowrap', | ||
| }, | ||
| }, | ||
| [ | ||
| "core/group", | ||
| { | ||
| layout: { | ||
| type: "flex", | ||
| flexWrap: "nowrap", | ||
| }, | ||
| }, | ||
| [ | ||
| 'core/paragraph', | ||
| { | ||
| metadata: { | ||
| bindings: { | ||
| content: { | ||
| source: 'lsx/post-meta', | ||
| args: { | ||
| key: 'checkout_time', | ||
| [ | ||
| "core/paragraph", | ||
| { | ||
| metadata: { | ||
| bindings: { | ||
| content: { | ||
| source: "lsx/post-meta", | ||
| args: { | ||
| key: "checkout_time", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| ], | ||
| ], | ||
| ], | ||
| ], | ||
| supports: { | ||
| renaming: false, | ||
| }, | ||
| } ); | ||
| } ); | ||
| supports: { | ||
| renaming: false, | ||
| }, | ||
| example: { | ||
| attributes: { | ||
| metadata: { | ||
| name: "Check Out Time", | ||
| }, | ||
| }, | ||
| innerBlocks: [ | ||
| [ | ||
| "core/group", | ||
| {}, | ||
| [ | ||
| [ | ||
| "core/heading", | ||
| { | ||
| content: "Check Out Time", | ||
| level: 3, | ||
| }, | ||
| ], | ||
| [ | ||
| "core/paragraph", | ||
| { | ||
| content: "3:00 PM", | ||
| }, | ||
| ], | ||
| ], | ||
| ], | ||
| ], | ||
| }, |
There was a problem hiding this comment.
Translate the variation label and preview.
The checkout variation still hard-codes metadata.name and the preview heading, so they won’t be localised in the editor UI. Please mirror the translated label across these fields.
- wp.blocks.registerBlockVariation("core/group", {
+ const variationLabel = __( 'Check out time', 'tour-operator' );
+
+ wp.blocks.registerBlockVariation("core/group", {
name: "lsx-tour-operator/checkout-time",
- title: __("Check out time", "tour-operator"),
+ title: variationLabel,
@@
attributes: {
metadata: {
- name: "Check out time",
+ name: variationLabel,
},
@@
example: {
attributes: {
metadata: {
- name: "Check Out Time",
+ name: variationLabel,
},
},
innerBlocks: [
[
"core/group",
{},
[
[
"core/heading",
{
- content: "Check Out Time",
+ content: variationLabel,
level: 3,
},As per coding guidelines.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| name: "lsx-tour-operator/checkout-time", | |
| title: __("Check out time", "tour-operator"), | |
| icon: "clock", | |
| category: "lsx-tour-operator", | |
| isActive: (blockAttributes, variationAttributes) => { | |
| return blockAttributes.metadata?.name === variationAttributes.metadata?.name; | |
| }, | |
| }, | |
| innerBlocks: [ | |
| [ | |
| 'core/group', | |
| { | |
| layout: { | |
| type: 'flex', | |
| flexWrap: 'nowrap', | |
| verticalAlignment: 'top', | |
| }, | |
| attributes: { | |
| metadata: { | |
| name: "Check out time", | |
| }, | |
| className: "lsx-checkout-time-wrapper", | |
| layout: { | |
| type: "flex", | |
| flexWrap: "nowrap", | |
| }, | |
| }, | |
| innerBlocks: [ | |
| [ | |
| [ | |
| 'core/image', | |
| { | |
| id: 122720, | |
| width: '20px', | |
| sizeSlug: 'large', | |
| linkDestination: 'none', | |
| url: | |
| lsxToEditor.assetsUrl + | |
| 'blocks/check-in-check-out-time.svg', | |
| alt: '', | |
| className: 'wp-image-122720', | |
| "core/group", | |
| { | |
| layout: { | |
| type: "flex", | |
| flexWrap: "nowrap", | |
| verticalAlignment: "middle", | |
| }, | |
| ], | |
| }, | |
| [ | |
| 'core/paragraph', | |
| { | |
| content: '<strong>Check out time:</strong>', | |
| }, | |
| [ | |
| "lsx-tour-operator/icons", | |
| { | |
| iconType: "solid", | |
| iconName: "checkInAccommodationIcon", | |
| }, | |
| ], | |
| [ | |
| "core/paragraph", | |
| { | |
| content: __( | |
| 'Check out time:', | |
| 'tour-operator' | |
| ), | |
| }, | |
| ], | |
| ], | |
| ], | |
| ], | |
| [ | |
| 'core/group', | |
| { | |
| layout: { | |
| type: 'flex', | |
| flexWrap: 'nowrap', | |
| }, | |
| }, | |
| [ | |
| "core/group", | |
| { | |
| layout: { | |
| type: "flex", | |
| flexWrap: "nowrap", | |
| }, | |
| }, | |
| [ | |
| 'core/paragraph', | |
| { | |
| metadata: { | |
| bindings: { | |
| content: { | |
| source: 'lsx/post-meta', | |
| args: { | |
| key: 'checkout_time', | |
| [ | |
| "core/paragraph", | |
| { | |
| metadata: { | |
| bindings: { | |
| content: { | |
| source: "lsx/post-meta", | |
| args: { | |
| key: "checkout_time", | |
| }, | |
| }, | |
| }, | |
| }, | |
| }, | |
| }, | |
| ], | |
| ], | |
| ], | |
| ], | |
| ], | |
| supports: { | |
| renaming: false, | |
| }, | |
| } ); | |
| } ); | |
| supports: { | |
| renaming: false, | |
| }, | |
| example: { | |
| attributes: { | |
| metadata: { | |
| name: "Check Out Time", | |
| }, | |
| }, | |
| innerBlocks: [ | |
| [ | |
| "core/group", | |
| {}, | |
| [ | |
| [ | |
| "core/heading", | |
| { | |
| content: "Check Out Time", | |
| level: 3, | |
| }, | |
| ], | |
| [ | |
| "core/paragraph", | |
| { | |
| content: "3:00 PM", | |
| }, | |
| ], | |
| ], | |
| ], | |
| ], | |
| }, | |
| const variationLabel = __( 'Check out time', 'tour-operator' ); | |
| wp.blocks.registerBlockVariation( "core/group", { | |
| name: "lsx-tour-operator/checkout-time", | |
| title: variationLabel, | |
| icon: "clock", | |
| category: "lsx-tour-operator", | |
| isActive: ( blockAttributes, variationAttributes ) => { | |
| return blockAttributes.metadata?.name === variationAttributes.metadata?.name; | |
| }, | |
| attributes: { | |
| metadata: { | |
| name: variationLabel, | |
| }, | |
| className: "lsx-checkout-time-wrapper", | |
| layout: { | |
| type: "flex", | |
| flexWrap: "nowrap", | |
| }, | |
| }, | |
| innerBlocks: [ | |
| [ | |
| "core/group", | |
| { | |
| layout: { | |
| type: "flex", | |
| flexWrap: "nowrap", | |
| verticalAlignment: "middle", | |
| }, | |
| }, | |
| [ | |
| [ | |
| "lsx-tour-operator/icons", | |
| { | |
| iconType: "solid", | |
| iconName: "checkInAccommodationIcon", | |
| }, | |
| ], | |
| [ | |
| "core/paragraph", | |
| { | |
| content: __( | |
| 'Check out time:', | |
| 'tour-operator' | |
| ), | |
| }, | |
| ], | |
| ], | |
| ], | |
| [ | |
| "core/group", | |
| { | |
| layout: { | |
| type: "flex", | |
| flexWrap: "nowrap", | |
| }, | |
| }, | |
| [ | |
| [ | |
| "core/paragraph", | |
| { | |
| metadata: { | |
| bindings: { | |
| content: { | |
| source: "lsx/post-meta", | |
| args: { | |
| key: "checkout_time", | |
| }, | |
| }, | |
| }, | |
| }, | |
| }, | |
| ], | |
| ], | |
| ], | |
| ], | |
| supports: { | |
| renaming: false, | |
| }, | |
| example: { | |
| attributes: { | |
| metadata: { | |
| name: variationLabel, | |
| }, | |
| }, | |
| innerBlocks: [ | |
| [ | |
| "core/group", | |
| {}, | |
| [ | |
| [ | |
| "core/heading", | |
| { | |
| content: variationLabel, | |
| level: 3, | |
| }, | |
| ], | |
| [ | |
| "core/paragraph", | |
| { | |
| content: "3:00 PM", | |
| }, | |
| ], | |
| ], | |
| ], | |
| ], | |
| }, | |
| } ); |
🤖 Prompt for AI Agents
In src/blocks/checkout-time/index.js around lines 16 to 119, the variation’s
metadata.name and the example preview heading are hard-coded and not localised;
replace those literal strings with the translation function so both the
variation label and the preview heading use __('Check out time',
'tour-operator') (or the appropriate case variant) so the metadata.name in
attributes and the example innerBlocks heading content are wrapped with __()
using the 'tour-operator' text domain.
There was a problem hiding this comment.
Files selected (2)
- src/blocks/checkin-time/index.js (1)
- src/blocks/checkout-time/index.js (1)
Files not summarized due to errors (2)
- src/blocks/checkout-time/index.js (nothing obtained from openai)
- src/blocks/checkin-time/index.js (nothing obtained from openai)
Files not reviewed due to errors (2)
- src/blocks/checkout-time/index.js (no response)
- src/blocks/checkin-time/index.js (no response)
Review comments generated (0)
- Review: 0
- LGTM: 0
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
build/blocks/checkin-time/index.asset.phpis excluded by!build/**build/blocks/checkin-time/index.jsis excluded by!build/**build/blocks/checkout-time/index.asset.phpis excluded by!build/**build/blocks/checkout-time/index.jsis excluded by!build/**
📒 Files selected for processing (2)
src/blocks/checkin-time/index.js(1 hunks)src/blocks/checkout-time/index.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
src/**/*.{js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use @wordpress/eslint-plugin for JavaScript linting
Files:
src/blocks/checkin-time/index.jssrc/blocks/checkout-time/index.js
src/**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/**/*.{js,jsx,ts,tsx}: Use useBlockProps() in block edit/save components when applicable
Use the text domaintour-operatorfor JS i18n calls
Files:
src/blocks/checkin-time/index.jssrc/blocks/checkout-time/index.js
{assets,src}/**/*
📄 CodeRabbit inference engine (.github/instructions/block-theme-structure.instructions.md)
Keep SCSS/JS/images source assets in assets/ or src/
Files:
src/blocks/checkin-time/index.jssrc/blocks/checkout-time/index.js
**/*.{js,ts}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts}: Use const or let instead of var for variable declarations
Use default parameters for function arguments where appropriate
Use @wordpress/api-fetch (optionally with addQueryArgs) for REST API requests
Register blocks via registerBlockType using block metadata (imported from block.json), and localize title/description/keywords
Use wp.media for media selection in custom components/utilities when needed
Create and register custom data stores with @wordpress/data (createReduxStore + register), and structure actions/selectors clearly
Initialize frontend interactivity after DOMContentLoaded and implement ARIA attributes for toggles (aria-controls, aria-expanded)
Handle AJAX form submissions with fetch, proper loading states, and user notices; restore UI state in finally
Implement accessibility utilities like focus trapping and polite screen reader announcements for dynamic content
Files:
src/blocks/checkin-time/index.jssrc/blocks/checkout-time/index.js
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts,jsx,tsx}: Prefer arrow functions for callbacks and inline handlers
Use object/array destructuring for cleaner code
Use template literals for string interpolation
Use async/await for promise handling with try/catch for errors
Use WordPress i18n APIs (__/_n/sprintf) with a consistent textdomain for all user-facing strings; include translator comments where needed
Use @wordpress/data dispatch/select for interacting with WP data stores (e.g., core/notices, core/editor)
Files:
src/blocks/checkin-time/index.jssrc/blocks/checkout-time/index.js
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/js-ts.instructions.md)
**/*.{ts,tsx,js,jsx}: Debounce user inputs to prevent excessive processing
Avoid blocking the UI thread (prefer async/non-blocking operations)
Files:
src/blocks/checkin-time/index.jssrc/blocks/checkout-time/index.js
**/*.{js,mjs,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/performance.instructions.md)
Defer non-critical JavaScript and avoid synchronous blocking operations
Files:
src/blocks/checkin-time/index.jssrc/blocks/checkout-time/index.js
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/review.instructions.md)
Internationalize user‑facing strings using WordPress i18n APIs
Files:
src/blocks/checkin-time/index.jssrc/blocks/checkout-time/index.js
**/*.{css,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Minimize CSS/JS payload size
Files:
src/blocks/checkin-time/index.jssrc/blocks/checkout-time/index.js
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Lazy-load code and resources where possible
Files:
src/blocks/checkin-time/index.jssrc/blocks/checkout-time/index.js
**/*.{js,ts,tsx,jsx}
⚙️ CodeRabbit configuration file
**/*.{js,ts,tsx,jsx}: Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards and @wordpress/eslint-plugin rules.
- Ensure the code is well-documented with proper JSDoc comments.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features.
- Follow WordPress JavaScript coding standards and use WordPress script localization.
- Use WordPress script dependencies and enqueue properly.
- Ensure React/JSX best practices for blocks and modern JavaScript/TypeScript patterns.
- Implement proper error handling and loading states.
- Use WordPress components and design system where applicable.
- For Tour Operator: Focus on tour booking interfaces, search functionality, and tour display components.
Files:
src/blocks/checkin-time/index.jssrc/blocks/checkout-time/index.js
src/blocks/**/*.{js,jsx,ts,tsx}
⚙️ CodeRabbit configuration file
src/blocks/**/*.{js,jsx,ts,tsx}: - Follow WordPress JavaScript coding standards and @wordpress/scripts configuration.
- Use WordPress components from @wordpress/components and design system.
- Implement proper React/JSX patterns for WordPress blocks.
- Ensure proper WordPress script dependencies and localization.
- Use WordPress data store patterns with @wordpress/data.
- Implement proper error boundaries and loading states.
- Follow modern JavaScript/TypeScript patterns with proper typing.
- Ensure accessibility in interactive block components.
- Use WordPress block editor APIs correctly (useBlockProps, InspectorControls, etc.).
- Implement proper block validation and save/edit functionality.
Files:
src/blocks/checkin-time/index.jssrc/blocks/checkout-time/index.js
🧬 Code graph analysis (2)
src/blocks/checkin-time/index.js (2)
src/blocks/checkout-time/index.js (5)
wp(129-129)supportedPostTypes(132-132)registered(133-133)checkAndRegister(136-154)interval(159-163)build/blocks/checkin-time/index.js (5)
wp(175-177)supportedPostTypes(180-180)registered(181-181)checkAndRegister(184-198)interval(203-207)
src/blocks/checkout-time/index.js (1)
src/blocks/checkin-time/index.js (5)
wp(129-129)supportedPostTypes(132-132)registered(133-133)checkAndRegister(136-154)interval(159-163)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: review
- GitHub Check: Summary
| if (supportedPostTypes.includes(postType) || ((postType === 'wp_template' || postType === 'wp_template_part') && postSlug.includes('accommodation'))) { | ||
| registerCheckinTimeVariation(); | ||
| registered = true; | ||
| } |
There was a problem hiding this comment.
Only set registered when registration succeeds.
We ignore the boolean returned by registerCheckinTimeVariation(), so a caught exception marks the variation as registered and we never retry. This leaves the block variation unregistered.
Apply this diff:
- if (supportedPostTypes.includes(postType) || ((postType === 'wp_template' || postType === 'wp_template_part') && postSlug.includes('accommodation'))) {
- registerCheckinTimeVariation();
- registered = true;
- }
+ if (supportedPostTypes.includes(postType) || ((postType === 'wp_template' || postType === 'wp_template_part') && postSlug.includes('accommodation'))) {
+ if (registerCheckinTimeVariation()) {
+ registered = true;
+ }
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (supportedPostTypes.includes(postType) || ((postType === 'wp_template' || postType === 'wp_template_part') && postSlug.includes('accommodation'))) { | |
| registerCheckinTimeVariation(); | |
| registered = true; | |
| } | |
| if ( | |
| supportedPostTypes.includes(postType) || | |
| ( | |
| (postType === 'wp_template' || postType === 'wp_template_part') && | |
| postSlug.includes('accommodation') | |
| ) | |
| ) { | |
| if ( registerCheckinTimeVariation() ) { | |
| registered = true; | |
| } | |
| } |
🤖 Prompt for AI Agents
In src/blocks/checkin-time/index.js around lines 148 to 151, the code sets
registered = true regardless of whether registerCheckinTimeVariation()
succeeded; update it to call registerCheckinTimeVariation() and capture its
return value or await it if async, then set registered = true only when that
call returns a truthy success value; additionally wrap the call in a try/catch
(or preserve existing one) and ensure the catch does not set registered, instead
log or rethrow the error so failed registrations can be retried.
| if (supportedPostTypes.includes(postType) || ((postType === 'wp_template' || postType === 'wp_template_part') && postSlug.includes('accommodation'))) { | ||
| registerCheckoutTimeVariation(); | ||
| registered = true; | ||
| } |
There was a problem hiding this comment.
Guard the registered flag with the function’s return value.
registerCheckoutTimeVariation() can return false when registerBlockVariation throws, yet we still flip registered to true, so we never retry and the variation stays unavailable. Wrap the assignment so the flag is only set when registration actually succeeds.
Apply this diff:
- if (supportedPostTypes.includes(postType) || ((postType === 'wp_template' || postType === 'wp_template_part') && postSlug.includes('accommodation'))) {
- registerCheckoutTimeVariation();
- registered = true;
- }
+ if (supportedPostTypes.includes(postType) || ((postType === 'wp_template' || postType === 'wp_template_part') && postSlug.includes('accommodation'))) {
+ if (registerCheckoutTimeVariation()) {
+ registered = true;
+ }
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (supportedPostTypes.includes(postType) || ((postType === 'wp_template' || postType === 'wp_template_part') && postSlug.includes('accommodation'))) { | |
| registerCheckoutTimeVariation(); | |
| registered = true; | |
| } | |
| if ( | |
| supportedPostTypes.includes(postType) || | |
| ( | |
| (postType === 'wp_template' || postType === 'wp_template_part') && | |
| postSlug.includes('accommodation') | |
| ) | |
| ) { | |
| if ( registerCheckoutTimeVariation() ) { | |
| registered = true; | |
| } | |
| } |
🤖 Prompt for AI Agents
In src/blocks/checkout-time/index.js around lines 148 to 151,
registerCheckoutTimeVariation() can return false when registration fails but the
code unconditionally sets registered = true; change this so you capture the
function's return value and only set registered = true when that return value is
truthy (i.e., registration succeeded), ensuring failed attempts don't mark the
variation as registered and allowing retries.
Added icon block icons for checkin/checkout times and a filter for relevant post types. Updated changelog with recent changes and integrations. Signed-off-by: Tibi Buzdugan <buzdugan.tiberiu@gmail.com>
There was a problem hiding this comment.
Files selected (1)
- changelog.md (1)
Files not summarized due to errors (1)
- changelog.md (nothing obtained from openai)
Files not reviewed due to errors (1)
- changelog.md (no response)
Review comments generated (0)
- Review: 0
- LGTM: 0
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
pr: 645
related_issues:
blocks:
post_types:
author: tibiii
labels:
Summary
This pull request updates both the Check In Time and Check Out Time block variations for the LSX Tour Operator plugin, making them more descriptive, context-aware, and visually consistent. The changes ensure the blocks only register for the
accommodationpost type, add richer metadata and examples, and switch to a custom icon component for improved branding.Block registration improvements:
checkin-timeandcheckout-timeblock variations now register only when editing anaccommodationpost type, using a polling mechanism to ensure correct timing. [1] [2]lsx-tour-operator/iconsblock withcheckInAccommodationIcon, improving consistency and maintainability. [1] [2]Block configuration enhancements:
description,icon,keywords, and a detailedexampleto bothblock.jsonfiles, improving discoverability and usability in the block editor. [1] [2]Technical and metadata updates:
textdomainfield to both block configurations for proper localization support. [1] [2]Scope
Screenshots / Videos
If relevant.
Checklist
block.jsonupdated (title, description, keywords, supports, example, selectors)Related issues
This closes #644
Summary by CodeRabbit
New Features
Improvements
Documentation
Chores