fix: omit Connect actions in UPC when plugin is not installed (#1417)

Removes Connect branding in dropdown when connect plugin is not installed.

Preview of dropdown:
<img width="453" alt="image"
src="https://github.com/user-attachments/assets/b3ba3954-f2d3-4760-a1e2-91556eb43903"
/>

## Summary by CodeRabbit

- **New Features**
- The Notifications Sidebar is now always visible in the user profile,
regardless of plugin installation status.

- **Refactor**
  - Improved detection logic for the connect plugin to enhance accuracy.
- Centralized and standardized the "Settings" link in the user profile
dropdown for consistent user experience.
- The account status section in Connect Settings now only appears when
the connect plugin is installed.
- Updated the Connect page title from "Unraid Connect" to "Unraid API"
for clarity.

- **Chores**
- Extended linting to include Vue files for better code quality
enforcement.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Pujit Mehrotra
2025-06-16 11:50:37 -04:00
committed by GitHub
parent 3dcbfbe489
commit 8c8a5276b4
7 changed files with 36 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
Menu="ManagementAccess:100"
Title="Unraid Connect"
Title="Unraid API"
Icon="icon-u-globe"
Tag="globe"
---

View File

@@ -146,10 +146,23 @@ class ServerState
private function setConnectValues()
{
if (file_exists('/usr/local/bin/unraid-api')) {
$this->connectPluginInstalled = 'dynamix.unraid.net.plg';
$apiConfigPath = '/boot/config/plugins/dynamix.my.servers/configs/api.json';
if (!file_exists($apiConfigPath)) {
return; // plugin is not installed; exit early
}
$apiConfig = @json_decode(file_get_contents($apiConfigPath), true);
$pluginName = 'unraid-api-plugin-connect'; // name of connect plugin's npm package
if ($apiConfig && is_array($apiConfig['plugins'])) {
foreach ($apiConfig['plugins'] as $plugin) {
// recognize npm version identifiers inside $apiConfig['plugins']
if ($plugin === $pluginName || strpos($plugin, $pluginName . '@') === 0) {
$this->connectPluginInstalled = 'dynamix.unraid.net.plg';
break;
}
}
}
// exit early if the plugin is not installed
if (!$this->connectPluginInstalled) {
return;
@@ -181,7 +194,7 @@ class ServerState
$this->myServersFlashCfg = file_exists($flashCfgPath) ? @parse_ini_file($flashCfgPath, true) : [];
$connectJsonPath = '/boot/config/plugins/dynamix.my.servers/configs/connect.json';
$connectConfig = file_exists($connectJsonPath) ? @json_decode(file_get_contents($connectJsonPath), true) : [];
// ensure some vars are defined here so we don't have to test them later
if (empty($connectConfig['apikey'])) {
$connectConfig['apikey'] = "";