diff --git a/app/routes/app.documents.$document.edit.tsx b/app/routes/app.documents.$document.edit.tsx index 638bdd6..10ec7c8 100644 --- a/app/routes/app.documents.$document.edit.tsx +++ b/app/routes/app.documents.$document.edit.tsx @@ -11,7 +11,13 @@ import {invariant} from '@arcath/utils' import {ensureUser} from '~/lib/utils/ensure-user' import {getPrisma} from '~/lib/prisma.server' import {Button} from '~/lib/components/button' -import {Label, Input, HelperText, TextArea} from '~/lib/components/input' +import { + Label, + Input, + HelperText, + TextArea, + Select +} from '~/lib/components/input' import {pageTitle} from '~/lib/utils/page-title' export const loader = async ({request, params}: LoaderFunctionArgs) => { @@ -25,7 +31,9 @@ export const loader = async ({request, params}: LoaderFunctionArgs) => { where: {id: params.document} }) - return json({user, document}) + const acls = await prisma.aCL.findMany({orderBy: {name: 'asc'}}) + + return json({user, document, acls}) } export const action = async ({request, params}: ActionFunctionArgs) => { @@ -71,7 +79,7 @@ export const meta: MetaFunction = ({data}) => { } const DocumentEdit = () => { - const {document} = useLoaderData() + const {document, acls} = useLoaderData() return (
@@ -91,6 +99,18 @@ const DocumentEdit = () => { /> Document body in Markdown +
diff --git a/app/routes/app.documents.add.tsx b/app/routes/app.documents.add.tsx index 2dab488..1ef4059 100644 --- a/app/routes/app.documents.add.tsx +++ b/app/routes/app.documents.add.tsx @@ -5,18 +5,32 @@ import { json, redirect } from '@remix-run/node' +import {useLoaderData} from '@remix-run/react' import {invariant} from '@arcath/utils' import {ensureUser} from '~/lib/utils/ensure-user' import {getPrisma} from '~/lib/prisma.server' import {Button} from '~/lib/components/button' -import {Label, Input, HelperText, TextArea} from '~/lib/components/input' +import { + Label, + Input, + HelperText, + TextArea, + Select +} from '~/lib/components/input' import {pageTitle} from '~/lib/utils/page-title' +import {getDefaultACLID} from '~/lib/rbac.server' export const loader = async ({request}: LoaderFunctionArgs) => { const user = await ensureUser(request, 'document:add', {}) - return json({user}) + const prisma = getPrisma() + + const acls = await prisma.aCL.findMany({orderBy: {name: 'asc'}}) + + const defaultAclId = await getDefaultACLID() + + return json({user, acls, defaultAclId}) } export const action = async ({request}: ActionFunctionArgs) => { @@ -46,6 +60,8 @@ export const meta: MetaFunction = () => { } const DocumentAdd = () => { + const {acls, defaultAclId} = useLoaderData() + return (

Add Document

@@ -60,6 +76,18 @@ const DocumentAdd = () => {