Skip to content

Commit

Permalink
[7.x] [Canvas] Update object-path-immutable; type AxisConfig a… (#42086)
Browse files Browse the repository at this point in the history
* Initial WIP

* Migrate to latest object-path-immutable; type arguments

* Fix Storybook Snapshot test; add snapshots

* Revert storyshots test change

* Adding SeriesStyle conversion + stories

* Addressing feedback; updating against master

* Update snapshots
  • Loading branch information
clintandrewhall committed Jul 29, 2019
1 parent 8240788 commit d77145c
Show file tree
Hide file tree
Showing 41 changed files with 3,305 additions and 300 deletions.
10 changes: 5 additions & 5 deletions x-pack/legacy/plugins/canvas/.storybook/storyshots.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ jest.mock('../canvas_plugin_src/renderers/shape/shapes', () => ({
jest.mock('@elastic/datemath', () => {
return {
parse: (d, opts) => {
const dateMath = jest.requireActual('@elastic/datemath');
return dateMath.parse(d, {...opts, forceNow: new Date(Date.UTC(2019, 5, 1))}); // June 1 2019
}
}
const dateMath = jest.requireActual('@elastic/datemath');
return dateMath.parse(d, { ...opts, forceNow: new Date(Date.UTC(2019, 5, 1)) }); // June 1 2019
},
};
});

// Mock react-datepicker dep used by eui to avoid rendering the entire large component
jest.mock('@elastic/eui/packages/react-datepicker', () => {
return {
__esModule: true,
default: 'ReactDatePicker',
}
};
});

addSerializer(styleSheetSerializer);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { action } from '@storybook/addon-actions';
import { storiesOf } from '@storybook/react';
import React from 'react';
import { ExpressionAST } from '../../../../../types';

import { ExtendedTemplate } from '../extended_template';

const defaultExpression: ExpressionAST = {
type: 'expression',
chain: [
{
type: 'function',
function: 'axisConfig',
arguments: {},
},
],
};

const defaultValues = {
argValue: defaultExpression,
};

class Interactive extends React.Component<{}, typeof defaultValues> {
public state = defaultValues;

_onValueChange: (argValue: ExpressionAST) => void = argValue => {
action('onValueChange')(argValue);
this.setState({ argValue });
};

public render() {
return (
<ExtendedTemplate
onValueChange={this._onValueChange}
argValue={this.state.argValue}
typeInstance={{ name: 'xaxis' }}
/>
);
}
}

storiesOf('arguments/AxisConfig', module)
.addDecorator(story => (
<div style={{ width: '323px', padding: '16px', background: '#fff' }}>{story()}</div>
))
.add('extended', () => <Interactive />);

storiesOf('arguments/AxisConfig/components', module)
.addDecorator(story => (
<div style={{ width: '323px', padding: '16px', background: '#fff' }}>{story()}</div>
))
.add('extended disabled', () => (
<ExtendedTemplate
onValueChange={action('onValueChange')}
argValue={false}
typeInstance={{ name: 'yaxis' }}
/>
))
.add('extended', () => (
<ExtendedTemplate
onValueChange={action('onValueChange')}
argValue={defaultExpression}
typeInstance={{ name: 'yaxis' }}
/>
));
Loading

0 comments on commit d77145c

Please sign in to comment.