-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: organisation categories are shown on project page
- Loading branch information
1 parent
8e5bdf7
commit 7b83564
Showing
20 changed files
with
307 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import {Fragment} from 'react' | ||
import {CategoryEntry, CategoryPath} from '~/types/Category' | ||
import {TreeNode} from '~/types/TreeNode' | ||
import TagChipFilter from '~/components/layout/TagChipFilter' | ||
|
||
export function CategoryChipFilter({nodes}:{nodes:TreeNode<CategoryEntry>[]}){ | ||
return nodes.map(node=>{ | ||
const cat = node.getValue() | ||
const children = node.children() | ||
return ( | ||
<Fragment key={cat.id}> | ||
<TagChipFilter key={cat.id} title={cat.name} label={cat.short_name} /> | ||
<CategoryChipFilter nodes={children} /> | ||
</Fragment> | ||
) | ||
}) | ||
} | ||
|
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,12 @@ | ||
// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export default function SidebarPanel({children,className}:{children:any,className?:string}) { | ||
return ( | ||
<aside className={`flex flex-col gap-8 ${className ?? ''}`}> | ||
{children} | ||
</aside> | ||
) | ||
} |
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,21 @@ | ||
// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export default function SidebarSection({children,className}:{children:any,className?:string}) { | ||
|
||
if (className){ | ||
return ( | ||
<div className={`${className ?? ''}`}> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
return ( | ||
<div> | ||
{children} | ||
</div> | ||
) | ||
} |
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,12 @@ | ||
// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export default function SidebarTitle({children,className}:{children:any,className?:string}) { | ||
return ( | ||
<div className={`text-primary pb-2 ${className ?? ''}`}> | ||
{children} | ||
</div> | ||
) | ||
} |
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,29 @@ | ||
// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import {CategoryPath} from '~/types/Category' | ||
import {useCategoryTree} from '~/utils/categories' | ||
import SidebarSection from '../layout/SidebarSection' | ||
import SidebarTitle from '../layout/SidebarTitle' | ||
import {CategoryChipFilter} from '../category/CategoryChipFilter' | ||
|
||
export default function ProjectCategories({categories}:{categories:CategoryPath[]}) { | ||
const tree = useCategoryTree(categories) | ||
|
||
// each root category is separate sidebar section | ||
return tree.map(node => { | ||
const category = node.getValue() | ||
const children = node.children() | ||
|
||
return ( | ||
<SidebarSection key={category.id}> | ||
<SidebarTitle>{category.name}</SidebarTitle> | ||
<div className="flex flex-wrap gap-2"> | ||
<CategoryChipFilter nodes={children} /> | ||
</div> | ||
</SidebarSection> | ||
) | ||
}) | ||
} |
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 |
---|---|---|
@@ -1,57 +1,52 @@ | ||
// SPDX-FileCopyrightText: 2022 - 2023 Dusan Mijatovic (dv4all) | ||
// SPDX-FileCopyrightText: 2022 - 2023 dv4all | ||
// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import Link from 'next/link' | ||
import {ProjectOrganisationProps} from '~/types/Organisation' | ||
import ProjectSidebarTitle from '~/components/layout/SidebarTitle' | ||
import ProjectSidebarSection from '../layout/SidebarSection' | ||
|
||
export default function ProjectFunding({grant_id, fundingOrganisations=[]}: | ||
{ grant_id: string | null, fundingOrganisations:ProjectOrganisationProps[] }) { | ||
|
||
function renderFundedUnder() { | ||
if (grant_id) { | ||
return ( | ||
<> | ||
<div className="text-primary py-4">Funded under</div> | ||
<div className="text-sm">Grant ID: {grant_id}</div> | ||
</> | ||
) | ||
} | ||
return null | ||
} | ||
|
||
function renderFundedBy() { | ||
if (fundingOrganisations && fundingOrganisations.length > 0) { | ||
return ( | ||
<> | ||
<div className="text-primary py-4">Funded by</div> | ||
<ul> | ||
{fundingOrganisations.map(item => { | ||
const link = `/organisations/${item.rsd_path}` | ||
return ( | ||
<li key={link} className="text-sm py-1"> | ||
<Link | ||
href={link} | ||
target="_self" | ||
passHref | ||
> | ||
{item.name} | ||
</Link> | ||
</li> | ||
) | ||
})} | ||
</ul> | ||
</> | ||
) | ||
} | ||
return null | ||
} | ||
|
||
export function FundedUnder({grant_id}:{grant_id:string|null}){ | ||
|
||
if (!grant_id) return null | ||
|
||
return ( | ||
<div> | ||
{renderFundedUnder()} | ||
{renderFundedBy()} | ||
</div> | ||
<ProjectSidebarSection> | ||
<ProjectSidebarTitle>Funded under</ProjectSidebarTitle> | ||
<div className="text-sm">Grant ID: {grant_id}</div> | ||
</ProjectSidebarSection> | ||
) | ||
} | ||
|
||
export function FundedBy({fundingOrganisations}:{fundingOrganisations:ProjectOrganisationProps[]}){ | ||
|
||
if (!fundingOrganisations || fundingOrganisations.length===0) return null | ||
|
||
return ( | ||
<ProjectSidebarSection> | ||
<ProjectSidebarTitle>Funded by</ProjectSidebarTitle> | ||
<ul> | ||
{fundingOrganisations.map(item => { | ||
const link = `/organisations/${item.rsd_path}` | ||
return ( | ||
<li key={link} className="text-sm py-1"> | ||
<Link | ||
href={link} | ||
target="_self" | ||
passHref | ||
> | ||
{item.name} | ||
</Link> | ||
</li> | ||
) | ||
})} | ||
</ul> | ||
</ProjectSidebarSection> | ||
) | ||
} | ||
|
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.