Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
logging-scratch-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Goessmann
logging-scratch-gui
Commits
2b3c70df
Commit
2b3c70df
authored
6 years ago
by
Christopher Willis-Ford
Browse files
Options
Downloads
Patches
Plain Diff
Move event processing out of LibraryItemComponent
parent
db9236be
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/library-item/library-item.jsx
+11
-47
11 additions, 47 deletions
src/components/library-item/library-item.jsx
src/containers/library-item.jsx
+62
-5
62 additions, 5 deletions
src/containers/library-item.jsx
with
73 additions
and
52 deletions
src/components/library-item/library-item.jsx
+
11
−
47
View file @
2b3c70df
import
bindAll
from
'
lodash.bindall
'
;
import
{
FormattedMessage
}
from
'
react-intl
'
;
import
PropTypes
from
'
prop-types
'
;
import
React
from
'
react
'
;
...
...
@@ -11,41 +10,6 @@ import bluetoothIconURL from './bluetooth.svg';
import
internetConnectionIconURL
from
'
./internet-connection.svg
'
;
class
LibraryItemComponent
extends
React
.
PureComponent
{
constructor
(
props
)
{
super
(
props
);
bindAll
(
this
,
[
'
handleBlur
'
,
'
handleClick
'
,
'
handleFocus
'
,
'
handleKeyPress
'
,
'
handleMouseEnter
'
,
'
handleMouseLeave
'
]);
}
handleBlur
()
{
this
.
props
.
onBlur
(
this
.
props
.
id
);
}
handleFocus
()
{
this
.
props
.
onFocus
(
this
.
props
.
id
);
}
handleClick
(
e
)
{
if
(
!
this
.
props
.
disabled
)
{
this
.
props
.
onSelect
(
this
.
props
.
id
);
}
e
.
preventDefault
();
}
handleKeyPress
(
e
)
{
if
(
e
.
key
===
'
'
||
e
.
key
===
'
Enter
'
)
{
e
.
preventDefault
();
this
.
props
.
onSelect
(
this
.
props
.
id
);
}
}
handleMouseEnter
()
{
this
.
props
.
onMouseEnter
(
this
.
props
.
id
);
}
handleMouseLeave
()
{
this
.
props
.
onMouseLeave
(
this
.
props
.
id
);
}
render
()
{
return
this
.
props
.
featured
?
(
<
div
...
...
@@ -58,7 +22,7 @@ class LibraryItemComponent extends React.PureComponent {
this
.
props
.
extensionId
?
styles
.
libraryItemExtension
:
null
,
this
.
props
.
hidden
?
styles
.
hidden
:
null
)
}
onClick
=
{
this
.
handle
Click
}
onClick
=
{
this
.
props
.
on
Click
}
>
<
div
className
=
{
styles
.
featuredImageContainer
}
>
{
this
.
props
.
disabled
?
(
...
...
@@ -146,12 +110,12 @@ class LibraryItemComponent extends React.PureComponent {
)
}
role
=
"button"
tabIndex
=
"0"
onBlur
=
{
this
.
handle
Blur
}
onClick
=
{
this
.
handle
Click
}
onFocus
=
{
this
.
handle
Focus
}
onKeyPress
=
{
this
.
handle
KeyPress
}
onMouseEnter
=
{
this
.
handle
MouseEnter
}
onMouseLeave
=
{
this
.
handle
MouseLeave
}
onBlur
=
{
this
.
props
.
on
Blur
}
onClick
=
{
this
.
props
.
on
Click
}
onFocus
=
{
this
.
props
.
on
Focus
}
onKeyPress
=
{
this
.
props
.
on
KeyPress
}
onMouseEnter
=
{
this
.
props
.
on
MouseEnter
}
onMouseLeave
=
{
this
.
props
.
on
MouseLeave
}
>
{
/* Layers of wrapping is to prevent layout thrashing on animation */
}
<
Box
className
=
{
styles
.
libraryItemImageContainerWrapper
}
>
...
...
@@ -180,7 +144,6 @@ LibraryItemComponent.propTypes = {
featured
:
PropTypes
.
bool
,
hidden
:
PropTypes
.
bool
,
iconURI
:
PropTypes
.
string
,
id
:
PropTypes
.
number
.
isRequired
,
insetIconURL
:
PropTypes
.
string
,
internetConnectionRequired
:
PropTypes
.
bool
,
name
:
PropTypes
.
oneOfType
([
...
...
@@ -188,10 +151,11 @@ LibraryItemComponent.propTypes = {
PropTypes
.
node
]),
onBlur
:
PropTypes
.
func
,
onClick
:
PropTypes
.
func
,
onFocus
:
PropTypes
.
func
,
on
MouseEnter
:
PropTypes
.
func
.
isRequired
,
onMouse
Leave
:
PropTypes
.
func
.
isRequired
,
on
Select
:
PropTypes
.
func
.
isRequired
on
KeyPress
:
PropTypes
.
func
,
onMouse
Enter
:
PropTypes
.
func
,
on
MouseLeave
:
PropTypes
.
func
};
LibraryItemComponent
.
defaultProps
=
{
...
...
This diff is collapsed.
Click to expand it.
src/containers/library-item.jsx
+
62
−
5
View file @
2b3c70df
import
bindAll
from
'
lodash.bindall
'
;
import
PropTypes
from
'
prop-types
'
;
import
React
from
'
react
'
;
import
LibraryItemComponent
from
'
../components/library-item/library-item.jsx
'
;
...
...
@@ -23,6 +25,14 @@ const getAssetTypeForExtension = function (extension) {
class
LibraryItem
extends
React
.
PureComponent
{
constructor
(
props
)
{
super
(
props
);
bindAll
(
this
,
[
'
handleBlur
'
,
'
handleClick
'
,
'
handleFocus
'
,
'
handleKeyPress
'
,
'
handleMouseEnter
'
,
'
handleMouseLeave
'
]);
this
.
state
=
Object
.
assign
(
this
.
state
||
{},
{
iconURI
:
props
.
iconURL
// may be undefined if we're using iconMD5 instead
});
...
...
@@ -40,10 +50,50 @@ class LibraryItem extends React.PureComponent {
});
}
}
handleBlur
()
{
this
.
props
.
onBlur
(
this
.
props
.
id
);
}
handleFocus
()
{
this
.
props
.
onFocus
(
this
.
props
.
id
);
}
handleClick
(
e
)
{
if
(
!
this
.
props
.
disabled
)
{
this
.
props
.
onSelect
(
this
.
props
.
id
);
}
e
.
preventDefault
();
}
handleKeyPress
(
e
)
{
if
(
e
.
key
===
'
'
||
e
.
key
===
'
Enter
'
)
{
e
.
preventDefault
();
this
.
props
.
onSelect
(
this
.
props
.
id
);
}
}
handleMouseEnter
()
{
this
.
props
.
onMouseEnter
(
this
.
props
.
id
);
}
handleMouseLeave
()
{
this
.
props
.
onMouseLeave
(
this
.
props
.
id
);
}
render
()
{
const
{
iconMD5
:
_iconMD5
,
iconURL
:
_iconURL
,
...
childProps
}
=
this
.
props
;
const
{
iconMD5
:
_iconMD5
,
iconURL
:
_iconURL
,
id
:
_id
,
onBlur
:
_onBlur
,
onFocus
:
_onFocus
,
onMouseEnter
:
_onMouseEnter
,
onMouseLeave
:
_onMouseLeave
,
onSelect
:
_onSelect
,
...
childProps
}
=
this
.
props
;
return
(<
LibraryItemComponent
iconURI
=
{
this
.
state
.
iconURI
}
onBlur
=
{
this
.
props
.
onBlur
&&
this
.
handleBlur
}
onClick
=
{
this
.
handleClick
}
onFocus
=
{
this
.
props
.
onFocus
&&
this
.
handleFocus
}
onKeyPress
=
{
this
.
handleKeyPress
}
onMouseEnter
=
{
this
.
props
.
onMouseEnter
&&
this
.
handleMouseEnter
}
onMouseLeave
=
{
this
.
props
.
onMouseLeave
&&
this
.
handleMouseLeave
}
{
...
childProps
}
/>);
}
...
...
@@ -61,13 +111,20 @@ LibraryItem.requireUrlOrMD5 = function (props) {
LibraryItem
.
propTypes
=
Object
.
assign
({},
(()
=>
{
// copy all props EXCEPT iconURI from LibraryItemComponent
const
{
iconURI
:
_iconURI
,
...
otherProps
}
=
LibraryItemComponent
.
propTypes
;
return
otherProps
;
// copy all prop types EXCEPT these from LibraryItemComponent
const
{
iconURI
:
_iconURI
,
onClick
:
_onClick
,
onKeyPress
:
_onKeyPress
,
...
otherPropTypes
}
=
LibraryItemComponent
.
propTypes
;
return
otherPropTypes
;
})(),
{
id
:
PropTypes
.
number
.
isRequired
,
iconMD5
:
LibraryItem
.
requireUrlOrMD5
,
iconURL
:
LibraryItem
.
requireUrlOrMD5
iconURL
:
LibraryItem
.
requireUrlOrMD5
,
onSelect
:
PropTypes
.
func
.
isRequired
}
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment