mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-11 16:05:47 +01:00
🐛 Fix docker enabled issue
This commit is contained in:
@@ -24,14 +24,15 @@ import { api } from '~/utils/api';
|
||||
import { MainLayout } from './MainLayout';
|
||||
|
||||
type BoardLayoutProps = {
|
||||
dockerEnabled: boolean;
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
export const BoardLayout = ({ children }: BoardLayoutProps) => {
|
||||
export const BoardLayout = ({ children, dockerEnabled }: BoardLayoutProps) => {
|
||||
const { config } = useConfigContext();
|
||||
|
||||
return (
|
||||
<MainLayout headerActions={<HeaderActions />}>
|
||||
<MainLayout headerActions={<HeaderActions dockerEnabled={dockerEnabled} />}>
|
||||
<BoardHeadOverride />
|
||||
<BackgroundImage />
|
||||
{children}
|
||||
@@ -40,14 +41,18 @@ export const BoardLayout = ({ children }: BoardLayoutProps) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const HeaderActions = () => {
|
||||
type HeaderActionProps = {
|
||||
dockerEnabled: boolean;
|
||||
};
|
||||
|
||||
export const HeaderActions = ({ dockerEnabled }: HeaderActionProps) => {
|
||||
const { data: sessionData } = useSession();
|
||||
|
||||
if (!sessionData?.user?.isAdmin) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
{env.NEXT_PUBLIC_DOCKER_ENABLED && <DockerButton />}
|
||||
{dockerEnabled && <DockerButton />}
|
||||
<ToggleEditModeButton />
|
||||
<CustomizeBoardButton />
|
||||
</>
|
||||
|
||||
@@ -39,7 +39,7 @@ const env = createEnv({
|
||||
.refine((s) => s === 'light' || s === 'dark')
|
||||
.optional()
|
||||
.default('light'),
|
||||
NEXT_PUBLIC_DOCKER_ENABLED: z.boolean().optional().default(false),
|
||||
NEXT_PUBLIC_DOCKER_HOST: z.string().optional(),
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,6 @@ const env = createEnv({
|
||||
NEXT_PUBLIC_DEFAULT_COLOR_SCHEME: process.env.DEFAULT_COLOR_SCHEME,
|
||||
NEXT_PUBLIC_PORT: process.env.PORT,
|
||||
NEXT_PUBLIC_NODE_ENV: process.env.NODE_ENV,
|
||||
NEXT_PUBLIC_DOCKER_ENABLED: process.env.DOCKER_PORT && process.env.DOCKER_HOST,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { z } from 'zod';
|
||||
import { Dashboard } from '~/components/Dashboard/Dashboard';
|
||||
import { BoardLayout } from '~/components/layout/Templates/BoardLayout';
|
||||
import { useInitConfig } from '~/config/init';
|
||||
import { env } from '~/env';
|
||||
import { configExists } from '~/tools/config/configExists';
|
||||
import { getFrontendConfig } from '~/tools/config/getFrontendConfig';
|
||||
import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations';
|
||||
@@ -12,11 +13,12 @@ import { ConfigType } from '~/types/config';
|
||||
|
||||
export default function BoardPage({
|
||||
config: initialConfig,
|
||||
dockerEnabled,
|
||||
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
|
||||
useInitConfig(initialConfig);
|
||||
|
||||
return (
|
||||
<BoardLayout>
|
||||
<BoardLayout dockerEnabled={dockerEnabled}>
|
||||
<Dashboard />
|
||||
</BoardLayout>
|
||||
);
|
||||
@@ -24,6 +26,7 @@ export default function BoardPage({
|
||||
|
||||
type BoardGetServerSideProps = {
|
||||
config: ConfigType;
|
||||
dockerEnabled: boolean;
|
||||
_nextI18Next?: SSRConfig['_nextI18Next'];
|
||||
};
|
||||
|
||||
@@ -60,6 +63,7 @@ export const getServerSideProps: GetServerSideProps<BoardGetServerSideProps> = a
|
||||
primaryColor: config.settings.customization.colors.primary,
|
||||
secondaryColor: config.settings.customization.colors.secondary,
|
||||
primaryShade: config.settings.customization.colors.shade,
|
||||
dockerEnabled: !!env.DOCKER_HOST && !!env.DOCKER_PORT,
|
||||
...translations,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@ import { SSRConfig } from 'next-i18next';
|
||||
import { Dashboard } from '~/components/Dashboard/Dashboard';
|
||||
import { BoardLayout } from '~/components/layout/Templates/BoardLayout';
|
||||
import { useInitConfig } from '~/config/init';
|
||||
import { env } from '~/env';
|
||||
import { getServerAuthSession } from '~/server/auth';
|
||||
import { prisma } from '~/server/db';
|
||||
import { getFrontendConfig } from '~/tools/config/getFrontendConfig';
|
||||
@@ -12,11 +13,12 @@ import { ConfigType } from '~/types/config';
|
||||
|
||||
export default function BoardPage({
|
||||
config: initialConfig,
|
||||
dockerEnabled,
|
||||
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
|
||||
useInitConfig(initialConfig);
|
||||
|
||||
return (
|
||||
<BoardLayout>
|
||||
<BoardLayout dockerEnabled={dockerEnabled}>
|
||||
<Dashboard />
|
||||
</BoardLayout>
|
||||
);
|
||||
@@ -24,6 +26,7 @@ export default function BoardPage({
|
||||
|
||||
type BoardGetServerSideProps = {
|
||||
config: ConfigType;
|
||||
dockerEnabled: boolean;
|
||||
_nextI18Next?: SSRConfig['_nextI18Next'];
|
||||
};
|
||||
|
||||
@@ -50,6 +53,7 @@ export const getServerSideProps: GetServerSideProps<BoardGetServerSideProps> = a
|
||||
primaryColor: config.settings.customization.colors.primary,
|
||||
secondaryColor: config.settings.customization.colors.secondary,
|
||||
primaryShade: config.settings.customization.colors.shade,
|
||||
dockerEnabled: !!env.DOCKER_HOST && !!env.DOCKER_PORT,
|
||||
...translations,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -13,10 +13,7 @@ import { api } from '~/utils/api';
|
||||
|
||||
export default function DockerPage() {
|
||||
const [selection, setSelection] = useState<ContainerInfo[]>([]);
|
||||
const dockerEnabled = env.NEXT_PUBLIC_DOCKER_ENABLED;
|
||||
const { data, refetch, isRefetching } = api.docker.containers.useQuery(undefined, {
|
||||
enabled: dockerEnabled,
|
||||
});
|
||||
const { data, refetch, isRefetching } = api.docker.containers.useQuery();
|
||||
|
||||
const reload = () => {
|
||||
refetch();
|
||||
@@ -34,7 +31,7 @@ export default function DockerPage() {
|
||||
}
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async ({ locale, req, res }) => {
|
||||
if (!env.NEXT_PUBLIC_DOCKER_ENABLED) return { notFound: true };
|
||||
if (!env.DOCKER_HOST || !env.DOCKER_PORT) return { notFound: true };
|
||||
const session = await getServerAuthSession({ req, res });
|
||||
if (!session?.user.isAdmin) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user