Commit 948bd107 authored by David O'Regan's avatar David O'Regan

Merge branch 'afontaine/persist-permanent-asset-links' into 'master'

Persist Direct Asset Path on Release Updates

See merge request gitlab-org/gitlab!64719
parents 0b27fd04 6c29da3e
...@@ -9,6 +9,7 @@ fragment ReleaseForEditing on Release { ...@@ -9,6 +9,7 @@ fragment ReleaseForEditing on Release {
name name
url url
linkType linkType
directAssetPath
} }
} }
} }
......
...@@ -165,6 +165,7 @@ const createReleaseLink = async ({ state, link }) => { ...@@ -165,6 +165,7 @@ const createReleaseLink = async ({ state, link }) => {
name: link.name, name: link.name,
url: link.url, url: link.url,
linkType: link.linkType.toUpperCase(), linkType: link.linkType.toUpperCase(),
directAssetPath: link.directAssetPath,
}, },
}, },
}); });
......
...@@ -20,6 +20,8 @@ module Types ...@@ -20,6 +20,8 @@ module Types
field :direct_asset_url, GraphQL::STRING_TYPE, null: true, field :direct_asset_url, GraphQL::STRING_TYPE, null: true,
description: 'Direct asset URL of the link.' description: 'Direct asset URL of the link.'
field :direct_asset_path, GraphQL::STRING_TYPE, null: true, method: :filepath,
description: 'Relative path for the direct asset link.'
def direct_asset_url def direct_asset_url
return object.url unless object.filepath return object.url unless object.filepath
......
...@@ -12259,6 +12259,7 @@ Represents an asset link associated with a release. ...@@ -12259,6 +12259,7 @@ Represents an asset link associated with a release.
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| <a id="releaseassetlinkdirectassetpath"></a>`directAssetPath` | [`String`](#string) | Relative path for the direct asset link. |
| <a id="releaseassetlinkdirectasseturl"></a>`directAssetUrl` | [`String`](#string) | Direct asset URL of the link. | | <a id="releaseassetlinkdirectasseturl"></a>`directAssetUrl` | [`String`](#string) | Direct asset URL of the link. |
| <a id="releaseassetlinkexternal"></a>`external` | [`Boolean`](#boolean) | Indicates the link points to an external resource. | | <a id="releaseassetlinkexternal"></a>`external` | [`Boolean`](#boolean) | Indicates the link points to an external resource. |
| <a id="releaseassetlinkid"></a>`id` | [`ID!`](#id) | ID of the link. | | <a id="releaseassetlinkid"></a>`id` | [`ID!`](#id) | ID of the link. |
......
...@@ -4,9 +4,11 @@ require 'spec_helper' ...@@ -4,9 +4,11 @@ require 'spec_helper'
RSpec.describe 'User edits Release', :js do RSpec.describe 'User edits Release', :js do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:release) { create(:release, :with_milestones, milestones_count: 1, project: project, name: 'The first release' ) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:release) { create(:release, :with_milestones, milestones_count: 1, project: project, name: 'The first release' ) }
let(:release_link) { create(:release_link, release: release) }
before do before do
project.add_developer(user) project.add_developer(user)
...@@ -68,6 +70,14 @@ RSpec.describe 'User edits Release', :js do ...@@ -68,6 +70,14 @@ RSpec.describe 'User edits Release', :js do
expect(release.description).to eq('Updated Release notes') expect(release.description).to eq('Updated Release notes')
end end
it 'does not affect the asset link' do
fill_out_form_and_click 'Save changes'
expected_filepath = release_link.filepath
release_link.reload
expect(release_link.filepath).to eq(expected_filepath)
end
it 'redirects to the previous page when "Cancel" is clicked when the url includes a back_url query parameter' do it 'redirects to the previous page when "Cancel" is clicked when the url includes a back_url query parameter' do
back_path = project_releases_path(project, params: { page: 2 }) back_path = project_releases_path(project, params: { page: 2 })
visit edit_project_release_path(project, release, params: { back_url: back_path }) visit edit_project_release_path(project, release, params: { back_url: back_path })
......
...@@ -212,24 +212,28 @@ Object { ...@@ -212,24 +212,28 @@ Object {
"count": undefined, "count": undefined,
"links": Array [ "links": Array [
Object { Object {
"directAssetPath": "/binaries/awesome-app-3",
"id": "gid://gitlab/Releases::Link/13", "id": "gid://gitlab/Releases::Link/13",
"linkType": "image", "linkType": "image",
"name": "Image", "name": "Image",
"url": "https://example.com/image", "url": "https://example.com/image",
}, },
Object { Object {
"directAssetPath": "/binaries/awesome-app-2",
"id": "gid://gitlab/Releases::Link/12", "id": "gid://gitlab/Releases::Link/12",
"linkType": "package", "linkType": "package",
"name": "Package", "name": "Package",
"url": "https://example.com/package", "url": "https://example.com/package",
}, },
Object { Object {
"directAssetPath": "/binaries/awesome-app-1",
"id": "gid://gitlab/Releases::Link/11", "id": "gid://gitlab/Releases::Link/11",
"linkType": "runbook", "linkType": "runbook",
"name": "Runbook", "name": "Runbook",
"url": "http://localhost/releases-namespace/releases-project/runbook", "url": "http://localhost/releases-namespace/releases-project/runbook",
}, },
Object { Object {
"directAssetPath": "/binaries/linux-amd64",
"id": "gid://gitlab/Releases::Link/10", "id": "gid://gitlab/Releases::Link/10",
"linkType": "other", "linkType": "other",
"name": "linux-amd64 binaries", "name": "linux-amd64 binaries",
......
...@@ -7,7 +7,7 @@ RSpec.describe GitlabSchema.types['ReleaseAssetLink'] do ...@@ -7,7 +7,7 @@ RSpec.describe GitlabSchema.types['ReleaseAssetLink'] do
it 'has the expected fields' do it 'has the expected fields' do
expected_fields = %w[ expected_fields = %w[
id name url external link_type direct_asset_url id name url external link_type direct_asset_url direct_asset_path
] ]
expect(described_class).to include_graphql_fields(*expected_fields) expect(described_class).to include_graphql_fields(*expected_fields)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment