Open-source and local-first Slack and Notion alternative that puts you in control of your data
TypeScript chatchat-applicationcrdteditorelectronknowledge-baselocal-firstnotionnotion-alternativerealtime-collaborationself-hostedslacksqliteteam-collaborationwikiyjs
import { LocalRecordNode } from '@colanode/client/types';
import { NodeRole, hasNodeRole } from '@colanode/core';
import { Document } from '@colanode/ui/components/documents/document';
import { RecordAttributes } from '@colanode/ui/components/records/record-attributes';
import { RecordDatabase } from '@colanode/ui/components/records/record-database';
import { RecordProvider } from '@colanode/ui/components/records/record-provider';
import { Separator } from '@colanode/ui/components/ui/separator';
import { useWorkspace } from '@colanode/ui/contexts/workspace';
interface RecordContainerProps {
record: LocalRecordNode;
role: NodeRole;
}
export const RecordContainer = ({ record, role }: RecordContainerProps) => {
const workspace = useWorkspace();
const canEdit =
record.createdBy === workspace.userId || hasNodeRole(role, 'editor');
return (
<RecordDatabase id={record.databaseId} role={role}>
<RecordProvider record={record} role={role}>
<RecordAttributes />
</RecordProvider>
<Separator className="my-4 w-full" />
<Document node={record} canEdit={canEdit} autoFocus={false} />
</RecordDatabase>
);
};