mirror of
https://github.com/apache/superset.git
synced 2024-09-18 19:49:37 -04:00
fix(explore): Enable saving metric after changing title (#23020)
This commit is contained in:
parent
493181c977
commit
98bf878d6e
@ -162,6 +162,16 @@ test('Clicking on "Save" should call onChange and onClose for new metric', () =>
|
|||||||
expect(props.onClose).toBeCalledTimes(1);
|
expect(props.onClose).toBeCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Clicking on "Save" should call onChange and onClose for new title', () => {
|
||||||
|
const props = createProps();
|
||||||
|
render(<AdhocMetricEditPopover {...props} isLabelModified />);
|
||||||
|
expect(props.onChange).toBeCalledTimes(0);
|
||||||
|
expect(props.onClose).toBeCalledTimes(0);
|
||||||
|
userEvent.click(screen.getByRole('button', { name: 'Save' }));
|
||||||
|
expect(props.onChange).toBeCalledTimes(1);
|
||||||
|
expect(props.onClose).toBeCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
test('Should switch to tab:Simple', () => {
|
test('Should switch to tab:Simple', () => {
|
||||||
const props = createProps();
|
const props = createProps();
|
||||||
props.getCurrentTab.mockImplementation(tab => {
|
props.getCurrentTab.mockImplementation(tab => {
|
||||||
|
@ -62,6 +62,7 @@ const propTypes = {
|
|||||||
savedMetric: savedMetricType,
|
savedMetric: savedMetricType,
|
||||||
datasource: PropTypes.object,
|
datasource: PropTypes.object,
|
||||||
isNewMetric: PropTypes.bool,
|
isNewMetric: PropTypes.bool,
|
||||||
|
isLabelModified: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
@ -299,6 +300,7 @@ export default class AdhocMetricEditPopover extends React.PureComponent {
|
|||||||
onResize,
|
onResize,
|
||||||
datasource,
|
datasource,
|
||||||
isNewMetric,
|
isNewMetric,
|
||||||
|
isLabelModified,
|
||||||
...popoverProps
|
...popoverProps
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { adhocMetric, savedMetric } = this.state;
|
const { adhocMetric, savedMetric } = this.state;
|
||||||
@ -345,6 +347,7 @@ export default class AdhocMetricEditPopover extends React.PureComponent {
|
|||||||
|
|
||||||
const stateIsValid = adhocMetric.isValid() || savedMetric?.metric_name;
|
const stateIsValid = adhocMetric.isValid() || savedMetric?.metric_name;
|
||||||
const hasUnsavedChanges =
|
const hasUnsavedChanges =
|
||||||
|
isLabelModified ||
|
||||||
isNewMetric ||
|
isNewMetric ||
|
||||||
!adhocMetric.equals(propsAdhocMetric) ||
|
!adhocMetric.equals(propsAdhocMetric) ||
|
||||||
(!(
|
(!(
|
||||||
|
@ -225,6 +225,10 @@ class AdhocMetricPopoverTrigger extends React.PureComponent<
|
|||||||
getCurrentTab={this.getCurrentTab}
|
getCurrentTab={this.getCurrentTab}
|
||||||
getCurrentLabel={this.getCurrentLabel}
|
getCurrentLabel={this.getCurrentLabel}
|
||||||
isNewMetric={this.props.isNew}
|
isNewMetric={this.props.isNew}
|
||||||
|
isLabelModified={
|
||||||
|
this.state.labelModified &&
|
||||||
|
adhocMetricLabel !== this.state.title.label
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</ExplorePopoverContent>
|
</ExplorePopoverContent>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user