Skip to content

Commit cf986ce

Browse files
Merge pull request #6919 from hotosm/develop
Bring latest changes to staging
2 parents 061cb30 + af3da09 commit cf986ce

23 files changed

Lines changed: 268 additions & 691 deletions

.circleci/config.yml

Lines changed: 0 additions & 510 deletions
This file was deleted.

.circleci/rdsid.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/add-version-to-db.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ jobs:
66
add_release:
77
runs-on: ubuntu-latest
88
steps:
9-
- name: Add release version to db
10-
run: |
11-
curl -X POST "https://tasking-manager-tm4-production-api.hotosm.org/api/v2/system/release/"
9+
- name: Add release version to db
10+
run: |
11+
curl -X POST "https://tasking-manager-production-api.hotosm.org/api/v2/system/release/"

.github/workflows/backend-build-deploy.yml

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -26,51 +26,11 @@ env:
2626

2727
jobs:
2828
image-build-and-push:
29-
name: Build Container Images
30-
runs-on: ubuntu-latest
31-
permissions:
32-
contents: read
33-
packages: write
34-
outputs:
35-
image_tags: ${{ steps.meta.outputs.tags }}
36-
37-
steps:
38-
- uses: docker/setup-qemu-action@v3
39-
- uses: docker/setup-buildx-action@v3
40-
41-
- name: Log in to the Container registry
42-
uses: docker/login-action@v3
43-
with:
44-
registry: ${{ env.REGISTRY }}
45-
username: ${{ github.actor }}
46-
password: ${{ secrets.GITHUB_TOKEN }}
47-
48-
- name: Set container image metadata
49-
id: meta
50-
uses: docker/metadata-action@v5
51-
with:
52-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
53-
tags: |
54-
type=raw,value=${{ github.ref_name }}
55-
type=raw,value=${{ github.sha }}
56-
57-
- name: Build and push container image
58-
id: build-push-image
59-
uses: docker/build-push-action@v5
60-
with:
61-
context: "{{defaultContext}}"
62-
target: prod
63-
platforms: linux/amd64,linux/arm64
64-
file: scripts/docker/Dockerfile
65-
push: true
66-
tags: ${{ steps.meta.outputs.tags }}
67-
labels: ${{ steps.meta.outputs.labels }}
68-
cache-from: |
69-
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ github.ref_name }}
70-
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-main
71-
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-staging
72-
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-develop
73-
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ github.ref_name }},mode=max
29+
uses: hotosm/gh-workflows/.github/workflows/image_build.yml@1.5.1
30+
with:
31+
image_name: ghcr.io/${{ github.repository }}/backend
32+
build_target: prod
33+
dockerfile: scripts/docker/Dockerfile
7434

7535
deploy-service:
7636
name: Deploy ${{ matrix.service }} to ECS

.github/workflows/backend-build.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 🧪 PR Test Backend
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- staging
8+
- develop
9+
paths:
10+
- "backend/**"
11+
workflow_dispatch:
12+
13+
jobs:
14+
code-check-PEP8:
15+
name: Run PEP8 code style checks
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Clone repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python 3.10
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: "3.10"
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install flake8
30+
pip install black==25.1.0
31+
32+
- name: Run PEP8 checks
33+
run: |
34+
flake8 manage.py backend tests migrations
35+
black --check manage.py backend tests migrations
36+
37+
pytest:
38+
uses: hotosm/gh-workflows/.github/workflows/test_compose.yml@3.2.0
39+
with:
40+
image_name: ghcr.io/${{ github.repository }}/backend
41+
build_context: .
42+
build_dockerfile: ./scripts/docker/Dockerfile
43+
pre_command: |
44+
cp example.env tasking-manager.env
45+
docker compose up -d tm-db tm-backend tm-migration tm-cron-jobs traefik
46+
docker compose exec tm-db bash -c "PGPASSWORD=tm psql -U tm -d tasking-manager <<EOF
47+
CREATE DATABASE taskingmanagertest;
48+
EOF"
49+
compose_file: "docker-compose.yml"
50+
compose_service: tm-backend
51+
compose_command: pytest tests/api/unit/ -p no:warnings
52+
cache_extra_imgs: |
53+
"postgis/postgis:14-3.3"
54+
secrets: inherit
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
name: Build & publish TM frontend static files
1+
name: 🧪 PR Test Frontend
22

33
on:
4-
push:
5-
branches:
6-
- deployment/hot-tasking-manager
7-
- deployment/demo-tasking-manager
8-
- deployment/container-tasking-manager
9-
104
pull_request:
115
branches:
126
- main
137
- staging
148
- develop
15-
- deployment/hot-tasking-manager
16-
- deployment/demo-tasking-manager
17-
- deployment/container-tasking-manager
9+
paths:
10+
- "frontend/**"
11+
workflow_dispatch:
1812

1913
jobs:
2014
build:
@@ -62,6 +56,10 @@ jobs:
6256
working-directory: ./frontend
6357
run: yarn install
6458

59+
- name: Run Yarn test
60+
working-directory: ./frontend
61+
run: yarn test
62+
6563
- name: Generate build
6664
working-directory: ./frontend
6765
run: |

backend/services/messaging/message_service.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,14 +774,29 @@ async def _parse_message_for_bulk_mentions(
774774
)
775775
usernames.extend([member["username"] for member in team_members])
776776

777+
organisation_managers_query = """
778+
SELECT DISTINCT u.username
779+
FROM projects p
780+
JOIN organisation_managers om ON p.organisation_id = om.organisation_id
781+
JOIN users u ON u.id = om.user_id
782+
WHERE p.id = :project_id
783+
"""
784+
785+
organisation_managers = await db.fetch_all(
786+
organisation_managers_query, values={"project_id": project_id}
787+
)
788+
if organisation_managers:
789+
usernames.extend(
790+
[manager["username"] for manager in organisation_managers]
791+
)
792+
777793
# Add contributors if task_id is provided and contributors are mentioned
778794
if task_id and "contributors" in parsed:
779795
contributors = await Message.get_all_tasks_contributors(
780796
project_id, task_id, db
781797
)
782798
usernames.extend(contributors)
783-
784-
return usernames
799+
return list(set(usernames))
785800

786801
@staticmethod
787802
async def _parse_message_for_username(

frontend/src/components/header/tests/index.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,18 @@ describe('Right side action items', () => {
134134
expect(screen.getByLabelText('Sample avatar')).toBeInTheDocument();
135135
});
136136

137-
test("when the user isn't logged in", () => {
137+
test("when the user isn't logged in", async () => {
138138
act(() => {
139139
store.dispatch({
140140
type: 'SET_USER_DETAILS',
141141
userDetails: {},
142142
});
143143
});
144144
setup();
145-
expect(screen.getByRole('combobox')).toBeInTheDocument();
146-
expect(screen.getByText('English')).toBeInTheDocument();
145+
await waitFor(() => {
146+
expect(screen.getByRole('combobox')).toBeInTheDocument();
147+
expect(screen.getByText('English')).toBeInTheDocument();
148+
});
147149
expect(
148150
screen.getByRole('button', {
149151
name: /log in/i,

frontend/src/components/localeSelect.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FormattedMessage } from 'react-intl';
33
import Select from 'react-select';
44

55
import messages from './messages';
6-
import { supportedLocales } from '../utils/internationalization';
6+
import { useFetch } from '../hooks/UseFetch';
77
import { setLocale } from '../store/actions/userPreferences';
88

99
function LocaleSelect({
@@ -13,22 +13,30 @@ function LocaleSelect({
1313
removeBorder = true,
1414
fullWidth = false,
1515
}) {
16+
const [errorLanguages, loadingLanguages, languages] = useFetch('system/languages/');
17+
18+
const supportedLanguages =
19+
!errorLanguages && !loadingLanguages ? languages.supportedLanguages : [];
20+
1621
const onLocaleSelect = (arr) => {
17-
setLocale(arr[0].value);
22+
setLocale(arr[0].code);
1823
};
1924

2025
const getActiveLanguageNames = () => {
2126
const locales = [userPreferences.locale, navigator.language, navigator.language.substr(0, 2)];
2227
let supportedLocaleNames = [];
2328
locales.forEach((locale) =>
24-
supportedLocales
25-
.filter((i) => i.value === locale)
29+
supportedLanguages
30+
.filter((i) => i.code === locale)
2631
.forEach((i) => supportedLocaleNames.push(i)),
2732
);
2833

29-
return supportedLocaleNames.length ? supportedLocaleNames[0].value : 'en';
34+
return supportedLocaleNames.length ? supportedLocaleNames[0].code : 'en';
3035
};
3136

37+
// wait till supportedLanguages are fetched
38+
if (!supportedLanguages.length) return <></>;
39+
3240
return (
3341
<div className={`settings-width ml-auto ${className || ''}`}>
3442
<Select
@@ -37,19 +45,22 @@ function LocaleSelect({
3745
control: (baseStyles, state) => ({
3846
...baseStyles,
3947
border: removeBorder ? 'none' : 'auto',
40-
width: fullWidth ? '100%' : `${8 * state.getValue()[0].label.length + 60}px`,
48+
width:
49+
fullWidth || !supportedLanguages.length
50+
? '100%'
51+
: `${8 * state.getValue()[0].language.length + 60}px`,
4152
marginLeft: 'auto',
4253
}),
4354
menu: (baseStyles) => ({
4455
...baseStyles,
4556
zIndex: 6,
4657
}),
4758
}}
48-
getOptionLabel={({ label }) => label}
59+
getOptionLabel={({ language }) => language}
4960
onChange={(e) => onLocaleSelect([e])}
50-
options={supportedLocales}
61+
options={supportedLanguages}
5162
placeholder={<FormattedMessage {...messages.language} />}
52-
value={supportedLocales.find((editor) => editor.value === getActiveLanguageNames())}
63+
value={supportedLanguages.find((editor) => editor.code === getActiveLanguageNames())}
5364
/>
5465
</div>
5566
);

0 commit comments

Comments
 (0)