fix: backport <unraid-modals> upon plg install when necessary (#1499)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Prevented duplicate insertion of the modal component in the page
layout.

* **Chores**
* Improved installation script to ensure the modal component is added
only if missing.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Pujit Mehrotra
2025-07-09 13:32:55 -04:00
committed by GitHub
parent ca4e2db1f2
commit 33e0b1ab24
2 changed files with 8 additions and 0 deletions

View File

@@ -66,6 +66,9 @@ if (is_localhost() && !is_good_session()) {
}
private addModalsWebComponent(source: string): string {
if (source.includes('<unraid-modals>')) {
return source;
}
return source.replace('<body>', '<body>\n<unraid-modals></unraid-modals>');
}

View File

@@ -155,6 +155,11 @@ exit 0
# Remove the old header logo from DefaultPageLayout.php if present
if [ -f "/usr/local/emhttp/plugins/dynamix/include/DefaultPageLayout.php" ]; then
sed -i 's|<a href="https://unraid.net" target="_blank"><?readfile("$docroot/webGui/images/UN-logotype-gradient.svg")?></a>||g' "/usr/local/emhttp/plugins/dynamix/include/DefaultPageLayout.php"
# Add unraid-modals element if not already present
if ! grep -q '<unraid-modals>' "/usr/local/emhttp/plugins/dynamix/include/DefaultPageLayout.php"; then
sed -i 's|<body>|<body>\n<unraid-modals></unraid-modals>|' "/usr/local/emhttp/plugins/dynamix/include/DefaultPageLayout.php"
fi
fi
]]>