Skip to content

Commit 827c107

Browse files
committed
Merge branch 'dev' into analytics
2 parents 630b91f + 784677e commit 827c107

File tree

15 files changed

+56
-44
lines changed

15 files changed

+56
-44
lines changed

next.config.mjs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ const cloudMode = process.env.CLOUD_MODE;
1212
const cloudUrl = process.env.CLOUD_URL;
1313
const corsMaxAge = process.env.CORS_MAX_AGE;
1414
const defaultLocale = process.env.DEFAULT_LOCALE;
15-
const disableLogin = process.env.DISABLE_LOGIN;
16-
const disableUI = process.env.DISABLE_UI;
17-
const faviconURL = process.env.FAVICON_URL;
1815
const forceSSL = process.env.FORCE_SSL;
1916
const frameAncestors = process.env.ALLOWED_FRAME_URLS ?? '';
20-
const privateMode = process.env.PRIVATE_MODE;
2117
const trackerScriptName = process.env.TRACKER_SCRIPT_NAME;
2218
const trackerScriptURL = process.env.TRACKER_SCRIPT_URL;
2319

@@ -173,13 +169,11 @@ if (cloudMode && cloudUrl) {
173169
permanent: false,
174170
});
175171

176-
if (disableLogin) {
177-
redirects.push({
178-
source: '/login',
179-
destination: cloudUrl,
180-
permanent: false,
181-
});
182-
}
172+
redirects.push({
173+
source: '/login',
174+
destination: cloudUrl,
175+
permanent: false,
176+
});
183177
}
184178

185179
/** @type {import('next').NextConfig} */
@@ -191,10 +185,6 @@ export default {
191185
cloudUrl,
192186
currentVersion: pkg.version,
193187
defaultLocale,
194-
disableLogin,
195-
disableUI,
196-
faviconURL,
197-
privateMode,
198188
},
199189
basePath,
200190
output: 'standalone',

src/app/(main)/App.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ export function App({ children }) {
2222
return null;
2323
}
2424

25-
if (config.uiDisabled) {
26-
return null;
27-
}
28-
2925
return (
3026
<>
3127
{children}

src/app/(main)/UpdateNotice.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ export function UpdateNotice({ user, config }) {
1313
const { latest, checked, hasUpdate, releaseUrl } = useStore();
1414
const pathname = usePathname();
1515
const [dismissed, setDismissed] = useState(checked);
16+
1617
const allowUpdate =
1718
process.env.NODE_ENV === 'production' &&
1819
user?.isAdmin &&
1920
!config?.updatesDisabled &&
21+
!config?.privateMode &&
2022
!pathname.includes('/share/') &&
2123
!process.env.cloudMode &&
22-
!process.env.privateMode &&
2324
!dismissed;
2425

2526
const updateCheck = useCallback(() => {

src/app/(main)/profile/LanguageSetting.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export function LanguageSetting() {
99
const [search, setSearch] = useState('');
1010
const { formatMessage, labels } = useMessages();
1111
const { locale, saveLocale } = useLocale();
12+
1213
const options = search
1314
? Object.keys(languages).filter(n => {
1415
return (

src/app/actions/getConfig.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
'use server';
22

3-
export async function getConfig() {
3+
export type Config = {
4+
faviconUrl: string | undefined;
5+
privateMode: boolean;
6+
telemetryDisabled: boolean;
7+
trackerScriptName: string | undefined;
8+
updatesDisabled: boolean;
9+
};
10+
11+
export async function getConfig(): Promise<Config> {
412
return {
13+
faviconUrl: process.env.FAVICON_URL,
14+
privateMode: !!process.env.PRIVATE_MODE,
515
telemetryDisabled: !!process.env.DISABLE_TELEMETRY,
616
trackerScriptName: process.env.TRACKER_SCRIPT_NAME,
7-
uiDisabled: !!process.env.DISABLE_UI,
817
updatesDisabled: !!process.env.DISABLE_UPDATES,
918
};
1019
}

src/app/api/scripts/telemetry/route.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ import { CURRENT_VERSION, TELEMETRY_PIXEL } from '@/lib/constants';
22

33
export async function GET() {
44
if (
5-
process.env.NODE_ENV !== 'production' &&
6-
process.env.DISABLE_TELEMETRY &&
5+
process.env.NODE_ENV !== 'production' ||
6+
process.env.DISABLE_TELEMETRY ||
77
process.env.PRIVATE_MODE
88
) {
9-
const script = `
10-
(()=>{const i=document.createElement('img');
11-
i.setAttribute('src','${TELEMETRY_PIXEL}?v=${CURRENT_VERSION}');
12-
i.setAttribute('style','width:0;height:0;position:absolute;pointer-events:none;');
13-
document.body.appendChild(i);})();
14-
`;
15-
16-
return new Response(script.replace(/\s\s+/g, ''), {
9+
return new Response('/* telemetry disabled */', {
1710
headers: {
1811
'content-type': 'text/javascript',
1912
},
2013
});
2114
}
2215

23-
return new Response('/* telemetry disabled */', {
16+
const script = `
17+
(()=>{const i=document.createElement('img');
18+
i.setAttribute('src','${TELEMETRY_PIXEL}?v=${CURRENT_VERSION}');
19+
i.setAttribute('style','width:0;height:0;position:absolute;pointer-events:none;');
20+
document.body.appendChild(i);})();
21+
`;
22+
23+
return new Response(script.replace(/\s\s+/g, ''), {
2424
headers: {
2525
'content-type': 'text/javascript',
2626
},

src/app/layout.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ import '@/styles/index.css';
99
import '@/styles/variables.css';
1010

1111
export default function ({ children }) {
12+
if (process.env.DISABLE_UI) {
13+
return (
14+
<html>
15+
<body></body>
16+
</html>
17+
);
18+
}
19+
1220
return (
1321
<html lang="en" data-scroll="0">
1422
<head>

src/app/login/LoginPage.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import LoginForm from './LoginForm';
33
import styles from './LoginPage.module.css';
44

55
export function LoginPage() {
6-
if (process.env.disableLogin) {
7-
return null;
8-
}
9-
106
return (
117
<div className={styles.page}>
128
<LoginForm />

src/app/login/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { Metadata } from 'next';
22
import LoginPage from './LoginPage';
33

44
export default async function () {
5+
if (process.env.DISABLE_LOGIN) {
6+
return null;
7+
}
8+
59
return <LoginPage />;
610
}
711

src/app/logout/LogoutPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { setUser } from '@/store/app';
66
import { removeClientAuthToken } from '@/lib/client';
77

88
export function LogoutPage() {
9-
const disabled = !!(process.env.disableLogin || process.env.cloudMode);
109
const router = useRouter();
1110
const { post } = useApi();
11+
const disabled = process.env.cloudMode;
1212

1313
useEffect(() => {
1414
async function logout() {

0 commit comments

Comments
 (0)