diff options
author | skjnldsv <skjnldsv@protonmail.com> | 2025-02-20 16:29:19 +0100 |
---|---|---|
committer | skjnldsv <skjnldsv@protonmail.com> | 2025-02-21 09:54:03 +0100 |
commit | 05f3f2dbb7ca6953f9887fe5e6dd40c16779a073 (patch) | |
tree | be7d933818b33a807b375423929ff95221006d87 /apps | |
parent | 84eaba63a8b5f9eca8ca0985f11d0f93b4168e46 (diff) | |
download | nextcloud-server-05f3f2dbb7ca6953f9887fe5e6dd40c16779a073.tar.gz nextcloud-server-05f3f2dbb7ca6953f9887fe5e6dd40c16779a073.zip |
chore(files_external): add cypress tests for user credentials action
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/src/actions/enterCredentialsAction.ts | 29 | ||||
-rw-r--r-- | apps/files_external/src/views/CredentialsDialog.vue | 2 |
2 files changed, 23 insertions, 8 deletions
diff --git a/apps/files_external/src/actions/enterCredentialsAction.ts b/apps/files_external/src/actions/enterCredentialsAction.ts index e9bbb92444c..580f15ad876 100644 --- a/apps/files_external/src/actions/enterCredentialsAction.ts +++ b/apps/files_external/src/actions/enterCredentialsAction.ts @@ -29,14 +29,20 @@ type CredentialResponse = { } /** + * Set credentials for external storage * - * @param node - * @param login - * @param password + * @param node The node for which to set the credentials + * @param login The username + * @param password The password */ async function setCredentials(node: Node, login: string, password: string): Promise<null|true> { - const configResponse = await axios.put(generateUrl('apps/files_external/userglobalstorages/{id}', node.attributes), { - backendOptions: { user: login, password }, + const configResponse = await axios.request({ + method: 'PUT', + url: generateUrl('apps/files_external/userglobalstorages/{id}', { id: node.attributes.id }), + confirmPassword: PwdConfirmationMode.Strict, + data: { + backendOptions: { user: login, password }, + }, }) as AxiosResponse<StorageConfig> const config = configResponse.data @@ -53,8 +59,10 @@ async function setCredentials(node: Node, login: string, password: string): Prom return true } +export const ACTION_CREDENTIALS_EXTERNAL_STORAGE = 'credentials-external-storage' + export const action = new FileAction({ - id: 'credentials-external-storage', + id: ACTION_CREDENTIALS_EXTERNAL_STORAGE, displayName: () => t('files', 'Enter missing credentials'), iconSvgInline: () => LoginSvg, @@ -87,7 +95,14 @@ export const action = new FileAction({ )) if (login && password) { - return await setCredentials(node, login, password) + try { + await setCredentials(node, login, password) + showSuccess(t('files_external', 'Credentials successfully set')) + } catch (error) { + showError(t('files_external', 'Error while setting credentials: {error}', { + error: (error as Error).message, + })) + } } return null diff --git a/apps/files_external/src/views/CredentialsDialog.vue b/apps/files_external/src/views/CredentialsDialog.vue index 56c8093db56..7e71c83cf10 100644 --- a/apps/files_external/src/views/CredentialsDialog.vue +++ b/apps/files_external/src/views/CredentialsDialog.vue @@ -76,7 +76,7 @@ export default defineComponent({ computed: { dialogButtons() { return [{ - label: t('files_external', 'Submit'), + label: t('files_external', 'Confirm'), type: 'primary', nativeType: 'submit', }] |