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
a9e54bee
Commit
a9e54bee
authored
Feb 27, 2020
by
Patrick Derichs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract SyntheticNote base class
Update existing synthetic note classes as well.
parent
7ee61f74
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
87 deletions
+57
-87
app/models/label_note.rb
app/models/label_note.rb
+2
-27
app/models/milestone_note.rb
app/models/milestone_note.rb
+3
-31
app/models/synthetic_note.rb
app/models/synthetic_note.rb
+50
-0
ee/app/models/weight_note.rb
ee/app/models/weight_note.rb
+2
-29
No files found.
app/models/label_note.rb
View file @
a9e54bee
# frozen_string_literal: true
# frozen_string_literal: true
class
LabelNote
<
Note
class
LabelNote
<
Synthetic
Note
attr_accessor
:resource_parent
attr_accessor
:resource_parent
attr_reader
:events
attr_reader
:events
def
self
.
from_events
(
events
,
resource:
nil
,
resource_parent:
nil
)
def
self
.
from_events
(
events
,
resource:
nil
,
resource_parent:
nil
)
resource
||=
events
.
first
.
issuable
resource
||=
events
.
first
.
issuable
attrs
=
{
attrs
=
note_attributes
(
'label'
,
events
.
first
,
resource
,
resource_parent
).
merge
(
events:
events
)
system:
true
,
author:
events
.
first
.
user
,
created_at:
events
.
first
.
created_at
,
discussion_id:
events
.
first
.
discussion_id
,
noteable:
resource
,
system_note_metadata:
SystemNoteMetadata
.
new
(
action:
'label'
),
events:
events
,
resource_parent:
resource_parent
}
if
resource_parent
.
is_a?
(
Project
)
attrs
[
:project_id
]
=
resource_parent
.
id
end
LabelNote
.
new
(
attrs
)
LabelNote
.
new
(
attrs
)
end
end
...
@@ -35,22 +22,10 @@ class LabelNote < Note
...
@@ -35,22 +22,10 @@ class LabelNote < Note
true
true
end
end
def
note
@note
||=
note_text
end
def
note_html
def
note_html
@note_html
||=
"<p dir=
\"
auto
\"
>
#{
note_text
(
html:
true
)
}
</p>"
@note_html
||=
"<p dir=
\"
auto
\"
>
#{
note_text
(
html:
true
)
}
</p>"
end
end
def
project
resource_parent
if
resource_parent
.
is_a?
(
Project
)
end
def
group
resource_parent
if
resource_parent
.
is_a?
(
Group
)
end
private
private
def
update_outdated_markdown
def
update_outdated_markdown
...
...
app/models/milestone_note.rb
View file @
a9e54bee
# frozen_string_literal: true
# frozen_string_literal: true
class
MilestoneNote
<
::
Note
class
MilestoneNote
<
Synthetic
Note
attr_accessor
:
resource_parent
,
:event
,
:
milestone
attr_accessor
:milestone
def
self
.
from_event
(
event
,
resource:
nil
,
resource_parent:
nil
)
def
self
.
from_event
(
event
,
resource:
nil
,
resource_parent:
nil
)
resource
||=
event
.
resource
attrs
=
note_attributes
(
'milestone'
,
event
,
resource
,
resource_parent
).
merge
(
milestone:
event
.
milestone
)
attrs
=
{
system:
true
,
author:
event
.
user
,
created_at:
event
.
created_at
,
noteable:
resource
,
milestone:
event
.
milestone
,
discussion_id:
event
.
discussion_id
,
event:
event
,
system_note_metadata:
::
SystemNoteMetadata
.
new
(
action:
'milestone'
),
resource_parent:
resource_parent
}
if
resource_parent
.
is_a?
(
Project
)
attrs
[
:project_id
]
=
resource_parent
.
id
end
MilestoneNote
.
new
(
attrs
)
MilestoneNote
.
new
(
attrs
)
end
end
def
note
@note
||=
note_text
end
def
note_html
def
note_html
@note_html
||=
Banzai
::
Renderer
.
cacheless_render_field
(
self
,
:note
,
{
group:
group
,
project:
project
})
@note_html
||=
Banzai
::
Renderer
.
cacheless_render_field
(
self
,
:note
,
{
group:
group
,
project:
project
})
end
end
def
project
resource_parent
if
resource_parent
.
is_a?
(
Project
)
end
def
group
resource_parent
if
resource_parent
.
is_a?
(
Group
)
end
private
private
def
note_text
(
html:
false
)
def
note_text
(
html:
false
)
...
...
app/models/synthetic_note.rb
0 → 100644
View file @
a9e54bee
# frozen_string_literal: true
class
SyntheticNote
<
Note
attr_accessor
:resource_parent
,
:event
self
.
abstract_class
=
true
def
self
.
note_attributes
(
action
,
event
,
resource
,
resource_parent
)
resource
||=
event
.
resource
attrs
=
{
system:
true
,
author:
event
.
user
,
created_at:
event
.
created_at
,
discussion_id:
event
.
discussion_id
,
noteable:
resource
,
event:
event
,
system_note_metadata:
::
SystemNoteMetadata
.
new
(
action:
action
),
resource_parent:
resource_parent
}
if
resource_parent
.
is_a?
(
Project
)
attrs
[
:project_id
]
=
resource_parent
.
id
end
attrs
end
def
project
resource_parent
if
resource_parent
.
is_a?
(
Project
)
end
def
group
resource_parent
if
resource_parent
.
is_a?
(
Group
)
end
def
note
@note
||=
note_text
end
def
note_html
raise
NotImplementedError
end
private
def
note_text
(
html:
false
)
raise
NotImplementedError
end
end
ee/app/models/weight_note.rb
View file @
a9e54bee
# frozen_string_literal: true
# frozen_string_literal: true
class
WeightNote
<
::
Note
class
WeightNote
<
::
Synthetic
Note
attr_accessor
:resource_parent
,
:event
attr_accessor
:resource_parent
,
:event
def
self
.
from_event
(
event
,
resource:
nil
,
resource_parent:
nil
)
def
self
.
from_event
(
event
,
resource:
nil
,
resource_parent:
nil
)
resource
||=
event
.
issue
attrs
=
note_attributes
(
'weight'
,
event
,
resource
,
resource_parent
)
attrs
=
{
system:
true
,
author:
event
.
user
,
created_at:
event
.
created_at
,
noteable:
resource
,
event:
event
,
discussion_id:
event
.
discussion_id
,
system_note_metadata:
::
SystemNoteMetadata
.
new
(
action:
'weight'
),
resource_parent:
resource_parent
}
if
resource_parent
.
is_a?
(
Project
)
attrs
[
:project_id
]
=
resource_parent
.
id
end
WeightNote
.
new
(
attrs
)
WeightNote
.
new
(
attrs
)
end
end
def
note
@note
||=
note_text
end
def
note_html
def
note_html
@note_html
||=
"<p dir=
\"
auto
\"
>
#{
note_text
(
html:
true
)
}
</p>"
@note_html
||=
"<p dir=
\"
auto
\"
>
#{
note_text
(
html:
true
)
}
</p>"
end
end
def
project
resource_parent
if
resource_parent
.
is_a?
(
Project
)
end
def
group
resource_parent
if
resource_parent
.
is_a?
(
Group
)
end
private
private
def
note_text
(
html:
false
)
def
note_text
(
html:
false
)
...
...
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