Skip to content

Commit 17b9b52

Browse files
Tert0jmattheis
authored andcommitted
Add delete confirmation dialog
1 parent 0250a48 commit 17b9b52

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

ui/src/message/Messages.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {inject, Stores} from '../inject';
1111
import {observable} from 'mobx';
1212
import ReactInfinite from 'react-infinite';
1313
import {IMessage} from '../types';
14+
import ConfirmDialog from "../common/ConfirmDialog";
1415

1516
type IProps = RouteComponentProps<{id: string}>;
1617

@@ -22,6 +23,8 @@ interface IState {
2223
class Messages extends Component<IProps & Stores<'messagesStore' | 'appStore'>, IState> {
2324
@observable
2425
private heights: Record<string, number> = {};
26+
@observable
27+
private deleteAll = false;
2528

2629
private static appId(props: IProps) {
2730
if (props === undefined) {
@@ -79,7 +82,7 @@ class Messages extends Component<IProps & Stores<'messagesStore' | 'appStore'>,
7982
variant="contained"
8083
disabled={!hasMessages}
8184
color="primary"
82-
onClick={() => messagesStore.removeByApp(appId)}
85+
onClick={() => {this.deleteAll = true}}
8386
>
8487
Delete All
8588
</Button>
@@ -108,6 +111,15 @@ class Messages extends Component<IProps & Stores<'messagesStore' | 'appStore'>,
108111
) : (
109112
this.label('No messages')
110113
)}
114+
115+
{this.deleteAll && (
116+
<ConfirmDialog
117+
title="Confirm Delete"
118+
text={'Delete all messages?'}
119+
fClose={() => (this.deleteAll = false)}
120+
fOnSubmit={() => messagesStore.removeByApp(appId)}
121+
/>
122+
)}
111123
</DefaultPage>
112124
);
113125
}

ui/src/tests/message.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ describe('Messages', () => {
219219
it('deletes all linux messages', async () => {
220220
await navigate('Linux');
221221
await page.click('#delete-all');
222+
await page.waitForSelector(selector.$confirmDialog.selector());
223+
await page.click(selector.$confirmDialog.button('.confirm'));
222224
await page.waitForSelector('#delete-all:disabled');
223225
await expectMessages({
224226
all: [windows3, backup1, windows1],
@@ -250,6 +252,9 @@ describe('Messages', () => {
250252
it('deletes all messages', async () => {
251253
await navigate('All Messages');
252254
await page.click('#delete-all');
255+
await page.waitForSelector(selector.$confirmDialog.selector());
256+
await page.click(selector.$confirmDialog.button('.confirm'));
257+
await page.waitForSelector('#delete-all:disabled');
253258
await expectMessages({
254259
all: [],
255260
windows: [],
@@ -269,6 +274,8 @@ describe('Messages', () => {
269274
it('deletes all backup messages and navigates to all messages', async () => {
270275
await navigate('Backup');
271276
await page.click('#delete-all');
277+
await page.waitForSelector(selector.$confirmDialog.selector());
278+
await page.click(selector.$confirmDialog.button('.confirm'));
272279
await page.waitForSelector('#delete-all:disabled');
273280
await navigate('All Messages');
274281
await createMessage(backup3, backupServerToken);

0 commit comments

Comments
 (0)