Updated handling of env vars.

This commit is contained in:
Mike Cao 2024-05-11 21:52:40 -07:00
parent abd0913e9b
commit 30c1933718
8 changed files with 192 additions and 155 deletions

View file

@ -19,15 +19,3 @@
height: calc(100vh - 60px);
overflow-y: auto;
}
.content {
flex: 1;
display: flex;
flex-direction: column;
position: relative;
width: 100%;
max-width: 1320px;
margin: 0 auto;
padding: 0 20px;
min-height: calc(100vh - 60px);
}

View file

@ -5,6 +5,10 @@ import Page from 'components/layout/Page';
import styles from './layout.module.css';
export default function ({ children }) {
if (process.env.DISABLE_UI) {
return null;
}
return (
<App>
<main className={styles.layout}>

View file

@ -15,14 +15,7 @@ import { WebsiteContext } from 'app/(main)/websites/[websiteId]/WebsiteProvider'
const generateId = () => getRandomChars(16);
export function ShareUrl({
hostUrl,
onSave,
}: {
websiteId: string;
hostUrl?: string;
onSave?: () => void;
}) {
export function ShareUrl({ onSave }: { websiteId: string; onSave?: () => void }) {
const website = useContext(WebsiteContext);
const { domain, shareId } = website;
const { formatMessage, labels, messages } = useMessages();
@ -33,8 +26,8 @@ export function ShareUrl({
});
const { touch } = useModified();
const url = `${hostUrl || process.env.hostUrl || window?.location.origin}${
process.env.basePath
const url = `${process.env.shareUrlHost || window?.location.origin || ''}${
process.env.basePath || ''
}/share/${id}/${domain}`;
const handleGenerate = () => {

View file

@ -3,7 +3,7 @@ import { useMessages, useConfig } from 'components/hooks';
const SCRIPT_NAME = 'script.js';
export function TrackingCode({ websiteId, hostUrl }: { websiteId: string; hostUrl?: string }) {
export function TrackingCode({ websiteId }: { websiteId: string }) {
const { formatMessage, messages } = useMessages();
const config = useConfig();
@ -12,8 +12,8 @@ export function TrackingCode({ websiteId, hostUrl }: { websiteId: string; hostUr
const url = trackerScriptName?.startsWith('http')
? trackerScriptName
: `${hostUrl || process.env.hostUrl || window?.location.origin}${
process.env.basePath
: `${process.env.trackerScriptHost || window?.location.origin || ''}${
process.env.basePath || ''
}/${trackerScriptName}`;
const code = `<script defer src="${url}" data-website-id="${websiteId}"></script>`;

View file

@ -13,11 +13,9 @@ import WebsiteEditForm from './WebsiteEditForm';
export function WebsiteSettings({
websiteId,
hostUrl,
openExternal = false,
}: {
websiteId: string;
hostUrl?: string;
openExternal?: boolean;
}) {
const website = useContext(WebsiteContext);
@ -62,8 +60,8 @@ export function WebsiteSettings({
<Item key="data">{formatMessage(labels.data)}</Item>
</Tabs>
{tab === 'details' && <WebsiteEditForm websiteId={websiteId} onSave={handleSave} />}
{tab === 'tracking' && <TrackingCode websiteId={websiteId} hostUrl={hostUrl} />}
{tab === 'share' && <ShareUrl websiteId={websiteId} hostUrl={hostUrl} onSave={handleSave} />}
{tab === 'tracking' && <TrackingCode websiteId={websiteId} />}
{tab === 'share' && <ShareUrl websiteId={websiteId} onSave={handleSave} />}
{tab === 'data' && <WebsiteData websiteId={websiteId} onSave={handleSave} />}
</>
);

View file

@ -3,7 +3,7 @@ import LoginForm from './LoginForm';
import styles from './LoginPage.module.css';
export function LoginPage() {
if (process.env.loginDisabled) {
if (process.env.disableLogin) {
return null;
}