Skip to content

Commit

Permalink
Merge branch 'master' into word-card-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imnasnainaec authored Sep 30, 2024
2 parents fd092fb + 631d139 commit 8da5951
Show file tree
Hide file tree
Showing 37 changed files with 175 additions and 84 deletions.
2 changes: 1 addition & 1 deletion deploy/helm/thecombine/charts/frontend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ imageName: combine_frontend
# The additional domain list is a space-separated string list of domains
combineAddlDomainList: ""
configAnalyticsWriteKey: ""
configCaptchaSiteKey: "None - defined in profiles"
configCaptchaSiteKey: ""
configOffline: false
configShowCertExpiration: false
2 changes: 1 addition & 1 deletion deploy/scripts/app_release.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion deploy/scripts/aws_env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python3
#!/usr/bin/env python
"""Set AWS Environment variables from aws cli profiles."""

from __future__ import annotations
Expand Down
2 changes: 1 addition & 1 deletion deploy/scripts/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

"""
Build the containerd images for The Combine.
Expand Down
2 changes: 1 addition & 1 deletion deploy/scripts/check_certs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python3
#!/usr/bin/env python

import argparse
import subprocess
Expand Down
2 changes: 1 addition & 1 deletion deploy/scripts/combine_charts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python3
#!/usr/bin/env python
"""
Update the Helm chart version with the specified version.
"""
Expand Down
2 changes: 1 addition & 1 deletion deploy/scripts/kube_env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
"""Manage the Kubernetes environment for kubectl & helm."""

from __future__ import annotations
Expand Down
2 changes: 1 addition & 1 deletion deploy/scripts/package_images.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python3
#!/usr/bin/env python

"""
Package the container images used for The Combine to support air-gapped installation.
Expand Down
2 changes: 1 addition & 1 deletion deploy/scripts/sem_dom_import.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python3
#!/usr/bin/env python
"""
Create data files for importing the Semantic Domain information into the Mongo database.
Expand Down
2 changes: 1 addition & 1 deletion deploy/scripts/setup_cluster.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
"""Install the pre-requisite helm charts for the Combine on a k8s cluster."""

from __future__ import annotations
Expand Down
2 changes: 1 addition & 1 deletion deploy/scripts/setup_combine.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python3
#!/usr/bin/env python

"""
Install The Combine Helm charts on a specified Kubernetes cluster.
Expand Down
2 changes: 1 addition & 1 deletion deploy/scripts/setup_target.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python3
#!/usr/bin/env python

import argparse
import os
Expand Down
2 changes: 1 addition & 1 deletion maintenance/scripts/add_user_to_proj.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
"""
Add user to a project.
Expand Down
2 changes: 1 addition & 1 deletion maintenance/scripts/combine_backup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
"""Create a backup of TheCombine and push the file to AWS S3 service."""

import argparse
Expand Down
2 changes: 1 addition & 1 deletion maintenance/scripts/combine_restore.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
"""
Restore The Combine from a backup stored in the AWS S3 service.
Expand Down
2 changes: 1 addition & 1 deletion maintenance/scripts/db_update_audio_type.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python3
#!/usr/bin/env python

import argparse
import logging
Expand Down
2 changes: 1 addition & 1 deletion maintenance/scripts/get_fonts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
"""
Generates font support for all SIL fonts used in Mui-Language-Picker.
Expand Down
2 changes: 1 addition & 1 deletion maintenance/scripts/monitor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
"""
Monitor TLS secrets for changes and push changes to AWS S3.
Expand Down
2 changes: 1 addition & 1 deletion maintenance/scripts/rm_project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
"""
Remove a project and its associated data from TheCombine.
Expand Down
2 changes: 1 addition & 1 deletion maintenance/scripts/update_cert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
"""
Check the expiration time of the TLS secret and update if needed.
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"forgotPassword": "Forgot password?",
"login": "Log in",
"failed": "Failed to log in. Please check your username and password.",
"failedUnknownReason": "Failed to log in. Something went wrong with The Combine.",
"backToLogin": "Back to login",
"signUp": "Sign Up",
"signUpNew": "Sign Up New User",
Expand Down
2 changes: 1 addition & 1 deletion scripts/clean_aws_repo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

"""
This script cleans out old docker images from the AWS ECR repository.
Expand Down
2 changes: 1 addition & 1 deletion scripts/cleanup_local_repo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

"""Remove all temporary files and folders within the local Git repository.
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_openapi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

"""Regenerate the frontend OpenAPI bindings to the backend.
Expand Down
2 changes: 1 addition & 1 deletion scripts/get_fonts_dev.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

"""
Runs maintenance/scripts/get_fonts.py with dev arguments for -f and -o.
Expand Down
2 changes: 1 addition & 1 deletion scripts/split_dictionary.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
"""
Splits a dictionary file into smaller files.
"""
Expand Down
2 changes: 1 addition & 1 deletion scripts/subtitle_tutorial_video.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
"""
Add subtitles to a tutorial video.
If video path is not provided, still generates .srt files.
Expand Down
19 changes: 8 additions & 11 deletions src/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ const config = new Api.Configuration(config_parameters);
/** A list of URL patterns for which the frontend explicitly handles errors
* and the blanket error pop ups should be suppressed.*/
const whiteListedErrorUrls = [
"users/authenticate",
"users/captcha",
"/speakers/create/",
"/speakers/update/",
"/users/authenticate",
"/users/captcha/",
];

// Create an axios instance to allow for attaching interceptors to it.
Expand All @@ -66,16 +66,13 @@ axiosInstance.interceptors.response.use(undefined, (err: AxiosError) => {
router.navigate(Path.Login);
}

// Check for fatal errors (4xx-5xx).
if (
status >= StatusCodes.BAD_REQUEST &&
status <= StatusCodes.NETWORK_AUTHENTICATION_REQUIRED
) {
// Suppress error pop-ups for URLs the frontend already explicitly handles.
if (url && whiteListedErrorUrls.some((u) => url.includes(u))) {
return Promise.reject(err);
}
// Suppress error pop-ups for URLs the frontend already explicitly handles.
if (url && whiteListedErrorUrls.some((u) => url.includes(u))) {
return Promise.reject(err);
}

// Check for fatal errors (400+).
if (status >= StatusCodes.BAD_REQUEST) {
console.error(err);
enqueueSnackbar(`${status} ${response.statusText}\n${err.config.url}`);
}
Expand Down
10 changes: 1 addition & 9 deletions src/components/Login/Captcha.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ export default function Captcha(props: CaptchaProps): ReactElement {
setSuccess(!isRequired.current);
}, [isRequired, setSuccess]);

const siteKey =
process.env.NODE_ENV === "production"
? RuntimeConfig.getInstance().captchaSiteKey()
: // https://developers.cloudflare.com/turnstile/troubleshooting/testing/
// has dummy site keys for development and testing; options are
// invisible pass, invisible fail, visible pass, visible fail, forced interaction
"1x00000000000000000000AA"; // visible pass

const fail = (): void => {
setSuccess(false);
toast.error(t("captcha.error"));
Expand All @@ -49,7 +41,7 @@ export default function Captcha(props: CaptchaProps): ReactElement {
onExpire={fail}
onSuccess={verify}
options={{ language: i18n.resolvedLanguage, theme: "light" }}
siteKey={siteKey}
siteKey={RuntimeConfig.getInstance().captchaSiteKey()}
/>
) : (
<Fragment />
Expand Down
9 changes: 8 additions & 1 deletion src/components/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export enum LoginId {
export default function Login(): ReactElement {
const dispatch = useAppDispatch();

const loginError = useAppSelector(
(state: StoreState) => state.loginState.error
);
const status = useAppSelector(
(state: StoreState) => state.loginState.loginStatus
);
Expand Down Expand Up @@ -147,7 +150,11 @@ export default function Login(): ReactElement {
style={{ color: "red", marginBottom: 24, marginTop: 24 }}
variant="body2"
>
{t("login.failed")}
{t(
loginError.includes("401")
? "login.failed"
: "login.failedUnknownReason"
)}
</Typography>
)}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Login/Redux/LoginActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function asyncLogIn(username: string, password: string) {
router.navigate(Path.ProjScreen);
})
.catch((err) =>
dispatch(loginFailure(err.response?.data ?? err.message))
dispatch(loginFailure(`${err.response?.status ?? err.message}`))
);
};
}
Expand Down
19 changes: 19 additions & 0 deletions src/components/Project/ProjectActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { type Action, type PayloadAction } from "@reduxjs/toolkit";
import {
type MRT_ColumnOrderState,
type MRT_Updater,
type MRT_VisibilityState,
} from "material-react-table";

import { type Project, type Speaker, type User } from "api/models";
import {
Expand All @@ -9,6 +14,8 @@ import {
import { setProjectId } from "backend/localStorage";
import {
resetAction,
setColumnOrderAction,
setColumnVisibilityAction,
setProjectAction,
setSemanticDomainsAction,
setSpeakerAction,
Expand All @@ -25,6 +32,18 @@ export function resetCurrentProject(): Action {
return resetAction();
}

export function setReviewEntriesColumnOrder(
updater: MRT_Updater<MRT_ColumnOrderState>
): PayloadAction {
return setColumnOrderAction(updater);
}

export function setReviewEntriesColumnVisibility(
updater: MRT_Updater<MRT_VisibilityState>
): PayloadAction {
return setColumnVisibilityAction(updater);
}

export function setCurrentProject(project?: Project): PayloadAction {
return setProjectAction(project ?? newProject());
}
Expand Down
23 changes: 23 additions & 0 deletions src/components/Project/ProjectReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,29 @@ const projectSlice = createSlice({
initialState: defaultState,
reducers: {
resetAction: () => defaultState,
setColumnOrderAction: (state, action) => {
const columns = state.reviewEntriesColumns;
// Payload is a state updater, which can either be a new state
// or a function that takes the previous state and returns a new state.
if (typeof action.payload === "function") {
columns.columnOrder = action.payload(columns.columnOrder);
} else {
columns.columnOrder = action.payload;
}
},
setColumnVisibilityAction: (state, action) => {
const columns = state.reviewEntriesColumns;
// Payload is a state updater, which can either be a new state
// or a function that takes the previous state and returns a new state.
if (typeof action.payload === "function") {
columns.columnVisibility = action.payload(columns.columnVisibility);
} else {
columns.columnVisibility = action.payload;
}
},
setProjectAction: (state, action) => {
if (state.project.id !== action.payload.id) {
state.reviewEntriesColumns = defaultState.reviewEntriesColumns;
state.speaker = undefined;
state.users = [];
}
Expand All @@ -31,6 +52,8 @@ const projectSlice = createSlice({

export const {
resetAction,
setColumnOrderAction,
setColumnVisibilityAction,
setProjectAction,
setSemanticDomainsAction,
setSpeakerAction,
Expand Down
12 changes: 12 additions & 0 deletions src/components/Project/ProjectReduxTypes.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
import {
type MRT_ColumnOrderState,
type MRT_VisibilityState,
} from "material-react-table";

import { type Project, type Speaker, type User } from "api/models";
import { type Hash } from "types/hash";
import { newProject } from "types/project";

export interface CurrentProjectState {
project: Project;
/** For project-level persistance of ReviewEntriesTable's managed states
* per https://www.material-react-table.com/docs/guides/state-management */
reviewEntriesColumns: {
columnOrder: MRT_ColumnOrderState;
columnVisibility: MRT_VisibilityState;
};
semanticDomains?: Hash<string>;
speaker?: Speaker;
users: User[];
}

export const defaultState: CurrentProjectState = {
project: newProject(),
reviewEntriesColumns: { columnOrder: [], columnVisibility: {} },
users: [],
};
Loading

0 comments on commit 8da5951

Please sign in to comment.