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
d9d30da8
Commit
d9d30da8
authored
Oct 15, 2019
by
allison.browne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transition zoom quick action code to use new model
parent
7479b1e6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
54 deletions
+53
-54
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+1
-4
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+1
-0
app/models/issue.rb
app/models/issue.rb
+1
-0
app/services/issues/zoom_link_service.rb
app/services/issues/zoom_link_service.rb
+29
-31
db/schema.rb
db/schema.rb
+12
-12
lib/gitlab/quick_actions/issue_actions.rb
lib/gitlab/quick_actions/issue_actions.rb
+9
-7
No files found.
app/helpers/issuables_helper.rb
View file @
d9d30da8
...
...
@@ -281,10 +281,7 @@ module IssuablesHelper
}
data
[
:hasClosingMergeRequest
]
=
issuable
.
merge_requests_count
(
current_user
)
!=
0
if
issuable
.
is_a?
(
Issue
)
zoom_links
=
Gitlab
::
ZoomLinkExtractor
.
new
(
issuable
.
description
).
links
data
[
:zoomMeetingUrl
]
=
zoom_links
.
last
if
zoom_links
.
any?
data
[
:zoomMeetingUrl
]
=
issuable
&
.
zoom_meetings
.
added_to_issue
.
first
&
.
url
if
parent
.
is_a?
(
Group
)
data
[
:groupPath
]
=
parent
.
path
...
...
app/models/concerns/issuable.rb
View file @
d9d30da8
...
...
@@ -66,6 +66,7 @@ module Issuable
has_many
:label_links
,
as: :target
,
dependent: :destroy
,
inverse_of: :target
# rubocop:disable Cop/ActiveRecordDependent
has_many
:labels
,
through: :label_links
has_many
:todos
,
as: :target
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:zoom_meetings
has_one
:metrics
...
...
app/models/issue.rb
View file @
d9d30da8
...
...
@@ -40,6 +40,7 @@ class Issue < ApplicationRecord
has_many
:issue_assignees
has_many
:assignees
,
class_name:
"User"
,
through: :issue_assignees
has_many
:zoom_meetings
validates
:project
,
presence:
true
...
...
app/services/issues/zoom_link_service.rb
View file @
d9d30da8
...
...
@@ -6,30 +6,31 @@ module Issues
super
(
issue
.
project
,
user
)
@issue
=
issue
@added_meeting
=
fetch_added_meeting
end
def
add_link
(
link
)
if
can_add_link?
&&
(
link
=
parse_link
(
link
))
success
(
_
(
'Zoom meeting added'
),
append_to_description
(
link
))
success
(
_
(
'Zoom meeting added'
),
create_zoom_meeting
(
link
))
else
error
(
_
(
'Failed to add a Zoom meeting'
))
end
end
def
can_add_link?
can?
&&
!
link_in_issue_description?
end
def
remove_link
if
can_remove_link?
success
(
_
(
'Zoom meeting removed'
),
remove_
from_description
)
success
(
_
(
'Zoom meeting removed'
),
remove_
zoom_meeting
)
else
error
(
_
(
'Failed to remove a Zoom meeting'
))
end
end
def
can_add_link?
can?
&&
!
@added_meeting
end
def
can_remove_link?
can?
&&
link_in_issue_description?
can?
&&
@added_meeting
end
def
parse_link
(
link
)
...
...
@@ -40,40 +41,37 @@ module Issues
attr_reader
:issue
def
issue_description
issue
.
description
||
''
def
fetch_added_meeting
ZoomMeeting
.
where
(
issue:
@issue
).
added_to_issue
.
first
end
def
success
(
message
,
description
)
ServiceResponse
.
success
(
message:
message
,
payload:
{
description:
description
})
def
create_zoom_meeting
(
link
)
meeting
=
ZoomMeeting
.
create
(
issue:
@issue
,
project:
@issue
.
project
,
issue_status: :added
,
url:
link
)
issue
.
zoom_meetings
end
def
error
(
message
)
ServiceResponse
.
error
(
message:
message
)
def
remove_zoom_meeting
@added_meeting
.
issue_status
=
:removed
@added_meeting
.
save
issue
.
zoom_meetings
end
def
append_to_description
(
link
)
"
#{
issue_description
}
\n\n
#{
link
}
"
def
success
(
message
,
zoom_meetings
)
ServiceResponse
.
success
(
message:
message
,
payload:
{
zoom_meetings:
zoom_meetings
}
)
end
def
remove_from_description
link
=
parse_link
(
issue_description
)
return
issue_description
unless
link
issue_description
.
delete_suffix
(
link
).
rstrip
end
def
link_in_issue_description?
link
=
extract_link_from_issue_description
return
unless
link
Gitlab
::
ZoomLinkExtractor
.
new
(
link
).
match?
def
error
(
message
)
ServiceResponse
.
error
(
message:
message
)
end
def
extract_link_from_issue_description
issue_description
[
/(\S+)\z/
,
1
]
end
def
can?
current_user
.
can?
(
:update_issue
,
project
)
...
...
db/schema.rb
View file @
d9d30da8
...
...
@@ -3175,8 +3175,8 @@ ActiveRecord::Schema.define(version: 2019_10_04_133612) do
t
.
string
"tag"
t
.
text
"description"
t
.
integer
"project_id"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
text
"description_html"
t
.
integer
"cached_markdown_version"
t
.
integer
"author_id"
...
...
@@ -3739,24 +3739,24 @@ ActiveRecord::Schema.define(version: 2019_10_04_133612) do
t
.
bigint
"author_id"
,
null:
false
t
.
bigint
"updated_by_id"
t
.
bigint
"last_edited_by_id"
t
.
date
"start_date"
t
.
date
"due_date"
t
.
datetime_with_timezone
"last_edited_at"
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
t
.
string
"title"
,
limit:
255
,
null:
false
t
.
text
"title_html"
,
null:
false
t
.
text
"description"
t
.
text
"description_html"
t
.
bigint
"start_date_sourcing_milestone_id"
t
.
bigint
"due_date_sourcing_milestone_id"
t
.
bigint
"closed_by_id"
t
.
datetime_with_timezone
"last_edited_at"
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
t
.
datetime_with_timezone
"closed_at"
t
.
date
"start_date"
t
.
date
"due_date"
t
.
integer
"state"
,
limit:
2
,
default:
1
,
null:
false
t
.
integer
"severity"
,
limit:
2
,
null:
false
t
.
boolean
"severity_overridden"
,
default:
false
t
.
integer
"confidence"
,
limit:
2
,
null:
false
t
.
boolean
"severity_overridden"
,
default:
false
t
.
boolean
"confidence_overridden"
,
default:
false
t
.
string
"title"
,
limit:
255
,
null:
false
t
.
text
"title_html"
,
null:
false
t
.
text
"description"
t
.
text
"description_html"
t
.
index
[
"author_id"
],
name:
"index_vulnerabilities_on_author_id"
t
.
index
[
"closed_by_id"
],
name:
"index_vulnerabilities_on_closed_by_id"
t
.
index
[
"due_date_sourcing_milestone_id"
],
name:
"index_vulnerabilities_on_due_date_sourcing_milestone_id"
...
...
lib/gitlab/quick_actions/issue_actions.rb
View file @
d9d30da8
...
...
@@ -174,16 +174,17 @@ module Gitlab
params
'<Zoom URL>'
types
Issue
condition
do
zoom_link_service
.
can_add_link?
@zoom_service
=
zoom_link_service
@zoom_service
.
can_add_link?
end
parse_params
do
|
link
|
zoom_link
_service
.
parse_link
(
link
)
@zoom
_service
.
parse_link
(
link
)
end
command
:zoom
do
|
link
|
result
=
zoom_link
_service
.
add_link
(
link
)
result
=
@zoom
_service
.
add_link
(
link
)
if
result
.
success?
@updates
[
:
description
]
=
result
.
payload
[
:description
]
@updates
[
:
zoom_meetings
]
=
result
.
payload
[
:zoom_meetings
]
end
@execution_message
[
:zoom
]
=
result
.
message
...
...
@@ -194,13 +195,14 @@ module Gitlab
execution_message
_
(
'Zoom meeting removed'
)
types
Issue
condition
do
zoom_link_service
.
can_remove_link?
@zoom_service
=
zoom_link_service
@zoom_service
.
can_remove_link?
end
command
:remove_zoom
do
result
=
zoom_link
_service
.
remove_link
result
=
@zoom
_service
.
remove_link
if
result
.
success?
@updates
[
:
description
]
=
result
.
payload
[
:description
]
@updates
[
:
zoom_meetings
]
=
result
.
payload
[
:zoom_meetings
]
end
@execution_message
[
:remove_zoom
]
=
result
.
message
...
...
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