Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
00c3a3f6
Commit
00c3a3f6
authored
Jan 18, 2022
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add url_text to create metric image API response
parent
31d4b47d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
8 deletions
+16
-8
doc/api/issues.md
doc/api/issues.md
+4
-2
ee/app/services/incident_management/incidents/upload_metric_service.rb
...es/incident_management/incidents/upload_metric_service.rb
+4
-2
ee/lib/ee/api/entities/issuable_metric_image.rb
ee/lib/ee/api/entities/issuable_metric_image.rb
+1
-1
ee/lib/ee/api/issues.rb
ee/lib/ee/api/issues.rb
+2
-1
ee/spec/requests/api/issues_spec.rb
ee/spec/requests/api/issues_spec.rb
+5
-2
No files found.
doc/api/issues.md
View file @
00c3a3f6
...
...
@@ -2422,10 +2422,11 @@ POST /projects/:id/issues/:issue_iid/metric_images
|
`issue_iid`
| integer | yes | The internal ID of a project's issue |
|
`file`
| file | yes | The image file to be uploaded |
|
`url`
| string | no | The URL to view more metric information |
|
`url_text`
| string | no | A description of the image or URL |
```
shell
curl
--header
"PRIVATE-TOKEN: <your_access_token>"
--form
'file=@/path/to/file.png'
\
--form
'url=http://example.com'
"https://gitlab.example.com/api/v4/projects/5/issues/93/metric_images"
--form
'url=http://example.com'
--form
'url_text=Example website'
"https://gitlab.example.com/api/v4/projects/5/issues/93/metric_images"
```
Example response:
...
...
@@ -2436,7 +2437,8 @@ Example response:
"created_at"
:
"2020-11-13T00:06:18.084Z"
,
"filename"
:
"file.png"
,
"file_path"
:
"/uploads/-/system/issuable_metric_image/file/23/file.png"
,
"url"
:
"http://example.com"
"url"
:
"http://example.com"
,
"url_text"
:
"Example website"
}
```
...
...
ee/app/services/incident_management/incidents/upload_metric_service.rb
View file @
00c3a3f6
...
...
@@ -10,6 +10,7 @@ module IncidentManagement
@project
=
issuable
&
.
project
@file
=
params
.
fetch
(
:file
)
@url
=
params
.
fetch
(
:url
,
nil
)
@url_text
=
params
.
fetch
(
:url_text
,
nil
)
end
def
execute
...
...
@@ -22,7 +23,7 @@ module IncidentManagement
ServiceResponse
.
error
(
message:
e
.
message
)
end
attr_reader
:issuable
,
:project
,
:file
,
:url
,
:metric
attr_reader
:issuable
,
:project
,
:file
,
:url
,
:
url_text
,
:
metric
private
...
...
@@ -30,7 +31,8 @@ module IncidentManagement
@metric
=
IssuableMetricImage
.
create!
(
issue:
issuable
,
file:
file
,
url:
url
url:
url
,
url_text:
url_text
)
end
...
...
ee/lib/ee/api/entities/issuable_metric_image.rb
View file @
00c3a3f6
...
...
@@ -5,7 +5,7 @@ module EE
module
Entities
class
IssuableMetricImage
<
Grape
::
Entity
expose
:id
,
:created_at
expose
:filename
,
:file_path
,
:url
expose
:filename
,
:file_path
,
:url
,
:url_text
end
end
end
...
...
ee/lib/ee/api/issues.rb
View file @
00c3a3f6
...
...
@@ -34,6 +34,7 @@ module EE
params
do
requires
:file
,
type:
::
API
::
Validations
::
Types
::
WorkhorseFile
,
desc:
'The image file to be uploaded'
optional
:url
,
type:
String
,
desc:
'The url to view more metric info'
optional
:url_text
,
type:
String
,
desc:
'A description of the image or URL'
end
post
do
require_gitlab_workhorse!
...
...
@@ -44,7 +45,7 @@ module EE
upload
=
::
IncidentManagement
::
Incidents
::
UploadMetricService
.
new
(
issue
,
current_user
,
params
.
slice
(
:file
,
:url
)
params
.
slice
(
:file
,
:url
,
:url_text
)
).
execute
if
upload
.
success?
...
...
ee/spec/requests/api/issues_spec.rb
View file @
00c3a3f6
...
...
@@ -583,8 +583,9 @@ RSpec.describe API::Issues, :mailer do
let
(
:file
)
{
fixture_file_upload
(
'spec/fixtures/rails_sample.jpg'
,
'image/jpg'
)
}
let
(
:file_name
)
{
'rails_sample.jpg'
}
let
(
:url
)
{
'http://gitlab.com'
}
let
(
:url_text
)
{
'GitLab'
}
let
(
:params
)
{
{
url:
url
}
}
let
(
:params
)
{
{
url:
url
,
url_text:
url_text
}
}
subject
do
workhorse_finalize
(
...
...
@@ -604,6 +605,7 @@ RSpec.describe API::Issues, :mailer do
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
[
'filename'
]).
to
eq
(
file_name
)
expect
(
json_response
[
'url'
]).
to
eq
(
url
)
expect
(
json_response
[
'url_text'
]).
to
eq
(
url_text
)
expect
(
json_response
[
'file_path'
]).
to
match
(
%r{/uploads/-/system/issuable_metric_image/file/[
\d
+]/
#{
file_name
}
}
)
expect
(
json_response
[
'created_at'
]).
not_to
be_nil
expect
(
json_response
[
'id'
]).
not_to
be_nil
...
...
@@ -701,7 +703,8 @@ RSpec.describe API::Issues, :mailer do
created_at:
image
.
created_at
.
strftime
(
'%Y-%m-%dT%H:%M:%S.%LZ'
),
filename:
image
.
filename
,
file_path:
image
.
file_path
,
url:
image
.
url
url:
image
.
url
,
url_text:
nil
}.
with_indifferent_access
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment