Skip to content

Fix JS Build Files Breaking Admin Interface - #2222

Merged
NoumaanAhamed merged 4 commits into
developfrom
fix/dashboard-build-files
Dec 3, 2025
Merged

NoumaanAhamed merged 4 commits into
developfrom
fix/dashboard-build-files

Conversation

@NoumaanAhamed

@NoumaanAhamed NoumaanAhamed commented Nov 28, 2025 •

Copy link
Copy Markdown
Collaborator

Pull Request: Fix Dashboard Build Files Breaking Admin Interface

Description

This PR fixes the root cause issues that were causing the rtMedia admin dashboard to break when running npx grunt build as per #2214

Solves #2224

Problem

After running npx grunt build, the admin settings page was broken:

  • All options displayed on one page (tabs not working)
  • Import/Export settings not functional
  • Console errors: rtTab is not a function, "[object Object]" is not valid JSON

Solution

Fixed multiple issues in the source JavaScript files and build configuration:

  1. Gruntfile.js: Added settings.js to the backend build (was missing from admin.min.js)
  2. RTMediaAdmin.php: Fixed tabs.js dependency loading for admin scripts
  3. settings.js: Fixed JSON.parse error in import settings handler

Changes

Gruntfile.js

  • Added settings.js to terser.backend.files array
  • Updated watch task to include settings.js

app/admin/RTMediaAdmin.php

  • Always enqueue rtmedia-admin-tabs script
  • Added it as dependency for admin scripts

app/assets/admin/js/settings.js

  • Added early return after handling import/export AJAX responses
  • Added type check before JSON.parse() to prevent parsing already-parsed objects

Testing Instructions

  1. Run npx grunt build
  2. Clear browser cache
  3. Go to rtMedia Settings page
  4. Verify:
    • Tabs work correctly (Display, BuddyPress, etc.)
    • Export Settings downloads JSON file
    • Import Settings accepts and applies JSON file
    • No console errors

Related Issues

Fixes the root cause of the dashboard build issue that required reverting to v4.7.4 build files.

@rtBot

rtBot commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

Unable to PHPCS or SVG scan one or more files due to error running PHPCS/SVG scanner:

  • Gruntfile.js
  • app/admin/RTMediaAdmin.php
  • app/assets/admin/js/admin.min.js
  • app/assets/admin/js/rtmedia-admin.min.js
  • app/assets/admin/js/settings.js
  • app/assets/js/admin-upload-terms.min.js
  • app/assets/js/rtmedia.min.js

The error may be temporary. If the error persists, please contact a human (commit-ID: 10af0c1).

@NoumaanAhamed NoumaanAhamed changed the title Fix/dashboard build files Fix JS Build Files Breaking Admin Interface Nov 28, 2025
@NoumaanAhamed
NoumaanAhamed marked this pull request as ready for review November 28, 2025 03:48
Copilot AI review requested due to automatic review settings November 28, 2025 03:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes critical issues in the rtMedia admin dashboard that occurred after running npx grunt build. The build process was breaking the admin interface due to missing dependencies and JSON parsing errors.

Key Changes:

  • Added settings.js to the Grunt build configuration to ensure it's included in admin.min.js
  • Fixed script dependency loading for tabs.js (rtTab jQuery plugin) to prevent console errors
  • Added defensive type checking before JSON parsing to avoid parsing already-parsed AJAX responses

Reviewed changes

Copilot reviewed 3 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Gruntfile.js Added settings.js to both the terser backend build configuration and watch task to ensure it's properly included in admin.min.js
app/admin/RTMediaAdmin.php Fixed script enqueuing by always loading tabs.js and adding it as a dependency to admin scripts, ensuring the rtTab plugin is available
app/assets/admin/js/settings.js Added early return after import/export AJAX responses and type checking before JSON.parse() to prevent parsing errors
app/assets/js/rtmedia.min.js Rebuilt frontend minified file with updated source code
app/assets/js/admin-upload-terms.min.js Rebuilt admin upload terms minified file
app/assets/admin/js/rtmedia-admin.min.js Rebuilt admin minified file (removed debug console.log)
app/assets/admin/js/admin.min.js Rebuilt admin minified file with settings.js included and additional bug fix for wp_nonce

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KMchaudhary KMchaudhary left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed and tested the PRs; they satisfy all the testing instructions.

@NoumaanAhamed
NoumaanAhamed merged commit 8bffe18 into develop Dec 3, 2025
12 of 13 checks passed
@NoumaanAhamed
NoumaanAhamed deleted the fix/dashboard-build-files branch January 8, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants