Skip to content

Commit

Permalink
Merge branch 'master' into improvement/new-chemistry-options
Browse files Browse the repository at this point in the history
  • Loading branch information
sjd210 committed Oct 23, 2024
2 parents b2e1300 + 2d98a71 commit fdcb4a1
Show file tree
Hide file tree
Showing 18 changed files with 117 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
REACT_APP_API_VERSION=v3.16.10
REACT_APP_API_VERSION=v3.16.12
5 changes: 1 addition & 4 deletions deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@ def update_config(ctx):
print(f"# Update configuration files")
ask_to_run_command(f"cd /local/data && ./fetch-isaac-sops-config.sh")
print(f"# Decrypt configuration files")
# GPG would normally prompt us for the key password, but it's not possible to answer that prompt through subprocess.run().
# Instead, we ask for it here and pass it in to the subprocess as an environment variable.
gpg_password = getpass.getpass("Enter password for SOPS GPG key: ")
ask_to_run_command(f"cd /local/src/isaac-sops-config && ./deploy_in_docker.sh /local/data/keys/$(hostname)_gpg.ppk /local/src/isaac-sops-config /local/data/isaac-sops-config-decrypted {ctx['env']} {ctx['site']}", env_vars={"GPG_KEY_PASSWORD": gpg_password})
ask_to_run_command(f"cd /local/src/isaac-sops-config && ./deploy_in_docker.sh /local/data/keys/$(hostname)_gpg.ppk /local/src/isaac-sops-config /local/data/isaac-sops-config-decrypted {ctx['env']} {ctx['site']}")


def run_db_migrations(ctx):
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isaac-react-app",
"version": "3.14.4-SNAPSHOT",
"version": "3.14.6-SNAPSHOT",
"private": true,
"engines": {
"node": ">=18",
Expand All @@ -24,7 +24,7 @@
"identity-obj-proxy": "3.0.0",
"immer": "^9.0.21",
"inequality": "1.1.3",
"inequality-grammar": "1.3.2",
"inequality-grammar": "1.3.4",
"isaac-graph-sketcher": "0.13.7",
"js-cookie": "^3.0.5",
"katex": "^0.16.11",
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/content/IsaacClozeQuestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
CLOZE_ITEM_SECTION_ID,
NULL_CLOZE_ITEM,
NULL_CLOZE_ITEM_ID,
below,
isDefined,
isTouchDevice,
useCurrentQuestionAttempt,
Expand Down Expand Up @@ -498,7 +499,7 @@ const IsaacClozeQuestion = ({doc, questionId, readonly, validationResponse}: Isa
{doc.children}
</IsaacContentValueOrChildren>

{(!(deviceSize === "xs" || isTouchDevice())) && <>
{(!(deviceSize === "xs" || (isTouchDevice() && below['md'](deviceSize)))) && <>
{/* The item attached to the users cursor while dragging (just for display, shouldn't contain useDraggable/useSortable hooks) */}
<DragOverlay>
{activeItem && <Badge className="p-1 cloze-item is-dragging">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {useDroppable} from "@dnd-kit/core";
import {CSS} from "@dnd-kit/utilities";
import {useSortable} from "@dnd-kit/sortable";
import classNames from "classnames";
import {CLOZE_DROP_ZONE_ID_PREFIX, NULL_CLOZE_ITEM, isAda, isDefined, isPhy, isTouchDevice, useDeviceSize} from "../../../../services";
import {CLOZE_DROP_ZONE_ID_PREFIX, NULL_CLOZE_ITEM, below, isAda, isDefined, isPhy, isTouchDevice, useDeviceSize} from "../../../../services";
import { Markup } from "..";

export function Item({item, id, type, overrideOver, isCorrect}: {item: Immutable<ItemDTO>, id: string, type: "drop-zone" | "item-section", overrideOver?: boolean, isCorrect?: boolean}) {
Expand Down Expand Up @@ -141,7 +141,7 @@ function InlineDropRegion({id, index, emptyWidth, emptyHeight, rootElement}: {id

if (dropRegionContext && droppableTarget) {
return ReactDOM.createPortal(
((isTouchDevice()) || (deviceSize === "xs")) ? dropdownZone : draggableDropZone,
(deviceSize === "xs" || (isTouchDevice() && below['md'](deviceSize))) ? dropdownZone : draggableDropZone,
droppableTarget
);
}
Expand Down
24 changes: 14 additions & 10 deletions src/app/components/elements/panels/TeacherConnections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,12 @@ export const TeacherConnections = ({user, authToken, editingOtherUser, userToEdi
}
return <React.Fragment key={teacherAuthorisation.id}>
<li style={style} className="py-2">
<span className="icon-person-active" />
<span id={`teacher-authorisation-${teacherAuthorisation.id}`} className="connections-fixed-length-text">
{extractTeacherName(teacherAuthorisation)}
</span>
<div className="d-inline-flex connections-fixed-length-container">
<span className="icon-person-active" />
<span id={`teacher-authorisation-${teacherAuthorisation.id}`} className="connections-fixed-length-text">
{extractTeacherName(teacherAuthorisation)}
</span>
</div>
<RS.UncontrolledTooltip
placement="bottom" target={`teacher-authorisation-${teacherAuthorisation.id}`}
>
Expand Down Expand Up @@ -264,10 +266,12 @@ export const TeacherConnections = ({user, authToken, editingOtherUser, userToEdi
return null;
}
return <li key={student.id} style={style} className="py-2">
<span className="icon-person-active" />
<span id={`student-authorisation-${student.id}`} className="connections-fixed-length-text">
{student.givenName} {student.familyName}
</span>
<div className="d-inline-flex connections-fixed-length-container">
<span className="icon-person-active" />
<span id={`student-authorisation-${student.id}`} className="connections-fixed-length-text">
{student.givenName} {student.familyName}
</span>
</div>
<RS.UncontrolledTooltip
placement="bottom" target={`student-authorisation-${student.id}`}
>
Expand Down Expand Up @@ -326,12 +330,12 @@ export const TeacherConnections = ({user, authToken, editingOtherUser, userToEdi
const inactiveInGroup = membership.membershipStatus === MEMBERSHIP_STATUS.INACTIVE;
return <li key={index} style={style} className={classNames("p-2 ps-3", {"inactive-group" : isAda && inactiveInGroup})}>
<div className="d-flex">
<RS.Col className="me-1">
<RS.Col className="connections-fixed-length-container me-1">
<div className="d-flex">
<span id={`group-membership-${index}`} className={classNames("connections-fixed-length-text", {"text-muted connection-inactive": inactiveInGroup})}>
<b>{(membership.group.groupName ?? "Group " + membership.group.id)}</b>
</span>
{inactiveInGroup && <span>{" ("}<i>inactive</i>{")"}</span>}
{inactiveInGroup && <span>&nbsp;{"("}<i>inactive</i>{")"}</span>}
{membership.group.selfRemoval && <img className={classNames("self-removal-group", {"ms-1": !inactiveInGroup})} src={siteSpecific("/assets/phy/icons/teacher_features_sprite.svg#groups", "/assets/cs/icons/group.svg")} alt=""/>}
<RS.UncontrolledTooltip
placement="top" target={`group-membership-${index}`}
Expand Down
8 changes: 4 additions & 4 deletions src/app/components/pages/MyAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ import {
validatePassword,
isTeacherOrAbove,
isFirstLoginInPersistence,
ACCOUNT_TABS
ACCOUNT_TABS,
ACCOUNT_TABS_ALIASES
} from "../../services";
import queryString from "query-string";
import {Link, withRouter} from "react-router-dom";
Expand Down Expand Up @@ -225,9 +226,8 @@ const AccountPageComponent = ({user, getChosenUserAuthSettings, error, userAuthS
// @ts-ignore
const tab: ACCOUNT_TAB =
(authToken && ACCOUNT_TAB.teacherconnections) ||
// This feel particularly bad
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(hashAnchor && ACCOUNT_TAB[hashAnchor as any]) ||
(hashAnchor && hashAnchor in ACCOUNT_TAB && ACCOUNT_TAB[hashAnchor as keyof typeof ACCOUNT_TAB]) ||
(hashAnchor && hashAnchor in ACCOUNT_TABS_ALIASES && ACCOUNT_TABS_ALIASES[hashAnchor as string]) ||
ACCOUNT_TAB.account;
setActiveTab(tab);
}, [hashAnchor, authToken]);
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/pages/Question.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const Question = withRouter(({questionIdOverride, match, location, previe
const isFastTrack = doc && doc.type === DOCUMENT_TYPE.FAST_TRACK_QUESTION;

return <GameboardContext.Provider value={navigation.currentGameboard}>
<Container className={`${doc.subjectId || ""}`}>
<Container className={classNames(doc.subjectId, "no-shadow")}>
{/*High contrast option*/}
<TitleAndBreadcrumb
currentPageTitle={generateQuestionTitle(doc)}
Expand Down
8 changes: 8 additions & 0 deletions src/app/services/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ export enum TAG_ID {
// Thermal
gases = "gases",
heatCapacity = "heat_capacity",
thermalRadiation = "thermal_radiation",
// Waves & Particles
nuclear = "nuclear",
superposition = "superposition",
Expand Down Expand Up @@ -822,6 +823,13 @@ export const ACCOUNT_TABS : AccountTabs[] = [
{tab: ACCOUNT_TAB.betafeatures, title: "Beta", hiddenIfEditingOtherUser: true},
];

// we can't change the names of tabs as we have historic links to them, so use aliases to use updated names instead
export const ACCOUNT_TABS_ALIASES: {[alias: string]: ACCOUNT_TAB} = {
"security": ACCOUNT_TAB.passwordreset,
"connections": ACCOUNT_TAB.teacherconnections,
"notifications": ACCOUNT_TAB.emailpreferences,
};

export enum MANAGE_QUIZ_TAB {set = 1, manage = 2}
export enum MARKBOOK_TYPE_TAB {assignments = 1, tests = 2}

Expand Down
3 changes: 2 additions & 1 deletion src/app/services/tagsPhy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ export class PhysicsTagService extends AbstractBaseTagService {
{id: TAG_ID.magnetic, title: "Magnetic Fields", parent: TAG_ID.fields},
{id: TAG_ID.combined, title: "Combined Fields", parent: TAG_ID.fields},
// Thermal
{id: TAG_ID.heatCapacity, title: "Heat Capacity", parent: TAG_ID.thermal},
{id: TAG_ID.heatCapacity, title: "Heat", parent: TAG_ID.thermal},
{id: TAG_ID.gases, title: "Gases", parent: TAG_ID.thermal},
{id: TAG_ID.thermalRadiation, title: "Radiation", parent: TAG_ID.thermal},
// Waves Particles
{id: TAG_ID.optics, title: "Optics", parent: TAG_ID.wavesParticles},
{id: TAG_ID.waveMotion, title: "Wave Motion", parent: TAG_ID.wavesParticles},
Expand Down
74 changes: 38 additions & 36 deletions src/app/state/actions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,52 +277,54 @@ export const updateCurrentUser = (
async function continueSettingsUpdate() {
const editingOtherUser = currentUser.loggedIn && currentUser.id != updatedUser.id;

await dispatch(requestCurrentUser() as any);
try {
dispatch({type: ACTION_TYPE.USER_DETAILS_UPDATE_REQUEST});
const currentUser = await api.users.updateCurrent(updatedUser, updatedUserPreferences, passwordCurrent, userContexts);
dispatch({type: ACTION_TYPE.USER_DETAILS_UPDATE_RESPONSE_SUCCESS, user: currentUser.data});

if (!editingOtherUser) {
// Invalidate tagged caches that are dependent on the current user's settings
dispatch(questionsApi.util.invalidateTags(['CanAttemptQuestionType']) as any);
}
await dispatch(requestCurrentUser() as any);

const isFirstLogin = isFirstLoginInPersistence() || false;
if (isFirstLogin) {
persistence.session.remove(KEY.FIRST_LOGIN);
if (redirect) {
history.push(persistence.pop(KEY.AFTER_AUTH_PATH) || '/account', {firstLogin: isFirstLogin});
if (!editingOtherUser) {
// Invalidate tagged caches that are dependent on the current user's settings
dispatch(questionsApi.util.invalidateTags(['CanAttemptQuestionType']) as any);
}
} else if (!editingOtherUser) {
dispatch(showToast({
title: "Account settings updated",
body: "Your account settings were updated successfully.",
color: "success",
timeout: 5000,
closable: false,
}) as any);
} else if (editingOtherUser) {
redirect && history.push('/');
dispatch(showToast({
title: "Account settings updated",
body: "The user's account settings were updated successfully.",
color: "success",
timeout: 5000,
closable: false,
}) as any);

const isFirstLogin = isFirstLoginInPersistence() || false;
if (isFirstLogin) {
persistence.session.remove(KEY.FIRST_LOGIN);
if (redirect) {
history.push(persistence.pop(KEY.AFTER_AUTH_PATH) || '/account', {firstLogin: isFirstLogin});
}
} else if (!editingOtherUser) {
dispatch(showToast({
title: "Account settings updated",
body: "Your account settings were updated successfully.",
color: "success",
timeout: 5000,
closable: false,
}) as any);
} else if (editingOtherUser) {
if (redirect) {
history.push('/');
}
dispatch(showToast({
title: "Account settings updated",
body: "The user's account settings were updated successfully.",
color: "success",
timeout: 5000,
closable: false,
}) as any);
}
} catch (e: any) {
dispatch({type: ACTION_TYPE.USER_DETAILS_UPDATE_RESPONSE_FAILURE, errorMessage: extractMessage(e)});
}
}

// Confirm email change
if (currentUser.loggedIn && currentUser.id == updatedUser.id && currentUser.email !== updatedUser.email) {
showEmailChangeModal();
} else {
try {
dispatch({type: ACTION_TYPE.USER_DETAILS_UPDATE_REQUEST});
const currentUser = await api.users.updateCurrent(updatedUser, updatedUserPreferences, passwordCurrent, userContexts);
dispatch({type: ACTION_TYPE.USER_DETAILS_UPDATE_RESPONSE_SUCCESS, user: currentUser.data});
continueSettingsUpdate();
}
catch (e: any) {
dispatch({type: ACTION_TYPE.USER_DETAILS_UPDATE_RESPONSE_FAILURE, errorMessage: extractMessage(e)});
}
continueSettingsUpdate();
}
};

Expand Down
7 changes: 1 addition & 6 deletions src/scss/common/my-account.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,16 @@
font-size: 14px;
margin-bottom: 5px;
}
.icon-person,
.icon-person-active {
margin-top: 2px;
}

.connections-fixed-length-text {
display: inline-block;
max-height: 24px;
width: max-content;
max-width: 264px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
&.connection-inactive {
max-width: 207px; // include space for "(inactive)" (57px)
max-width: calc(100% - 60px); // include space for "(inactive)" (
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/scss/common/print.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
display: none !important;
}

.no-shadow {
box-shadow: none !important;
}

.force-print, .only-print {
display: initial !important;
}
Expand Down Expand Up @@ -84,6 +88,7 @@
border-bottom: lightgray solid 1px;
padding: 0 !important;
margin-bottom: 1rem;
box-shadow: none;
}

.expansion-layout {
Expand Down
8 changes: 8 additions & 0 deletions src/scss/cs/my-account.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@
}
}
}

.connections-fixed-length-container {
max-width: calc(100% - 88px);

> .icon-person-active {
min-width: 1.25rem;
}
}
23 changes: 23 additions & 0 deletions src/scss/phy/my-account.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,26 @@
width: max-content;
}
}

.connect-list {
.connect-list-header {
.icon-person-active {
margin-top: 7px;
}

h4 {
padding: 0rem 1rem;
}
}
}

.teachers-connected {
.icon-person,
.icon-person-active {
margin-top: 2px;
}

.connections-fixed-length-container {
max-width: calc(100% - 91.8px);
}
}
2 changes: 1 addition & 1 deletion src/test/pages/MyAccount.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe("My Account", () => {
const teacherName = extractTeacherName(mockTeacher);
const teacherNameSpan = await within(teacherConnectionsList).findByText(teacherName as string);

const teacherSpan = teacherNameSpan.parentElement;
const teacherSpan = teacherNameSpan.closest("li");
expect(teacherSpan).toBeInTheDocument();

const teacherRevokeButton = await within(teacherSpan as HTMLElement).findByRole("button", {name: "Revoke"});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5932,10 +5932,10 @@ indent-string@^4.0.0:
resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251"
integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==

inequality-grammar@1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/inequality-grammar/-/inequality-grammar-1.3.2.tgz#119a8afb3ea802c8abfe44bf561fde38a24a816e"
integrity sha512-mlwS1kXr3z60NcSXCv1CFXf7VSHXPgZzjSzN4hQSaSHJSkFGb4cJJONT3M+PiLUgUwlsjOEUBFLxE8p9V6nlWQ==
inequality-grammar@1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/inequality-grammar/-/inequality-grammar-1.3.4.tgz#22b34c7fbb6c61e5567f3c4a290b212500ea5881"
integrity sha512-LyRxj57cC8xW+OAj15WAK7hA3BblZtNLl8fDyXP9x/mn5hmd44bCCkWRsBdDqXZZZAwdmLCjPfAPJh48/sJaMw==
dependencies:
lodash "^4.17.21"
moo "^0.5.2"
Expand Down

0 comments on commit fdcb4a1

Please sign in to comment.