Skip to content

Commit d2228bf

Browse files
committed
Add button for accessing Quick Connect directly from tokens view
1 parent c14feeb commit d2228bf

4 files changed

Lines changed: 72 additions & 44 deletions

File tree

src/app/components/token/token.component.html

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
aria-hidden="true"
3434
>
3535
</mat-icon>
36-
<span>Quick connect pending</span>
36+
<span>Quick Connect pending</span>
3737
<mat-progress-spinner
3838
diameter="24"
3939
mode="indeterminate"
@@ -86,9 +86,7 @@
8686
panelClass="mat-select-panel--dark"
8787
>
8888
</app-token-network-selector>
89-
<ng-container
90-
*ngIf="!isAllNetworksView && (!onMainnet || openChannels > 0)"
91-
>
89+
<ng-container *ngIf="!isAllNetworksView">
9290
<button
9391
class="options-button"
9492
mat-icon-button
@@ -104,26 +102,25 @@
104102
[overlapTrigger]="true"
105103
xPosition="before"
106104
>
105+
<ng-container *ngIf="!onMainnet">
106+
<button mat-menu-item (click)="mint()" id="mint">
107+
Mint
108+
</button>
109+
<div class="options__divider"></div>
110+
</ng-container>
107111
<button
108-
*ngIf="!onMainnet"
109-
mat-menu-item
110-
(click)="mint()"
111-
id="mint"
112-
>
113-
Mint
114-
</button>
115-
<div
116-
*ngIf="!onMainnet && openChannels > 0"
117-
class="options__divider"
118-
></div>
119-
<button
120-
*ngIf="openChannels > 0"
121112
mat-menu-item
122-
(click)="leaveNetwork()"
123-
id="leave"
113+
(click)="openQuickConnect()"
114+
id="quick-connect"
124115
>
125-
Leave network
116+
Quick Connect
126117
</button>
118+
<ng-container *ngIf="openChannels > 0">
119+
<div class="options__divider"></div>
120+
<button mat-menu-item (click)="leaveNetwork()" id="leave">
121+
Leave network
122+
</button>
123+
</ng-container>
127124
</mat-menu>
128125
</ng-container>
129126
</div>

src/app/components/token/token.component.spec.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ describe('TokenComponent', () => {
201201
const confirmationPayload: ConfirmationDialogPayload = {
202202
title: 'No open channels',
203203
message:
204-
'Do you want to use quick connect to automatically open channels?',
204+
'Do you want to use Quick Connect to automatically open channels?',
205205
};
206206
const quickConnectPayload: QuickConnectDialogPayload = {
207207
token: undefined,
@@ -323,7 +323,7 @@ describe('TokenComponent', () => {
323323

324324
const confirmationPayload: ConfirmationDialogPayload = {
325325
title: `No open ${unconnectedToken.symbol} channels`,
326-
message: `Do you want to use quick connect to automatically open ${unconnectedToken.symbol} channels?`,
326+
message: `Do you want to use Quick Connect to automatically open ${unconnectedToken.symbol} channels?`,
327327
};
328328
const quickConnectPayload: QuickConnectDialogPayload = {
329329
token: unconnectedToken,
@@ -457,5 +457,36 @@ describe('TokenComponent', () => {
457457
expect(dialogSpy).toHaveBeenCalledTimes(1);
458458
expect(leaveSpy).toHaveBeenCalledTimes(0);
459459
});
460+
461+
it('should open quick connect dialog', () => {
462+
selectedTokenService.setToken(unconnectedToken);
463+
fixture.detectChanges();
464+
465+
clickElement(fixture.debugElement, '#options');
466+
fixture.detectChanges();
467+
468+
const dialogSpy = spyOn(dialog, 'open').and.callThrough();
469+
const dialogResult: QuickConnectDialogResult = {
470+
token: unconnectedToken,
471+
connectionChoices: createConnectionChoices(),
472+
};
473+
spyOn(dialog, 'returns').and.returnValues(true, dialogResult);
474+
spyOn(raidenService, 'openBatchOfChannels').and.returnValue(
475+
of(null)
476+
);
477+
clickElement(fixture.debugElement, '#quick-connect');
478+
479+
const payload: QuickConnectDialogPayload = {
480+
token: unconnectedToken,
481+
};
482+
expect(dialogSpy).toHaveBeenCalledTimes(1);
483+
expect(dialogSpy).toHaveBeenCalledWith(
484+
QuickConnectDialogComponent,
485+
{
486+
data: payload,
487+
width: '400px',
488+
}
489+
);
490+
});
460491
});
461492
});

src/app/components/token/token.component.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -191,25 +191,7 @@ export class TokenComponent implements OnInit, OnDestroy {
191191
});
192192
}
193193

194-
private askForQuickConnect() {
195-
const tokenSymbol = this.selectedToken?.symbol ?? '';
196-
const payload: ConfirmationDialogPayload = {
197-
title: `No open ${tokenSymbol} channels`,
198-
message: `Do you want to use quick connect to automatically open ${tokenSymbol} channels?`,
199-
};
200-
201-
const dialog = this.dialog.open(ConfirmationDialogComponent, {
202-
data: payload,
203-
});
204-
205-
dialog.afterClosed().subscribe((result) => {
206-
if (result) {
207-
this.openQuickConnect();
208-
}
209-
});
210-
}
211-
212-
private openQuickConnect() {
194+
openQuickConnect() {
213195
const payload: QuickConnectDialogPayload = {
214196
token: this.selectedToken,
215197
};
@@ -239,4 +221,22 @@ export class TokenComponent implements OnInit, OnDestroy {
239221
this.channelPollingService.refresh();
240222
});
241223
}
224+
225+
private askForQuickConnect() {
226+
const tokenSymbol = this.selectedToken?.symbol ?? '';
227+
const payload: ConfirmationDialogPayload = {
228+
title: `No open ${tokenSymbol} channels`,
229+
message: `Do you want to use Quick Connect to automatically open ${tokenSymbol} channels?`,
230+
};
231+
232+
const dialog = this.dialog.open(ConfirmationDialogComponent, {
233+
data: payload,
234+
});
235+
236+
dialog.afterClosed().subscribe((result) => {
237+
if (result) {
238+
this.openQuickConnect();
239+
}
240+
});
241+
}
242242
}

src/app/services/raiden.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ export class RaidenService {
658658
tap(() => {
659659
this.quickConnectPending[token.address] = true;
660660
const message: UiMessage = {
661-
title: 'Quick connect',
661+
title: 'Quick Connect',
662662
description: `${connectionChoices.length} channels on ${token.symbol}`,
663663
icon: 'thunderbolt',
664664
userToken: token,
@@ -690,7 +690,7 @@ export class RaidenService {
690690
),
691691
tap(() => {
692692
const message: UiMessage = {
693-
title: 'Quick connect successful',
693+
title: 'Quick Connect successful',
694694
description: `${
695695
connectionChoices.length - errorCount
696696
} channels on ${token.symbol}`,
@@ -701,7 +701,7 @@ export class RaidenService {
701701
}),
702702
catchError((error) => {
703703
this.notificationService.addErrorNotification({
704-
title: 'Quick connect failed',
704+
title: 'Quick Connect failed',
705705
description: error,
706706
icon: 'error-mark',
707707
userToken: token,

0 commit comments

Comments
 (0)