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
0c3e9a11
Unverified
Commit
0c3e9a11
authored
7 years ago
by
Kyle Doherty
Browse files
Options
Downloads
Patches
Plain Diff
special treatment for saved question item
parent
3201d22c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/metabase/query_builder/components/DataSelector.jsx
+46
-18
46 additions, 18 deletions
...nd/src/metabase/query_builder/components/DataSelector.jsx
with
46 additions
and
18 deletions
frontend/src/metabase/query_builder/components/DataSelector.jsx
+
46
−
18
View file @
0c3e9a11
...
...
@@ -174,12 +174,27 @@ export default class DataSelector extends Component {
renderDatabaseSchemaPicker
()
{
const
{
selectedSchema
}
=
this
.
state
;
let
sections
=
this
.
state
.
databases
.
map
(
database
=>
{
return
{
// for nested queries we want to present some different styling so we need
// a way to identify this "database"
// for now we use it's unique ID that the backend specifies
// TODO (@kdoh) - have a nice heart to heart with whoever chose this value
const
savedQuestionId
=
-
1337
let
sections
=
this
.
state
.
databases
.
filter
(
database
=>
database
.
id
!==
savedQuestionId
)
.
map
(
database
=>
({
name
:
database
.
name
,
items
:
database
.
schemas
.
length
>
1
?
database
.
schemas
:
[]
};
});
}));
// do the opposite of what we just did and get a reference to the saved question "db"
// there will only ever be one of these hence [0]
const
savedQuestionSection
=
this
.
state
.
databases
.
filter
(
db
=>
db
.
id
===
savedQuestionId
)[
0
]
// some of the change functions need the index in the databases array
const
savedQuestionSectionIndex
=
this
.
state
.
databases
.
indexOf
(
savedQuestionSection
)
let
openSection
=
selectedSchema
&&
_
.
findIndex
(
this
.
state
.
databases
,
(
db
)
=>
_
.
find
(
db
.
schemas
,
selectedSchema
));
if
(
openSection
>=
0
&&
this
.
state
.
databases
[
openSection
]
&&
this
.
state
.
databases
[
openSection
].
schemas
.
length
===
1
)
{
...
...
@@ -187,20 +202,33 @@ export default class DataSelector extends Component {
}
return
(
<
AccordianList
id
=
"DatabaseSchemaPicker"
key
=
"schemaPicker"
className
=
"text-brand"
sections
=
{
sections
}
onChange
=
{
this
.
onChangeSchema
}
onChangeSection
=
{
this
.
onChangeDatabase
}
itemIsSelected
=
{
(
schema
)
=>
this
.
state
.
selectedSchema
===
schema
}
renderSectionIcon
=
{
()
=>
<
Icon
className
=
"Icon text-default"
name
=
"database"
size
=
{
18
}
/>
}
renderItemIcon
=
{
()
=>
<
Icon
name
=
"folder"
size
=
{
16
}
/>
}
initiallyOpenSection
=
{
openSection
}
showItemArrows
=
{
true
}
alwaysTogglable
=
{
true
}
/>
<
div
>
<
AccordianList
id
=
"DatabaseSchemaPicker"
key
=
"schemaPicker"
className
=
"text-brand"
sections
=
{
sections
}
onChange
=
{
this
.
onChangeSchema
}
onChangeSection
=
{
this
.
onChangeDatabase
}
itemIsSelected
=
{
(
schema
)
=>
this
.
state
.
selectedSchema
===
schema
}
renderSectionIcon
=
{
()
=>
<
Icon
className
=
"Icon text-default"
name
=
"database"
size
=
{
18
}
/>
}
renderItemIcon
=
{
()
=>
<
Icon
name
=
"folder"
size
=
{
16
}
/>
}
initiallyOpenSection
=
{
openSection
}
showItemArrows
=
{
true
}
alwaysTogglable
=
{
true
}
/>
{
savedQuestionSection
&&
(
<
div
className
=
"List-section p2 cursor-pointer text-brand-hover bg-slate-extra-light"
onClick
=
{
()
=>
this
.
onChangeDatabase
(
savedQuestionSectionIndex
)
}
>
<
div
className
=
"List-section-header flex align-center"
>
<
Icon
className
=
"Icon text-default mr2"
size
=
{
18
}
name
=
"all"
/>
<
h3
className
=
"List-section-title"
>
Saved questions
</
h3
>
</
div
>
</
div
>
)
}
</
div
>
);
}
...
...
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