mirror of
https://github.com/umami-software/umami.git
synced 2026-02-13 17:15:37 +01:00
Compare commits
No commits in common. "ffc8f6faaeb5363f6bfb24c3f5dbff6ec667f216" and "1c7f9da320470c00fb3524ec5e98b88a310c11a4" have entirely different histories.
ffc8f6faae
...
1c7f9da320
3 changed files with 35 additions and 28 deletions
|
|
@ -1,14 +1,19 @@
|
|||
import { parseRequest } from '@/lib/request';
|
||||
import { json } from '@/lib/response';
|
||||
'use server';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const { error } = await parseRequest(request, null, { skipAuth: true });
|
||||
export type Config = {
|
||||
cloudMode: boolean;
|
||||
cloudUrl?: string;
|
||||
faviconUrl?: string;
|
||||
linksUrl?: string;
|
||||
pixelsUrl?: string;
|
||||
privateMode: boolean;
|
||||
telemetryDisabled: boolean;
|
||||
trackerScriptName?: string;
|
||||
updatesDisabled: boolean;
|
||||
};
|
||||
|
||||
if (error) {
|
||||
return error();
|
||||
}
|
||||
|
||||
return json({
|
||||
export async function getConfig(): Promise<Config> {
|
||||
return {
|
||||
cloudMode: !!process.env.CLOUD_URL,
|
||||
cloudUrl: process.env.CLOUD_URL,
|
||||
faviconUrl: process.env.FAVICON_URL,
|
||||
|
|
@ -18,5 +23,5 @@ export async function GET(request: Request) {
|
|||
telemetryDisabled: !!process.env.DISABLE_TELEMETRY,
|
||||
trackerScriptName: process.env.TRACKER_SCRIPT_NAME,
|
||||
updatesDisabled: !!process.env.DISABLE_UPDATES,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
@ -1,27 +1,12 @@
|
|||
import { useEffect } from 'react';
|
||||
import { useApp, setConfig } from '@/store/app';
|
||||
import { useApi } from '@/components/hooks/useApi';
|
||||
|
||||
export type Config = {
|
||||
cloudMode: boolean;
|
||||
cloudUrl?: string;
|
||||
faviconUrl?: string;
|
||||
linksUrl?: string;
|
||||
pixelsUrl?: string;
|
||||
privateMode: boolean;
|
||||
telemetryDisabled: boolean;
|
||||
trackerScriptName?: string;
|
||||
updatesDisabled: boolean;
|
||||
};
|
||||
import { getConfig, Config } from '@/app/actions/getConfig';
|
||||
|
||||
export function useConfig(): Config {
|
||||
const { config } = useApp();
|
||||
const { get } = useApi();
|
||||
|
||||
async function loadConfig() {
|
||||
const data = await get(`/config`);
|
||||
|
||||
setConfig(data);
|
||||
setConfig(await getConfig());
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,12 @@ import {
|
|||
MenuItem,
|
||||
MenuSeparator,
|
||||
MenuSection,
|
||||
Dialog,
|
||||
SubMenuTrigger,
|
||||
} from '@umami/react-zen';
|
||||
import { useMessages, useLoginQuery, useNavigation, useConfig } from '@/components/hooks';
|
||||
import { LogOut, LockKeyhole, Settings } from '@/components/icons';
|
||||
import { LogOut, LockKeyhole, Settings, Knobs } from '@/components/icons';
|
||||
import { PreferenceSettings } from '@/app/(main)/settings/preferences/PreferenceSettings';
|
||||
|
||||
export function SettingsButton() {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
|
|
@ -41,6 +44,20 @@ export function SettingsButton() {
|
|||
<MenuSection title={user.username}>
|
||||
<MenuSeparator />
|
||||
<MenuItem id="settings" icon={<Settings />} label={formatMessage(labels.settings)} />
|
||||
{cloudMode && (
|
||||
<SubMenuTrigger>
|
||||
<MenuItem
|
||||
icon={<Knobs />}
|
||||
label={formatMessage(labels.preferences)}
|
||||
showSubMenuIcon
|
||||
/>
|
||||
<Popover placement="right bottom">
|
||||
<Dialog>
|
||||
<PreferenceSettings />
|
||||
</Dialog>
|
||||
</Popover>
|
||||
</SubMenuTrigger>
|
||||
)}
|
||||
{!cloudMode && user.isAdmin && (
|
||||
<MenuItem id="admin" icon={<LockKeyhole />} label={formatMessage(labels.admin)} />
|
||||
)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue