Skip to content

Commit e812365

Browse files
authored
Merge pull request #3705 from openequella/hotfix/2020.2.1
Hotfix/2020.2.1
2 parents 753a3ab + a0696cf commit e812365

File tree

6 files changed

+55
-17
lines changed

6 files changed

+55
-17
lines changed

Source/Plugins/Core/com.equella.core/js/tsrc/legacycontent/LegacyContent.tsx

+42
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
import * as OEQ from "@openequella/rest-api-client";
1919
import Axios from "axios";
20+
import { isEqual } from "lodash";
2021
import * as React from "react";
2122
import { v4 } from "uuid";
2223
import {
@@ -114,6 +115,21 @@ export interface LegacyContentProps {
114115
children?: never;
115116
}
116117

118+
interface LegacyContentSubmission {
119+
/**
120+
* Indicate whether there is a request submitted to `LegacyContentApi` already but not completed yet.
121+
*/
122+
submitting: boolean;
123+
/**
124+
* Where to send the form data.
125+
*/
126+
action?: string;
127+
/**
128+
* Payload of the submission.
129+
*/
130+
payload?: StateData;
131+
}
132+
117133
export type SubmitResponse =
118134
| ExternalRedirect
119135
| LegacyContentResponse
@@ -149,6 +165,9 @@ export const LegacyContent = React.memo(function LegacyContent({
149165
userUpdated,
150166
}: LegacyContentProps) {
151167
const [content, setContent] = React.useState<PageContent>();
168+
const submittingForm = React.useRef<LegacyContentSubmission>({
169+
submitting: false,
170+
});
152171
const baseUrl = document.getElementsByTagName("base")[0].href;
153172

154173
function toRelativeUrl(url: string) {
@@ -186,6 +205,24 @@ export const LegacyContent = React.memo(function LegacyContent({
186205
submitValues: StateData,
187206
callback?: (response: SubmitResponse) => void
188207
) {
208+
if (formAction) {
209+
const { submitting, action, payload } = submittingForm.current;
210+
if (
211+
submitting &&
212+
formAction === action &&
213+
isEqual(submitValues, payload)
214+
) {
215+
console.error(`ignore redundant submission to ${formAction}`);
216+
return;
217+
}
218+
219+
submittingForm.current = {
220+
submitting: true,
221+
action: formAction,
222+
payload: submitValues,
223+
};
224+
}
225+
189226
submitRequest(toRelativeUrl(formAction || pathname), submitValues)
190227
.then((content) => {
191228
if (callback) {
@@ -207,6 +244,11 @@ export const LegacyContent = React.memo(function LegacyContent({
207244
? fromAxiosResponse(error.response)
208245
: generateFromError(error);
209246
onError({ error: errorResponse, fullScreen });
247+
})
248+
.finally(() => {
249+
if (formAction) {
250+
submittingForm.current = { submitting: false };
251+
}
210252
});
211253
}
212254

Source/Plugins/Core/com.equella.core/resources/web/js/datepicker.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
$.datepicker.setDefaults({
77
showOn : 'both',
8-
yearRange : "c-50:c+10",
8+
yearRange : "1970:c+10",
99
changeYear : true,
1010
changeMonth : true,
1111
constrainInput : true,
@@ -32,7 +32,7 @@ function disablePicker($jelem, disabled)
3232
}
3333

3434
/**
35-
*
35+
*
3636
* @param $jelem
3737
* @param $hiddenElem
3838
* @param timezoneOffset
@@ -56,7 +56,7 @@ function setupPicker($jelem, $hiddenElem, timezoneOffset, changeFunc, $otherCale
5656
showButtonPanel : false,
5757
buttonText : buttonText
5858
};
59-
59+
6060
$jelem.datepicker(settings);
6161
$jelem.data('$hiddenElem', $hiddenElem);
6262

@@ -175,7 +175,7 @@ function stripExtras($dp)
175175
}
176176

177177
/**
178-
*
178+
*
179179
* @param $elem
180180
* @param timezoneOffset
181181
* @returns A UTC date which is Midnight *our* time
@@ -189,13 +189,13 @@ function getPickerUiValue($elem, timezoneOffset)
189189
// Convert to midnight our time
190190
// var toff2 = new Date(dtUtc).getTimezoneOffset() * 60000;
191191
return dtUtc; /* - toff2 */
192-
;
192+
193193
}
194194
return null;
195195
}
196196

197197
/**
198-
*
198+
*
199199
* @param $elem
200200
* @param utcDate
201201
* A UTC date which is Midnight *our* time
@@ -238,4 +238,4 @@ function setPickerHiddenValue($elem, utcDate)
238238
{
239239
$elem.data('$hiddenElem').val('');
240240
}
241-
}
241+
}

autotest/OldTests/src/test/java/com/tle/webtests/test/viewing/ItemSummaryTest.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public void testViewCount() {
134134
public void testAttachmentViewCount() {
135135
final String linkAttachment = "https://archive.org/";
136136

137-
final String archiveOrgPreambleString = "div.preamble-whoweare";
137+
final By title = By.xpath("//title[contains(text(),'Internet Archive')]");
138138
logon(AUTOTEST_LOGON, AUTOTEST_PASSWD);
139139

140140
final WizardPageTab wizard = new ContributePage(context).load().openWizard(COLLECTION3);
@@ -145,9 +145,7 @@ public void testAttachmentViewCount() {
145145
checkViews(summary, 1, linkAttachment, 0);
146146

147147
// view the attachment and go back
148-
summary
149-
.attachments()
150-
.viewLinkAttachment(linkAttachment, By.cssSelector(archiveOrgPreambleString));
148+
summary.attachments().viewLinkAttachment(linkAttachment, title);
151149
final WebDriver.Navigation navigate = context.getDriver().navigate();
152150
navigate.back();
153151
// navigate.refresh();
@@ -157,9 +155,7 @@ public void testAttachmentViewCount() {
157155
checkViews(summary, 2, linkAttachment, 1);
158156

159157
// view the attachment again and go back
160-
summary
161-
.attachments()
162-
.viewLinkAttachment(linkAttachment, By.cssSelector(archiveOrgPreambleString));
158+
summary.attachments().viewLinkAttachment(linkAttachment, title);
163159
navigate.back();
164160
// navigate.refresh();
165161

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ name := "Equella"
116116

117117
equellaMajor in ThisBuild := 2020
118118
equellaMinor in ThisBuild := 2
119-
equellaPatch in ThisBuild := 0
119+
equellaPatch in ThisBuild := 1
120120
equellaStream in ThisBuild := "Stable"
121121
equellaBuild in ThisBuild := buildConfig.value.getString("build.buildname")
122122

buildspec.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ phases:
1111
commands:
1212
- env | sort | grep -vi -e key -e secret -e password
1313
- setupBuild
14-
- . $NVM_DIR/nvm.sh && nvm install # version from nvmrc
14+
- . $NVM_DIR/nvm.sh && set +a && nvm install # version from nvmrc
1515
- npm config set unsafe-perm true
1616
install:
1717
commands:

project/plugins.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.4.0")
44

55
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
66

7-
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
7+
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2")
88

99
addSbtPlugin("de.johoop" % "sbt-testng-plugin" % "3.1.1")
1010

0 commit comments

Comments
 (0)