diff --git a/cypress/integration/persistent-identifiers.spec.js b/cypress/integration/persistent-identifiers.spec.js --- a/cypress/integration/persistent-identifiers.spec.js +++ b/cypress/integration/persistent-identifiers.spec.js @@ -21,7 +21,7 @@ before(function() { origin = this.origin[1]; url = `${this.Urls.browse_origin_content()}?origin_url=${origin.url}&path=${origin.content[0].path}`; - url = `${url}&release=${origin.release}#L${firstSelLine}-L${lastSelLine}`; + url = `${url}&release=${origin.release.name}#L${firstSelLine}-L${lastSelLine}`; originBadgeUrl = this.Urls.swh_badge('origin', origin.url); originBrowseUrl = `${this.Urls.browse_origin()}?origin_url=${origin.url}`; cy.visit(url).window().then(win => { diff --git a/cypress/integration/vault.spec.js b/cypress/integration/vault.spec.js --- a/cypress/integration/vault.spec.js +++ b/cypress/integration/vault.spec.js @@ -79,6 +79,10 @@ this.vaultRevisionUrl = this.Urls.api_1_vault_cook_revision_gitfast(this.revision); this.vaultFetchRevisionUrl = this.Urls.api_1_vault_fetch_revision_gitfast(this.revision); + const release = this.origin[1].release; + this.releaseUrl = this.Urls.browse_release(release.id) + `?origin_url=${this.origin[1].url}`; + this.vaultReleaseDirectoryUrl = this.Urls.api_1_vault_cook_directory(release.directory); + vaultItems[0] = { 'object_type': 'revision', 'object_id': this.revision, @@ -364,6 +368,47 @@ }); }); + it('should create a directory cooking task from the release view', function() { + + // Browse a directory + cy.visit(this.releaseUrl); + + // Stub responses when requesting the vault API to simulate + // a task has been created + cy.route({ + method: 'GET', + url: this.vaultReleaseDirectoryUrl, + response: {'exception': 'NotFoundExc'} + }).as('checkVaultCookingTask'); + + cy.route({ + method: 'POST', + url: this.vaultReleaseDirectoryUrl, + response: this.genVaultDirCookingResponse('new') + }).as('createVaultCookingTask'); + + cy.contains('button', 'Download') + .click(); + + cy.route({ + method: 'GET', + url: this.vaultReleaseDirectoryUrl, + response: this.genVaultDirCookingResponse('new') + }).as('checkVaultCookingTask'); + + // Create a vault cooking task through the GUI + cy.get('.modal-dialog') + .contains('button:visible', 'Ok') + .click(); + + cy.wait('@createVaultCookingTask'); + + // Check success alert is displayed + cy.get('.alert-success') + .should('be.visible') + .should('contain', 'Archive cooking request successfully submitted.'); + }); + it('should offer to recook an archive if no more available to download', function() { updateVaultItemList(this.Urls.browse_vault(), vaultItems); diff --git a/cypress/support/index.js b/cypress/support/index.js --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -80,7 +80,11 @@ }], directory: [], revisions: ['1c480a4573d2a003fc2630c21c2b25829de49972'], - release: 'v2.6.0' + release: { + name: 'v2.6.0', + id: '6877028d6e5412780517d0bfa81f07f6c51abb41', + directory: '5b61d50ef35ca9a4618a3572bde947b8cccf71ad' + } }]; const getMetadataForOrigin = async originUrl => { diff --git a/swh/web/browse/utils.py b/swh/web/browse/utils.py --- a/swh/web/browse/utils.py +++ b/swh/web/browse/utils.py @@ -319,7 +319,9 @@ """ query_params = _snapshot_context_query_params(snapshot_context) + # remove query parameters not needed for a revision view query_params.pop("revision", None) + query_params.pop("release", None) return reverse( "browse-revision", url_args={"sha1_git": revision_id}, query_params=query_params diff --git a/swh/web/browse/views/release.py b/swh/web/browse/views/release.py --- a/swh/web/browse/views/release.py +++ b/swh/web/browse/views/release.py @@ -51,7 +51,11 @@ if origin_url: try: snapshot_context = get_snapshot_context( - snapshot_id, origin_url, timestamp, visit_id + snapshot_id, + origin_url, + timestamp, + visit_id, + release_name=release["name"], ) except NotFoundExc as e: raw_rel_url = reverse("browse-release", url_args={"sha1_git": sha1_git}) @@ -70,7 +74,9 @@ raise e origin_info = snapshot_context["origin_info"] elif snapshot_id: - snapshot_context = get_snapshot_context(snapshot_id) + snapshot_context = get_snapshot_context( + snapshot_id, release_name=release["name"] + ) snapshot_id = snapshot_context.get("snapshot_id", None) @@ -95,6 +101,8 @@ if release["message"]: release_note_lines = release["message"].split("\n") + swh_objects = [SWHObjectInfo(object_type=RELEASE, object_id=sha1_git)] + vault_cooking = None rev_directory = None @@ -115,6 +123,12 @@ "revision_context": True, "revision_id": release["target"], } + swh_objects.append( + SWHObjectInfo(object_type=REVISION, object_id=release["target"]) + ) + swh_objects.append( + SWHObjectInfo(object_type=DIRECTORY, object_id=rev_directory) + ) except Exception as exc: sentry_sdk.capture_exception(exc) elif release["target_type"] == DIRECTORY: @@ -133,6 +147,9 @@ "revision_context": False, "revision_id": None, } + swh_objects.append( + SWHObjectInfo(object_type=DIRECTORY, object_id=release["target"]) + ) except Exception as exc: sentry_sdk.capture_exception(exc) elif release["target_type"] == CONTENT: @@ -142,6 +159,9 @@ link_text=None, link_attrs=None, ) + swh_objects.append( + SWHObjectInfo(object_type=CONTENT, object_id=release["target"]) + ) elif release["target_type"] == RELEASE: target_link = gen_release_link( release["target"], @@ -178,8 +198,6 @@ release["directory_link"] = directory_link release["target_link"] = target_link - swh_objects = [SWHObjectInfo(object_type=RELEASE, object_id=sha1_git)] - if snapshot_context: snapshot_id = snapshot_context["snapshot_id"]