mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Merge branch 'dev' of https://github.com/umami-software/umami into dev
This commit is contained in:
commit
c66553c023
3 changed files with 28 additions and 35 deletions
|
|
@ -1,19 +1,14 @@
|
|||
'use server';
|
||||
import { parseRequest } from '@/lib/request';
|
||||
import { json } from '@/lib/response';
|
||||
|
||||
export type Config = {
|
||||
cloudMode: boolean;
|
||||
cloudUrl?: string;
|
||||
faviconUrl?: string;
|
||||
linksUrl?: string;
|
||||
pixelsUrl?: string;
|
||||
privateMode: boolean;
|
||||
telemetryDisabled: boolean;
|
||||
trackerScriptName?: string;
|
||||
updatesDisabled: boolean;
|
||||
};
|
||||
export async function GET(request: Request) {
|
||||
const { error } = await parseRequest(request, null, { skipAuth: true });
|
||||
|
||||
export async function getConfig(): Promise<Config> {
|
||||
return {
|
||||
if (error) {
|
||||
return error();
|
||||
}
|
||||
|
||||
return json({
|
||||
cloudMode: !!process.env.CLOUD_URL,
|
||||
cloudUrl: process.env.CLOUD_URL,
|
||||
faviconUrl: process.env.FAVICON_URL,
|
||||
|
|
@ -23,5 +18,5 @@ export async function getConfig(): Promise<Config> {
|
|||
telemetryDisabled: !!process.env.DISABLE_TELEMETRY,
|
||||
trackerScriptName: process.env.TRACKER_SCRIPT_NAME,
|
||||
updatesDisabled: !!process.env.DISABLE_UPDATES,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
@ -1,12 +1,27 @@
|
|||
import { useEffect } from 'react';
|
||||
import { useApp, setConfig } from '@/store/app';
|
||||
import { getConfig, Config } from '@/app/actions/getConfig';
|
||||
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;
|
||||
};
|
||||
|
||||
export function useConfig(): Config {
|
||||
const { config } = useApp();
|
||||
const { get } = useApi();
|
||||
|
||||
async function loadConfig() {
|
||||
setConfig(await getConfig());
|
||||
const data = await get(`/config`);
|
||||
|
||||
setConfig(data);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -8,12 +8,9 @@ import {
|
|||
MenuItem,
|
||||
MenuSeparator,
|
||||
MenuSection,
|
||||
Dialog,
|
||||
SubMenuTrigger,
|
||||
} from '@umami/react-zen';
|
||||
import { useMessages, useLoginQuery, useNavigation, useConfig } from '@/components/hooks';
|
||||
import { LogOut, LockKeyhole, Settings, Knobs } from '@/components/icons';
|
||||
import { PreferenceSettings } from '@/app/(main)/settings/preferences/PreferenceSettings';
|
||||
import { LogOut, LockKeyhole, Settings } from '@/components/icons';
|
||||
|
||||
export function SettingsButton() {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
|
|
@ -44,20 +41,6 @@ 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