From dbe711662bb4644947861f13a3dee792b2f39292 Mon Sep 17 00:00:00 2001 From: Oliver Fritz Date: Thu, 27 Apr 2023 15:52:30 +0200 Subject: [PATCH 1/4] fix(manager-dashboard): use project type labels from projectTypes.ts uses project type labels from config in TutorialList and ProjectDetails and removes redundant projectTypeLabelMap from utils/common.ts --- .../app/components/TutorialList/index.tsx | 13 ++++++++----- manager-dashboard/app/utils/common.ts | 9 --------- .../app/views/Projects/ProjectDetails/index.tsx | 9 +++++++-- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/manager-dashboard/app/components/TutorialList/index.tsx b/manager-dashboard/app/components/TutorialList/index.tsx index 9ab818f41..55328bea0 100644 --- a/manager-dashboard/app/components/TutorialList/index.tsx +++ b/manager-dashboard/app/components/TutorialList/index.tsx @@ -14,10 +14,8 @@ import usePagination from '#hooks/usePagination'; import PendingMessage from '#components/PendingMessage'; import Pager from '#components/Pager'; import { rankedSearchOnList } from '#components/SelectInput/utils'; -import { - ProjectType, - projectTypeLabelMap, -} from '#utils/common'; +import { ProjectType } from '#utils/common'; +import projectTypeOptions from '#base/configs/projectTypes'; import styles from './styles.css'; @@ -79,6 +77,11 @@ function TutorialList(props: Props) { items: tutorialListInCurrentPage, } = usePagination(filteredTutorialList); + const projectTypeLabel = projectTypeOptions.find((projType: { + value: ProjectType; + label: string; + }) => projType.value === tutorial.projectType)?.label; + return (
{pending && ( @@ -101,7 +104,7 @@ function TutorialList(props: Props) {
- {projectTypeLabelMap[tutorial.projectType]} + {projectTypeLabel}
); diff --git a/manager-dashboard/app/utils/common.ts b/manager-dashboard/app/utils/common.ts index 90ad219b7..b5b7775a5 100644 --- a/manager-dashboard/app/utils/common.ts +++ b/manager-dashboard/app/utils/common.ts @@ -26,12 +26,3 @@ export const PROJECT_TYPE_CHANGE_DETECTION = 3; export const PROJECT_TYPE_COMPLETENESS = 4; export type ProjectType = 1 | 2 | 3 | 4; - -export const projectTypeLabelMap: { - [key in ProjectType]: string -} = { - [PROJECT_TYPE_BUILD_AREA]: 'Build Area', - [PROJECT_TYPE_FOOTPRINT]: 'Footprint', - [PROJECT_TYPE_CHANGE_DETECTION]: 'Change Detection', - [PROJECT_TYPE_COMPLETENESS]: 'Completeness', -}; diff --git a/manager-dashboard/app/views/Projects/ProjectDetails/index.tsx b/manager-dashboard/app/views/Projects/ProjectDetails/index.tsx index 5bbf0741b..8c9bbead0 100644 --- a/manager-dashboard/app/views/Projects/ProjectDetails/index.tsx +++ b/manager-dashboard/app/views/Projects/ProjectDetails/index.tsx @@ -23,10 +23,10 @@ import { labelSelector, valueSelector, ProjectType, - projectTypeLabelMap, ProjectInputType, ProjectStatus, } from '#utils/common'; +import projectTypeOptions from '#base/configs/projectTypes'; import styles from './styles.css'; @@ -184,6 +184,11 @@ function ProjectDetails(props: Props) { const [title, org] = data.name.split('\n'); + const projectTypeLabel = projectTypeOptions.find((projType: { + value: ProjectType; + label: string; + }) => projType.value === data.projectType)?.label; + /* This is probably due to a faulty dataset in the dev instance of firebase that * one of the active private project doesn't have teamId and it's producing inconsistent * result.Let's overcome that adding following check for now. @@ -221,7 +226,7 @@ function ProjectDetails(props: Props) { Type:
- {projectTypeLabelMap[data.projectType]} + {projectTypeLabel}
{detailsShown && ( From 430acc34342196f5b1ba88327c081ec3f399eba7 Mon Sep 17 00:00:00 2001 From: Oliver Fritz Date: Thu, 27 Apr 2023 16:14:12 +0200 Subject: [PATCH 2/4] fix(manager-dashboard): fix project type label lookup in TutorialList --- .../app/components/TutorialList/index.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/manager-dashboard/app/components/TutorialList/index.tsx b/manager-dashboard/app/components/TutorialList/index.tsx index 55328bea0..14d4d3e52 100644 --- a/manager-dashboard/app/components/TutorialList/index.tsx +++ b/manager-dashboard/app/components/TutorialList/index.tsx @@ -77,11 +77,6 @@ function TutorialList(props: Props) { items: tutorialListInCurrentPage, } = usePagination(filteredTutorialList); - const projectTypeLabel = projectTypeOptions.find((projType: { - value: ProjectType; - label: string; - }) => projType.value === tutorial.projectType)?.label; - return (
{pending && ( @@ -104,7 +99,10 @@ function TutorialList(props: Props) {
- {projectTypeLabel} + {projectTypeOptions.find((projType: { + value: ProjectType; + label: string; + }) => projType.value === tutorial.projectType)?.label}
); From bd69fedffdf2b595e04978b7e840f27dc2ced832 Mon Sep 17 00:00:00 2001 From: Oliver Fritz Date: Thu, 27 Apr 2023 16:15:34 +0200 Subject: [PATCH 3/4] docs(manager-dashboard): add example project config name to .env.example --- manager-dashboard/.env.example | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manager-dashboard/.env.example b/manager-dashboard/.env.example index 453a97527..43e93fcb8 100644 --- a/manager-dashboard/.env.example +++ b/manager-dashboard/.env.example @@ -10,3 +10,6 @@ REACT_APP_FIREBASE_STORAGE_BUCKET= REACT_APP_FIREBASE_MESSAGING_SENDER_ID= REACT_APP_FIREBASE_APP_ID= REACT_APP_COMMUNITY_DASHBOARD_URL= + +# any value except "webapp" will result in default mapswipe project config +REACT_APP_PROJECT_CONFIG_NAME="mapswipe" \ No newline at end of file From 50fecf623d90bdea930e791a82ae7e56469a0960 Mon Sep 17 00:00:00 2001 From: Oliver Fritz Date: Thu, 27 Apr 2023 16:20:11 +0200 Subject: [PATCH 4/4] fix(manager-dashboard): use generic project type labels in webapp configuration uses more appropriate labels for more generic webapp version project types --- manager-dashboard/app/Base/configs/projectTypes.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manager-dashboard/app/Base/configs/projectTypes.ts b/manager-dashboard/app/Base/configs/projectTypes.ts index 020644f67..6c373b8f3 100644 --- a/manager-dashboard/app/Base/configs/projectTypes.ts +++ b/manager-dashboard/app/Base/configs/projectTypes.ts @@ -18,14 +18,14 @@ const mapswipeProjectTypeOptions: { { value: PROJECT_TYPE_COMPLETENESS, label: 'Completeness' }, ]; -const crowdmapProjectTypeOptions: { +const webappProjectTypeOptions: { value: ProjectType; label: string; }[] = [ - { value: PROJECT_TYPE_BUILD_AREA, label: 'Build Area' }, - { value: PROJECT_TYPE_COMPLETENESS, label: 'Completeness' }, + { value: PROJECT_TYPE_BUILD_AREA, label: 'Tile Classification' }, + { value: PROJECT_TYPE_COMPLETENESS, label: 'Comparison' }, ]; -const projectTypeOptions = PROJECT_CONFIG_NAME === 'crowdmap' ? crowdmapProjectTypeOptions : mapswipeProjectTypeOptions; +const projectTypeOptions = PROJECT_CONFIG_NAME === 'webapp' ? webappProjectTypeOptions : mapswipeProjectTypeOptions; export default projectTypeOptions;