mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 09:45:04 +01:00
add DISABLE_UI, DISABLE_ADMIN
This commit is contained in:
parent
736f06442c
commit
99c975c329
@ -38,7 +38,7 @@ export default function Header() {
|
||||
<Link href="/realtime">
|
||||
<FormattedMessage id="label.realtime" defaultMessage="Realtime" />
|
||||
</Link>
|
||||
{!process.env.isCloudMode && (
|
||||
{!process.env.isAdminDisabled && (
|
||||
<Link href="/settings">
|
||||
<FormattedMessage id="label.settings" defaultMessage="Settings" />
|
||||
</Link>
|
||||
|
@ -28,7 +28,7 @@ export default function UserButton() {
|
||||
{
|
||||
label: <FormattedMessage id="label.profile" defaultMessage="Profile" />,
|
||||
value: 'profile',
|
||||
hidden: process.env.isCloudMode,
|
||||
hidden: process.env.isAdminDisabled,
|
||||
},
|
||||
{ label: <FormattedMessage id="label.logout" defaultMessage="Logout" />, value: 'logout' },
|
||||
];
|
||||
|
@ -36,7 +36,7 @@ module.exports = {
|
||||
env: {
|
||||
currentVersion: pkg.version,
|
||||
isProduction: process.env.NODE_ENV === 'production',
|
||||
isCloudMode: process.env.CLOUD_MODE,
|
||||
isAdminDisabled: process.env.DISABLE_ADMIN,
|
||||
},
|
||||
basePath: process.env.BASE_PATH,
|
||||
output: 'standalone',
|
||||
|
14
pages/404.js
14
pages/404.js
@ -2,7 +2,11 @@ import React from 'react';
|
||||
import Layout from 'components/layout/Layout';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
export default function Custom404() {
|
||||
export default function Custom404({ pageDisabled }) {
|
||||
if (pageDisabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<div className="row justify-content-center">
|
||||
@ -13,3 +17,11 @@ export default function Custom404() {
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps() {
|
||||
return {
|
||||
props: {
|
||||
pageDisabled: !!process.env.DISABLE_UI,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ import TestConsole from 'components/pages/TestConsole';
|
||||
import useRequireLogin from 'hooks/useRequireLogin';
|
||||
import useUser from 'hooks/useUser';
|
||||
|
||||
export default function ConsolePage({ enabled }) {
|
||||
export default function ConsolePage({ enabled, pageDisabled }) {
|
||||
const { loading } = useRequireLogin();
|
||||
const { user } = useUser();
|
||||
|
||||
if (loading || !enabled || !user?.isAdmin) {
|
||||
if (pageDisabled || loading || !enabled || !user?.isAdmin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -21,6 +21,9 @@ export default function ConsolePage({ enabled }) {
|
||||
|
||||
export async function getServerSideProps() {
|
||||
return {
|
||||
props: { enabled: !!process.env.ENABLE_TEST_CONSOLE },
|
||||
props: {
|
||||
pageDisabled: !!process.env.DISABLE_UI,
|
||||
enabled: !!process.env.ENABLE_TEST_CONSOLE,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import useRequireLogin from 'hooks/useRequireLogin';
|
||||
import { useRouter } from 'next/router';
|
||||
import useUser from 'hooks/useUser';
|
||||
|
||||
export default function DashboardPage() {
|
||||
export default function DashboardPage({ pageDisabled }) {
|
||||
const {
|
||||
query: { id },
|
||||
isReady,
|
||||
@ -14,7 +14,7 @@ export default function DashboardPage() {
|
||||
const { loading } = useRequireLogin();
|
||||
const user = useUser();
|
||||
|
||||
if (!user || !isReady || loading) {
|
||||
if (pageDisabled || !user || !isReady || loading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -26,3 +26,11 @@ export default function DashboardPage() {
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps() {
|
||||
return {
|
||||
props: {
|
||||
pageDisabled: !!process.env.DISABLE_UI,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ import React from 'react';
|
||||
import Layout from 'components/layout/Layout';
|
||||
import LoginForm from 'components/forms/LoginForm';
|
||||
|
||||
export default function LoginPage({ loginDisabled }) {
|
||||
if (loginDisabled) {
|
||||
export default function LoginPage({ pageDisabled }) {
|
||||
if (pageDisabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -16,6 +16,9 @@ export default function LoginPage({ loginDisabled }) {
|
||||
|
||||
export async function getServerSideProps() {
|
||||
return {
|
||||
props: { loginDisabled: !!process.env.DISABLE_LOGIN || !!process.env.isCloudMode },
|
||||
props: {
|
||||
pageDisabled:
|
||||
!!process.env.DISABLE_LOGIN || !!process.env.DISABLE_UI || !!process.env.isAdminDisabled,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ import Layout from 'components/layout/Layout';
|
||||
import RealtimeDashboard from 'components/pages/RealtimeDashboard';
|
||||
import useRequireLogin from 'hooks/useRequireLogin';
|
||||
|
||||
export default function RealtimePage() {
|
||||
export default function RealtimePage({ pageDisabled }) {
|
||||
const { loading } = useRequireLogin();
|
||||
|
||||
if (loading) {
|
||||
if (pageDisabled || loading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -16,3 +16,11 @@ export default function RealtimePage() {
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps() {
|
||||
return {
|
||||
props: {
|
||||
pageDisabled: !!process.env.DISABLE_UI,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -1,3 +1,11 @@
|
||||
import Index from './index';
|
||||
|
||||
export default Index;
|
||||
|
||||
export async function getServerSideProps() {
|
||||
return {
|
||||
props: {
|
||||
pageDisabled: !!process.env.DISABLE_UI,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ import Layout from 'components/layout/Layout';
|
||||
import Settings from 'components/pages/Settings';
|
||||
import useRequireLogin from 'hooks/useRequireLogin';
|
||||
|
||||
export default function SettingsPage() {
|
||||
export default function SettingsPage({ pageDisabled }) {
|
||||
const { loading } = useRequireLogin();
|
||||
|
||||
if (process.env.isCloudMode || loading) {
|
||||
if (pageDisabled || loading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -16,3 +16,11 @@ export default function SettingsPage() {
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps() {
|
||||
return {
|
||||
props: {
|
||||
pageDisabled: !!process.env.DISABLE_UI || !!process.env.isAdminDisabled,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -1,3 +1,11 @@
|
||||
import Index from './index';
|
||||
|
||||
export default Index;
|
||||
|
||||
export async function getServerSideProps() {
|
||||
return {
|
||||
props: {
|
||||
pageDisabled: !!process.env.DISABLE_UI,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -4,13 +4,13 @@ import Layout from 'components/layout/Layout';
|
||||
import WebsiteDetails from 'components/pages/WebsiteDetails';
|
||||
import useShareToken from 'hooks/useShareToken';
|
||||
|
||||
export default function SharePage() {
|
||||
export default function SharePage({ pageDisabled }) {
|
||||
const router = useRouter();
|
||||
const { id } = router.query;
|
||||
const shareId = id?.[0];
|
||||
const shareToken = useShareToken(shareId);
|
||||
|
||||
if (!shareToken) {
|
||||
if (pageDisabled || !shareToken) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -20,3 +20,11 @@ export default function SharePage() {
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps() {
|
||||
return {
|
||||
props: {
|
||||
pageDisabled: !!process.env.DISABLE_UI,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ import Layout from 'components/layout/Layout';
|
||||
import WebsiteDetails from 'components/pages/WebsiteDetails';
|
||||
import useRequireLogin from 'hooks/useRequireLogin';
|
||||
|
||||
export default function DetailsPage() {
|
||||
export default function DetailsPage({ pageDisabled }) {
|
||||
const { loading } = useRequireLogin();
|
||||
const router = useRouter();
|
||||
const { id } = router.query;
|
||||
|
||||
if (!id || loading) {
|
||||
if (pageDisabled || !id || loading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -21,3 +21,11 @@ export default function DetailsPage() {
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps() {
|
||||
return {
|
||||
props: {
|
||||
pageDisabled: !!process.env.DISABLE_UI,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user