Skip to content

Commit c3e706b

Browse files
committed
Merge branch 'beta' into stable
2 parents 3842088 + a6aef08 commit c3e706b

File tree

22 files changed

+607
-417
lines changed

22 files changed

+607
-417
lines changed

package.json

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
"@babel/runtime": "^7.17.7",
3232
"@cospired/i18n-iso-languages": "^4.0.0",
3333
"@elastic/elasticsearch": "^5.6.22",
34-
"@fortawesome/fontawesome-svg-core": "^1.2.30",
35-
"@fortawesome/free-brands-svg-icons": "^6.1.1",
34+
"@fortawesome/fontawesome-svg-core": "^6.4.2",
35+
"@fortawesome/free-brands-svg-icons": "^6.4.2",
3636
"@fortawesome/free-solid-svg-icons": "^6.4.2",
3737
"@fortawesome/react-fontawesome": "^0.1.11",
3838
"array-move": "^3.0.1",
39-
"bookbrainz-data": "4.1.1",
39+
"bookbrainz-data": "^5.0.0",
4040
"chart.js": "^2.9.4",
4141
"chartjs-adapter-date-fns": "^1.0.0",
4242
"classnames": "^2.3.2",
@@ -47,7 +47,7 @@
4747
"date-fns": "^2.15.0",
4848
"debug": "^4.3.2",
4949
"express": "^4.18.2",
50-
"express-session": "^1.17.1",
50+
"express-session": "^1.17.3",
5151
"express-slow-down": "^1.3.1",
5252
"http-status": "^1.6.2",
5353
"immutable": "^3.8.2",
@@ -70,7 +70,7 @@
7070
"react-datepicker": "^4.7.0",
7171
"react-dom": "^16.13.1",
7272
"react-hot-loader": "^4.13.0",
73-
"react-redux": "^7.2.6",
73+
"react-redux": "^8.1.3",
7474
"react-select": "^4.3.1",
7575
"react-select-fast-filter-options": "^0.2.3",
7676
"react-simple-star-rating": "^4.0.5",
@@ -94,16 +94,16 @@
9494
"@babel/core": "^7.20.12",
9595
"@babel/node": "^7.14.2",
9696
"@babel/plugin-proposal-class-properties": "^7.10.1",
97-
"@babel/plugin-proposal-object-rest-spread": "^7.17.3",
97+
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
9898
"@babel/plugin-transform-classes": "^7.16.7",
9999
"@babel/plugin-transform-runtime": "^7.17.0",
100100
"@babel/preset-env": "^7.10.1",
101-
"@babel/preset-react": "^7.18.6",
101+
"@babel/preset-react": "^7.22.15",
102102
"@babel/preset-typescript": "^7.12.1",
103-
"@babel/register": "^7.17.0",
104-
"@faker-js/faker": "^7.2.0",
103+
"@babel/register": "^7.23.7",
104+
"@faker-js/faker": "^8.1.0",
105105
"@types/express": "^4.17.15",
106-
"@types/lodash": "^4.14.191",
106+
"@types/lodash": "^4.14.202",
107107
"@types/react-select": "^4.0.18",
108108
"@typescript-eslint/eslint-plugin": "^4.28.3",
109109
"@typescript-eslint/parser": "^4.6.1",
@@ -118,7 +118,7 @@
118118
"chai-sorted": "^0.2.0",
119119
"clean-webpack-plugin": "^4.0.0",
120120
"compression-webpack-plugin": "^9.2.0",
121-
"css-loader": "^6.7.1",
121+
"css-loader": "^6.9.1",
122122
"enzyme": "^3.11.0",
123123
"enzyme-adapter-react-16": "^1.15.6",
124124
"eslint": "^7.30.0",
@@ -127,7 +127,6 @@
127127
"eslint-plugin-node": "^11.1.0",
128128
"eslint-plugin-react": "^7.26.1",
129129
"eslint-webpack-plugin": "^2.4.1",
130-
"faker": "^4.1.0",
131130
"file-loader": "^6.2.0",
132131
"jsdom": "22.1.0",
133132
"jsdom-global": "3.0.2",
@@ -141,7 +140,6 @@
141140
"sass-loader": "^13.2.0",
142141
"sinon": "^14.0.0",
143142
"typescript": "^4.0.5",
144-
"uuid": "^8.3.2",
145143
"webpack": "^5.76.0",
146144
"webpack-bundle-analyzer": "^4.3.0",
147145
"webpack-cli": "^4.10.0",

src/client/components/input/drag-and-drop.js

Lines changed: 0 additions & 107 deletions
This file was deleted.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
* Copyright (C) 2016 Max Prettyjohns
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along
15+
* with this program; if not, write to the Free Software Foundation, Inc.,
16+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17+
*/
18+
19+
import * as bootstrap from 'react-bootstrap';
20+
import PropTypes from 'prop-types';
21+
import React from 'react';
22+
23+
24+
const {Card, Form} = bootstrap;
25+
const {useState, useCallback} = React;
26+
27+
/**
28+
* The Achievement interface, defining the properties of an achievement.
29+
* @typedef
30+
* @property {string} name - The name of the achievement.
31+
* @property {string} badgeUrl - The source URL of the achievement's badge image.
32+
* @property {number} id - The ID of the achievement.
33+
*/
34+
type Achievement = {
35+
name: string;
36+
badgeUrl: string | null;
37+
id: number;
38+
};
39+
40+
/**
41+
* Props for DragAndDropImage component
42+
* @typedef {Object} Props
43+
* @property {string} name - The name of the DragAndDrop component.
44+
* @property {Achievement} initialAchievement - The initial achievement to display in the card.
45+
*/
46+
type Props = {
47+
name: string;
48+
initialAchievement?: Achievement;
49+
};
50+
51+
/**
52+
* A component for a drag-and-drop card that displays an achievement.
53+
* The card displays an image of the achievement and allows the user to drag and drop a different achievement onto it.
54+
* When a new achievement is dropped onto the card, it is displayed instead of the original achievement.
55+
* @param {Props} props - The props object containing the following:
56+
* @returns {JSX.Element} A React component that displays a drag-and-drop card for an achievement.
57+
*/
58+
function DragAndDrop({name, initialAchievement}: Props): JSX.Element {
59+
const [achievement, setAchievement] = useState<Achievement>(initialAchievement);
60+
const handleClick = useCallback((event: React.MouseEvent<HTMLDivElement>) => {
61+
event.preventDefault();
62+
setAchievement({
63+
badgeUrl: '/images/blankbadge.svg',
64+
id: null,
65+
name: 'drag badge to set'
66+
});
67+
});
68+
const handleDragOver = useCallback((event: React.DragEvent<HTMLDivElement>) => {
69+
event.preventDefault();
70+
});
71+
const handleDrop = useCallback((event: React.DragEvent<HTMLDivElement>) => {
72+
event.preventDefault();
73+
let data;
74+
75+
try {
76+
data = JSON.parse(event.dataTransfer.getData('text'));
77+
}
78+
catch (error) {
79+
return;
80+
}
81+
setAchievement({
82+
badgeUrl: data.src,
83+
id: data.id,
84+
name: data.name
85+
});
86+
});
87+
return (
88+
<Card
89+
bg="light"
90+
onClick={handleClick}
91+
onDragOver={handleDragOver}
92+
onDrop={handleDrop}
93+
>
94+
<Card.Img
95+
className="mt-4"
96+
height={100}
97+
src={achievement.badgeUrl}
98+
variant="top"
99+
/>
100+
<Card.Body className="text-center">
101+
<Form.Group>
102+
<Form.Control
103+
name={name}
104+
type="hidden"
105+
value={achievement.id ? achievement.id.toString() : ''}
106+
/>
107+
</Form.Group>
108+
<div className="h3">
109+
{achievement.name}
110+
</div>
111+
</Card.Body>
112+
</Card>
113+
);
114+
}
115+
116+
DragAndDrop.displayName = 'DragAndDrop';
117+
DragAndDrop.propTypes = {
118+
initialAchievement: PropTypes.shape({
119+
badgeUrl: PropTypes.string,
120+
id: PropTypes.number,
121+
name: PropTypes.string.isRequired
122+
}),
123+
name: PropTypes.string.isRequired
124+
};
125+
DragAndDrop.defaultProps = {
126+
initialAchievement: {
127+
badgeUrl: '/images/blankbadge.svg',
128+
id: null,
129+
name: 'drag badge to set'
130+
}
131+
};
132+
133+
export default DragAndDrop;

src/client/components/pages/entities/cbReviewModal.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,11 @@ class CBReviewModal extends React.Component<
501501

502502
private accessToken = '';
503503

504+
/* executes getAccessToken() only in a browser to avoid unnecessary server-side calls during component mounting */
504505
componentDidMount = async () => {
505-
this.accessToken = await this.getAccessToken();
506+
if (typeof window !== "undefined") {
507+
this.accessToken = await this.getAccessToken();
508+
}
506509
};
507510

508511
render() {

src/client/components/pages/entities/wikipedia-extract.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import {Col, Row} from 'react-bootstrap';
2020
import React, {useEffect, useState} from 'react';
2121
import {WikipediaArticleExtract, buildWikipediaUrl, getWikidataId} from '../../../../common/helpers/wikimedia';
2222
import DOMPurify from 'isomorphic-dompurify';
23-
import type {EntityT} from 'bookbrainz-data/lib/types/entity';
23+
import type {LazyLoadedEntityT} from 'bookbrainz-data/lib/types/entity';
2424
import {getAliasLanguageCodes} from '../../../../common/helpers/utils';
2525
import {uniq} from 'lodash';
2626

2727

2828
type Props = {
29-
entity: EntityT,
29+
entity: LazyLoadedEntityT,
3030
articleExtract?: WikipediaArticleExtract,
3131
};
3232

src/client/components/pages/help.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function HelpPage() {
128128
Example:
129129
<ul>
130130
<li>The Alchemist (philosophical novel) by Paulo Coelho</li>
131-
<li>The Alchemyst (Nicolas Flamel biography) by Michael Scott</li>
131+
<li>The Alchemyst (YA novel featuring Nicolas Flamel) by Michael Scott</li>
132132
</ul>
133133
</ListGroup.Item>
134134

0 commit comments

Comments
 (0)