Skip to content

Conversation

@rchlfryn
Copy link
Collaborator

@rchlfryn rchlfryn commented Jul 11, 2025

Description

There is a request to help avalanche centers build there pages. The way we decided to do this is build a "template tenant" that will not be seen by anyone but super admins, create the pages under that tenant, and duplicate any pages to the respective avalance center that wants the page. This PR:

  • Adds a new tenant Death Valley Avalance Center (dvac)
  • Adds a Duplicate page for... button in the edit view of pages

We still need to alter permissions, but that will be a follow up PR with #316 out in the wild at the same time.
We also need to build the pages which will be a separate PR

Issue

Addressed part of of #243

@rchlfryn rchlfryn self-assigned this Jul 11, 2025
@github-actions
Copy link

Preview deployment: https://template-tenant.preview.avy-fx.org

@rchlfryn rchlfryn force-pushed the template-tenant branch 3 times, most recently from b2e8d26 to 010c057 Compare July 15, 2025 00:08
Copy link
Collaborator

@busbyk busbyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it!

We talked about some UI for duplicating all off the template tenant's (i.e. dvac) pages to a newly created tenant. I assume this is a precursor to that and that will be in another PR?

Comment on lines 21 to 22
// TODOs
// - Remove photos from blocks or use a global photo?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah because photos are tenant scoped right. Hadn't thought about that.

I think using a global, fallback photo might be a nice UX. Might be worth calling this out in some helper text in the duplicate to drawer.

@rchlfryn rchlfryn marked this pull request as ready for review July 16, 2025 01:01
@rchlfryn rchlfryn requested a review from busbyk July 16, 2025 05:07
layout,
title,
tenant,
slug: `${slug.replace(/^\/([^/]+)\//, `/${tenant.slug}/`)}-${timestamp}`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I duplicate a page to a tenant the slug is generated with the timestamp suffix. When viewing it in the pages list view I see that timestamped slug but in the edit view it shows as the slug determined from the fieldToUse which defaults to 'title' in https://github.com/NWACus/web/blob/template-tenant/src/fields/slug/SlugComponent.tsx
CleanShot 2025-07-16 at 08 59 51

Then saving this results in a conflict:
CleanShot 2025-07-16 at 09 00 40@2x

I guess I have a few thoughts here:

  1. Whoa our slug field should probably allow us to modify the slug to be different than a slug determined from the configured fieldToUse which is title for the pages collection. I think the behavior here is a bug with the slug field separate from this PR but does impact the functionality here.
  2. Rather than generating a slug with a suffixed timestamp it would be nice to check if the slug is already taken and then append an incrementing number. I know that's more effort than just a guaranteed unique slug via the timestamp method. It would be nice to do this in a server action to be able to use the local API.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@busbyk I took the shortcut but agree adding a sequential/incremental number is so much better. I added a new endpoint to do all the heavy lifting for us in d554444.

I also side stepped the "slug bug" in payload where it is rendered based on the title since I added the sequential number to the title. This seemed like the cleanest approach.

@rchlfryn rchlfryn requested a review from busbyk July 19, 2025 01:05
Copy link
Collaborator

@busbyk busbyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the changes! Breaking this out into it's own endpoint will probably be helpful for future the script to copy all pages from the template tenant to a new tenant during onboarding.

Just one suggested change and a thought:

I've been colocating things (components, hooks, server actions, etc.) within the collection's folder if they are specific to a collection. What do you think about that? Do you like that approach?

It might be nice to colocate the DuplicatePageFor components and the duplicatePageToTenant handler inside of the pages collection for consistency if you think that makes sense.

i.e. ./src/collections/Pages/component/DuplicatePageFor and ./src/collections/Pages/endpoints/duplicatePageToTenant

Looks good pending the incrementing slug change (feel free to take a different approach than my suggestion of course but I do think we should handle copying the title and slug without an integer suffix if there is no conflict).

@rchlfryn
Copy link
Collaborator Author

I've been colocating things (components, hooks, server actions, etc.) within the collection's folder if they are specific to a collection. What do you think about that? Do you like that approach?

It might be nice to colocate the DuplicatePageFor components and the duplicatePageToTenant handler inside of the pages collection for consistency if you think that makes sense.

I like this approach better as well. If we do end up using it for posts or something else, we can unnest it from Pages.

@rchlfryn rchlfryn added this pull request to the merge queue Jul 23, 2025
Merged via the queue into main with commit 95c5947 Jul 23, 2025
5 checks passed
@rchlfryn rchlfryn deleted the template-tenant branch July 23, 2025 03:50
@rchlfryn rchlfryn mentioned this pull request Jul 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants