-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feature: org settings #1147
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
Merged
feature: org settings #1147
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
ae1393b
wip
ameer2468 792ca43
Merge branch 'main' into org-settings
ameer2468 12e7ae4
wip
ameer2468 c1a9f9a
Merge branch 'main' into org-settings
ameer2468 938e7b8
Merge branch 'main' into org-settings
ameer2468 c31a74b
wip
ameer2468 93a1aa0
Merge branch 'main' into org-settings
ameer2468 359d5cf
wip
ameer2468 f4f60e9
Merge branch 'main' into org-settings
ameer2468 9efe4ae
more settings
ameer2468 19dae6d
setup org-wide settings and more
ameer2468 235339f
cleanup
ameer2468 83395dd
Merge branch 'main' into org-settings
ameer2468 85aab08
Merge branch 'main' into org-settings
ameer2468 91a634f
edge cases, handle backend and stop transcript generation, ui enable/…
ameer2468 2e7523d
text
ameer2468 339548c
show download button for non-owners
ameer2468 ce30f6b
Merge branch 'main' into org-settings
richiemcilroy 7eb43f3
skipped transcription status and conditionally render chapters and su…
ameer2468 820e86f
Merge branch 'main' into org-settings
ameer2468 bade5f6
Update _journal.json
ameer2468 10bcd08
Update pnpm-lock.yaml
ameer2468 0bd11fa
switches toggled by default
ameer2468 e319cb7
review points
ameer2468 a4429f7
cleanup
ameer2468 6f8d603
better messaging
ameer2468 f6614dd
description abit too long
ameer2468 1ee233e
fix label
ameer2468 734029f
make sure dialog resets, fix pro text color
ameer2468 86a13ec
Update SharedCaps.tsx
ameer2468 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| "use server"; | ||
|
|
||
| import { db } from "@cap/database"; | ||
| import { getCurrentUser } from "@cap/database/auth/session"; | ||
| import { organizations } from "@cap/database/schema"; | ||
| import { eq } from "drizzle-orm"; | ||
| import { revalidatePath } from "next/cache"; | ||
|
|
||
| export async function updateOrganizationSettings(settings: { | ||
| disableSummary?: boolean; | ||
| disableCaptions?: boolean; | ||
| disableChapters?: boolean; | ||
| disableReactions?: boolean; | ||
| disableTranscript?: boolean; | ||
| disableComments?: boolean; | ||
| }) { | ||
| const user = await getCurrentUser(); | ||
|
|
||
| if (!user) { | ||
| throw new Error("Unauthorized"); | ||
| } | ||
|
|
||
| if (!settings) { | ||
| throw new Error("Settings are required"); | ||
| } | ||
|
|
||
| const [organization] = await db() | ||
| .select() | ||
| .from(organizations) | ||
| .where(eq(organizations.id, user.activeOrganizationId)); | ||
|
|
||
| if (!organization) { | ||
| throw new Error("Organization not found"); | ||
| } | ||
|
|
||
| await db() | ||
| .update(organizations) | ||
| .set({ settings }) | ||
| .where(eq(organizations.id, user.activeOrganizationId)); | ||
|
|
||
| revalidatePath("/dashboard/caps"); | ||
|
|
||
| return { success: true }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| "use server"; | ||
|
|
||
| import { db } from "@cap/database"; | ||
| import { getCurrentUser } from "@cap/database/auth/session"; | ||
| import { videos } from "@cap/database/schema"; | ||
| import type { Video } from "@cap/web-domain"; | ||
| import { eq } from "drizzle-orm"; | ||
|
|
||
| export async function updateVideoSettings( | ||
| videoId: Video.VideoId, | ||
| videoSettings: { | ||
| disableSummary?: boolean; | ||
| disableCaptions?: boolean; | ||
| disableChapters?: boolean; | ||
| disableReactions?: boolean; | ||
| disableTranscript?: boolean; | ||
| disableComments?: boolean; | ||
| }, | ||
| ) { | ||
| const user = await getCurrentUser(); | ||
|
|
||
| if (!user || !videoId || !videoSettings) { | ||
| throw new Error("Missing required data for updating video settings"); | ||
| } | ||
|
|
||
| const [video] = await db() | ||
| .select() | ||
| .from(videos) | ||
| .where(eq(videos.id, videoId)); | ||
|
|
||
| if (!video) { | ||
| throw new Error("Video not found for updating video settings"); | ||
| } | ||
|
|
||
| if (video.ownerId !== user.id) { | ||
| throw new Error("You don't have permission to update this video settings"); | ||
| } | ||
|
|
||
| await db() | ||
| .update(videos) | ||
| .set({ settings: videoSettings }) | ||
| .where(eq(videos.id, videoId)); | ||
|
|
||
| return { success: true }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.