Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugins/login-resources/src/components/Form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@
export let withProviders: boolean = false
export let subtitle: string | undefined = undefined
export let signUpDisabled = false
export let isLoading: boolean = false

const validate = makeSequential(async function validateAsync (language: string): Promise<boolean> {
if (ignoreInitialValidation) return true
if (ignoreInitialValidation || isLoading) return true

for (const field of fields) {
const v = object[field.name]
const f = field
if (!f.optional && (!v || v.trim() === '')) {

Check warning on line 56 in plugins/login-resources/src/components/Form.svelte

View workflow job for this annotation

GitHub Actions / formatting

Unexpected nullable boolean value in conditional. Please handle the nullish case explicitly
status = new Status(Severity.INFO, login.status.RequiredField, {
field: await translate(field.i18n, {}, language)
})
Expand Down
33 changes: 20 additions & 13 deletions plugins/login-resources/src/components/LoginPasswordForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,30 @@
}

let status = OK
let isLoading = false

const action = {
i18n: login.string.LogIn,
func: async () => {
status = new Status(Severity.INFO, login.status.ConnectingToServer, {})
const [loginStatus, result] = await doLogin(object.username, object.password)
status = loginStatus
isLoading = true
try {
status = new Status(Severity.INFO, login.status.ConnectingToServer, {})
const [loginStatus, result] = await doLogin(object.username, object.password)
status = loginStatus

if (onLogin !== undefined) {
void onLogin(result, status)
} else {
await doLoginNavigate(
result,
(st) => {
status = st
},
navigateUrl
)
if (onLogin !== undefined) {
void onLogin(result, status)
} else {
await doLoginNavigate(
result,
(st) => {
status = st
},
navigateUrl
)
}
} finally {
isLoading = false
}
}
}
Expand All @@ -79,6 +85,7 @@
{object}
{action}
{signUpDisabled}
{isLoading}
bottomActions={[recoveryAction]}
ignoreInitialValidation
withProviders
Expand Down
4 changes: 4 additions & 0 deletions qms-tests/sanity/tests/model/login-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export class LoginPage {
async login (email: string, password: string): Promise<void> {
await this.inputEmail.fill(email)
await this.inputPassword.fill(password)

// Wait for form validation to complete
await this.page.waitForTimeout(1000)

expect(await this.buttonLogin.isEnabled()).toBe(true)
await this.buttonLogin.click()
}
Expand Down
Loading