Skip to content

Commit bdb6372

Browse files
foxbit19jmattheis
authored andcommitted
Add refresh button to messages list
Fixes #171
1 parent d6055f3 commit bdb6372

File tree

10 files changed

+66
-44
lines changed

10 files changed

+66
-44
lines changed

ui/src/application/Applications.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import CloudUpload from '@material-ui/icons/CloudUpload';
1313
import React, {ChangeEvent, Component, SFC} from 'react';
1414
import ConfirmDialog from '../common/ConfirmDialog';
1515
import DefaultPage from '../common/DefaultPage';
16+
import Button from '@material-ui/core/Button';
1617
import ToggleVisibility from '../common/ToggleVisibility';
1718
import AddApplicationDialog from './AddApplicationDialog';
1819
import {observer} from 'mobx-react';
@@ -47,10 +48,16 @@ class Applications extends Component<Stores<'appStore'>> {
4748
return (
4849
<DefaultPage
4950
title="Applications"
50-
buttonTitle="Create Application"
51-
buttonId="create-app"
52-
maxWidth={1000}
53-
fButton={() => (this.createDialog = true)}>
51+
rightControl={
52+
<Button
53+
id="create-app"
54+
variant="contained"
55+
color="primary"
56+
onClick={() => (this.createDialog = true)}>
57+
Create Application
58+
</Button>
59+
}
60+
maxWidth={1000}>
5461
<Grid item xs={12}>
5562
<Paper elevation={6}>
5663
<Table id="app-table">

ui/src/client/Clients.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Edit from '@material-ui/icons/Edit';
1111
import React, {Component, SFC} from 'react';
1212
import ConfirmDialog from '../common/ConfirmDialog';
1313
import DefaultPage from '../common/DefaultPage';
14+
import Button from '@material-ui/core/Button';
1415
import ToggleVisibility from '../common/ToggleVisibility';
1516
import AddClientDialog from './AddClientDialog';
1617
import UpdateDialog from './UpdateClientDialog';
@@ -42,9 +43,15 @@ class Clients extends Component<Stores<'clientStore'>> {
4243
return (
4344
<DefaultPage
4445
title="Clients"
45-
buttonTitle="Create Client"
46-
buttonId="create-client"
47-
fButton={() => (this.showDialog = true)}>
46+
rightControl={
47+
<Button
48+
id="create-client"
49+
variant="contained"
50+
color="primary"
51+
onClick={() => (this.showDialog = true)}>
52+
Create Client
53+
</Button>
54+
}>
4855
<Grid item xs={12}>
4956
<Paper elevation={6}>
5057
<Table id="client-table">

ui/src/common/DefaultPage.tsx

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,21 @@
1-
import Button from '@material-ui/core/Button';
21
import Grid from '@material-ui/core/Grid';
32
import Typography from '@material-ui/core/Typography';
43
import React, {SFC} from 'react';
54

65
interface IProps {
76
title: string;
8-
buttonTitle?: string;
9-
fButton?: VoidFunction;
10-
buttonDisabled?: boolean;
7+
rightControl?: React.ReactNode;
118
maxWidth?: number;
12-
hideButton?: boolean;
13-
buttonId?: string;
149
}
1510

16-
const DefaultPage: SFC<IProps> = ({
17-
title,
18-
buttonTitle,
19-
buttonId,
20-
fButton,
21-
buttonDisabled = false,
22-
maxWidth = 700,
23-
hideButton,
24-
children,
25-
}) => (
11+
const DefaultPage: SFC<IProps> = ({title, rightControl, maxWidth = 700, children}) => (
2612
<main style={{margin: '0 auto', maxWidth}}>
2713
<Grid container spacing={4}>
2814
<Grid item xs={12} style={{display: 'flex'}}>
2915
<Typography variant="h4" style={{flex: 1}}>
3016
{title}
3117
</Typography>
32-
{hideButton ? null : (
33-
<Button
34-
id={buttonId}
35-
variant="contained"
36-
color="primary"
37-
disabled={buttonDisabled}
38-
onClick={fButton}>
39-
{buttonTitle}
40-
</Button>
41-
)}
18+
{rightControl}
4219
</Grid>
4320
{children}
4421
</Grid>

ui/src/common/LoadingSpinner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import DefaultPage from './DefaultPage';
55

66
export default function LoadingSpinner() {
77
return (
8-
<DefaultPage title="" maxWidth={250} hideButton={true}>
8+
<DefaultPage title="" maxWidth={250}>
99
<Grid item xs={12} style={{textAlign: 'center'}}>
1010
<CircularProgress size={150} />
1111
</Grid>

ui/src/message/Messages.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Typography from '@material-ui/core/Typography';
44
import React, {Component} from 'react';
55
import {RouteComponentProps} from 'react-router';
66
import DefaultPage from '../common/DefaultPage';
7+
import Button from '@material-ui/core/Button';
78
import Message from './Message';
89
import {observer} from 'mobx-react';
910
import {inject, Stores} from '../inject';
@@ -61,10 +62,27 @@ class Messages extends Component<IProps & Stores<'messagesStore' | 'appStore'>,
6162
return (
6263
<DefaultPage
6364
title={name}
64-
buttonTitle="Delete All"
65-
buttonId="delete-all"
66-
fButton={() => messagesStore.removeByApp(appId)}
67-
buttonDisabled={!hasMessages}>
65+
rightControl={
66+
<div>
67+
<Button
68+
id="refresh-all"
69+
variant="contained"
70+
disabled={!hasMessages}
71+
color="primary"
72+
onClick={() => messagesStore.refreshByApp(appId)}
73+
style={{marginRight: 5}}>
74+
Refresh
75+
</Button>
76+
<Button
77+
id="delete-all"
78+
variant="contained"
79+
disabled={!hasMessages}
80+
color="primary"
81+
onClick={() => messagesStore.removeByApp(appId)}>
82+
Delete All
83+
</Button>
84+
</div>
85+
}>
6886
{hasMessages ? (
6987
<div style={{width: '100%'}} id="messages">
7088
<ReactInfinite

ui/src/message/MessagesStore.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ export class MessagesStore {
100100
this.createEmptyStatesForApps(this.appStore.getItems());
101101
};
102102

103+
@action
104+
public refreshByApp = async (appId: number) => {
105+
this.clearAll();
106+
this.loadMore(appId);
107+
};
108+
103109
public exists = (id: number) => this.stateOf(id).loaded;
104110

105111
private removeFromList(messages: IMessage[], messageToDelete: IMessage): false | number {

ui/src/plugin/PluginDetailView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class PluginDetailView extends Component<IProps & Stores<'pluginStore'>, IState>
7070
const pluginInfo = this.pluginInfo();
7171
const {name, capabilities} = pluginInfo;
7272
return (
73-
<DefaultPage title={name} hideButton={true} maxWidth={1000}>
73+
<DefaultPage title={name} maxWidth={1000}>
7474
<PanelWrapper name={'Plugin Info'} icon={Info}>
7575
<PluginInfo pluginInfo={pluginInfo} />
7676
</PanelWrapper>

ui/src/plugin/Plugins.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Plugins extends Component<Stores<'pluginStore'>> {
2525
} = this;
2626
const plugins = pluginStore.getItems();
2727
return (
28-
<DefaultPage title="Plugins" hideButton={true} maxWidth={1000}>
28+
<DefaultPage title="Plugins" maxWidth={1000}>
2929
<Grid item xs={12}>
3030
<Paper elevation={6}>
3131
<Table id="plugin-table">

ui/src/user/Login.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Login extends Component<Stores<'currentUser'>> {
1818
public render() {
1919
const {username, password} = this;
2020
return (
21-
<DefaultPage title="Login" maxWidth={250} hideButton={true}>
21+
<DefaultPage title="Login" maxWidth={250}>
2222
<Grid item xs={12} style={{textAlign: 'center'}}>
2323
<Container>
2424
<form onSubmit={this.preventDefault} id="login-form">

ui/src/user/Users.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Edit from '@material-ui/icons/Edit';
1212
import React, {Component, SFC} from 'react';
1313
import ConfirmDialog from '../common/ConfirmDialog';
1414
import DefaultPage from '../common/DefaultPage';
15+
import Button from '@material-ui/core/Button';
1516
import AddEditDialog from './AddEditUserDialog';
1617
import {observer} from 'mobx-react';
1718
import {observable} from 'mobx';
@@ -69,9 +70,15 @@ class Users extends Component<WithStyles<'wrapper'> & Stores<'userStore'>> {
6970
return (
7071
<DefaultPage
7172
title="Users"
72-
buttonTitle="Create User"
73-
buttonId="create-user"
74-
fButton={() => (this.createDialog = true)}>
73+
rightControl={
74+
<Button
75+
id="create-user"
76+
variant="contained"
77+
color="primary"
78+
onClick={() => (this.createDialog = true)}>
79+
Create User
80+
</Button>
81+
}>
7582
<Grid item xs={12}>
7683
<Paper elevation={6}>
7784
<Table id="user-table">

0 commit comments

Comments
 (0)