Skip to content

Commit

Permalink
Merge pull request #473 from FalkorDB/staging
Browse files Browse the repository at this point in the history
Merge staging to main
  • Loading branch information
AviAvni authored Sep 22, 2024
2 parents d0ed4f6 + 59904ff commit 3559566
Show file tree
Hide file tree
Showing 7 changed files with 1,214 additions and 386 deletions.
22 changes: 11 additions & 11 deletions app/api/auth/[...nextauth]/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function newClient(credentials: { host: string, port: string, password: st
const connectionOptions: FalkorDBOptions = credentials.ca === "undefined" ?
{
socket: {
host: credentials.host ?? "localhost",
host: credentials.host || "localhost",
port: credentials.port ? parseInt(credentials.port, 10) : 6379,
},
password: credentials.password ?? undefined,
Expand Down Expand Up @@ -51,25 +51,25 @@ async function newClient(credentials: { host: string, port: string, password: st
const connection = await client.connection

try {
connection.aclGetUser(credentials.username || "default")
await connection.aclGetUser(credentials.username || "default")
return { role: "Admin", client }
} catch (error: unknown) {
if (error instanceof ErrorReply && (error as ErrorReply).message.startsWith("NOPERM")) {
console.debug(error);
} else throw error
} catch (err) {
if (err instanceof ErrorReply && (err as ErrorReply).message.startsWith("NOPERM")) {
console.debug(err);
} else throw err
}

try {
await connection.sendCommand(["GRAPH.QUERY"])
} catch (error: unknown) {
if ((error as Error).message.includes("permissions")) {
console.debug(error);
} catch (err) {
if ((err as Error).message.includes("permissions")) {
console.debug(err);
return { role: "Read-Only", client }
}
console.debug(error);
console.debug(err);
return { role: "Read-Write", client }
}

return { role: "Admin", client }
}

Expand Down
4 changes: 2 additions & 2 deletions app/api/user/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface CreateUser {
export const ROLE = new Map<string, string[]>(
[
["Admin", ["on", "~*", "&*", "+@all"]],
["Read-Write", ["on", "~*", "resetchannels", "-@all", "+graph.query", "+graph.explain", "+graph.list", "+ping", "+graph.profile",]],
["Read-Only", ["on", "~*", "resetchannels", "-@all", "+graph.ro_query", "+graph.explain", "+graph.list", "+ping"]]
["Read-Write", ["on", "~*", "resetchannels", "-@all", "+graph.query", "+graph.ro_query", "+graph.explain", "+graph.list", "+ping", "+graph.profile", "+info"]],
["Read-Only", ["on", "~*", "resetchannels", "-@all", "+graph.ro_query", "+graph.explain", "+graph.list", "+ping", "+info"]]
]
)
12 changes: 5 additions & 7 deletions app/graph/GraphView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ const GraphView = forwardRef(({ graph, runQuery, historyQuery, fetchCount }: {
<ResizablePanelGroup direction="horizontal" className={cn(maximize && "h-full p-10 bg-background fixed left-[50%] top-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%]")}>
<ResizablePanel
className={cn("flex flex-col gap-8", !isCollapsed && "mr-8")}
defaultSize={100}
defaultSize={selectedElement ? 75 : 100}
>
{
!maximize &&
Expand Down Expand Up @@ -507,6 +507,7 @@ const GraphView = forwardRef(({ graph, runQuery, historyQuery, fetchCount }: {
}
<div className="flex items-center justify-between">
<Toolbar
addDisabled
disabled={!graph.Id}
deleteDisabled={Object.values(selectedElements).length === 0 && !selectedElement}
onDeleteElement={handelDeleteElement}
Expand Down Expand Up @@ -567,20 +568,17 @@ const GraphView = forwardRef(({ graph, runQuery, historyQuery, fetchCount }: {
(graph.Categories.length > 0 || graph.Labels.length > 0) &&
<>
<Labels className="left-2" categories={graph.Categories} onClick={onCategoryClick} label="Labels" graph={graph} />
<Labels className="right-2 text-end" categories={graph.Labels} onClick={onLabelClick} label="RelationshipTypes" graph={graph}/>
<Labels className="right-2 text-end" categories={graph.Labels} onClick={onLabelClick} label="RelationshipTypes" graph={graph} />
</>
}
</div>
</ResizablePanel>
{
!isCollapsed &&
<ResizableHandle className="w-3" />
}
<ResizableHandle className={!isCollapsed ? "w-3" : "w-0"} />
<ResizablePanel
className="rounded-lg"
collapsible
ref={dataPanel}
defaultSize={25}
defaultSize={selectedElement ? 25 : 0}
minSize={25}
maxSize={50}
onCollapse={() => setIsCollapsed(true)}
Expand Down
7 changes: 5 additions & 2 deletions app/graph/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { useState } from "react";
import Button from "../components/ui/Button";
import DialogComponent from "../components/DialogComponent";

export default function Toolbar({ disabled, chartRef, onDeleteElement, onAddEntity, onAddRelation, deleteDisabled }: {
export default function Toolbar({ disabled, addDisabled, chartRef, onDeleteElement, onAddEntity, onAddRelation, deleteDisabled }: {
addDisabled?: boolean,
disabled?: boolean,
chartRef: React.RefObject<cytoscape.Core>,
onDeleteElement?: () => Promise<void>,
Expand Down Expand Up @@ -44,13 +45,15 @@ export default function Toolbar({ disabled, chartRef, onDeleteElement, onAddEnti
<div className="flex items-center gap-6 p-1">
<div className="flex gap-4">
<Button
disabled={addDisabled}
variant="Secondary"
label="Add Entity"
className="flex items-center gap-2"
onClick={onAddEntity}
icon={<PlusCircle />}
/>
/>
<Button
disabled={addDisabled}
variant="Secondary"
className="flex items-center gap-2"
label="Add Relation"
Expand Down
5 changes: 3 additions & 2 deletions app/login/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export default function LoginForm() {

const params: SignInOptions = {
redirect: false,
host: host.trim() ?? DEFAULT_HOST,
port: port.trim() ?? DEFAULT_PORT,
host: host.trim(),
port: port.trim(),
tls: TLS,
ca: CA
};
Expand All @@ -55,6 +55,7 @@ export default function LoginForm() {
if (password) {
params.password = password;
}

signIn("credentials", params).then((res?: SignInResponse) => {
if (res?.error) {
setError(true);
Expand Down
Loading

0 comments on commit 3559566

Please sign in to comment.