mirror of
https://github.com/apache/superset.git
synced 2024-09-16 02:29:39 -04:00
move metric parsing to state instantiation (#15069)
This commit is contained in:
parent
821519fcfa
commit
0c470feaef
@ -233,4 +233,21 @@ describe('DatasourceEditor RTL', () => {
|
||||
);
|
||||
expect(warningMarkdown.value).toEqual('someone');
|
||||
});
|
||||
it('properly updates the metric information', async () => {
|
||||
render(<DatasourceEditor {...props} />, {
|
||||
useRedux: true,
|
||||
});
|
||||
const metricButton = screen.getByTestId('collection-tab-Metrics');
|
||||
userEvent.click(metricButton);
|
||||
const expandToggle = await screen.findAllByLabelText(/toggle expand/i);
|
||||
userEvent.click(expandToggle[1]);
|
||||
const certifiedBy = await screen.findByPlaceholderText(/certified by/i);
|
||||
userEvent.type(certifiedBy, 'I am typing a new name');
|
||||
const certificationDetails = await screen.findByPlaceholderText(
|
||||
/certification details/i,
|
||||
);
|
||||
expect(certifiedBy.value).toEqual('I am typing a new name');
|
||||
userEvent.type(certificationDetails, 'I am typing something new');
|
||||
expect(certificationDetails.value).toEqual('I am typing something new');
|
||||
});
|
||||
});
|
||||
|
@ -307,7 +307,21 @@ class DatasourceEditor extends React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
datasource: props.datasource,
|
||||
datasource: {
|
||||
...props.datasource,
|
||||
metrics: props.datasource.metrics?.map(metric => {
|
||||
const {
|
||||
certification: { details, certified_by: certifiedBy } = {},
|
||||
warning_markdown: warningMarkdown,
|
||||
} = JSON.parse(metric.extra || '{}') || {};
|
||||
return {
|
||||
...metric,
|
||||
certification_details: details || '',
|
||||
warning_markdown: warningMarkdown || '',
|
||||
certified_by: certifiedBy,
|
||||
};
|
||||
}),
|
||||
},
|
||||
errors: [],
|
||||
isDruid:
|
||||
props.datasource.type === 'druid' ||
|
||||
@ -936,18 +950,7 @@ class DatasourceEditor extends React.PureComponent {
|
||||
</Fieldset>
|
||||
</FormContainer>
|
||||
}
|
||||
collection={this.state.datasource.metrics?.map(metric => {
|
||||
const {
|
||||
certification: { details, certified_by: certifiedBy } = {},
|
||||
warning_markdown: warningMarkdown,
|
||||
} = JSON.parse(metric.extra || '{}') || {};
|
||||
return {
|
||||
...metric,
|
||||
certification_details: details || '',
|
||||
warning_markdown: warningMarkdown || '',
|
||||
certified_by: certifiedBy,
|
||||
};
|
||||
})}
|
||||
collection={this.state.datasource.metrics}
|
||||
allowAddItem
|
||||
onChange={this.onDatasourcePropChange.bind(this, 'metrics')}
|
||||
itemGenerator={() => ({
|
||||
|
Loading…
Reference in New Issue
Block a user