From a7e6c324602cdfb196560fd2569ab24f8e554d53 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 21 Apr 2023 15:14:30 -0700 Subject: [PATCH] Updated page titles. --- next.config.js | 8 +++++++- pages/realtime/[id]/index.js | 6 ++++-- pages/settings/index.js | 12 ------------ pages/settings/profile/index.js | 2 +- pages/settings/teams/[id]/index.js | 2 +- pages/settings/teams/index.js | 2 +- pages/settings/users/[id]/index.js | 2 +- pages/settings/users/index.js | 2 +- pages/settings/websites/[id]/index.js | 2 +- pages/settings/websites/index.js | 2 +- 10 files changed, 18 insertions(+), 22 deletions(-) delete mode 100644 pages/settings/index.js diff --git a/next.config.js b/next.config.js index 7d5fd565..58e0561f 100644 --- a/next.config.js +++ b/next.config.js @@ -57,7 +57,13 @@ if (process.env.TRACKER_SCRIPT_NAME) { } } -const redirects = []; +const redirects = [ + { + source: '/settings', + destination: process.env.CLOUD_MODE ? '/settings/profile' : '/settings/websites', + permanent: true, + }, +]; if (process.env.CLOUD_MODE) { redirects.push({ diff --git a/pages/realtime/[id]/index.js b/pages/realtime/[id]/index.js index 1cc826ee..43475fa5 100644 --- a/pages/realtime/[id]/index.js +++ b/pages/realtime/[id]/index.js @@ -9,8 +9,10 @@ export default function RealtimeDetailsPage() { const { id: websiteId } = router.query; const { formatMessage, labels } = useMessages(); const { get, useQuery } = useApi(); - const { data: website } = useQuery(['websites', websiteId], () => get(`/websites/${websiteId}`)); - const title = formatMessage(labels.realtime) + ' | ' + website?.name; + const { data: website } = useQuery(['websites', websiteId], () => + get(`/websites/${websiteId}`, { enabled: !!websiteId }), + ); + const title = `${formatMessage(labels.realtime)}${website?.name ? ` - ${website.name}` : ''}`; if (!websiteId) { return null; diff --git a/pages/settings/index.js b/pages/settings/index.js deleted file mode 100644 index f76d6406..00000000 --- a/pages/settings/index.js +++ /dev/null @@ -1,12 +0,0 @@ -export default () => null; - -export async function getServerSideProps() { - const dest = process.env.CLOUD_MODE ? 'profile' : 'websites'; - - return { - redirect: { - destination: `/settings/${dest}`, - permanent: true, - }, - }; -} diff --git a/pages/settings/profile/index.js b/pages/settings/profile/index.js index c7dd7d6c..aef21bb6 100644 --- a/pages/settings/profile/index.js +++ b/pages/settings/profile/index.js @@ -6,7 +6,7 @@ import useMessages from 'hooks/useMessages'; export default function ProfilePage() { const { formatMessage, labels } = useMessages(); return ( - + diff --git a/pages/settings/teams/[id]/index.js b/pages/settings/teams/[id]/index.js index 400d5735..6eb631b1 100644 --- a/pages/settings/teams/[id]/index.js +++ b/pages/settings/teams/[id]/index.js @@ -14,7 +14,7 @@ export default function TeamDetailPage({ disabled }) { } return ( - + diff --git a/pages/settings/teams/index.js b/pages/settings/teams/index.js index c2304ab0..471ddf0f 100644 --- a/pages/settings/teams/index.js +++ b/pages/settings/teams/index.js @@ -10,7 +10,7 @@ export default function TeamsPage({ disabled }) { } return ( - + diff --git a/pages/settings/users/[id]/index.js b/pages/settings/users/[id]/index.js index b25d5295..94df6951 100644 --- a/pages/settings/users/[id]/index.js +++ b/pages/settings/users/[id]/index.js @@ -14,7 +14,7 @@ export default function TeamDetailPage({ disabled }) { } return ( - + diff --git a/pages/settings/users/index.js b/pages/settings/users/index.js index 5dbb6966..6e021a74 100644 --- a/pages/settings/users/index.js +++ b/pages/settings/users/index.js @@ -10,7 +10,7 @@ export default function UsersPage({ disabled }) { } return ( - + diff --git a/pages/settings/websites/[id]/index.js b/pages/settings/websites/[id]/index.js index 63afbf81..7b97b8f5 100644 --- a/pages/settings/websites/[id]/index.js +++ b/pages/settings/websites/[id]/index.js @@ -14,7 +14,7 @@ export default function WebsiteSettingsPage({ disabled }) { } return ( - + diff --git a/pages/settings/websites/index.js b/pages/settings/websites/index.js index 4599e793..c115b081 100644 --- a/pages/settings/websites/index.js +++ b/pages/settings/websites/index.js @@ -10,7 +10,7 @@ export default function WebsitesPage({ disabled }) { } return ( - +