Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISOM-1292: Add publish endpoint #381

Merged
merged 13 commits into from
Aug 12, 2024
Merged

ISOM-1292: Add publish endpoint #381

merged 13 commits into from
Aug 12, 2024

Conversation

harishv7
Copy link
Contributor

@harishv7 harishv7 commented Jul 28, 2024

TL;DR

This pull request introduces a publish endpoint and PublishButton component to the AppNavbar to enable page publishing.

What changed?

  • Relocated AppNavbar to a new folder structure: components/AppNavbar/AppNavbar.tsx.
  • Added PublishButton component to AppNavbar.
  • Implemented publish functionality in PublishButton.tsx with page and site parameters from the navigation path.
  • Added a new API endpoint publishPage to handle the publishing logic and update the database accordingly.
  • Updated page.router.ts and page.service.ts with publish logic.

Brief description of logic:

  1. Check if there is a draft to be published, if yes, proceed
  2. Fetch the page and the create a new version by incrementing the current version number
  3. Use this newly created versionId to update the existing resource and set the draftBlobId to null

Pending Todos:

  1. Implement trigger of CodeBuild

How to test?

  1. Navigate to the admin dashboard.
  2. Click the new Publish button.
  3. Verify page publication success or failure messages.

Why make this change?

This feature allows users to publish pages directly from the navigation bar, improving the publishing workflow and user experience.

Copy link

vercel bot commented Jul 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
isomer-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 9, 2024 5:01pm

Copy link
Contributor Author

harishv7 commented Jul 28, 2024

@harishv7 harishv7 changed the title add publish endpoint Add Publish Feature to AppNavbar Jul 28, 2024
@harishv7 harishv7 changed the title Add Publish Feature to AppNavbar ISOM-1292: Add publish endpoint Jul 28, 2024
Copy link

linear bot commented Jul 28, 2024

@harishv7 harishv7 marked this pull request as ready for review July 28, 2024 12:24
@harishv7 harishv7 requested a review from a team as a code owner July 28, 2024 12:24
@harishv7 harishv7 force-pushed the 07-25-add_migration_for_versions branch from 839db7a to 724aeb1 Compare July 29, 2024 05:20
@harishv7 harishv7 force-pushed the 07-28-add_publish_endpoint branch from 7d96701 to 5478fe4 Compare July 29, 2024 05:21
@harishv7 harishv7 force-pushed the 07-28-add_publish_endpoint branch from 5478fe4 to 3af1c1b Compare July 29, 2024 08:07
@harishv7 harishv7 marked this pull request as draft July 29, 2024 08:10
@harishv7 harishv7 force-pushed the 07-25-add_migration_for_versions branch from 3c993ca to 428ba73 Compare July 31, 2024 06:46
@harishv7 harishv7 force-pushed the 07-28-add_publish_endpoint branch from 3af1c1b to 50d871a Compare July 31, 2024 06:46
@harishv7 harishv7 force-pushed the 07-28-add_publish_endpoint branch from 50d871a to ff7ac7d Compare July 31, 2024 07:57
Base automatically changed from 07-25-add_migration_for_versions to main July 31, 2024 08:15
@harishv7 harishv7 force-pushed the 07-28-add_publish_endpoint branch from ff7ac7d to c150004 Compare July 31, 2024 08:17
Comment on lines 102 to 107
{publishButtonProps.showPublish && (
<PublishButton
pageId={publishButtonProps.pageId}
siteId={publishButtonProps.siteId}
/>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

question(non-blocking): should the button be completely hidden, or should it be shown but hidden?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Completely hiding might confuse the user as to why they can't publish. I prefer to show but disable and add a Tooltip saying:
"Publish will be enabled if there are unpublished edits"

@sehyunidaaa lmk your thoughts!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup agree, it should be shown but disabled! As for the copy, maybe All changes have been published ?

seaerchin
seaerchin previously approved these changes Aug 8, 2024
Copy link
Contributor

@seaerchin seaerchin left a comment

Choose a reason for hiding this comment

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

some minor comments, happy to approve after!

apps/studio/src/components/AppNavbar/AppNavbar.tsx Outdated Show resolved Hide resolved
apps/studio/src/components/AppNavbar/AppNavbar.tsx Outdated Show resolved Hide resolved
apps/studio/src/components/AppNavbar/AppNavbar.tsx Outdated Show resolved Hide resolved
apps/studio/src/components/AppNavbar/PublishButton.tsx Outdated Show resolved Hide resolved
apps/studio/src/components/AppNavbar/PublishButton.tsx Outdated Show resolved Hide resolved
apps/studio/src/server/modules/page/page.router.ts Outdated Show resolved Hide resolved
apps/studio/src/server/modules/version/version.service.ts Outdated Show resolved Hide resolved
const addedVersion = await db
.insertInto("Version")
.values({
versionNum,
Copy link
Contributor

Choose a reason for hiding this comment

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

why do callers need to pas in a versionNum? wouldn't we create the version at 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A resource has multiple versions -> every publish on the resource will increment its version by 1

Version numbering starts from 1

apps/studio/src/server/modules/version/version.service.ts Outdated Show resolved Hide resolved
.values({
versionNum,
resourceId: String(resourceId),
blobId: String(blobId),
Copy link
Contributor

Choose a reason for hiding this comment

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

not directly actionable but how will we utilise this blobId? the reason i'm asking is because this is a reference so even if we publish, the value of the blob itself can still change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once published the blob shouldn't change, it will be tied closely to the version. on the page resource, draftBlobId is immediately set to null so any future edits will be captured as a new blob

@seaerchin seaerchin dismissed their stale review August 8, 2024 10:22

accidental approval

Copy link
Contributor Author

harishv7 commented Aug 12, 2024

Merge activity

  • Aug 12, 12:44 PM EDT: @harishv7 started a stack merge that includes this pull request via Graphite.
  • Aug 12, 12:45 PM EDT: @harishv7 merged this pull request with Graphite.

@harishv7 harishv7 merged commit f06c139 into main Aug 12, 2024
15 of 17 checks passed
@harishv7 harishv7 deleted the 07-28-add_publish_endpoint branch August 12, 2024 16:45
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