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

Merged commits management #44

Merged
merged 1 commit into from
Jul 18, 2024
Merged

Merged commits management #44

merged 1 commit into from
Jul 18, 2024

Conversation

csansoon
Copy link
Contributor

@csansoon csansoon commented Jul 18, 2024

  • Added mergedAt property to commits
  • Created ProjectProvider and CommitProvider components
  • Modified getDocumentsAtCommit and other methods to new schema.

Note: Many functions require both commitUuid and projectId, since the commitUuid can be 'HEAD', and we will require the project to know which commit does that represent.

@csansoon csansoon force-pushed the commit-merged-at branch 2 times, most recently from 532a603 to 4ea0e26 Compare July 18, 2024 08:08
return (
<main className='flex flex-row w-full'>
<div className='w-[280px]'>
<Sidebar />
</div>
<div className='flex-1'>{children}</div>
</main>
)
return children
}
Copy link
Contributor Author

@csansoon csansoon Jul 18, 2024

Choose a reason for hiding this comment

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

Sidebar has been moved to /projects/[projectId]/commits/[commitUuid]/

@csansoon csansoon requested a review from andresgutgon July 18, 2024 08:18
Comment on lines +12 to +15
const CommitContext = createContext<CommitContextType>({
commitUuid: HEAD_COMMIT,
isDraft: false,
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

useCurrentCommit will return both the commitUuid and an isDraft property, which can be used to allow or forbid modifications depending on the commit.

Comment on lines +63 to +67
if (commit.mergedAt !== null) {
return Result.error(
new ForbiddenError('Cannot create a document version in a merged commit'),
)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this restriction on createDocumentVersion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm would be cool to have model level validations like activerecord, @andresgutgon do u know if there's something for this in drizzle land?

Copy link
Contributor

Choose a reason for hiding this comment

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

I saw this kind of repository pattern example:
https://gist.github.com/cayter/49d5c256a885d90c399ca6c1eca19f51

We could implement it and hook into beforeCreate to validate the row
https://gist.github.com/cayter/49d5c256a885d90c399ca6c1eca19f51#file-repository-ts-L357

But I didn't see anything official.

I'm a fan of ActiveRecord but Drizzle is super functional. I don't think it is wrong to have a service to create documents with the validation inside. As long as we use it as unique way for creating documents

@csansoon csansoon merged commit 52101f5 into main Jul 18, 2024
2 checks passed
@csansoon csansoon deleted the commit-merged-at branch July 18, 2024 10:07
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.

3 participants