Skip to content

Add Pro Features react page and integrate with admin dashboard. #2787

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Aunshon
Copy link
Collaborator

@Aunshon Aunshon commented Jul 4, 2025

All Submissions:

  • My code follow the WordPress' coding standards
  • My code satisfies feature requirements
  • My code is tested
  • My code passes the PHPCS tests
  • My code has proper inline documentation
  • I've included related pull request(s) (optional)
  • I've included developer documentation (optional)
  • I've added proper labels to this pull request

Changes proposed in this Pull Request:

Related Pull Request(s)

  • Full PR Link

Closes

How to test the changes in this Pull Request:

  • Steps or issue link

Changelog entry

Title

Detailed Description of the pull request. What was previous behaviour
and what will be changed in this PR.

Before Changes

Describe the issue before changes with screenshots(s).

After Changes

Describe the issue after changes with screenshot(s).

Feature Video (optional)

Link of detailed video if this PR is for a feature.

PR Self Review Checklist:

  • Code is not following code style guidelines
  • Bad naming: make sure you would understand your code if you read it a few months from now.
  • KISS: Keep it simple, Sweetie (not stupid!).
  • DRY: Don't Repeat Yourself.
  • Code that is not readable: too many nested 'if's are a bad sign.
  • Performance issues
  • Complicated constructions that need refactoring or comments: code should almost always be self-explanatory.
  • Grammar errors.

FOR PR REVIEWER ONLY:

As a reviewer, your feedback should be focused on the idea, not the person. Seek to understand, be respectful, and focus on constructive dialog.

As a contributor, your responsibility is to learn from suggestions and iterate your pull request should it be needed based on feedback. Seek to collaborate and produce the best possible contribution to the greater whole.

  • Correct — Does the change do what it’s supposed to? ie: code 100% fulfilling the requirements?
  • Secure — Would a nefarious party find some way to exploit this change? ie: everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities?
  • Readable — Will your future self be able to understand this change months down the road?
  • Elegant — Does the change fit aesthetically within the overall style and architecture?

Summary by CodeRabbit

  • New Features

    • Introduced a new "Pro Features" page in the Dokan admin dashboard.
    • Added a dedicated route and menu entry for "Pro Features" accessible from the admin interface.
    • Implemented a React-based interface for the "Pro Features" page with tailored styling.
  • Chores

    • Added configuration and asset management for the new "Pro Features" page to ensure proper loading of scripts and styles.

@Aunshon Aunshon self-assigned this Jul 4, 2025
@Aunshon Aunshon added the In Progress The issues is being worked on label Jul 4, 2025
Copy link
Contributor

coderabbitai bot commented Jul 4, 2025

Walkthrough

A new "Pro Features" page is added to the Dokan admin dashboard. This includes a PHP backend page registration, service provider inclusion, a React frontend with route integration, dedicated Tailwind CSS configuration, and a new Webpack entry for asset bundling. No existing logic or flows are modified.

Changes

Files/Paths Change Summary
includes/Admin/Dashboard/Pages/ProFeatures.php Added new ProFeatures class for admin dashboard, registering scripts, styles, and page menu.
includes/DependencyManagement/Providers/AdminDashboardServiceProvider.php Imported and registered ProFeatures class in the dashboard service provider.
src/ProFeatures/ProFeatures.tsx Added new React component ProFeatures with a simple heading.
src/ProFeatures/index.tsx Registered a new admin dashboard route for "Pro Features" and rendered the React component.
src/ProFeatures/tailwind.config.js, src/ProFeatures/tailwind.scss Added Tailwind CSS config and SCSS for styling the new feature page.
webpack-entries.js Added new Webpack entry for dokan-pro-features targeting the new frontend feature.

Sequence Diagram(s)

sequenceDiagram
    participant Admin as Admin User
    participant Dashboard as Dokan Admin Dashboard
    participant PHP as ProFeatures PHP Page
    participant React as ProFeatures React Component

    Admin->>Dashboard: Navigates to "Pro Features"
    Dashboard->>PHP: Loads ProFeatures page (registers scripts/styles)
    PHP->>Dashboard: Enqueues assets (JS/CSS)
    Dashboard->>React: Loads React component via route
    React-->>Admin: Renders Pro Features UI
Loading

Suggested labels

QA approved, :+1: Dev Review Done, Need Dev Review Only, Upcoming Release

Suggested reviewers

  • mrabbani

Poem

A dashboard grows with features new,
"Pro" arrives with code so true.
PHP and React, a stylish pair,
Tailwind breezes everywhere.
Webpack packs it, ready to go—
Rabbits cheer for this fresh show! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-04T11_24_35_684Z-debug-0.log

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (6)
src/ProFeatures/ProFeatures.tsx (1)

1-7: Consider using design system colors instead of hardcoded values.

The component uses a hardcoded color text-[#e3a333] which doesn't align with the established design system. Based on the base Tailwind configuration, consider using semantic color tokens like text-dokan-warning-DEFAULT or other appropriate design system colors.

-            <h1 className="text-[#e3a333]">Hello From ProFeatures.tsx 🔥</h1>
+            <h1 className="text-dokan-warning-DEFAULT">Pro Features</h1>
src/ProFeatures/tailwind.scss (1)

3-3: Clarify the commented-out dokan-ui import.

Is the commented-out @import "@getdokan/dokan-ui/dist/dokan-ui.css"; intentional? Consider removing it if not needed, or add a comment explaining why it's preserved.

src/ProFeatures/index.tsx (1)

7-8: Consider adding proper TypeScript declarations instead of @ts-ignore.

The @ts-ignore comment suppresses TypeScript errors but reduces type safety. Consider adding proper TypeScript declarations for wp.hooks or importing it from @wordpress/hooks.

-    // @ts-ignore
-    wp.hooks.addFilter(
+    import { addFilter } from '@wordpress/hooks';
+    
+    addFilter(

Alternatively, if you need to keep the global wp object, consider adding a proper type declaration:

+declare global {
+    interface Window {
+        wp: {
+            hooks: {
+                addFilter: (hookName: string, namespace: string, callback: Function) => void;
+            };
+        };
+    }
+}
+
-    // @ts-ignore
     wp.hooks.addFilter(
includes/Admin/Dashboard/Pages/ProFeatures.php (3)

10-10: Replace placeholder @SInCE tag with actual version.

The @since DOKAN_SINCE appears to be a placeholder. Please replace it with the actual version number when this feature will be released.

-     * @since DOKAN_SINCE
+     * @since 3.12.0

48-48: Replace placeholder @SInCE tag with actual version.

Same issue as above - the @since DOKAN_SINCE needs to be replaced with the actual version number.

-     * @since DOKAN_SINCE
+     * @since 3.12.0

59-59: Replace placeholder @SInCE tag with actual version.

Same issue as above - the @since DOKAN_SINCE needs to be replaced with the actual version number.

-     * @since DOKAN_SINCE
+     * @since 3.12.0
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fab1435 and 039e1b5.

📒 Files selected for processing (7)
  • includes/Admin/Dashboard/Pages/ProFeatures.php (1 hunks)
  • includes/DependencyManagement/Providers/AdminDashboardServiceProvider.php (2 hunks)
  • src/ProFeatures/ProFeatures.tsx (1 hunks)
  • src/ProFeatures/index.tsx (1 hunks)
  • src/ProFeatures/tailwind.config.js (1 hunks)
  • src/ProFeatures/tailwind.scss (1 hunks)
  • webpack-entries.js (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/ProFeatures/ProFeatures.tsx (1)
includes/Admin/Dashboard/Pages/ProFeatures.php (1)
  • ProFeatures (5-79)
src/ProFeatures/tailwind.config.js (1)
base-tailwind.config.js (1)
  • baseConfig (9-291)
src/ProFeatures/index.tsx (2)
src/admin/dashboard/components/Dashboard.tsx (1)
  • DokanAdminRoute (8-13)
includes/Admin/Dashboard/Pages/ProFeatures.php (1)
  • ProFeatures (5-79)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: e2e tests (3, 3)
  • GitHub Check: e2e tests (2, 3)
  • GitHub Check: e2e tests (1, 3)
  • GitHub Check: api tests (1, 1)
🔇 Additional comments (8)
webpack-entries.js (1)

61-61: LGTM! Entry point follows established patterns.

The new webpack entry point for the Pro Features module is correctly added and follows the naming convention used throughout the configuration.

src/ProFeatures/tailwind.config.js (1)

1-9: LGTM! Tailwind configuration is properly scoped.

The configuration correctly extends the base Tailwind config and appropriately scopes the content to only include files within the ProFeatures directory. This follows the established pattern for module-specific styling.

src/ProFeatures/tailwind.scss (1)

1-3: LGTM! SCSS structure is correct.

The file properly imports the base Tailwind styles and configures the module-specific Tailwind config. The use of modern @use syntax is appropriate.

includes/DependencyManagement/Providers/AdminDashboardServiceProvider.php (2)

7-7: LGTM! Import is properly namespaced and positioned.

The ProFeatures class import follows the established pattern and is correctly positioned with other dashboard page imports.


23-23: LGTM! Service registration follows established patterns.

The ProFeatures class is correctly added to the services array, ensuring it will be registered with the dependency injection container alongside other dashboard pages.

src/ProFeatures/index.tsx (1)

11-19: LGTM! Well-structured route registration.

The route registration implementation is clean and follows WordPress patterns properly. The use of satisfies DokanAdminRoute ensures type safety while maintaining the correct structure.

includes/Admin/Dashboard/Pages/ProFeatures.php (2)

21-28: LGTM! Proper menu configuration.

The menu configuration follows WordPress standards with proper translation, capability handling, and positioning. The position value of 99 ensures it appears at the end of the menu as expected for a Pro Features page.


66-78: LGTM! Proper asset registration.

The script and style registration follows WordPress best practices with proper dependency management, versioning, and loading strategies. The deferred loading strategy is appropriate for dashboard functionality.

function ProFeatures() {
return (
<div>
<h1 className="text-[#e3a333]">Hello From ProFeatures.tsx 🔥</h1>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

This appears to be placeholder content.

The current implementation displays a placeholder message. Ensure this gets replaced with actual Pro Features content before merging to production.

🤖 Prompt for AI Agents
In src/ProFeatures/ProFeatures.tsx at line 4, the current heading is placeholder
content. Replace the placeholder message with the actual Pro Features content
that should be displayed in this component before merging to production.

Comment on lines +63 to +65
public function register(): void {
$asset_file = include DOKAN_DIR . '/assets/js/dokan-pro-features.asset.php';

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for asset file inclusion.

The asset file inclusion should have error handling to prevent fatal errors if the file doesn't exist.

-    public function register(): void {
-        $asset_file = include DOKAN_DIR . '/assets/js/dokan-pro-features.asset.php';
+    public function register(): void {
+        $asset_file_path = DOKAN_DIR . '/assets/js/dokan-pro-features.asset.php';
+        
+        if ( ! file_exists( $asset_file_path ) ) {
+            return;
+        }
+        
+        $asset_file = include $asset_file_path;
+        
+        if ( ! is_array( $asset_file ) || ! isset( $asset_file['dependencies'], $asset_file['version'] ) ) {
+            return;
+        }
📝 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.

Suggested change
public function register(): void {
$asset_file = include DOKAN_DIR . '/assets/js/dokan-pro-features.asset.php';
public function register(): void {
$asset_file_path = DOKAN_DIR . '/assets/js/dokan-pro-features.asset.php';
if ( ! file_exists( $asset_file_path ) ) {
return;
}
$asset_file = include $asset_file_path;
if ( ! is_array( $asset_file ) || ! isset( $asset_file['dependencies'], $asset_file['version'] ) ) {
return;
}
🤖 Prompt for AI Agents
In includes/Admin/Dashboard/Pages/ProFeatures.php around lines 63 to 65, the
code includes an asset file without checking if the file exists, which can cause
a fatal error if the file is missing. Add error handling by verifying the file's
existence before including it, and handle the case where the file is not found
gracefully, such as logging an error or providing a fallback to prevent fatal
errors.

@Aunshon
Copy link
Collaborator Author

Aunshon commented Jul 4, 2025

@Wasi-Ur-Rahman vai i have setup the page and component You can go with ProFeatures.tsx. I have already setup the tatilwindcss you can use tailwindcss classes also.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In Progress The issues is being worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant