Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model overview: disable confirm button when no changes were made #1509

Merged
merged 6 commits into from
Jun 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ export class FeatureConfigurationFlyout extends React.Component<
this.state = {
items: [],
newlySelectedFeatures: this.props.selectedFeatures,
newNumberOfContinuousFeatureBins: this.props.numberOfContinuousFeatureBins
newNumberOfContinuousFeatureBins: {
...this.props.numberOfContinuousFeatureBins
}
};
this.updateSelection();
}
Expand All @@ -98,7 +100,12 @@ export class FeatureConfigurationFlyout extends React.Component<
// At other times we can't update with props since they may be outdated compared to the state.
if (this.props.isOpen && !prevProps.isOpen) {
this.setState(
{ newlySelectedFeatures: this.props.selectedFeatures },
{
newlySelectedFeatures: this.props.selectedFeatures,
newNumberOfContinuousFeatureBins: {
...this.props.numberOfContinuousFeatureBins
}
},
() => {
this.updateSelection();
}
Expand Down Expand Up @@ -181,6 +188,25 @@ export class FeatureConfigurationFlyout extends React.Component<

private onRenderFooterContent = () => {
const tooManyFeaturesSelected = this._selection.getSelectedCount() > 2;
// check that feature selection has not changed
const featureSelectionChanged =
this.props.selectedFeatures.length !==
this.state.newlySelectedFeatures.length ||
this.props.selectedFeatures.some(
(feature, featureIndex) =>
this.state.newlySelectedFeatures[featureIndex] !== feature
);
// check that number of continuous feature bins for the selected features has not changed
const continuousFeatureBinningChanged =
this.state.newlySelectedFeatures.some((_, featureIndex) => {
const newNumberOfBins =
this.state.newNumberOfContinuousFeatureBins[featureIndex] ??
defaultNumberOfContinuousFeatureBins;
const prevNumberOfBins =
this.props.numberOfContinuousFeatureBins[featureIndex] ??
defaultNumberOfContinuousFeatureBins;
return newNumberOfBins !== prevNumberOfBins;
});
return (
<Stack tokens={{ childrenGap: "10px" }}>
{tooManyFeaturesSelected && (
Expand All @@ -195,7 +221,10 @@ export class FeatureConfigurationFlyout extends React.Component<
<PrimaryButton
onClick={this.onConfirm}
text={localization.ModelAssessment.ModelOverview.chartConfigConfirm}
disabled={tooManyFeaturesSelected}
disabled={
tooManyFeaturesSelected ||
(!featureSelectionChanged && !continuousFeatureBinningChanged)
}
/>
<DefaultButton
onClick={this.props.onDismissFlyout}
Expand Down