mirror of
https://github.com/apache/superset.git
synced 2024-09-16 10:39:55 -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);
|
||||
});
|
||||
|
||||
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', () => {
|
||||
const props = createProps();
|
||||
props.getCurrentTab.mockImplementation(tab => {
|
||||
|
@ -62,6 +62,7 @@ const propTypes = {
|
||||
savedMetric: savedMetricType,
|
||||
datasource: PropTypes.object,
|
||||
isNewMetric: PropTypes.bool,
|
||||
isLabelModified: PropTypes.bool,
|
||||
};
|
||||
|
||||
const defaultProps = {
|
||||
@ -299,6 +300,7 @@ export default class AdhocMetricEditPopover extends React.PureComponent {
|
||||
onResize,
|
||||
datasource,
|
||||
isNewMetric,
|
||||
isLabelModified,
|
||||
...popoverProps
|
||||
} = this.props;
|
||||
const { adhocMetric, savedMetric } = this.state;
|
||||
@ -345,6 +347,7 @@ export default class AdhocMetricEditPopover extends React.PureComponent {
|
||||
|
||||
const stateIsValid = adhocMetric.isValid() || savedMetric?.metric_name;
|
||||
const hasUnsavedChanges =
|
||||
isLabelModified ||
|
||||
isNewMetric ||
|
||||
!adhocMetric.equals(propsAdhocMetric) ||
|
||||
(!(
|
||||
|
@ -225,6 +225,10 @@ class AdhocMetricPopoverTrigger extends React.PureComponent<
|
||||
getCurrentTab={this.getCurrentTab}
|
||||
getCurrentLabel={this.getCurrentLabel}
|
||||
isNewMetric={this.props.isNew}
|
||||
isLabelModified={
|
||||
this.state.labelModified &&
|
||||
adhocMetricLabel !== this.state.title.label
|
||||
}
|
||||
/>
|
||||
</ExplorePopoverContent>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user