-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Pull individual dataset info * Add a view for individual datasets * Add breadcrumbs and style Select * Clean up * Update changelog
- Loading branch information
1 parent
d364762
commit 2b15040
Showing
8 changed files
with
180 additions
and
13 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
71 changes: 71 additions & 0 deletions
71
clients/admin-ui/src/features/dataset/DatasetCollectionView.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,71 @@ | ||
import { Box, Select, Spinner } from "@fidesui/react"; | ||
import { ChangeEvent, useEffect, useState } from "react"; | ||
|
||
import { FidesKey } from "../common/fides-types"; | ||
import { useGetDatasetByKeyQuery } from "./dataset.slice"; | ||
import DatasetFieldsTable from "./DatasetFieldsTable"; | ||
import { DatasetCollection } from "./types"; | ||
|
||
const useDataset = (key: FidesKey) => { | ||
const { data, isLoading } = useGetDatasetByKeyQuery(key); | ||
|
||
return { | ||
isLoading, | ||
dataset: data, | ||
}; | ||
}; | ||
|
||
interface Props { | ||
fidesKey: FidesKey; | ||
} | ||
|
||
const DatasetCollectionView = ({ fidesKey }: Props) => { | ||
const { dataset, isLoading } = useDataset(fidesKey); | ||
const [activeCollection, setActiveCollection] = useState< | ||
DatasetCollection | undefined | ||
>(); | ||
|
||
useEffect(() => { | ||
if (dataset) { | ||
setActiveCollection(dataset.collections[0]); | ||
} else { | ||
setActiveCollection(undefined); | ||
} | ||
}, [dataset]); | ||
|
||
if (!dataset) { | ||
return <div>Dataset not found</div>; | ||
} | ||
|
||
const { collections } = dataset; | ||
|
||
const handleChangeCollection = (event: ChangeEvent<HTMLSelectElement>) => { | ||
const collection = collections.filter( | ||
(c) => c.name === event.target.value | ||
)[0]; | ||
setActiveCollection(collection); | ||
}; | ||
|
||
if (isLoading) { | ||
return <Spinner />; | ||
} | ||
|
||
return ( | ||
<Box> | ||
<Box mb={4} display="flex"> | ||
<Select onChange={handleChangeCollection} mr={2} width="auto"> | ||
{collections.map((collection) => ( | ||
<option key={collection.name} value={collection.name}> | ||
{collection.name} | ||
</option> | ||
))} | ||
</Select> | ||
</Box> | ||
{activeCollection && ( | ||
<DatasetFieldsTable fields={activeCollection.fields} /> | ||
)} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default DatasetCollectionView; |
30 changes: 30 additions & 0 deletions
30
clients/admin-ui/src/features/dataset/DatasetFieldsTable.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,30 @@ | ||
import { Table, Tbody, Td, Th, Thead, Tr } from "@fidesui/react"; | ||
|
||
import { DatasetField } from "./types"; | ||
|
||
interface Props { | ||
fields: DatasetField[]; | ||
} | ||
|
||
const DatasetFieldsTable = ({ fields }: Props) => ( | ||
<Table size="sm"> | ||
<Thead> | ||
<Tr> | ||
<Th pl={0}>Field Name</Th> | ||
<Th pl={0}>Description</Th> | ||
<Th pl={0}>Identifiability</Th> | ||
</Tr> | ||
</Thead> | ||
<Tbody> | ||
{fields.map((field) => ( | ||
<Tr key={field.name}> | ||
<Td pl={0}>{field.name}</Td> | ||
<Td pl={0}>{field.description}</Td> | ||
<Td pl={0}>{field.data_qualifier}</Td> | ||
</Tr> | ||
))} | ||
</Tbody> | ||
</Table> | ||
); | ||
|
||
export default DatasetFieldsTable; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Box, Breadcrumb, BreadcrumbItem, Heading } from "@fidesui/react"; | ||
import type { NextPage } from "next"; | ||
import NextLink from "next/link"; | ||
import { useRouter } from "next/router"; | ||
|
||
import Layout from "~/features/common/Layout"; | ||
import DatasetCollectionView from "~/features/dataset/DatasetCollectionView"; | ||
|
||
const DatasetDetail: NextPage = () => { | ||
const router = useRouter(); | ||
const { id } = router.query; | ||
|
||
if (!id) { | ||
return <Layout title="Dataset">Dataset not found</Layout>; | ||
} | ||
|
||
const fidesKey = Array.isArray(id) ? id[0] : id; | ||
|
||
return ( | ||
<Layout title={`Dataset - ${id}`}> | ||
<Heading mb={2} fontSize="2xl" fontWeight="semibold"> | ||
Dataset | ||
</Heading> | ||
<Box mb={8}> | ||
<Breadcrumb fontWeight="medium" fontSize="sm" color="gray.600"> | ||
<BreadcrumbItem> | ||
<NextLink href="/dataset">Datasets</NextLink> | ||
</BreadcrumbItem> | ||
<BreadcrumbItem> | ||
<NextLink href="#">{id}</NextLink> | ||
</BreadcrumbItem> | ||
</Breadcrumb> | ||
</Box> | ||
<DatasetCollectionView fidesKey={fidesKey} /> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default DatasetDetail; |
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