diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 34ebded0..aacc4dcd 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -2,6 +2,9 @@ name: MapSwipe Workers on: [push] +env: + COMPOSE_FILE: docker-compose.yaml:docker-compose-ci.yaml + jobs: build: @@ -77,6 +80,7 @@ jobs: POSTGRES_DB: postgres OSMCHA_API_KEY: ${{ secrets.OSMCHA_API_KEY }} DJANGO_SECRET_KEY: test-django-secret-key + COMPOSE_FILE: ../docker-compose.yaml:../docker-compose-ci.yaml run: | docker compose run --rm mapswipe_workers_creation python -m unittest discover --verbose --start-directory tests/unittests/ docker compose run --rm mapswipe_workers_creation bash -c 'pip install pytest && pytest -ra -v --durations=10 tests/integration/' diff --git a/docker-compose-ci.yaml b/docker-compose-ci.yaml new file mode 100644 index 00000000..e356eb2d --- /dev/null +++ b/docker-compose-ci.yaml @@ -0,0 +1,8 @@ +# Quick hack to avoid on GH CI +# Check .github/workflows/actions.yml for usages +# Related error: +# failed to create network python-mapswipe-workers_mapswipe_network: +# Error response from daemon: Pool overlaps with other one on this address space +networks: + mapswipe_network: + ipam: !reset null diff --git a/firebase/functions/src/index.ts b/firebase/functions/src/index.ts index 6cd924e0..02a70dd3 100644 --- a/firebase/functions/src/index.ts +++ b/firebase/functions/src/index.ts @@ -353,14 +353,14 @@ exports.addProjectTopicKey = functions.https.onRequest(async (_, res) => { const isEmptyProject = Object.keys(data).length === 0; if (isEmptyProject) { res.status(404).send('No projects found'); - } - - if (!isEmptyProject && data) { + } else { const newProjectData: {[key: string]: string} = {}; Object.keys(data).forEach((id) => { - if (data[id]?.projectTopic) { - const newProjectTopicKey = formatProjectTopic(data[id].projectTopic); + const projectData = data[id]; + + if (projectData?.name) { + const newProjectTopicKey = formatProjectTopic(projectData.name); newProjectData[`v2/projects/${id}/projectTopicKey`] = newProjectTopicKey; } }); @@ -383,9 +383,7 @@ exports.addUserNameLowercase = functions.https.onRequest(async (_, res) => { const isEmptyUser = Object.keys(data).length === 0; if (isEmptyUser) { res.status(404).send('No user found'); - } - - if (!isEmptyUser && data) { + } else { const newUserData: {[key: string]: string} = {}; Object.keys(data).forEach((id) => { diff --git a/manager-dashboard/app/views/NewProject/BasicProjectInfoForm/index.tsx b/manager-dashboard/app/views/NewProject/BasicProjectInfoForm/index.tsx index 8fc88c98..397a1e03 100644 --- a/manager-dashboard/app/views/NewProject/BasicProjectInfoForm/index.tsx +++ b/manager-dashboard/app/views/NewProject/BasicProjectInfoForm/index.tsx @@ -126,7 +126,7 @@ function BasicProjectInfoForm(props: Props) { hint="We will generate you project name based on your inputs above." readOnly placeholder="[Project Topic] - [Project Region] ([Task Number]) [Requesting Organisation]" - // error={error?.name} + error={error?.name} disabled={disabled} />
diff --git a/manager-dashboard/app/views/NewProject/index.tsx b/manager-dashboard/app/views/NewProject/index.tsx index 85bd13d7..f63bbc06 100644 --- a/manager-dashboard/app/views/NewProject/index.tsx +++ b/manager-dashboard/app/views/NewProject/index.tsx @@ -275,7 +275,7 @@ function NewProject(props: Props) { visibility, filter, filterText, - projectTopic, + name, ...valuesToCopy } = finalValues; @@ -331,8 +331,7 @@ function NewProject(props: Props) { // NOTE: All the user don't have permission to access draft project // FIXME: The firebase rules need to be changed to perform this on draft project const database = getDatabase(); - const projectTopicKeyLowercase = (projectTopic?.trim())?.toLowerCase() as string; - const projectTopicKey = formatProjectTopic(projectTopicKeyLowercase); + const projectTopicKey = formatProjectTopic(name); const projectRef = databaseRef(database, 'v2/projects/'); const prevProjectNameQuery = query( @@ -350,7 +349,7 @@ function NewProject(props: Props) { setError((prevErr) => ({ ...getErrorObject(prevErr), [nonFieldError]: 'A project with this name already exists, please use a different project name (Please note that the name comparison is not case sensitive)', - projectTopic: 'A project with this name already exists', + name: 'A project with this name already exists', })); setProjectSubmissionStatus(undefined); return; @@ -369,7 +368,7 @@ function NewProject(props: Props) { const uploadData = { ...valuesToCopy, - projectTopic, + name, projectTopicKey, filter: finalFilter, image: downloadUrl,