Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Components with schema #289

Closed
wants to merge 44 commits into from
Closed

Components with schema #289

wants to merge 44 commits into from

Conversation

rmarren1
Copy link
Contributor

@rmarren1 rmarren1 commented Aug 30, 2018

This PR is dependent on the validation PR plotly/dash#452, and consists of the Dash Core Components generated with schemas, some tests, and some modifications to DCC prop-types to make validation work.

@@ -99,7 +99,7 @@ ConfirmDialog.propTypes = {
/**
* Set to true to send the ConfirmDialog.
*/
displayed: PropTypes.bool,
displayed: PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.bool]),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Necessary because of this test, since it will set displayed=None. Or, should we change that test and keep this as only PropTypes.bool

@@ -173,36 +173,36 @@ DatePickerRange.propTypes = {
* Accepts datetime.datetime objects or strings
* in the format 'YYYY-MM-DD'
*/
start_date: PropTypes.string,
start_date: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically a Python datetime object is stored, which is automatically serialized to a string; however, validation occurs before serialization, so we need this so the validation schema is automatically generated to accept datetime objects.

@@ -8,7 +8,7 @@ const filterEventData = (gd, eventData, event) => {
if (contains(event, ['click', 'hover', 'selected'])) {
const points = [];

if (isNil(eventData)) {
if (isNil(eventData) || isNil(eventData.points)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was throwing front-end error is eventData.points was undefined.

@@ -74,7 +74,10 @@ export default class PlotlyGraph extends Component {
const {id, figure, animate, animation_options, config} = props;
const gd = document.getElementById(id);

if (animate && this._hasPlotted && figure.data.length === gd.data.length) {
if (animate && this._hasPlotted &&
!isNil(figure) && !isNil(gd) &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was throwing front-end errors.

pathname: PropTypes.string,
pathname: PropTypes.oneOfType([
PropTypes.string,
PropTypes.oneOf([null])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added because of this test, which results in an initial callback setting pathname=None. We can change the test instead.

@@ -52,8 +52,8 @@ Slider.propTypes = {
* the value should be an object which
* contains style and label properties.
*/
marks: PropTypes.shape({
number: PropTypes.oneOfType([
marks: PropTypes.objectOf(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just had the wrong schema initially.

@@ -214,7 +214,7 @@ export default class Tabs extends Component {
selectedTab = this.props.children.filter(child => {
return child.props.children.props.value === this.state.selected;
});
if ('props' in selectedTab[0]) {
if (selectedTab[0] && 'props' in selectedTab[0]) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was throwing front-end exceptions.

@@ -359,7 +359,7 @@ Tabs.propTypes = {
/**
* Array that holds Tab components
*/
children: PropTypes.node,
children: PropTypes.node.isRequired,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Front-end exceptions when this is None.

@Marc-Andre-Rivet
Copy link
Contributor

@rmarren1 What's the status of this PR? Is this blocked or moot? If blocked, what can we do to help unblock it. Just doing sanity checks on PRs that have been outstanding for a while. Thanks!

@rmarren1
Copy link
Contributor Author

rmarren1 commented Dec 11, 2018

@Marc-Andre-Rivet This is dependent on plotly/dash#452 which is still awaiting approval. I'll update the top level to explain that! (It was linked to old version of the PR).

@rmarren1 rmarren1 reopened this Dec 18, 2018
@byronz
Copy link
Contributor

byronz commented Apr 24, 2019

Close this PR as we shifted the validation in dash-renderer #100

@byronz byronz closed this Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants