From 3131ecb959bd31ea3109f8ac10d85e79eea13ea6 Mon Sep 17 00:00:00 2001 From: Sam Park Date: Tue, 17 Sep 2024 15:14:21 -0400 Subject: [PATCH] split combined error message component and cleaned up browse page slightly --- web/src/components/browse/namespace-grid.tsx | 4 +- .../components/browse/namespace-long-row.tsx | 4 +- .../components/browse/project-accordion.tsx | 6 +- .../components/forms/blank-project-form.tsx | 32 +---- .../components/combined-error-message.tsx | 49 ++++++++ .../components/forms/create-schema-form.tsx | 25 +--- web/src/components/forms/pop-form.tsx | 32 +---- .../components/forms/project-upload-form.tsx | 36 +----- .../components/forms/upload-schema-form.tsx | 25 +--- web/src/pages/Browse.tsx | 6 +- web/src/pages/Namespace.tsx | 1 + web/src/pages/Schemas copy.tsx | 110 ------------------ 12 files changed, 72 insertions(+), 258 deletions(-) create mode 100644 web/src/components/forms/components/combined-error-message.tsx delete mode 100644 web/src/pages/Schemas copy.tsx diff --git a/web/src/components/browse/namespace-grid.tsx b/web/src/components/browse/namespace-grid.tsx index 33ad4a71..0ca136ec 100644 --- a/web/src/components/browse/namespace-grid.tsx +++ b/web/src/components/browse/namespace-grid.tsx @@ -18,7 +18,7 @@ export const NamespaceGrid = (props: Props) => { return (
-
+
{namespaces && ( Object.values(namespaces).map((item, index: number) => (
@@ -30,7 +30,7 @@ export const NamespaceGrid = (props: Props) => {

- {item?.number_of_projects} Projects + {item?.number_of_projects} {item?.number_of_projects === 1 ? 'Project' : 'Projects'}

diff --git a/web/src/components/browse/namespace-long-row.tsx b/web/src/components/browse/namespace-long-row.tsx index 0dcae945..e1933e8f 100644 --- a/web/src/components/browse/namespace-long-row.tsx +++ b/web/src/components/browse/namespace-long-row.tsx @@ -59,7 +59,7 @@ export const NamespaceLongRow = (props: Props) => {
{ itemRefs.current[item.namespace] = el; }} - className="col-xl-2 col-md-4 flex-shrink-0" + className="col-xxl-2 col-lg-3 col-md-4 col-sm-6 flex-shrink-0" style={{ scrollSnapAlign: 'start' }} >
@@ -70,7 +70,7 @@ export const NamespaceLongRow = (props: Props) => {

- {item?.number_of_projects} Projects + {item?.number_of_projects} {item?.number_of_projects === 1 ? 'Project' : 'Projects'}

diff --git a/web/src/components/browse/project-accordion.tsx b/web/src/components/browse/project-accordion.tsx index 91161075..ca8ae125 100644 --- a/web/src/components/browse/project-accordion.tsx +++ b/web/src/components/browse/project-accordion.tsx @@ -28,15 +28,15 @@ export const ProjectAccordion = (props: Props) => { aria-controls={`collapse${key}`} > {index + 1}. - {project.namespace}/{project.name}:{project.tag} +
{project.namespace}/{project.name}:{project.tag}
- +
Sample Count: {project.number_of_samples} | Stars: {project.stars_number} - +
; -}; - -const CombinedErrorMessage = (props: CombinedErrorMessageProps) => { - const { errors } = props; - const nameError = errors.project_name?.message; - const tagError = errors.tag?.message; - let msg = null; - - if (nameError == 'empty' && !tagError) { - msg = 'Project Name must not be empty.'; - } else if (nameError == 'invalid' && !tagError) { - msg = "Project Name must contain only alphanumeric characters, '-', or '_'."; - } else if (nameError == 'empty' && tagError == 'invalid') { - msg = "Project Name must not be empty and Tag must contain only alphanumeric characters, '-', or '_'."; - } else if (nameError == 'invalid' && tagError == 'invalid') { - msg = "Project Name and Tag must contain only alphanumeric characters, '-', or '_'."; - } else if (!nameError && tagError == 'invalid') { - msg = "Project Tag must contain only alphanumeric characters, '-', or '_'."; - } - - if (nameError || tagError) { - return

{msg}

; - } - - return null; -}; - export const BlankProjectForm = (props: Props) => { const { onHide, defaultNamespace } = props; // get user innfo @@ -175,7 +147,7 @@ sample_table: samples.csv placeholder="default" />
- +