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
57c7bbe6
Unverified
Commit
57c7bbe6
authored
3 years ago
by
Gustavo Saiani
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Clean up prop destructuring in Dashboard component file (#17338)
parent
74b02afd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/metabase/dashboard/components/Dashboard.jsx
+37
-25
37 additions, 25 deletions
frontend/src/metabase/dashboard/components/Dashboard.jsx
with
37 additions
and
25 deletions
frontend/src/metabase/dashboard/components/Dashboard.jsx
+
37
−
25
View file @
57c7bbe6
...
...
@@ -4,6 +4,8 @@ import React, { Component } from "react";
import
PropTypes
from
"
prop-types
"
;
import
{
Box
}
from
"
grid-styled
"
;
import
{
t
}
from
"
ttag
"
;
import
_
from
"
underscore
"
;
import
cx
from
"
classnames
"
;
import
DashboardHeader
from
"
./DashboardHeader
"
;
import
DashboardGrid
from
"
./DashboardGrid
"
;
...
...
@@ -14,9 +16,6 @@ import { DashboardSidebars } from "./DashboardSidebars";
import
DashboardControls
from
"
../hoc/DashboardControls
"
;
import
_
from
"
underscore
"
;
import
cx
from
"
classnames
"
;
// NOTE: move DashboardControls HoC to container
@
DashboardControls
export
default
class
Dashboard
extends
Component
{
...
...
@@ -78,21 +77,25 @@ export default class Dashboard extends Component {
}
async
loadDashboard
(
dashboardId
)
{
this
.
props
.
initialize
();
this
.
props
.
loadDashboardParams
();
const
{
addCardOnLoad
,
fetchDashboard
,
addCardToDashboard
,
setErrorPage
,
fetchDashboard
,
initialize
,
loadDashboardParams
,
location
,
setErrorPage
,
}
=
this
.
props
;
initialize
();
loadDashboardParams
();
try
{
await
fetchDashboard
(
dashboardId
,
location
.
query
);
if
(
addCardOnLoad
!=
null
)
{
// if we destructure this.props.dashboard, for some reason
// if will render dashboards as empty
this
.
setEditing
(
this
.
props
.
dashboard
);
addCardToDashboard
({
dashId
:
dashboardId
,
cardId
:
addCardOnLoad
});
}
...
...
@@ -139,21 +142,27 @@ export default class Dashboard extends Component {
onEmbeddingClick
=
()
=>
{};
render
()
{
le
t
{
cons
t
{
dashboard
,
isEditing
,
editingParameter
,
parameters
,
parameterValues
,
location
,
hideParameters
,
isEditing
,
isFullscreen
,
isNightMode
,
isSharing
,
hideParameters
,
location
,
parameterValues
,
parameters
,
removeParameter
,
setEditingParameter
,
setParameterDefaultValue
,
setParameterIndex
,
setParameterName
,
setParameterValue
,
}
=
this
.
props
;
const
{
error
,
showAddQuestionSidebar
}
=
this
.
state
;
i
sNightMode
=
isNightMode
&&
isFullscreen
;
const
shouldRenderA
sNightMode
=
isNightMode
&&
isFullscreen
;
let
parametersWidget
;
if
(
parameters
&&
parameters
.
length
>
0
)
{
...
...
@@ -163,7 +172,7 @@ export default class Dashboard extends Component {
dashboard
=
{
dashboard
}
isEditing
=
{
isEditing
}
isFullscreen
=
{
isFullscreen
}
isNightMode
=
{
i
sNightMode
}
isNightMode
=
{
shouldRenderA
sNightMode
}
hideParameters
=
{
hideParameters
}
parameters
=
{
parameters
.
map
(
p
=>
({
...
p
,
...
...
@@ -171,12 +180,12 @@ export default class Dashboard extends Component {
}))
}
query
=
{
location
.
query
}
editingParameter
=
{
editingParameter
}
setEditingParameter
=
{
this
.
props
.
setEditingParameter
}
setParameterName
=
{
this
.
props
.
setParameterName
}
setParameterIndex
=
{
this
.
props
.
setParameterIndex
}
setParameterDefaultValue
=
{
this
.
props
.
setParameterDefaultValue
}
removeParameter
=
{
this
.
props
.
removeParameter
}
setParameterValue
=
{
this
.
props
.
setParameterValue
}
setEditingParameter
=
{
setEditingParameter
}
setParameterName
=
{
setParameterName
}
setParameterIndex
=
{
setParameterIndex
}
setParameterDefaultValue
=
{
setParameterDefaultValue
}
removeParameter
=
{
removeParameter
}
setParameterValue
=
{
setParameterValue
}
/>
);
}
...
...
@@ -185,7 +194,7 @@ export default class Dashboard extends Component {
<
LoadingAndErrorWrapper
className
=
{
cx
(
"
Dashboard flex-full
"
,
{
"
Dashboard--fullscreen
"
:
isFullscreen
,
"
Dashboard--night
"
:
i
sNightMode
,
"
Dashboard--night
"
:
shouldRenderA
sNightMode
,
// prevents header from scrolling so we can have a fixed sidebar
"
full-height
"
:
isEditing
||
isSharing
,
})
}
...
...
@@ -223,7 +232,10 @@ export default class Dashboard extends Component {
)
}
<
div
className
=
"wrapper"
>
{
dashboard
.
ordered_cards
.
length
===
0
?
(
<
Box
mt
=
{
[
2
,
4
]
}
color
=
{
isNightMode
?
"
white
"
:
"
inherit
"
}
>
<
Box
mt
=
{
[
2
,
4
]
}
color
=
{
shouldRenderAsNightMode
?
"
white
"
:
"
inherit
"
}
>
<
EmptyState
illustrationElement
=
{
<
span
className
=
"QuestionCircle"
>
?
</
span
>
...
...
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