Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7147913
D5738.id20501.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Subscribers
None
D5738.id20501.diff
View Options
diff --git a/assets/src/bundles/save/index.js b/assets/src/bundles/save/index.js
--- a/assets/src/bundles/save/index.js
+++ b/assets/src/bundles/save/index.js
@@ -45,12 +45,31 @@
});
}
-export function maybeDisplayExtraInputs() {
+export function maybeRequireExtraInputs() {
// Read the actual selected value and depending on the origin type, display some extra
- // inputs or hide them.
+ // inputs or hide them. This also makes the extra inputs required when displayed.
const originType = $('#swh-input-visit-type').val();
- const display = originType === 'archives' ? 'flex' : 'none';
- $('#optional-origin-forms').css('display', display);
+ let cssDisplay;
+ let requiredBool;
+
+ if (originType === 'archives') {
+ requiredBool = true;
+ cssDisplay = 'flex';
+ } else {
+ cssDisplay = 'none';
+ requiredBool = false;
+ }
+
+ console.log(`css display ${cssDisplay}`);
+ console.log(`required bool ${requiredBool}`);
+
+ $('#optional-origin-forms').css('display', cssDisplay);
+ document.getElementById('swh-input-artifact-url').required = requiredBool;
+ document.getElementById('swh-input-artifact-version').required = requiredBool;
+
+ // following did not work
+ // $('#swh-input-artifact-url').prop('required', requiredBool);
+ // $('#swh-input-artifact-url').attr('required', requiredBool);
}
const userRequestsFilterCheckbox = `
@@ -245,7 +264,6 @@
// read the extra inputs for the 'archives' type
let extraData = originType !== 'archives' ? {} : {
'artifact_url': $('#swh-input-artifact-url').val(),
- 'artifact_filename': $('#swh-input-artifact-filename').val(),
'artifact_version': $('#swh-input-artifact-version').val()
};
diff --git a/cypress/integration/origin-save.spec.js b/cypress/integration/origin-save.spec.js
--- a/cypress/integration/origin-save.spec.js
+++ b/cypress/integration/origin-save.spec.js
@@ -519,7 +519,6 @@
it('should be allowed to submit \'archives\' save request when connected as ambassador', function() {
let originUrl = 'https://ftp.gnu.org/pub/pub/gnu/3dldf';
let artifactUrl = 'https://ftp.gnu.org/pub/pub/gnu/3dldf/3DLDF-1.1.4.tar.gz';
- let artifactFilename = '3DLDF-1.1.4.tar.gz';
let artifactVersion = '1.1.4';
stubSaveRequest({
requestUrl: this.Urls.api_1_save_origin('archives', originUrl),
@@ -538,8 +537,6 @@
.select('archives')
.get('#swh-input-artifact-url')
.type(artifactUrl)
- .get('#swh-input-artifact-filename')
- .type(artifactFilename)
.get('#swh-input-artifact-version')
.type(artifactVersion)
.get('#swh-save-origin-form')
diff --git a/swh/web/common/origin_save.py b/swh/web/common/origin_save.py
--- a/swh/web/common/origin_save.py
+++ b/swh/web/common/origin_save.py
@@ -450,7 +450,6 @@
artifacts=[
{
"url": artifact_url,
- "filename": kwargs["artifact_filename"],
"version": kwargs["artifact_version"],
"time": metadata["last_modified"],
"length": metadata["content_length"],
diff --git a/swh/web/templates/misc/origin-save.html b/swh/web/templates/misc/origin-save.html
--- a/swh/web/templates/misc/origin-save.html
+++ b/swh/web/templates/misc/origin-save.html
@@ -33,7 +33,7 @@
<div class="col-md-1"></div>
<div class="form-group col-md-2">
<label for="swh-input-visit-type">Origin type</label>
- <select id="swh-input-visit-type" class="form-control" required onchange="swh.save.maybeDisplayExtraInputs();">
+ <select id="swh-input-visit-type" class="form-control" required onchange="swh.save.maybeRequireExtraInputs();">
{% comment %} <option selected value="">Choose...</option> {% endcomment %}
</select>
<div class="invalid-feedback">The origin type must be specified</div>
@@ -55,15 +55,13 @@
<div class="col-md-1">Artifact information:</div>
<div class="form-group col-md-6">
<label for="swh-input-artifact-url">Url</label>
- <input type="text" class="form-control" id="swh-input-artifact-url">
- </div>
- <div class="form-group col-md-3">
- <label for="swh-input-artifact-filename">Filename</label>
- <input type="text" class="form-control" id="swh-input-artifact-filename">
+ <input type="text" class="form-control" id="swh-input-artifact-url" aria-describedby="artifactUrlHelp">
+ <small id="artifactUrlHelp" class="form-text text-muted">Full archive url to ingest</small>
</div>
<div class="form-group col-md-1">
<label for="swh-input-artifact-version">Version</label>
- <input type="text" class="form-control" id="swh-input-artifact-version">
+ <input type="text" class="form-control" id="swh-input-artifact-version" aria-describedby="artifactVersionHelp">
+ <small id="artifactVersionHelp" class="form-text text-muted">Archive version</small>
</div>
</div>
</form>
diff --git a/swh/web/tests/api/views/test_origin_save.py b/swh/web/tests/api/views/test_origin_save.py
--- a/swh/web/tests/api/views/test_origin_save.py
+++ b/swh/web/tests/api/views/test_origin_save.py
@@ -497,7 +497,6 @@
"artifacts": [
{
"url": artifact_url,
- "filename": artifact_filename,
"version": artifact_version,
"time": last_modified,
"length": content_length,
@@ -518,11 +517,7 @@
api_client,
url,
status_code=200,
- data={
- "artifact_url": artifact_url,
- "artifact_filename": artifact_filename,
- "artifact_version": artifact_version,
- },
+ data={"artifact_url": artifact_url, "artifact_version": artifact_version,},
)
assert response.data["save_request_status"] == SAVE_REQUEST_ACCEPTED
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 23, 2:59 AM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3234897
Attached To
D5738: save-code-now: Make extra inputs required
Event Timeline
Log In to Comment