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 @@
- {% comment %} {% endcomment %}
The origin type must be specified
@@ -55,15 +55,13 @@
Artifact information:
- -
-
- - + + Full archive url to ingest
- + + Archive version
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