Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Container 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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
8866685a
Commit
8866685a
authored
6 years ago
by
Tom Robinson
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup EntityItem, explicitly pass in all actions
parent
bf411408
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/components/CollectionLanding.jsx
+25
-10
25 additions, 10 deletions
frontend/src/metabase/components/CollectionLanding.jsx
frontend/src/metabase/components/EntityItem.jsx
+45
-51
45 additions, 51 deletions
frontend/src/metabase/components/EntityItem.jsx
with
70 additions
and
61 deletions
frontend/src/metabase/components/CollectionLanding.jsx
+
25
−
10
View file @
8866685a
...
...
@@ -4,7 +4,7 @@ import { t } from "c-3po";
import
{
connect
}
from
"
react-redux
"
;
import
_
from
"
underscore
"
;
import
listSelect
from
"
metabase/hoc/ListSelect
"
;
import
BulkActionBar
from
"
metabase/components/BulkActionBar
"
import
BulkActionBar
from
"
metabase/components/BulkActionBar
"
;
import
*
as
Urls
from
"
metabase/lib/urls
"
;
import
{
normal
}
from
"
metabase/lib/colors
"
;
...
...
@@ -96,7 +96,13 @@ class DefaultLanding extends React.Component {
};
render
()
{
const
{
collectionId
,
list
,
onToggleSelected
,
selection
,
selected
}
=
this
.
props
;
const
{
collectionId
,
list
,
onToggleSelected
,
selection
,
selected
,
}
=
this
.
props
;
// Show the
const
showCollectionList
=
collectionId
===
"
root
"
;
...
...
@@ -189,29 +195,38 @@ class DefaultLanding extends React.Component {
name
=
{
item
.
getName
()
}
iconName
=
{
item
.
getIcon
()
}
iconColor
=
{
item
.
getColor
()
}
isFavorite
=
{
item
.
getFavorited
&&
item
.
getFavorited
()
}
onFavorite
=
{
item
.
setFavorited
?
()
=>
item
.
setFavorited
(
true
)
:
null
}
isFavorite
=
{
item
.
getFavorited
&&
item
.
getFavorited
()
}
onPin
=
{
collection
.
can_write
&&
item
.
setPinned
?
()
=>
item
.
setPinned
(
true
)
:
null
}
onMove
=
{
collection
.
can_write
?
()
=>
{
alert
(
"
FIXME: move not yet implemented!
"
,
);
}
:
null
}
onArchive
=
{
collection
.
can_write
&&
item
.
setArchived
?
()
=>
item
.
setArchived
(
true
)
:
null
}
selected
=
{
selection
.
has
(
item
)
}
onToggleSelected
=
{
ev
=>
{
ev
.
preventDefault
();
onToggleSelected
(
item
);
}
}
onArchived
=
{
item
.
setArchived
?
()
=>
item
.
setArchived
(
true
)
:
null
}
/>
</
Link
>
</
Box
>
...
...
This diff is collapsed.
Click to expand it.
frontend/src/metabase/components/EntityItem.jsx
+
45
−
51
View file @
8866685a
import
React
from
"
react
"
;
import
{
t
}
from
"
c-3po
"
;
import
EntityMenu
from
"
metabase/components/EntityMenu
"
;
import
Swapper
from
"
metabase/components/Swapper
"
import
IconWrapper
from
"
metabase/components/IconWrapper
"
import
Swapper
from
"
metabase/components/Swapper
"
;
import
IconWrapper
from
"
metabase/components/IconWrapper
"
;
import
{
Flex
,
Box
,
Truncate
}
from
"
rebass
"
;
...
...
@@ -27,37 +27,51 @@ const EntityItem = ({
name
,
iconName
,
iconColor
,
item
,
isFavorite
,
onPin
,
onFavorite
,
onMove
,
onArchive
,
selected
,
onToggleSelected
,
selectable
,
showSelect
showSelect
,
})
=>
{
const
actions
=
[
onPin
&&
{
title
:
t
`Pin this item`
,
icon
:
"
pin
"
,
action
:
onPin
,
},
onMove
&&
{
title
:
t
`Move this item`
,
icon
:
"
move
"
,
action
:
onMove
,
},
onArchive
&&
{
title
:
t
`Archive`
,
icon
:
"
archive
"
,
action
:
onArchive
,
},
].
filter
(
action
=>
action
);
return
(
<
EntityItemWrapper
py
=
{
2
}
px
=
{
2
}
className
=
"hover-parent hover--visibility"
>
<
IconWrapper
p
=
{
1
}
mr
=
{
1
}
align
=
"center"
justify
=
"center"
>
{
selectable
?
(
<
Swapper
startSwapped
=
{
showSelect
}
defaultElement
=
{
<
Icon
name
=
{
iconName
}
color
=
{
iconColor
}
/>
}
swappedElement
=
{
<
CheckBox
checked
=
{
selected
}
onChange
=
{
(
ev
)
=>
onToggleSelected
(
ev
)
}
/>
}
/>
)
:
(
<
Icon
name
=
{
iconName
}
color
=
{
iconColor
}
/>
)
}
<
IconWrapper
p
=
{
1
}
mr
=
{
1
}
align
=
"center"
justify
=
"center"
>
{
selectable
?
(
<
Swapper
startSwapped
=
{
showSelect
}
defaultElement
=
{
<
Icon
name
=
{
iconName
}
color
=
{
iconColor
}
/>
}
swappedElement
=
{
<
CheckBox
checked
=
{
selected
}
onChange
=
{
ev
=>
onToggleSelected
(
ev
)
}
/>
}
/>
)
:
(
<
Icon
name
=
{
iconName
}
color
=
{
iconColor
}
/>
)
}
</
IconWrapper
>
<
h3
>
<
Truncate
>
{
name
}
</
Truncate
>
...
...
@@ -69,43 +83,23 @@ const EntityItem = ({
className
=
"hover-child"
onClick
=
{
e
=>
e
.
preventDefault
()
}
>
{
onFavorite
&&
(
{
(
onFavorite
||
isFavorite
)
&&
(
<
Icon
name
=
{
isFavorite
?
"
star
"
:
"
staroutline
"
}
mr
=
{
1
}
onClick
=
{
()
=>
onFavorite
()
}
onClick
=
{
onFavorite
}
/>
)
}
<
EntityMenu
triggerIcon
=
"ellipsis"
items
=
{
[
{
title
:
t
`Pin this item`
,
icon
:
"
pin
"
,
action
:
()
=>
onPin
(
item
),
},
{
title
:
t
`Move this item`
,
icon
:
"
move
"
,
action
:
()
=>
onPin
(
item
),
},
{
title
:
t
`Archive`
,
icon
:
"
archive
"
,
action
:
()
=>
{
item
.
setArchived
(
true
)
}
},
]
}
/>
{
actions
.
length
>
0
&&
(
<
EntityMenu
triggerIcon
=
"ellipsis"
items
=
{
actions
}
/>
)
}
</
Flex
>
</
EntityItemWrapper
>
);
};
EntityItem
.
defaultProps
=
{
selectable
:
false
}
selectable
:
false
,
}
;
export
default
EntityItem
;
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