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
822b0e40
Commit
822b0e40
authored
7 years ago
by
Kyle Doherty
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix #4668 (#6191)
* only show collection options if there are collections * clean up render method
parent
55ebca75
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/metabase/questions/containers/AddToDashboard.jsx
+81
-59
81 additions, 59 deletions
...tend/src/metabase/questions/containers/AddToDashboard.jsx
with
81 additions
and
59 deletions
frontend/src/metabase/questions/containers/AddToDashboard.jsx
+
81
−
59
View file @
822b0e40
...
...
@@ -10,13 +10,83 @@ import EntityList from "./EntityList";
import
ExpandingSearchField
from
"
../components/ExpandingSearchField.jsx
"
;
export
default
class
AddToDashboard
extends
Component
{
constructor
(
props
,
context
)
{
super
(
props
,
context
);
this
.
state
=
{
collection
:
null
,
query
:
null
}
state
=
{
collection
:
null
,
query
:
null
}
renderQuestionList
=
()
=>
{
return
(
<
EntityList
entityType
=
"cards"
entityQuery
=
{
this
.
state
.
query
}
editable
=
{
false
}
showSearchWidget
=
{
false
}
onEntityClick
=
{
this
.
props
.
onAdd
}
/>
)
}
renderCollections
=
()
=>
{
return
(
<
Collections
>
{
collections
=>
<
div
>
{
/*
only show the collections list if there are actually collections
fixes #4668
*/
collections
.
length
>
0
?
(
<
ol
>
{
collections
.
map
((
collection
,
index
)
=>
<
li
className
=
"text-brand-hover flex align-center border-bottom cursor-pointer py1 md-py2"
key
=
{
index
}
onClick
=
{
()
=>
this
.
setState
({
collection
:
collection
,
query
:
{
collection
:
collection
.
slug
}
})
}
>
<
Icon
className
=
"mr2"
name
=
"all"
style
=
{
{
color
:
collection
.
color
}
}
/>
<
h3
>
{
collection
.
name
}
</
h3
>
<
Icon
className
=
"ml-auto"
name
=
"chevronright"
/>
</
li
>
)
}
<
li
className
=
"text-brand-hover flex align-center border-bottom cursor-pointer py1 md-py2"
onClick
=
{
()
=>
this
.
setState
({
collection
:
{
name
:
"
Everything else
"
},
query
:
{
collection
:
""
}
})
}
>
<
Icon
className
=
"mr2"
name
=
"everything"
/>
<
h3
>
Everything else
</
h3
>
<
Icon
className
=
"ml-auto"
name
=
"chevronright"
/>
</
li
>
</
ol
>
)
:
this
.
renderQuestionList
()
}
</
div
>
}
</
Collections
>
)
}
render
()
{
...
...
@@ -56,59 +126,11 @@ export default class AddToDashboard extends Component {
}
</
div
>
</
div
>
{
this
.
state
.
query
?
<
EntityList
entityType
=
"cards"
entityQuery
=
{
this
.
state
.
query
}
editable
=
{
false
}
showSearchWidget
=
{
false
}
onEntityClick
=
{
this
.
props
.
onAdd
}
/>
:
<
Collections
>
{
collections
=>
<
ol
>
{
collections
.
map
((
collection
,
index
)
=>
<
li
className
=
"text-brand-hover flex align-center border-bottom cursor-pointer py1 md-py2"
key
=
{
index
}
onClick
=
{
()
=>
this
.
setState
({
collection
:
collection
,
query
:
{
collection
:
collection
.
slug
}
})
}
>
<
Icon
className
=
"mr2"
name
=
"all"
style
=
{
{
color
:
collection
.
color
}
}
/>
<
h3
>
{
collection
.
name
}
</
h3
>
<
Icon
className
=
"ml-auto"
name
=
"chevronright"
/>
</
li
>
)
}
<
li
className
=
"text-brand-hover flex align-center border-bottom cursor-pointer py1 md-py2"
onClick
=
{
()
=>
this
.
setState
({
collection
:
{
name
:
"
Everything else
"
},
query
:
{
collection
:
""
}
})
}
>
<
Icon
className
=
"mr2"
name
=
"everything"
/>
<
h3
>
Everything else
</
h3
>
<
Icon
className
=
"ml-auto"
name
=
"chevronright"
/>
</
li
>
</
ol
>
}
</
Collections
>
{
query
// a search term has been entered so show the questions list
?
this
.
renderQuestionList
()
// show the collections list
:
this
.
renderCollections
()
}
</
ModalContent
>
);
...
...
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