From 27aea943623851e05afaf728e82472fddba0556e Mon Sep 17 00:00:00 2001 From: Clinton Lunn Date: Sat, 7 Dec 2024 10:38:25 -0700 Subject: [PATCH 1/7] fix: adding a default vercel url to fix the share button --- src/app/(default)/components/SharePageURLButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/(default)/components/SharePageURLButton.tsx b/src/app/(default)/components/SharePageURLButton.tsx index 43500a25b..3cac7e520 100644 --- a/src/app/(default)/components/SharePageURLButton.tsx +++ b/src/app/(default)/components/SharePageURLButton.tsx @@ -10,7 +10,7 @@ import { ControlledTooltip } from '@/components/ui/Tooltip' */ export const SharePageURLButton: React.FC<{ path: string, name: string }> = ({ path, name }) => { const slug = getFriendlySlug(name) - const baseUrl = process.env.NEXT_PUBLIC_BASE_URL != null ? process.env.NEXT_PUBLIC_BASE_URL : 'http://localhost:3000' + const baseUrl = process.env.VERCEL_URL != null ? `https://${process.env.VERCEL_URL}` : 'http://localhost:3000' const optionalSlug = slug !== '' ? `/${slug}` : '' const url = `${baseUrl}${path}${optionalSlug}` From 071b60cab2e4bd30d54d39b21210b617c18858bf Mon Sep 17 00:00:00 2001 From: Clinton Lunn Date: Sat, 7 Dec 2024 10:57:36 -0700 Subject: [PATCH 2/7] refactor: add NEXT_PUBLIC_VERCEL_URL to env file --- .env | 2 ++ src/app/(default)/components/SharePageURLButton.tsx | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 415ac1936..e5797c3a0 100644 --- a/.env +++ b/.env @@ -21,6 +21,8 @@ NEXT_PUBLIC_CDN_URL=https://stg-media.openbeta.io NEXT_PUBLIC_API_SERVER=https://stg-api.openbeta.io +NEXT_PUBLIC_VERCEL_URL=$VERCEL_URL + # Disable telemetry NEXT_TELEMETRY_DISABLED=1 diff --git a/src/app/(default)/components/SharePageURLButton.tsx b/src/app/(default)/components/SharePageURLButton.tsx index 3cac7e520..ad6130cda 100644 --- a/src/app/(default)/components/SharePageURLButton.tsx +++ b/src/app/(default)/components/SharePageURLButton.tsx @@ -10,7 +10,8 @@ import { ControlledTooltip } from '@/components/ui/Tooltip' */ export const SharePageURLButton: React.FC<{ path: string, name: string }> = ({ path, name }) => { const slug = getFriendlySlug(name) - const baseUrl = process.env.VERCEL_URL != null ? `https://${process.env.VERCEL_URL}` : 'http://localhost:3000' + const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL != null ? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}` : 'http://localhost:3000' + console.log(process.env.NEXT_PUBLIC_VERCEL_URL) const optionalSlug = slug !== '' ? `/${slug}` : '' const url = `${baseUrl}${path}${optionalSlug}` From f912389b8b81c74adc598c2dfd289e2cf9385049 Mon Sep 17 00:00:00 2001 From: Clinton Lunn Date: Sat, 7 Dec 2024 11:17:47 -0700 Subject: [PATCH 3/7] refactor: fix conditions for checking env var --- src/app/(default)/components/SharePageURLButton.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/(default)/components/SharePageURLButton.tsx b/src/app/(default)/components/SharePageURLButton.tsx index ad6130cda..ccbd4fc17 100644 --- a/src/app/(default)/components/SharePageURLButton.tsx +++ b/src/app/(default)/components/SharePageURLButton.tsx @@ -10,8 +10,7 @@ import { ControlledTooltip } from '@/components/ui/Tooltip' */ export const SharePageURLButton: React.FC<{ path: string, name: string }> = ({ path, name }) => { const slug = getFriendlySlug(name) - const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL != null ? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}` : 'http://localhost:3000' - console.log(process.env.NEXT_PUBLIC_VERCEL_URL) + const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL !== '' && process.env.NEXT_PUBLIC_VERCEL_URL != null ? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}` : 'http://localhost:3000' const optionalSlug = slug !== '' ? `/${slug}` : '' const url = `${baseUrl}${path}${optionalSlug}` From deec60a066d196d249034b5039e388f41cf7afa1 Mon Sep 17 00:00:00 2001 From: Clinton Lunn Date: Sat, 7 Dec 2024 11:26:19 -0700 Subject: [PATCH 4/7] refactor: don't show share button on area page --- src/components/maps/TileHandlers/CragContent.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/maps/TileHandlers/CragContent.tsx b/src/components/maps/TileHandlers/CragContent.tsx index 4363d6323..30f0a08b3 100644 --- a/src/components/maps/TileHandlers/CragContent.tsx +++ b/src/components/maps/TileHandlers/CragContent.tsx @@ -11,6 +11,7 @@ export const CragDrawerContent: React.FC = ({ id, areaNam const friendlyUrl = getAreaPageFriendlyUrl(id, areaName) const editUrl = `/editArea/${id}/general` const pathname = `${usePathname()}${window.location.search}` + const isAreaPage = pathname.startsWith('/area/') return ( <> @@ -19,7 +20,7 @@ export const CragDrawerContent: React.FC = ({ id, areaNam heading={{areaName}} subheading={} cta={Edit area} - share={} + share={!isAreaPage && } >
{description == null || description.trim() === '' From c49b6c41b0ec33703b7e2d8714c7064dd6f939c5 Mon Sep 17 00:00:00 2001 From: Clinton Lunn Date: Sat, 7 Dec 2024 11:31:56 -0700 Subject: [PATCH 5/7] refactor: check if on map page instead, and change size of edit area button --- src/components/maps/TileHandlers/CragContent.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/maps/TileHandlers/CragContent.tsx b/src/components/maps/TileHandlers/CragContent.tsx index 30f0a08b3..0de8c3503 100644 --- a/src/components/maps/TileHandlers/CragContent.tsx +++ b/src/components/maps/TileHandlers/CragContent.tsx @@ -11,7 +11,7 @@ export const CragDrawerContent: React.FC = ({ id, areaNam const friendlyUrl = getAreaPageFriendlyUrl(id, areaName) const editUrl = `/editArea/${id}/general` const pathname = `${usePathname()}${window.location.search}` - const isAreaPage = pathname.startsWith('/area/') + const isMapPage = pathname.startsWith('/maps?') return ( <> @@ -19,8 +19,8 @@ export const CragDrawerContent: React.FC = ({ id, areaNam media={} heading={{areaName}} subheading={} - cta={Edit area} - share={!isAreaPage && } + cta={Edit area} + share={isMapPage && } >
{description == null || description.trim() === '' From 973e06514b938ada432a9a24d8a20517e339144b Mon Sep 17 00:00:00 2001 From: Clinton Lunn Date: Sat, 7 Dec 2024 12:30:23 -0700 Subject: [PATCH 6/7] refactor: link to /maps? from climb or area page, if on climb, will link to parent --- src/app/(default)/area/[[...slug]]/page.tsx | 2 +- src/app/(default)/climb/[[...slug]]/page.tsx | 5 ++++- src/app/(default)/components/AreaAndClimbPageActions.tsx | 8 ++++++-- src/js/graphql/gql/climbById.ts | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/(default)/area/[[...slug]]/page.tsx b/src/app/(default)/area/[[...slug]]/page.tsx index 3c6875a50..ff8a602cc 100644 --- a/src/app/(default)/area/[[...slug]]/page.tsx +++ b/src/app/(default)/area/[[...slug]]/page.tsx @@ -56,7 +56,7 @@ export default async function Page ({ params }: PageWithCatchAllUuidProps): Prom ? : } - pageActions={} + pageActions={} breadcrumbs={ diff --git a/src/app/(default)/climb/[[...slug]]/page.tsx b/src/app/(default)/climb/[[...slug]]/page.tsx index 0242c18e6..16911ea9a 100644 --- a/src/app/(default)/climb/[[...slug]]/page.tsx +++ b/src/app/(default)/climb/[[...slug]]/page.tsx @@ -40,6 +40,9 @@ export default async function Page ({ params }: PageWithCatchAllUuidProps): Prom id, name, type, ancestors, pathTokens, parent } = climb + console.log('parent', parent.uuid); + + const correctSlug = getFriendlySlug(name) if (correctSlug !== userProvidedSlug) { @@ -66,7 +69,7 @@ export default async function Page ({ params }: PageWithCatchAllUuidProps): Prom ? : } - pageActions={} + pageActions={} breadcrumbs={ diff --git a/src/app/(default)/components/AreaAndClimbPageActions.tsx b/src/app/(default)/components/AreaAndClimbPageActions.tsx index e66acb89a..ca2f904d4 100644 --- a/src/app/(default)/components/AreaAndClimbPageActions.tsx +++ b/src/app/(default)/components/AreaAndClimbPageActions.tsx @@ -8,22 +8,26 @@ import { TagTargetType } from '@/js/types' /** * Main action bar for area & climb page + * In an area page, pass in the same uuid for both `uuid` and `parentUuid` but `parentUuid` is not used. */ -export const AreaAndClimbPageActions: React.FC<{ uuid: string, name: string, targetType: TagTargetType }> = ({ uuid, name, targetType }) => { +export const AreaAndClimbPageActions: React.FC<{ uuid: string, name: string, targetType: TagTargetType, parentUuid: string }> = ({ uuid, name, targetType, parentUuid }) => { let url: string let sharePath: string let enableEdit = true let editLabel = 'Edit' + let navigateUuid = '' switch (targetType) { case TagTargetType.area: url = `/editArea/${uuid}` sharePath = `/area/${uuid}` + navigateUuid = uuid break case TagTargetType.climb: url = `/editClimb/${uuid}` sharePath = `/climb/${uuid}` enableEdit = false editLabel = 'Edit (TBD)' + navigateUuid = parentUuid ?? '' } return (
    @@ -33,7 +37,7 @@ export const AreaAndClimbPageActions: React.FC<{ uuid: string, name: string, tar - + Map diff --git a/src/js/graphql/gql/climbById.ts b/src/js/graphql/gql/climbById.ts index 9f85506be..99212ef7b 100644 --- a/src/js/graphql/gql/climbById.ts +++ b/src/js/graphql/gql/climbById.ts @@ -55,6 +55,7 @@ export const QUERY_CLIMB_BY_ID = gql` climbId } parent { + uuid, areaName gradeContext metadata { From ba8107a9529a6c3e5a49e897214cf2f015465bd0 Mon Sep 17 00:00:00 2001 From: Clinton Lunn Date: Sat, 7 Dec 2024 13:03:25 -0700 Subject: [PATCH 7/7] refactor: remove console log --- src/app/(default)/climb/[[...slug]]/page.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/app/(default)/climb/[[...slug]]/page.tsx b/src/app/(default)/climb/[[...slug]]/page.tsx index 16911ea9a..6345dfd23 100644 --- a/src/app/(default)/climb/[[...slug]]/page.tsx +++ b/src/app/(default)/climb/[[...slug]]/page.tsx @@ -40,9 +40,6 @@ export default async function Page ({ params }: PageWithCatchAllUuidProps): Prom id, name, type, ancestors, pathTokens, parent } = climb - console.log('parent', parent.uuid); - - const correctSlug = getFriendlySlug(name) if (correctSlug !== userProvidedSlug) {