1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-23 07:14:21 +00:00

Create ProjectListBox and ProjectResourcePanel

This commit is contained in:
Steffo 2021-10-07 05:25:53 +02:00
parent 1cc229730c
commit 5280f2d432
Signed by: steffo
GPG key ID: 6965406171929D01
4 changed files with 68 additions and 2 deletions

View file

@ -11,6 +11,7 @@ import {GroupRouter} from "./components/group/GroupRouter"
import {InstanceRouter} from "./components/instance/InstanceRouter"
import {InstanceStepPage} from "./components/instance/InstanceStepPage"
import {DebugBox} from "./components/placeholder/DebugBox"
import {ProjectListBox} from "./components/project/ProjectListBox"
import {ProjectRouter} from "./components/project/ProjectRouter"
import {ThemedBluelib} from "./components/theme/ThemedBluelib"
import {ThemedTitle} from "./components/theme/ThemedTitle"
@ -38,7 +39,7 @@ function App({}: RouteComponentProps) {
selectedRoute={(props) => <>
<ProjectRouter
groupPk={props.selection.value.slug}
unselectedRoute={DebugBox}
unselectedRoute={(props) => <ProjectListBox viewSet={props.viewSet}/>}
selectedRoute={DebugBox}
/>
</>}

View file

@ -0,0 +1,24 @@
import {Box, Heading} from "@steffo/bluelib-react"
import * as React from "react"
import {ManagedViewSet} from "../../hooks/useManagedViewSet"
import {SophonResearchProject} from "../../types/SophonTypes"
import {ProjectResourcePanel} from "./ProjectResourcePanel"
export interface ProjectListBoxProps {
viewSet: ManagedViewSet<SophonResearchProject>
}
export function ProjectListBox({viewSet}: ProjectListBoxProps): JSX.Element {
// TODO: Add some flavour text
return (
<Box>
<Heading level={3}>
Research projects
</Heading>
{viewSet.resources?.map(res => <ProjectResourcePanel resource={res} key={res.value.slug}/>)}
</Box>
)
}

View file

@ -0,0 +1,41 @@
import {IconDefinition} from "@fortawesome/fontawesome-svg-core"
import {faGlobe, faLock, faUniversity} from "@fortawesome/free-solid-svg-icons"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
import * as React from "react"
import {ManagedResource} from "../../hooks/useManagedViewSet"
import {SophonResearchProject} from "../../types/SophonTypes"
import {Link} from "../elements/Link"
import {ResourcePanel} from "../elements/ResourcePanel"
export interface ProjectResourcePanelProps {
resource: ManagedResource<SophonResearchProject>,
}
export function ProjectResourcePanel({resource}: ProjectResourcePanelProps): JSX.Element {
const icon: IconDefinition = {
"PUBLIC": faGlobe,
"INTERNAL": faUniversity,
"PRIVATE": faLock,
}[resource.value.visibility]
return (
<ResourcePanel>
<ResourcePanel.Icon>
<FontAwesomeIcon icon={icon}/>
</ResourcePanel.Icon>
<ResourcePanel.Name>
<Link href={`p/${resource.value.slug}/`}>
{resource.value.name}
</Link>
</ResourcePanel.Name>
<ResourcePanel.Text>
</ResourcePanel.Text>
<ResourcePanel.Buttons>
</ResourcePanel.Buttons>
</ResourcePanel>
)
}

View file

@ -17,7 +17,7 @@ export function ProjectRouter({groupPk, ...props}: ProjectRouterProps): JSX.Elem
<ViewSetRouter
{...props}
viewSet={useManagedViewSet<SophonResearchProject>(`/api/projects/by-group/${groupPk}`, "slug")}
pathSegment={"researchGroup"}
pathSegment={"researchProject"}
pkKey={"slug"}
/>
)