mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-15 09:46:19 +01:00
♻️ Disable docker when not configured
This commit is contained in:
@@ -1,20 +1,19 @@
|
||||
import { Stack } from '@mantine/core';
|
||||
import { useDebouncedValue } from '@mantine/hooks';
|
||||
import { ContainerInfo } from 'dockerode';
|
||||
import { GetServerSideProps } from 'next';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useState } from 'react';
|
||||
import { MainLayout } from '~/components/layout/main';
|
||||
import { env } from '~/env';
|
||||
import ContainerActionBar from '~/modules/Docker/ContainerActionBar';
|
||||
import DockerTable from '~/modules/Docker/DockerTable';
|
||||
import { getServerAuthSession } from '~/server/auth';
|
||||
import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations';
|
||||
import { dashboardNamespaces } from '~/tools/server/translation-namespaces';
|
||||
import { api } from '~/utils/api';
|
||||
|
||||
export default function DockerPage() {
|
||||
const [selection, setSelection] = useState<ContainerInfo[]>([]);
|
||||
// TODO: read that from somewhere else?
|
||||
const dockerEnabled = true;
|
||||
const dockerEnabled = env.NEXT_PUBLIC_DOCKER_ENABLED;
|
||||
const { data, refetch, isRefetching } = api.docker.containers.useQuery(undefined, {
|
||||
enabled: dockerEnabled,
|
||||
});
|
||||
@@ -35,6 +34,14 @@ export default function DockerPage() {
|
||||
}
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async ({ locale, req, res }) => {
|
||||
if (!env.NEXT_PUBLIC_DOCKER_ENABLED) return { notFound: true };
|
||||
const session = await getServerAuthSession({ req, res });
|
||||
if (!session?.user.isAdmin) {
|
||||
return {
|
||||
notFound: true,
|
||||
};
|
||||
}
|
||||
|
||||
const translations = await getServerSideTranslations(dashboardNamespaces, locale, req, res);
|
||||
return {
|
||||
props: {
|
||||
|
||||
Reference in New Issue
Block a user