-
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.
Merge pull request #42 from bruinenxyz/grant/bru-1067
Grant/bru-1067
- Loading branch information
Showing
12 changed files
with
522 additions
and
82 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
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
64 changes: 64 additions & 0 deletions
64
frontend/src/app/databases/[databaseId]/database-relations.tsx
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,64 @@ | ||
"use client"; | ||
import { CleanDatabase, Relation } from "@/definitions"; | ||
import { Card, CardList, Icon, Text } from "@blueprintjs/core"; | ||
import Loading from "@/app/loading"; | ||
import { ErrorDisplay } from "@/components/error-display"; | ||
import RelationCard from "@/components/relation/relation-card"; | ||
import CreateRelation from "@/components/relation/create-relation"; | ||
import DeleteRelation from "@/components/relation/delete-relation"; | ||
import { useRelations } from "@/data/use-relations"; | ||
import { useState } from "react"; | ||
import * as _ from "lodash"; | ||
|
||
export default function DatabaseRelations({ | ||
database, | ||
}: { | ||
database: CleanDatabase; | ||
}) { | ||
const [createRelationToggle, setCreateRelationToggle] = | ||
useState<boolean>(false); | ||
const [deleteRelation, setDeleteRelation] = useState<Relation | null>(null); | ||
const { | ||
data: relations, | ||
isLoading: isLoadingRelations, | ||
error: relationsError, | ||
} = useRelations(database.id); | ||
|
||
if (isLoadingRelations) { | ||
return <Loading />; | ||
} | ||
|
||
if (relationsError) { | ||
return <ErrorDisplay description={relationsError.message} />; | ||
} | ||
|
||
return ( | ||
<CardList className="h-full overflow-y-auto"> | ||
<Card | ||
className="cursor-pointer" | ||
onClick={() => setCreateRelationToggle(true)} | ||
> | ||
<div className="flex flex-row items-center gap-1 ml-1"> | ||
<Icon icon="new-object" intent="success" /> | ||
<Text className="text-success">New Relation</Text> | ||
</div> | ||
</Card> | ||
{_.map(relations, (relation: Relation) => ( | ||
<RelationCard | ||
key={relation.id} | ||
relation={relation} | ||
setDeleteRelation={setDeleteRelation} | ||
/> | ||
))} | ||
<CreateRelation | ||
selectedDatabase={database} | ||
isOpen={createRelationToggle} | ||
setIsOpen={setCreateRelationToggle} | ||
/> | ||
<DeleteRelation | ||
relation={deleteRelation} | ||
setRelation={setDeleteRelation} | ||
/> | ||
</CardList> | ||
); | ||
} |
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
Oops, something went wrong.