-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add presets for files, firebase rules
Added firebase rules in the firebase/ folder. Added custom presets to show latex
- Loading branch information
1 parent
ba923e2
commit 9332487
Showing
3 changed files
with
154 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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,33 @@ | ||
rules_version = '2'; | ||
|
||
service cloud.firestore { | ||
match /databases/{database}/documents { | ||
|
||
match /documents/{documentId} { | ||
// Allow read and write if the user is the owner or has write access | ||
allow read, write: if request.auth.uid == resource.data.owner || request.auth.uid in resource.data.writeAccess; | ||
|
||
// Allow read if the user has read access or if "all" is in the readAccess array | ||
allow read: if request.auth.uid in resource.data.readAccess || "all" in resource.data.readAccess; | ||
|
||
// Allow instances to be created and accessed by authenticated users | ||
match /instances/{instanceId=**} { | ||
allow read, write: if request.auth.uid != null; | ||
} | ||
|
||
// Allow create if user is authenticated and provides valid data | ||
allow create: if request.auth.uid != null && request.resource.data.owner == request.auth.uid; | ||
|
||
// Add validation to ensure data integrity | ||
allow create, update: if request.resource.data.keys().hasAll(['owner', 'writeAccess', 'readAccess']) && | ||
request.resource.data.owner == request.auth.uid && | ||
request.resource.data.writeAccess is list && | ||
request.resource.data.readAccess is list; | ||
} | ||
|
||
// User document access | ||
match /users/{userId} { | ||
allow read, update: if request.auth.uid == userId; | ||
} | ||
} | ||
} |
This file contains 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 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,69 @@ | ||
import { useState } from "react" | ||
import { Button } from "@/components/ui/button" | ||
import { | ||
Dialog, | ||
DialogClose, | ||
DialogContent, | ||
DialogDescription, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from "@/components/ui/dialog" | ||
import { Input } from "@/components/ui/input" | ||
|
||
interface DocumentDialogProps { | ||
documentName: string | ||
onDialogClose: (documentName: string) => Promise<void> | ||
children: React.ReactNode | ||
} | ||
|
||
const DocumentDialog: React.FC<DocumentDialogProps> = ({ | ||
documentName, | ||
onDialogClose, | ||
children, | ||
}) => { | ||
const [rename, setRename] = useState<string>("") | ||
|
||
return ( | ||
<div className="flex h-56 w-44 flex-col items-center"> | ||
<Dialog> | ||
<DialogTrigger asChild> | ||
<Button | ||
variant="ghost" | ||
className="size-full rounded bg-foreground/5 p-2" | ||
onClick={() => setRename("")} | ||
> | ||
{children} | ||
</Button> | ||
</DialogTrigger> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>New Document</DialogTitle> | ||
<DialogDescription> | ||
Create a new document with a blank slate | ||
</DialogDescription> | ||
</DialogHeader> | ||
<div> | ||
<Input | ||
className="w-full" | ||
placeholder="Document Name" | ||
value={rename} | ||
onChange={(e) => setRename(e.target.value)} | ||
/> | ||
<DialogClose asChild> | ||
<Button | ||
className="mt-4" | ||
onClick={async () => await onDialogClose(rename)} | ||
> | ||
Create | ||
</Button> | ||
</DialogClose> | ||
</div> | ||
</DialogContent> | ||
</Dialog> | ||
<div className="mt-1 font-semibold">{documentName}</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default DocumentDialog |