Disable settings "Apply" button when no changes have been made

Summary: It's a bit nicer to be able to see if there are any changes made, and save restarting flipper when nothing has changed.

Reviewed By: passy

Differential Revision: D17738036

fbshipit-source-id: 3d7cdc5be1bf948094c3df54439625e5052a9a2f
This commit is contained in:
John Knox
2019-10-07 08:49:05 -07:00
committed by Facebook Github Bot
parent 8e5b69164a
commit 44ab23557e
3 changed files with 21 additions and 1 deletions

View File

@@ -58,6 +58,7 @@
"@types/invariant": "^2.2.30",
"@types/jest": "^24.0.16",
"@types/lodash.debounce": "^4.0.6",
"@types/lodash.isequal": "^4.5.5",
"@types/react": "^16.8.24",
"@types/react-dom": "^16.8.5",
"@types/react-redux": "^7.1.1",
@@ -123,6 +124,7 @@
"line-replace": "^1.0.2",
"live-plugin-manager": "^0.13.2",
"lodash.debounce": "^4.0.8",
"lodash.isequal": "^4.5.0",
"mkdirp": "^0.5.1",
"node-fetch": "^2.3.0",
"open": "^6.4.0",

View File

@@ -25,6 +25,7 @@ import {flush} from '../utils/persistor';
import {promises as fs} from 'fs';
import {remote} from 'electron';
import path from 'path';
import isEqual from 'lodash.isequal';
const Container = styled(FlexColumn)({
padding: 20,
@@ -158,7 +159,12 @@ class SignInSheet extends Component<Props, State> {
<Button compact padded onClick={this.props.onHide}>
Cancel
</Button>
<Button type="primary" compact padded onClick={this.applyChanges}>
<Button
disabled={isEqual(this.props.settings, this.state.updatedSettings)}
type="primary"
compact
padded
onClick={this.applyChanges}>
Apply and Restart
</Button>
</FlexRow>

View File

@@ -1172,6 +1172,13 @@
dependencies:
"@types/lodash" "*"
"@types/lodash.isequal@^4.5.5":
version "4.5.5"
resolved "https://registry.yarnpkg.com/@types/lodash.isequal/-/lodash.isequal-4.5.5.tgz#4fed1b1b00bef79e305de0352d797e9bb816c8ff"
integrity sha512-4IKbinG7MGP131wRfceK6W4E/Qt3qssEFLF30LnJbjYiSfHGGRU/Io8YxXrZX109ir+iDETC8hw8QsDijukUVg==
dependencies:
"@types/lodash" "*"
"@types/lodash@*":
version "4.14.136"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.136.tgz#413e85089046b865d960c9ff1d400e04c31ab60f"
@@ -5942,6 +5949,11 @@ lodash.debounce@^4.0.8:
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=
lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA=
lodash.isplainobject@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"