Skip to content

Commit 89d5cee

Browse files
committed
fix(wallet-gateway-remote): updates to creating a party in the wallet gateway
- Show loading indicator on submissionn - update language. 'Add' -> "Create" Signed-off-by: Fayi Femi-Balogun <fayimora.femibalogun@digitalasset.com>
1 parent 922271a commit 89d5cee

6 files changed

Lines changed: 56 additions & 19 deletions

File tree

core/wallet-test-utils/src/wallet-gateway.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class WalletGateway {
129129
await (await this.popup()).getByRole('button', { name: 'New' }).click()
130130
await expect(
131131
(await this.popup()).getByRole('heading', {
132-
name: 'Add a new party',
132+
name: 'Create a new party',
133133
})
134134
).toBeVisible({ timeout: 15000 })
135135
await (await this.popup())
@@ -143,7 +143,9 @@ export class WalletGateway {
143143
.getByRole('checkbox', { name: 'Set as primary wallet' })
144144
.check()
145145
}
146-
await (await this.popup()).getByRole('button', { name: 'Add' }).click()
146+
await (await this.popup())
147+
.getByRole('button', { name: 'Create' })
148+
.click()
147149

148150
await this.waitForPartiesPageReady()
149151

core/wallet-ui-components/src/components/login-form.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { customElement, property, state } from 'lit/decorators.js'
66
import './back-link.js'
77
import { BaseElement } from '../internal/base-element.js'
88
import { Network, Idp } from '@canton-network/core-wallet-user-rpc-client'
9-
import { toRelPath } from '../routing'
109
import { chevronDownIcon } from '../icons'
1110
import cantonLogo from '../../images/logos/canton-logo.png'
1211

@@ -219,15 +218,6 @@ export class WgLoginForm extends BaseElement {
219218
)
220219
}
221220

222-
private handleBack() {
223-
const event = new LoginBackEvent()
224-
const shouldContinue = this.dispatchEvent(event)
225-
226-
if (shouldContinue) {
227-
window.location.href = toRelPath(this.backHref)
228-
}
229-
}
230-
231221
/** Set a status message on the form (e.g. "Redirecting...") */
232222
setMessage(message: string, type: 'error' | 'info') {
233223
this.message = message

core/wallet-ui-components/src/components/wallet-create-form.ts

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export class WgWalletCreateForm extends BaseElement {
2323
@property({ type: Array }) networkIds: string[] = []
2424
@property({ type: Boolean }) loading = false
2525
@property({ type: String }) submitLabel = 'Add'
26+
@property({ type: String }) loadingLabel = 'Adding...'
27+
@property({ type: String }) loadingMessage =
28+
'Creating party, please wait...'
2629

2730
@query('#party-id-hint') accessor partyHintInput: HTMLInputElement | null =
2831
null
@@ -130,12 +133,31 @@ export class WgWalletCreateForm extends BaseElement {
130133
font-size: var(--wg-font-size-sm);
131134
font-weight: var(--wg-font-weight-medium);
132135
}
136+
137+
.submit-wrap {
138+
gap: var(--wg-space-3);
139+
}
140+
141+
.submit-button {
142+
min-height: 44px;
143+
}
144+
145+
.loading-message {
146+
margin: 0;
147+
color: var(--wg-text-secondary);
148+
font-size: var(--wg-font-size-sm);
149+
text-align: center;
150+
}
133151
`,
134152
]
135153

136154
private onSubmit(event: Event) {
137155
event.preventDefault()
138156

157+
if (this.loading) {
158+
return
159+
}
160+
139161
const partyHint = this.partyHintInput?.value || ''
140162
const signingProviderId = this.signingProviderSelect?.value || ''
141163
const primary = this.primaryCheckbox?.checked || false
@@ -156,7 +178,11 @@ export class WgWalletCreateForm extends BaseElement {
156178

157179
protected render() {
158180
return html`
159-
<form class="d-flex flex-column h-100" @submit=${this.onSubmit}>
181+
<form
182+
class="d-flex flex-column h-100"
183+
aria-busy=${this.loading ? 'true' : 'false'}
184+
@submit=${this.onSubmit}
185+
>
160186
<div class="form-fields d-flex flex-column">
161187
<div class="field-group d-flex flex-column">
162188
<label
@@ -220,14 +246,30 @@ export class WgWalletCreateForm extends BaseElement {
220246
</div>
221247
</div>
222248
223-
<div class="mt-auto pt-3">
249+
<div class="submit-wrap mt-auto pt-3 d-flex flex-column">
224250
<button
225-
class="btn btn-primary rounded-pill w-100"
251+
class="submit-button btn btn-primary rounded-pill w-100 d-inline-flex align-items-center justify-content-center gap-2"
226252
?disabled=${this.loading}
227253
type="submit"
228254
>
229-
${this.submitLabel}
255+
${this.loading
256+
? html`<span
257+
class="spinner-border spinner-border-sm"
258+
aria-hidden="true"
259+
></span>`
260+
: null}
261+
${this.loading ? this.loadingLabel : this.submitLabel}
230262
</button>
263+
264+
${this.loading
265+
? html`<p
266+
class="loading-message"
267+
role="status"
268+
aria-live="polite"
269+
>
270+
${this.loadingMessage}
271+
</p>`
272+
: null}
231273
</div>
232274
</form>
233275
`

wallet-gateway/remote/src/web/frontend/parties/add/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Wallet Gateway - Add Party</title>
6+
<title>Wallet Gateway - Create Party</title>
77
<script type="module" src="./index.ts"></script>
88
</head>
99
<body>

wallet-gateway/remote/src/web/frontend/parties/add/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class UserUiAddParty extends BaseElement {
103103
protected render() {
104104
return html`
105105
<div class="page-header">
106-
<h1 class="h4 fw-semibold mb-0">Add a new party</h1>
106+
<h1 class="h4 fw-semibold mb-0">Create a new party</h1>
107107
<button
108108
class="btn btn-link btn-sm text-body text-decoration-none p-0 d-inline-flex align-items-center gap-1"
109109
type="button"
@@ -118,6 +118,9 @@ export class UserUiAddParty extends BaseElement {
118118
<wg-wallet-create-form
119119
.signingProviders=${this.signingProviders}
120120
.networkIds=${this.networkIds}
121+
.submitLabel=${'Create party'}
122+
.loadingLabel=${'Creating party...'}
123+
.loadingMessage=${'Creating party, please wait...'}
121124
?loading=${this.loading}
122125
@wallet-create=${this.onCreateParty}
123126
></wg-wallet-create-form>

wallet-gateway/remote/src/web/frontend/parties/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export class UserUiParties extends BaseElement {
174174
if (createdParam === WALLET_CREATION_STATUS_CODE.WALLET_ALLOCATED) {
175175
showToast(
176176
'Party created',
177-
'Your new party has been added successfully.',
177+
'Your new party has been created successfully.',
178178
'success'
179179
)
180180
} else if (

0 commit comments

Comments
 (0)