Skip to content

Fix ScriptTask UI button actions and scheduled job handling for current MeshCentral versions - #69

Open
fud18 wants to merge 10 commits into
ryanblenis:masterfrom
fud18:master
Open

fud18 wants to merge 10 commits into
ryanblenis:masterfrom
fud18:master

Conversation

@fud18

@fud18 fud18 commented Jul 2, 2026

Copy link
Copy Markdown

Fix ScriptTask UI compatibility and editor functionality for current MeshCentral versions

Summary

This pull request fixes several compatibility issues in the ScriptTask plugin that prevent normal operation on current versions of MeshCentral.

While testing the plugin against the latest MeshCentral release, several UI actions, scheduled task functions, and the script editor were either non-functional or generated server-side errors. This PR restores those features while preserving the plugin’s original workflow and behavior.

User Interface

Toolbar Improvements

  • Updated the toolbar to use modern MeshCentral-style buttons.
  • Fixed the following toolbar actions:
    • New
    • Rename
    • Edit
    • Delete
    • New Folder
    • Download
    • Run
    • Schedule on Selected
  • Removed conflicting event handling that caused button actions to execute twice or require multiple confirmations.
  • Simplified the button implementation for improved compatibility with current MeshCentral releases.

Script Editor

Save Functionality

Fixed an issue where editing a script did not properly save changes on current MeshCentral versions.

Changes include:

  • Fixed the Save callback to correctly update the parent window.
  • Fixed Save so the editor automatically closes after a successful save.
  • Renamed the Close button to Cancel for improved usability and consistency.
  • Preserved the existing editing workflow while restoring expected behavior.

Scheduled Jobs

Scheduling

  • Fixed scheduled job creation when only a single node is selected.
  • Fixed scheduled job creation for both single-node and multi-node selections.
  • Improved reliability of scheduled task management.

Schedule Deletion

  • Fixed deletion of scheduled jobs by correctly identifying the selected schedule row.
  • Eliminated issues where Delete actions failed because the incorrect DOM element was referenced.

Backend Improvements

Added validation before processing script content to prevent orphaned or invalid scheduled jobs from causing server exceptions.

This prevents errors similar to:

TypeError: Cannot read properties of undefined (reading 'content')

and previously:

TypeError: Cannot read properties of undefined (reading 'match')

when scheduled jobs reference missing or deleted scripts.

Instead of crashing, invalid scheduled jobs are now skipped safely.

Compatibility

These changes improve compatibility with current MeshCentral releases while maintaining backward compatibility with the existing plugin design.

No changes were made to the overall plugin workflow or user experience beyond restoring broken functionality.

Testing Performed

The following functionality has been tested successfully:

Script Management

  • ✅ Create Script
  • ✅ Rename Script
  • ✅ Edit Script
  • ✅ Save Script
  • ✅ Save and automatically close editor
  • ✅ Cancel editing
  • ✅ Delete Script
  • ✅ Create Folder
  • ✅ Download Script

Execution

  • ✅ Run Script
  • ✅ Schedule Script
  • ✅ Schedule on one node
  • ✅ Schedule on multiple nodes
  • ✅ Delete Scheduled Jobs

History

  • ✅ Script History
  • ✅ Node History

General

  • ✅ Plugin loads correctly on current MeshCentral versions
  • ✅ No JavaScript errors during normal operation
  • ✅ No server-side exceptions caused by invalid scheduled jobs

Goal

The goal of this pull request is to restore compatibility with current MeshCentral releases while preserving the original functionality and user workflow of the ScriptTask plugin.

This pull request intentionally focuses on bug fixes and compatibility improvements without introducing new features or altering the existing design.

Future enhancements—such as additional UI modernization, dark mode improvements, and code cleanup—can be submitted separately to keep this pull request focused and easy to review.

@marck-reconvert

marck-reconvert commented Aug 12, 2026

Copy link
Copy Markdown

I'm very eager to have this PR passed, because I'm currently limited in my use of the plugin by the UI bugs

Is there a way to generate a (beta) release so I can already test-drive this in our environment?

Edit: found your fork @fud18 and installed the plugin from there

Comment thread views/user.handlebars

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In this file every line seems to be touched, but not always changes, making the actual diff impossible to see.
Perhaps a line-ending/formatting thing?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For some reason Github won't let me resolve my comment, but confirming that this has been resolved ✅

@fud18
fud18 marked this pull request as draft September 11, 2026 21:13
@fud18
fud18 marked this pull request as ready for review September 11, 2026 21:36
@fud18

fud18 commented Sep 11, 2026

Copy link
Copy Markdown
Author

Thanks for catching this. It was a line-ending issue.

The upstream user.handlebars file uses CRLF line endings, and my edited copy had been converted differently, which caused GitHub to show essentially the entire file as modified.

I restored the upstream CRLF formatting and cleaned up the branch. The PR now only contains the actual functional changes in:

  • scripttask.js
  • views/scriptedit.handlebars
  • views/user.handlebars

I also removed the fork-specific config.json changes so they are no longer part of the PR.

The resulting diff is now limited to the intended ScriptTask fixes.

@marck-reconvert

Copy link
Copy Markdown

I've been testing this version on our instance and it seems to work well.
One thing I noticed last week however is the variable input modal is not working. I had not noticed yet because I didn't use it.

Just checked in the 'non-modern' UI what it should look like
image

Not sure if it is easy to include in this, otherwise maybe at least 'block' it or replace with a 'Not implemented yet' alert, because now when I click it in modern-ui, it seems to block the entire interface (clicks anywhere don't work anymore) so it requires a page reload

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.

2 participants