From d09dd8ddc6735a232a4365a0ac507e33dcc5545b Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 8 Dec 2018 13:29:53 +0200 Subject: [PATCH] Highlight edited fields --- .../src/components/PreferenceTable.js | 34 +++++++++++-------- .../src/pages/dashboard/BaseMainView.js | 2 +- .../frontend/src/pages/dashboard/Client.js | 30 +++++++++------- .../frontend/src/pages/dashboard/Instance.js | 9 +++-- .../frontend/src/pages/dashboard/index.js | 12 ++++--- .../src/style/lib/preferencetable.sass | 5 +++ 6 files changed, 56 insertions(+), 36 deletions(-) diff --git a/maubot/management/frontend/src/components/PreferenceTable.js b/maubot/management/frontend/src/components/PreferenceTable.js index 92dc3ce..ee10726 100644 --- a/maubot/management/frontend/src/components/PreferenceTable.js +++ b/maubot/management/frontend/src/components/PreferenceTable.js @@ -34,28 +34,32 @@ export const PrefTable = ({ children, wrapperClass }) => { ) } -export const PrefRow = ({ name, fullWidth = false, labelFor = undefined, children }) => ( -
- -
{children}
-
-) +export const PrefRow = + ({ name, fullWidth = false, labelFor = undefined, changed = false, children }) => ( +
+ +
{children}
+
+ ) -export const PrefInput = ({ rowName, fullWidth = false, ...args }) => ( - - +export const PrefInput = ({ rowName, value, origValue, fullWidth = false, ...args }) => ( + + ) -export const PrefSwitch = ({ rowName, fullWidth = false, ...args }) => ( - - +export const PrefSwitch = ({ rowName, active, origActive, fullWidth = false, ...args }) => ( + + ) -export const PrefSelect = ({ rowName, fullWidth = false, ...args }) => ( - - ) diff --git a/maubot/management/frontend/src/pages/dashboard/BaseMainView.js b/maubot/management/frontend/src/pages/dashboard/BaseMainView.js index 2ad72b1..7a8ba47 100644 --- a/maubot/management/frontend/src/pages/dashboard/BaseMainView.js +++ b/maubot/management/frontend/src/pages/dashboard/BaseMainView.js @@ -34,7 +34,7 @@ class BaseMainView extends Component { } get isNew() { - return !this.props.entry + return !this.props.entry.id } inputChange = event => { diff --git a/maubot/management/frontend/src/pages/dashboard/Client.js b/maubot/management/frontend/src/pages/dashboard/Client.js index c4ed60d..5d965d4 100644 --- a/maubot/management/frontend/src/pages/dashboard/Client.js +++ b/maubot/management/frontend/src/pages/dashboard/Client.js @@ -157,25 +157,31 @@ class Client extends BaseMainView { renderPreferences = () => ( + value={this.state.homeserver} origValue={this.props.entry.homeserver} + placeholder="https://example.com" onChange={this.inputChange}/> - + - + this.setState({ sync })}/> - this.setState({ autojoin })}/> - this.setState({ enabled, started: enabled && this.state.started, diff --git a/maubot/management/frontend/src/pages/dashboard/Instance.js b/maubot/management/frontend/src/pages/dashboard/Instance.js index d89cda0..83ceed5 100644 --- a/maubot/management/frontend/src/pages/dashboard/Instance.js +++ b/maubot/management/frontend/src/pages/dashboard/Instance.js @@ -138,15 +138,18 @@ class Instance extends BaseMainView { - this.setState({ enabled })}/> - this.setState({ started })}/> this.setState({ primary_user: id })}/> this.setState({ type: id })}/> {!this.isNew && diff --git a/maubot/management/frontend/src/pages/dashboard/index.js b/maubot/management/frontend/src/pages/dashboard/index.js index c593bd0..4aabe92 100644 --- a/maubot/management/frontend/src/pages/dashboard/index.js +++ b/maubot/management/frontend/src/pages/dashboard/index.js @@ -191,11 +191,13 @@ class Dashboard extends Component { }/> this.add("instances", newEntry)} - ctx={this.state}/>}/> - this.add("clients", newEntry)}/>}/> - this.add("plugins", newEntry)}/>}/> + entry={{}} ctx={this.state}/>}/> + + + this.add("clients", newEntry)}/>}/> + + + this.add("plugins", newEntry)}/>}/> this.renderView("instances", Instance, match.params.id)}/> diff --git a/maubot/management/frontend/src/style/lib/preferencetable.sass b/maubot/management/frontend/src/style/lib/preferencetable.sass index c72dff1..35b3ab5 100644 --- a/maubot/management/frontend/src/style/lib/preferencetable.sass +++ b/maubot/management/frontend/src/style/lib/preferencetable.sass @@ -32,6 +32,11 @@ &.full-width width: 100% + &.changed > label + font-weight: bold + &:after + content: "*" + > label, > .value display: block width: 100%