Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Update redirects for teams.

Mike Caof01073c46afd
diff --git a/next.config.js b/next.config.js
index f353b1f95..dce49100e 100644
--- a/next.config.js
+++ b/next.config.js
@@ -70,7 +70,7 @@ if (trackerScriptName) {
const redirects = [
{
source: '/settings',
- destination: cloudMode ? `${cloudUrl}/settings/websites` : '/settings/websites',
+ destination: '/settings/websites',
permanent: true,
},
{
@@ -80,17 +80,31 @@ const redirects = [
},
{
source: '/teams/:id/settings',
- destination: cloudMode ? `${cloudUrl}/teams/:id/settings` : '/teams/:id/settings/team',
+ destination: '/teams/:id/settings/team',
permanent: true,
},
];
-if (cloudMode && cloudUrl && disableLogin) {
+if (cloudMode && cloudUrl) {
redirects.push({
- source: '/login',
- destination: cloudUrl,
+ source: '/settings/:path*',
+ destination: `${cloudUrl}/settings/:path*`,
permanent: false,
});
+
+ redirects.push({
+ source: '/teams/:id/settings/:path*',
+ destination: `${cloudUrl}/teams/:id/settings/:path*`,
+ permanent: false,
+ });
+
+ if (disableLogin) {
+ redirects.push({
+ source: '/login',
+ destination: cloudUrl,
+ permanent: false,
+ });
+ }
}
/** @type {import('next').NextConfig} */
diff --git a/src/app/(main)/NavBar.tsx b/src/app/(main)/NavBar.tsx
index 86d1db71a..15b233559 100644
--- a/src/app/(main)/NavBar.tsx
+++ b/src/app/(main)/NavBar.tsx
@@ -17,7 +17,7 @@ export function NavBar() {
const { pathname } = useNavigation();
const { teamId, renderTeamUrl } = useTeamUrl();
- const cloudMode = Boolean(process.env.cloudMode);
+ const cloudMode = !!process.env.cloudMode;
const links = [
{ label: formatMessage(labels.dashboard), url: renderTeamUrl('/dashboard') },
diff --git a/src/app/(main)/settings/layout.tsx b/src/app/(main)/settings/layout.tsx
index eb382e3b7..487a9d596 100644
--- a/src/app/(main)/settings/layout.tsx
+++ b/src/app/(main)/settings/layout.tsx
@@ -1,5 +1,9 @@
import SettingsLayout from './SettingsLayout';
export default function ({ children }) {
+ if (process.env.cloudMode) {
+ return null;
+ }
+
return <SettingsLayout>{children}</SettingsLayout>;
}
diff --git a/src/components/input/TeamsButton.tsx b/src/components/input/TeamsButton.tsx
index a91cdb2f6..c7fc535ac 100644
--- a/src/components/input/TeamsButton.tsx
+++ b/src/components/input/TeamsButton.tsx
@@ -10,10 +10,11 @@ export function TeamsButton({ teamId }: { teamId: string }) {
const { formatMessage, labels } = useMessages();
const { router } = useNavigation();
const team = user?.teams?.find(({ id }) => id === teamId);
+ const cloudMode = !!process.env.cloudMode;
const handleSelect = (close: () => void, id: Key) => {
if (id !== user.id) {
- router.push(`/teams/${id}`);
+ router.push(cloudMode ? `${process.env.cloudUrl}/teams/${id}` : `/teams/${id}`);
} else {
router.push('/');
}