Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spotlight): add project_page metadata, refactor tier metadata to strings instead of numbers #6188

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions frontend/census-projects.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"tier": 3,
"tier": "community",
"census_version": "LTS 1.0",
"experiment_name": "homo_sapiens",
"measurement_name": "RNA",
Expand All @@ -18,10 +18,11 @@
"DOI": null,
"publication_info": "Cul et al. (2023) bioRxiv",
"publication_link": "",
"project_page": "https://example.com/",
"notebook_links": [["link A", "https://example.com/"]]
},
{
"tier": 1,
"tier": "maintained",
"census_version": "LTS 1.0",
"experiment_name": "homo_sapiens",
"measurement_name": "RNA",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/common/analytics/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export enum EVENTS {
CENSUS_CONTACT_CLICKED = "CENSUS_CONTACT_CLICKED",
CENSUS_NOTEBOOK_CLICKED = "CENSUS_NOTEBOOK_CLICKED",
CENSUS_EMBEDDING_COPIED = "CENSUS_EMBEDDING_COPIED",
CENSUS_PROJECT_LINK_CLICKED = "CENSUS_PROJECT_LINK_CLICKED",
DATASETS_CLICK_NAV = "DATASETS_CLICK_NAV",
COLLECTIONS_CLICK_NAV = "COLLECTIONS_CLICK_NAV",
DOCUMENTATION_CLICK_NAV = "DOCUMENTATION_CLICK_NAV",
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/types/census-projects.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ declare module "census-projects.json" {
export interface StaticProject
extends Partial<import("src/common/queries/censusDirectory").Project> {
notebook_links?: [string, string][];
tier: number;
tier: "community" | "maintained";
project_page: string;
}
const content: StaticProject[];
export default content;
Expand Down
18 changes: 17 additions & 1 deletion frontend/src/views/CensusDirectory/components/Project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,23 @@ const Project = ({ project, id }: ProjectProps) => {
</DetailsContainer>
</ProjectDetails>
<ProjectButtons>
<EmbeddingButton project={project} />
{"project_page" in project && project.project_page && (
<Link href={project.project_page}>
<StyledButton
sdsType="secondary"
sdsStyle="square"
onClick={() => {
track(EVENTS.CENSUS_PROJECT_LINK_CLICKED, {
project: project.title,
category: projectTier,
});
}}
>
Project Page
</StyledButton>
</Link>
)}
{projectTier === "hosted" && <EmbeddingButton project={project} />}
{project.model_link && (
<Link href={project.model_link}>
<StyledButton
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/CensusDirectory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ function CensusDirectory() {
);

const communityProjects = Object.values(staticProjects).filter(
(project) => project.tier === 3
(project) => project.tier === "community"
);
const maintainedProjects = Object.values(staticProjects).filter(
(project) => project.tier === 1
(project) => project.tier === "maintained"
);

return (
Expand Down
13 changes: 1 addition & 12 deletions frontend/src/views/CensusDirectory/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,7 @@ import { ProjectProps } from "./components/Project/types";

export const getProjectTier = (project: ProjectProps["project"]) => {
let projectTier = "hosted";
if ("tier" in project)
switch (project.tier ?? 2) {
case 1:
projectTier = "maintained";
break;
case 2:
projectTier = "hosted";
break;
case 3:
projectTier = "community";
break;
}
if ("tier" in project) projectTier = project.tier;

return projectTier;
};