Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"pre-commit": "pnpm lint-staged"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"*.{js,jsx,ts,tsx,vue}": [
"pnpm lint:fix"
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Menu="ManagementAccess:100"
Title="Unraid Connect"
Title="Unraid API"
Icon="icon-u-globe"
Tag="globe"
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,23 @@ public function getWebguiGlobal(string $key, ?string $subkey = null)

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;
Expand Down Expand Up @@ -181,7 +194,7 @@ private function getMyServersCfgValues()
$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'] = "";
Expand Down
4 changes: 2 additions & 2 deletions web/__test__/components/UserProfile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,13 @@ describe('UserProfile.ce.vue', () => {
expect(heading.html()).toContain(initialServerData.description);
});

it('conditionally renders notifications sidebar based on connectPluginInstalled', async () => {
it('always renders notifications sidebar, regardless of connectPluginInstalled', async () => {
expect(wrapper.find('[data-testid="notifications-sidebar"]').exists()).toBe(true);

serverStore.connectPluginInstalled = '';
await wrapper.vm.$nextTick();

expect(wrapper.find('[data-testid="notifications-sidebar"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="notifications-sidebar"]').exists()).toBe(true);
});

it('conditionally renders banner based on theme store', async () => {
Expand Down
9 changes: 7 additions & 2 deletions web/components/ConnectSettings/ConnectSettings.ce.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import { useMutation, useQuery } from '@vue/apollo-composable';
import { BrandButton, jsonFormsRenderers, Label } from '@unraid/ui';
import { JsonForms } from '@jsonforms/vue';

import { useServerStore } from '~/store/server';
// unified settings values are returned as JSON, so use a generic record type
// import type { ConnectSettingsValues } from '~/composables/gql/graphql';

import { getConnectSettingsForm, updateConnectSettings } from './graphql/settings.query';

const { connectPluginInstalled } = storeToRefs(useServerStore());

/**--------------------------------------------
* Settings State & Form definition
*---------------------------------------------**/
Expand Down Expand Up @@ -99,8 +102,10 @@ const onChange = ({ data }: { data: Record<string, unknown> }) => {
<div
class="grid grid-cols-settings items-baseline pl-3 gap-y-6 [&>*:nth-child(odd)]:text-end [&>*:nth-child(even)]:ml-10"
>
<Label>Account Status:</Label>
<div v-html="'<unraid-i18n-host><unraid-auth></unraid-auth></unraid-i18n-host>'"></div>
<template v-if="connectPluginInstalled">
<Label>Account Status:</Label>
<div v-html="'<unraid-i18n-host><unraid-auth></unraid-auth></unraid-i18n-host>'"></div>
</template>
<Label>Download Unraid API Logs:</Label>
<div
v-html="
Expand Down
7 changes: 2 additions & 5 deletions web/components/UserProfile.ce.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const callbackStore = useCallbackActionsStore();
const serverStore = useServerStore();

const { callbackData } = storeToRefs(callbackStore);
const { name, description, guid, keyfile, lanIp, connectPluginInstalled } = storeToRefs(serverStore);
const { name, description, guid, keyfile, lanIp } = storeToRefs(serverStore);
const { bannerGradient, theme } = storeToRefs(useThemeStore());

/**
Expand Down Expand Up @@ -134,10 +134,7 @@ onMounted(() => {

<div class="block w-2px h-24px bg-header-text-secondary" />

<template v-if="connectPluginInstalled">
<!-- Keep the sidebar out of staging/prod builds, but easily accessible for development -->
<NotificationsSidebar />
</template>
<NotificationsSidebar />

<UpcDropdownMenu :t="t">
<template #trigger>
Expand Down
12 changes: 6 additions & 6 deletions web/components/UserProfile/DropdownContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ const links = computed((): UserProfileLink[] => {
title: props.t('Opens Connect in new tab'),
},
...[manageUnraidNetAccount.value],
{
href: WEBGUI_CONNECT_SETTINGS.toString(),
icon: CogIcon,
text: props.t('Settings'),
title: props.t('Go to Connect plugin settings'),
},
...signOutAction.value,
]
: [...[manageUnraidNetAccount.value]]),
{
href: WEBGUI_CONNECT_SETTINGS.toString(),
icon: CogIcon,
text: props.t('Settings'),
title: props.t('Go to API Settings'),
},
];
});

Expand Down
Loading