Skip to content

Commit ef41414

Browse files
committed
merge upstream
2 parents 956d70a + 949215e commit ef41414

File tree

262 files changed

+33567
-5702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

262 files changed

+33567
-5702
lines changed

.github/workflows/cypress-tests.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
mkcert -cert-file localhost.pem -key-file localhost-key.pem \
3535
localhost 127.0.0.1 ::1 oidc-simulator host.docker.internal
3636
37-
# Copy mkcert root CA to the certs directory for Docker containers
37+
# Copy mkcert root CA for other containers
3838
cp "$(mkcert -CAROOT)/rootCA.pem" ./rootCA.pem
3939
4040
# List generated files for debugging
@@ -89,11 +89,14 @@ jobs:
8989
if: always()
9090
run: |
9191
# Show logs from critical services for debugging
92+
echo "=== NGINX Proxy logs ==="
93+
docker compose -f docker-compose.test.yml logs nginx-proxy || true
94+
9295
echo "=== OIDC Simulator logs ==="
93-
docker compose -f docker-compose.test.yml logs oidc-simulator | tail -100
96+
docker compose -f docker-compose.test.yml logs oidc-simulator || true
9497
9598
echo "=== Server logs ==="
96-
docker compose -f docker-compose.test.yml logs server | tail -100
99+
docker compose -f docker-compose.test.yml logs server || true
97100
98101
- name: Run auth setup test
99102
run: |

.github/workflows/jest-server-test.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ jobs:
6565
run: |
6666
# Build all services except server (tests run on host)
6767
docker compose -f docker-compose.test.yml --env-file test.env build \
68-
math postgres file-server maildev oidc-simulator
68+
math postgres file-server maildev oidc-simulator dynamodb
6969
7070
- name: Start services
7171
run: |
7272
# Start only required services in detached mode (exclude server)
7373
docker compose -f docker-compose.test.yml --env-file test.env up -d \
74-
math postgres file-server maildev oidc-simulator
74+
math postgres file-server maildev oidc-simulator dynamodb
7575
7676
# Wait for services to be ready
7777
echo "Waiting for services to start..."
@@ -88,6 +88,11 @@ jobs:
8888
8989
echo "Checking oidc-simulator..."
9090
curl -k -f https://localhost:3000/.well-known/jwks.json || true
91+
92+
echo "Checking DynamoDB..."
93+
curl -f http://localhost:8000 || true
94+
# Alternative check using AWS CLI if available
95+
aws dynamodb list-tables --endpoint-url http://localhost:8000 --region us-east-1 2>/dev/null || true
9196
9297
- name: Setup Node.js
9398
uses: actions/setup-node@v4
@@ -114,6 +119,7 @@ jobs:
114119
export DATABASE_URL=postgres://postgres:PdwPNS2mDN73Vfbc@localhost:5432/polis-test
115120
export MAILDEV_HOST=localhost
116121
export STATIC_FILES_HOST=localhost
122+
export DYNAMODB_ENDPOINT=http://localhost:8000
117123
118124
# Run the tests on the host machine
119125
npm test -- --ci --coverage --maxWorkers=2
@@ -138,6 +144,9 @@ jobs:
138144
139145
echo "=== Math logs ==="
140146
docker compose -f docker-compose.test.yml logs math | tail -50
147+
148+
echo "=== DynamoDB logs ==="
149+
docker compose -f docker-compose.test.yml logs dynamodb | tail -100
141150
142151
- name: Clean up
143152
if: always()

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ start-FULL-REBUILD: echo_vars stop rm-ALL ## Remove and restart all Docker conta
102102
docker compose ${COMPOSE_FILE_ARGS} --env-file ${ENV_FILE} build --no-cache
103103
docker compose ${COMPOSE_FILE_ARGS} --env-file ${ENV_FILE} up ${DETACH_ARG}
104104

105-
rebuild-web: echo_vars ## Rebuild and restart just the file-server container and its static assets
106-
docker compose ${COMPOSE_FILE_ARGS} --env-file ${ENV_FILE} up ${DETACH_ARG} --build --force-recreate file-server
105+
rebuild-web: echo_vars ## Rebuild and restart just the file-server container and its static assets, and client-participation-alpha
106+
docker compose ${COMPOSE_FILE_ARGS} --env-file ${ENV_FILE} up ${DETACH_ARG} --build --force-recreate file-server client-participation-alpha
107107

108108
build-web-assets: ## Build and extract static web assets for cloud deployment to `build` dir
109109
docker compose ${COMPOSE_FILE_ARGS} --env-file ${ENV_FILE} create --build --force-recreate file-server

cdk/launchTemplates.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ export default (
3030
ollamaKeyPair: ec2.IKeyPair | undefined,
3131
ollamaSecurityGroup: ec2.ISecurityGroup
3232
) => {
33-
// Generic User Data function (Works with NAT Gateway for internet)
3433
const usrdata = (CLOUDWATCH_LOG_GROUP_NAME: string, service: string, instanceSize?: string) => {
3534
let ld: ec2.UserData;
3635
ld = ec2.UserData.forLinux();
36+
const persistentConfigDir = '/etc/app-info';
3737
ld.addCommands(
3838
'#!/bin/bash',
3939
'set -e',
4040
'set -x',
41-
`echo "Writing service type '${service}' to /tmp/service_type.txt"`,
42-
`echo "${service}" > /tmp/service_type.txt`,
43-
`echo "Contents of /tmp/service_type.txt: $(cat /tmp/service_type.txt)"`,
44-
// If instanceSize is provided, write it to a file
45-
instanceSize ? `echo "Writing instance size '${instanceSize}' to /tmp/instance_size.txt"` : '',
46-
instanceSize ? `echo "${instanceSize}" > /tmp/instance_size.txt` : '',
47-
instanceSize ? `echo "Contents of /tmp/instance_size.txt: $(cat /tmp/instance_size.txt)"` : '',
41+
`sudo mkdir -p ${persistentConfigDir}`,
42+
`sudo chown root:root ${persistentConfigDir}`,
43+
`sudo chmod 755 ${persistentConfigDir}`,
44+
`echo "Writing service type '${service}' to ${persistentConfigDir}/service_type.txt"`,
45+
`echo "${service}" | sudo tee ${persistentConfigDir}/service_type.txt`,
46+
instanceSize ? `echo "Writing instance size '${instanceSize}' to ${persistentConfigDir}/instance_size.txt"` : '',
47+
instanceSize ? `echo "${instanceSize}" | sudo tee ${persistentConfigDir}/instance_size.txt` : '',
4848
'sudo yum update -y',
4949
'sudo yum install -y amazon-cloudwatch-agent -y',
5050
'sudo dnf install -y wget ruby docker',
@@ -53,13 +53,13 @@ export default (
5353
'sudo usermod -a -G docker ec2-user',
5454
'sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose',
5555
'sudo chmod +x /usr/local/bin/docker-compose',
56-
'docker-compose --version', // Verify installation
56+
'docker-compose --version',
5757
'sudo yum install -y jq',
5858
`export SERVICE=${service}`,
5959
instanceSize ? `export INSTANCE_SIZE=${instanceSize}` : '',
6060
'exec 1>>/var/log/user-data.log 2>&1',
6161
'echo "Finished User Data Execution at $(date)"',
62-
'sudo mkdir -p /etc/docker', // Ensure /etc/docker directory exists
62+
'sudo mkdir -p /etc/docker',
6363
`cat << EOF | sudo tee /etc/docker/daemon.json
6464
{
6565
"log-driver": "awslogs",
@@ -69,10 +69,10 @@ export default (
6969
"awslogs-stream": "${service}"
7070
}
7171
}
72-
EOF`, // Ensure EOF is on a new line with no leading/trailing spaces
73-
`sudo chmod 644 /etc/docker/daemon.json`, // Good practice to set permissions
72+
EOF`,
73+
`sudo chmod 644 /etc/docker/daemon.json`,
7474
'sudo systemctl restart docker',
75-
'sudo systemctl status docker'
75+
'sudo systemctl status docker'
7676
);
7777
return ld;
7878
};

client-admin/package-lock.json

Lines changed: 20 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-admin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"react-oidc-context": "^3.3.0",
6767
"react-redux": "^9.2.0",
6868
"react-router": "^7.6.3",
69+
"react-router-dom": "^7.7.1",
6970
"redux": "^5.0.1",
7071
"theme-ui": "^0.17.2",
7172
"victory": "~37.3.6"

client-admin/src/components/conversation-admin/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ConversationStats from './stats'
1111
import { useAuth } from 'react-oidc-context'
1212

1313
import ModerateComments from './comment-moderation/'
14+
import TopicModeration from './topic-moderation/'
1415

1516
// import DataExport from "./data-export";
1617
import ShareAndEmbed from './share-and-embed'
@@ -61,6 +62,16 @@ const ConversationAdminContainer = () => {
6162
All
6263
</Link>
6364
</Box>
65+
<Box sx={{ mb: [3] }}>
66+
<Link
67+
sx={{
68+
variant: url === 'topics' ? 'links.activeNav' : 'links.nav'
69+
}}
70+
data-test-id="moderate-topics"
71+
to={`${baseUrl}/topics`}>
72+
Topic Mod
73+
</Link>
74+
</Box>
6475
<Box sx={{ mb: [3] }}>
6576
<Link sx={{ variant: url ? 'links.nav' : 'links.activeNav' }} to={baseUrl}>
6677
Configure
@@ -111,6 +122,12 @@ const ConversationAdminContainer = () => {
111122
<Route path="reports/*" element={<Reports />} />
112123
<Route path="comments/*" element={<ModerateComments />} />
113124
<Route path="stats" element={<ConversationStats />} />
125+
<Route
126+
path={`${baseUrl}/topics`}
127+
render={(props) => (
128+
<TopicModeration {...props} conversation_id={params.conversation_id} />
129+
)}
130+
/>
114131
{/* <Route path="export" element={<DataExport />} /> */}
115132
</Routes>
116133
</Box>

client-admin/src/components/conversation-admin/seed-comment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const ModerateCommentsSeed = ({ params }) => {
117117
Upload a CSV of seed comments
118118
</Heading>
119119
<input onChange={handleFileChange} type="file" id="csvFile" accept=".csv"></input>
120-
<Button onClick={handleSubmitSeedBulk}>{getButtonText()}</Button>
120+
<Button onClick={handleSubmitSeedBulk} data-testid="upload-csv-button">{getButtonText()}</Button>
121121
</Box>
122122
</Box>
123123
)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Topic Moderation Components
2+
3+
This directory contains the React components for the Topic-Based Moderation system in pol.is.
4+
5+
## Components
6+
7+
### `index.js` - TopicModeration
8+
Main container component with tabbed navigation between different views:
9+
- Topics Tree view
10+
- Proximity Map visualization
11+
- Statistics dashboard
12+
13+
### `topic-tree.js` - TopicTree
14+
Hierarchical display of topics organized by layers:
15+
- Layer selection (0, 1, 2, or all)
16+
- Topic cards with moderation controls
17+
- Bulk topic-level actions (Accept/Reject/Meta)
18+
- Navigation to detailed comment view
19+
20+
### `topic-detail.js` - TopicDetail
21+
Detailed view of comments within a specific topic:
22+
- Individual comment display with selection
23+
- Bulk comment selection and actions
24+
- UMAP coordinate display
25+
- Moderation status tracking
26+
27+
### `proximity-visualization.js` - ProximityVisualization
28+
SVG-based UMAP visualization:
29+
- Interactive scatter plot of comment positions
30+
- Cluster grouping visualization
31+
- Color coding by moderation status
32+
- Layer selection for different granularities
33+
34+
### `topic-stats.js` - TopicStats
35+
Statistics and progress tracking:
36+
- Moderation completion rates
37+
- Status distribution (pending/accepted/rejected/meta)
38+
- Progress bars and visual indicators
39+
- Overview dashboard
40+
41+
## Usage
42+
43+
The components are integrated into the conversation admin interface at:
44+
`/m/:conversation_id/topics`
45+
46+
## Dependencies
47+
48+
- React with hooks
49+
- theme-ui for styling
50+
- React Router for navigation
51+
- SVG manipulation for visualizations
52+
53+
## Data Flow
54+
55+
1. Components fetch data from `/api/v3/topicMod/*` endpoints
56+
2. Real-time polling for updates (60-second intervals)
57+
3. Optimistic UI updates for moderation actions
58+
4. Error handling with retry mechanisms
59+
60+
## Styling
61+
62+
Uses theme-ui variants and custom CSS in `topic-moderation.css` for:
63+
- Hover effects and transitions
64+
- Status-based color coding
65+
- Responsive design
66+
- Loading states and animations

0 commit comments

Comments
 (0)