Skip to content

Commit

Permalink
[TSVB] [Cleanup] Remove extra dateFormat props
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Dec 2, 2020
1 parent 126c99a commit 6831627
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export class MarkdownEditor extends Component {
}

render() {
const { visData, model, dateFormat } = this.props;
const { visData, model, getConfig } = this.props;

if (!visData) {
return null;
}

const dateFormat = getConfig('dateFormat');
const series = _.get(visData, `${model.id}.series`, []);
const variables = convertSeriesToVars(series, model, dateFormat, this.props.getConfig);
const rows = [];
Expand Down Expand Up @@ -214,6 +214,6 @@ export class MarkdownEditor extends Component {
MarkdownEditor.propTypes = {
onChange: PropTypes.func,
model: PropTypes.object,
dateFormat: PropTypes.string,
getConfig: PropTypes.func,
visData: PropTypes.object,
};
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ PanelConfig.propTypes = {
fields: PropTypes.object,
model: PropTypes.object,
onChange: PropTypes.func,
dateFormat: PropTypes.string,
visData$: PropTypes.object,
getConfig: PropTypes.func,
};
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ MarkdownPanelConfigUi.propTypes = {
fields: PropTypes.object,
model: PropTypes.object,
onChange: PropTypes.func,
dateFormat: PropTypes.string,
};

export const MarkdownPanelConfig = injectI18n(MarkdownPanelConfigUi);
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ function TimeseriesVisualization({
if (VisComponent) {
return (
<VisComponent
dateFormat={getConfig('dateFormat')}
getConfig={getConfig}
model={model}
visData={visData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ export class VisEditor extends Component {
fields={this.state.visFields}
model={model}
visData$={this.visData$}
dateFormat={this.props.config.get('dateFormat')}
onChange={this.handleChange}
getConfig={this.getConfig}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,5 @@ export interface TimeseriesVisProps {
) => void;
uiState: PersistedState;
visData: TimeseriesVisData;
dateFormat: string;
getConfig: IUiSettingsClient['get'];
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import { isBackgroundInverted } from '../../../lib/set_is_reversed';
const getMarkdownId = (id) => `markdown-${id}`;

function MarkdownVisualization(props) {
const { backgroundColor, model, visData, dateFormat } = props;
const { backgroundColor, model, visData, getConfig } = props;
const series = get(visData, `${model.id}.series`, []);
const variables = convertSeriesToVars(series, model, dateFormat, props.getConfig);
const variables = convertSeriesToVars(series, model, getConfig('dateFormat'), props.getConfig);
const markdownElementId = getMarkdownId(uuid.v1());

const panelBackgroundColor = model.background_color || backgroundColor;
Expand Down Expand Up @@ -103,7 +103,6 @@ MarkdownVisualization.propTypes = {
onBrush: PropTypes.func,
onChange: PropTypes.func,
visData: PropTypes.object,
dateFormat: PropTypes.string,
getConfig: PropTypes.func,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,18 @@ class TimeseriesVisualization extends Component {
model: PropTypes.object,
onBrush: PropTypes.func,
visData: PropTypes.object,
dateFormat: PropTypes.string,
getConfig: PropTypes.func,
};

xAxisFormatter = (interval) => (val) => {
const scaledDataFormat = this.props.getConfig('dateFormat:scaled');
const { dateFormat } = this.props;
scaledDataFormat = this.props.getConfig('dateFormat:scaled');
dateFormat = this.props.getConfig('dateFormat');

if (!scaledDataFormat || !dateFormat) {
xAxisFormatter = (interval) => (val) => {
if (!this.scaledDataFormat || !this.dateFormat) {
return val;
}

const formatter = createXaxisFormatter(interval, scaledDataFormat, dateFormat);

const formatter = createXaxisFormatter(interval, this.scaledDataFormat, this.dateFormat);
return formatter(val);
};

Expand Down

0 comments on commit 6831627

Please sign in to comment.