mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-06 13:35:48 +01:00
Changes for demo purposes
Add login button to login page, demo mode env variable and fix update indicator
This commit is contained in:
@@ -39,7 +39,7 @@ export const AvatarMenu = () => {
|
|||||||
<Menu width={256}>
|
<Menu width={256}>
|
||||||
<Menu.Target>
|
<Menu.Target>
|
||||||
<CurrentUserAvatar
|
<CurrentUserAvatar
|
||||||
newVersionAvailable={newVersionAvailable !== undefined}
|
newVersionAvailable={newVersionAvailable ? true : false}
|
||||||
user={sessionData?.user ?? null}
|
user={sessionData?.user ?? null}
|
||||||
/>
|
/>
|
||||||
</Menu.Target>
|
</Menu.Target>
|
||||||
@@ -128,13 +128,21 @@ const CurrentUserAvatar = forwardRef<HTMLDivElement, CurrentUserAvatarProps>(
|
|||||||
({ user, newVersionAvailable, ...others }, ref) => {
|
({ user, newVersionAvailable, ...others }, ref) => {
|
||||||
const { primaryColor } = useMantineTheme();
|
const { primaryColor } = useMantineTheme();
|
||||||
if (!user) return <Avatar ref={ref} {...others} />;
|
if (!user) return <Avatar ref={ref} {...others} />;
|
||||||
|
|
||||||
|
if (!newVersionAvailable)
|
||||||
return (
|
return (
|
||||||
<Indicator color="blue" processing size={10} hidden={!newVersionAvailable}>
|
<Indicator withBorder offset={2} color="blue" processing size={15}>
|
||||||
<Avatar ref={ref} color={primaryColor} {...others}>
|
<Avatar ref={ref} color={primaryColor} {...others}>
|
||||||
{user.name?.slice(0, 2).toUpperCase()}
|
{user.name?.slice(0, 2).toUpperCase()}
|
||||||
</Avatar>
|
</Avatar>
|
||||||
</Indicator>
|
</Indicator>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Avatar ref={ref} color={primaryColor} {...others}>
|
||||||
|
{user.name?.slice(0, 2).toUpperCase()}
|
||||||
|
</Avatar>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ const env = createEnv({
|
|||||||
),
|
),
|
||||||
DOCKER_HOST: z.string().optional(),
|
DOCKER_HOST: z.string().optional(),
|
||||||
DOCKER_PORT: portSchema,
|
DOCKER_PORT: portSchema,
|
||||||
|
DEMO_MODE: z.string().optional(),
|
||||||
HOSTNAME: z.string().optional(),
|
HOSTNAME: z.string().optional(),
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -62,6 +63,7 @@ const env = createEnv({
|
|||||||
NEXT_PUBLIC_PORT: process.env.PORT,
|
NEXT_PUBLIC_PORT: process.env.PORT,
|
||||||
NEXT_PUBLIC_NODE_ENV: process.env.NODE_ENV,
|
NEXT_PUBLIC_NODE_ENV: process.env.NODE_ENV,
|
||||||
HOSTNAME: process.env.HOSTNAME,
|
HOSTNAME: process.env.HOSTNAME,
|
||||||
|
DEMO_MODE: process.env.DEMO_MODE,
|
||||||
},
|
},
|
||||||
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
|
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ export default function Custom404() {
|
|||||||
<Button component={Link} variant="light" href="/b">
|
<Button component={Link} variant="light" href="/b">
|
||||||
{t('button')}
|
{t('button')}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button component={Link} variant="light" href="/auth/login">
|
||||||
|
Login
|
||||||
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Center>
|
</Center>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { useState } from 'react';
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { ThemeSchemeToggle } from '~/components/ThemeSchemeToggle/ThemeSchemeToggle';
|
import { ThemeSchemeToggle } from '~/components/ThemeSchemeToggle/ThemeSchemeToggle';
|
||||||
import { FloatingBackground } from '~/components/layout/Background/FloatingBackground';
|
import { FloatingBackground } from '~/components/layout/Background/FloatingBackground';
|
||||||
|
import { env } from '~/env';
|
||||||
import { getServerAuthSession } from '~/server/auth';
|
import { getServerAuthSession } from '~/server/auth';
|
||||||
import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations';
|
import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations';
|
||||||
import { useI18nZodResolver } from '~/utils/i18n-zod-resolver';
|
import { useI18nZodResolver } from '~/utils/i18n-zod-resolver';
|
||||||
@@ -29,6 +30,7 @@ import { signInSchema } from '~/validations/user';
|
|||||||
|
|
||||||
export default function LoginPage({
|
export default function LoginPage({
|
||||||
redirectAfterLogin,
|
redirectAfterLogin,
|
||||||
|
isDemo,
|
||||||
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
|
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
|
||||||
const { t } = useTranslation('authentication/login');
|
const { t } = useTranslation('authentication/login');
|
||||||
const { i18nZodResolver } = useI18nZodResolver();
|
const { i18nZodResolver } = useI18nZodResolver();
|
||||||
@@ -86,6 +88,12 @@ export default function LoginPage({
|
|||||||
Homarr
|
Homarr
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
{isDemo && (
|
||||||
|
<Alert title="Demo credentials">
|
||||||
|
For demo purposes, you can login with the login <b>demo</b> and password :{' '}
|
||||||
|
<b>demodemo</b>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
<Card withBorder shadow="md" p="xl" radius="md" w="90%" maw={450}>
|
<Card withBorder shadow="md" p="xl" radius="md" w="90%" maw={450}>
|
||||||
<Title style={{ whiteSpace: 'nowrap' }} align="center" weight={900}>
|
<Title style={{ whiteSpace: 'nowrap' }} align="center" weight={900}>
|
||||||
{t('title')}
|
{t('title')}
|
||||||
@@ -156,10 +164,13 @@ export const getServerSideProps: GetServerSideProps = async ({ locale, req, res,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isDemo = env.DEMO_MODE === 'true';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
...(await getServerSideTranslations(['authentication/login'], locale, req, res)),
|
...(await getServerSideTranslations(['authentication/login'], locale, req, res)),
|
||||||
redirectAfterLogin,
|
redirectAfterLogin,
|
||||||
|
isDemo,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user