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
69680632
Commit
69680632
authored
6 years ago
by
Tom Robinson
Browse files
Options
Downloads
Patches
Plain Diff
Add frontend/src/metabase/visualizations/components/settings/ChartSettingNestedSettings.jsx
parent
ba74d01b
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/visualizations/components/settings/ChartSettingNestedSettings.jsx
+92
-0
92 additions, 0 deletions
...ations/components/settings/ChartSettingNestedSettings.jsx
with
92 additions
and
0 deletions
frontend/src/metabase/visualizations/components/settings/ChartSettingNestedSettings.jsx
0 → 100644
+
92
−
0
View file @
69680632
import
React
from
"
react
"
;
import
ChartSettingsWidget
from
"
../ChartSettingsWidget
"
;
const
chartSettingNestedSettings
=
({
getObjectKey
,
getSettingsWidgetsForObject
,
})
=>
ComposedComponent
=>
class
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
editingObject
:
props
.
objects
.
length
===
1
?
props
.
objects
[
0
]
:
null
,
};
}
componentWillReceiveProps
(
nextProps
)
{
// reset editingObject if there's only one object
if
(
nextProps
.
objects
.
length
===
1
&&
this
.
state
.
editingObject
!==
nextProps
.
objects
[
0
]
)
{
this
.
setState
({
editingObject
:
nextProps
.
objects
[
0
],
});
}
}
handleChangeEditingObject
=
editingObject
=>
{
this
.
setState
({
editingObject
});
};
handleChangeSettingsForEditingObject
=
newSettings
=>
{
this
.
handleChangeSettingsForObject
(
this
.
state
.
editingObject
,
newSettings
);
};
handleChangeSettingsForObject
=
(
object
,
newSettings
)
=>
{
const
{
onChange
}
=
this
.
props
;
const
objectKey
=
getObjectKey
(
object
);
const
objectsSettings
=
this
.
props
.
value
||
{};
const
objectSettings
=
objectsSettings
[
objectKey
]
||
{};
onChange
({
...
objectsSettings
,
[
objectKey
]:
{
...
objectSettings
,
...
newSettings
,
},
});
};
render
()
{
const
{
series
,
objects
,
extra
}
=
this
.
props
;
const
{
editingObject
}
=
this
.
state
;
const
objectsSettings
=
this
.
props
.
value
||
{};
if
(
editingObject
)
{
const
objectKey
=
getObjectKey
(
editingObject
);
const
objectSettings
=
objectsSettings
[
objectKey
]
||
{};
const
objectSettingsWidgets
=
getSettingsWidgetsForObject
(
series
,
editingObject
,
objectSettings
,
this
.
handleChangeSettingsForEditingObject
,
extra
,
);
return
(
<
ComposedComponent
{
...
this
.
props
}
getObjectKey
=
{
getObjectKey
}
onChangeEditingObject
=
{
this
.
handleChangeEditingObject
}
onChangeObjectSettings
=
{
this
.
handleChangeSettingsForObject
}
object
=
{
editingObject
}
objectSettingsWidgets
=
{
objectSettingsWidgets
.
map
(
widget
=>
(
<
ChartSettingsWidget
key
=
{
widget
.
id
}
{
...
widget
}
/>
))
}
/>
);
}
else
{
return
(
<
ComposedComponent
{
...
this
.
props
}
getObjectKey
=
{
getObjectKey
}
onChangeEditingObject
=
{
this
.
handleChangeEditingObject
}
onChangeObjectSettings
=
{
this
.
handleChangeSettingsForObject
}
/>
);
}
}
};
export
default
chartSettingNestedSettings
;
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