From bdb63722357cd123f53a9b68ce88fe53f6c77cb4 Mon Sep 17 00:00:00 2001 From: foxbit19 Date: Sat, 19 Oct 2019 09:15:10 +0200 Subject: [PATCH] Add refresh button to messages list Fixes #171 --- ui/src/application/Applications.tsx | 15 +++++++++++---- ui/src/client/Clients.tsx | 13 ++++++++++--- ui/src/common/DefaultPage.tsx | 29 +++-------------------------- ui/src/common/LoadingSpinner.tsx | 2 +- ui/src/message/Messages.tsx | 26 ++++++++++++++++++++++---- ui/src/message/MessagesStore.ts | 6 ++++++ ui/src/plugin/PluginDetailView.tsx | 2 +- ui/src/plugin/Plugins.tsx | 2 +- ui/src/user/Login.tsx | 2 +- ui/src/user/Users.tsx | 13 ++++++++++--- 10 files changed, 66 insertions(+), 44 deletions(-) diff --git a/ui/src/application/Applications.tsx b/ui/src/application/Applications.tsx index bbb0ab9..6172c35 100644 --- a/ui/src/application/Applications.tsx +++ b/ui/src/application/Applications.tsx @@ -13,6 +13,7 @@ import CloudUpload from '@material-ui/icons/CloudUpload'; import React, {ChangeEvent, Component, SFC} from 'react'; import ConfirmDialog from '../common/ConfirmDialog'; import DefaultPage from '../common/DefaultPage'; +import Button from '@material-ui/core/Button'; import ToggleVisibility from '../common/ToggleVisibility'; import AddApplicationDialog from './AddApplicationDialog'; import {observer} from 'mobx-react'; @@ -47,10 +48,16 @@ class Applications extends Component> { return ( (this.createDialog = true)}> + rightControl={ + + } + maxWidth={1000}> diff --git a/ui/src/client/Clients.tsx b/ui/src/client/Clients.tsx index aef9c3e..6ace49e 100644 --- a/ui/src/client/Clients.tsx +++ b/ui/src/client/Clients.tsx @@ -11,6 +11,7 @@ import Edit from '@material-ui/icons/Edit'; import React, {Component, SFC} from 'react'; import ConfirmDialog from '../common/ConfirmDialog'; import DefaultPage from '../common/DefaultPage'; +import Button from '@material-ui/core/Button'; import ToggleVisibility from '../common/ToggleVisibility'; import AddClientDialog from './AddClientDialog'; import UpdateDialog from './UpdateClientDialog'; @@ -42,9 +43,15 @@ class Clients extends Component> { return ( (this.showDialog = true)}> + rightControl={ + + }>
diff --git a/ui/src/common/DefaultPage.tsx b/ui/src/common/DefaultPage.tsx index 63e6203..f9586f1 100644 --- a/ui/src/common/DefaultPage.tsx +++ b/ui/src/common/DefaultPage.tsx @@ -1,44 +1,21 @@ -import Button from '@material-ui/core/Button'; import Grid from '@material-ui/core/Grid'; import Typography from '@material-ui/core/Typography'; import React, {SFC} from 'react'; interface IProps { title: string; - buttonTitle?: string; - fButton?: VoidFunction; - buttonDisabled?: boolean; + rightControl?: React.ReactNode; maxWidth?: number; - hideButton?: boolean; - buttonId?: string; } -const DefaultPage: SFC = ({ - title, - buttonTitle, - buttonId, - fButton, - buttonDisabled = false, - maxWidth = 700, - hideButton, - children, -}) => ( +const DefaultPage: SFC = ({title, rightControl, maxWidth = 700, children}) => (
{title} - {hideButton ? null : ( - - )} + {rightControl} {children} diff --git a/ui/src/common/LoadingSpinner.tsx b/ui/src/common/LoadingSpinner.tsx index ab467a8..3f0df56 100644 --- a/ui/src/common/LoadingSpinner.tsx +++ b/ui/src/common/LoadingSpinner.tsx @@ -5,7 +5,7 @@ import DefaultPage from './DefaultPage'; export default function LoadingSpinner() { return ( - + diff --git a/ui/src/message/Messages.tsx b/ui/src/message/Messages.tsx index 545a2c8..3f8d638 100644 --- a/ui/src/message/Messages.tsx +++ b/ui/src/message/Messages.tsx @@ -4,6 +4,7 @@ import Typography from '@material-ui/core/Typography'; import React, {Component} from 'react'; import {RouteComponentProps} from 'react-router'; import DefaultPage from '../common/DefaultPage'; +import Button from '@material-ui/core/Button'; import Message from './Message'; import {observer} from 'mobx-react'; import {inject, Stores} from '../inject'; @@ -61,10 +62,27 @@ class Messages extends Component, return ( messagesStore.removeByApp(appId)} - buttonDisabled={!hasMessages}> + rightControl={ +
+ + +
+ }> {hasMessages ? (
{ + this.clearAll(); + this.loadMore(appId); + }; + public exists = (id: number) => this.stateOf(id).loaded; private removeFromList(messages: IMessage[], messageToDelete: IMessage): false | number { diff --git a/ui/src/plugin/PluginDetailView.tsx b/ui/src/plugin/PluginDetailView.tsx index 30f2fb6..6843bcb 100644 --- a/ui/src/plugin/PluginDetailView.tsx +++ b/ui/src/plugin/PluginDetailView.tsx @@ -70,7 +70,7 @@ class PluginDetailView extends Component, IState> const pluginInfo = this.pluginInfo(); const {name, capabilities} = pluginInfo; return ( - + diff --git a/ui/src/plugin/Plugins.tsx b/ui/src/plugin/Plugins.tsx index f493e45..45a860e 100644 --- a/ui/src/plugin/Plugins.tsx +++ b/ui/src/plugin/Plugins.tsx @@ -25,7 +25,7 @@ class Plugins extends Component> { } = this; const plugins = pluginStore.getItems(); return ( - +
diff --git a/ui/src/user/Login.tsx b/ui/src/user/Login.tsx index 1a0114e..cb20ad4 100644 --- a/ui/src/user/Login.tsx +++ b/ui/src/user/Login.tsx @@ -18,7 +18,7 @@ class Login extends Component> { public render() { const {username, password} = this; return ( - +
diff --git a/ui/src/user/Users.tsx b/ui/src/user/Users.tsx index b1ecd95..899569f 100644 --- a/ui/src/user/Users.tsx +++ b/ui/src/user/Users.tsx @@ -12,6 +12,7 @@ import Edit from '@material-ui/icons/Edit'; import React, {Component, SFC} from 'react'; import ConfirmDialog from '../common/ConfirmDialog'; import DefaultPage from '../common/DefaultPage'; +import Button from '@material-ui/core/Button'; import AddEditDialog from './AddEditUserDialog'; import {observer} from 'mobx-react'; import {observable} from 'mobx'; @@ -69,9 +70,15 @@ class Users extends Component & Stores<'userStore'>> { return ( (this.createDialog = true)}> + rightControl={ + + }>