From f745f3cff7203d502714eb31354f37f7c9727e63 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 6 Oct 2022 10:57:46 +0200 Subject: [PATCH] feat(nc-gui): show error when entering invalid password --- .../composables/useSharedFormViewStore.ts | 10 +++++++ .../pages/[projectType]/form/[viewId].vue | 30 +++++++++++++++---- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/packages/nc-gui/composables/useSharedFormViewStore.ts b/packages/nc-gui/composables/useSharedFormViewStore.ts index 0ed600eb21..6ef566ce8b 100644 --- a/packages/nc-gui/composables/useSharedFormViewStore.ts +++ b/packages/nc-gui/composables/useSharedFormViewStore.ts @@ -25,6 +25,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share const submitted = ref(false) const passwordDlg = ref(false) const password = ref(null) + const passwordError = ref(null) const secondsRemain = ref(0) provide(SharedViewPasswordInj, password) @@ -55,6 +56,8 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share columns.value?.filter((c) => c.show).filter((col) => !isVirtualCol(col) || col.uidt === UITypes.LinkToAnotherRecord), ) const loadSharedView = async () => { + passwordError.value = null + try { const viewMeta = await api.public.sharedViewMetaGet(sharedViewId, { headers: { @@ -82,6 +85,8 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share notFound.value = true } else if ((await extractSdkResponseErrorMsg(e)) === ErrorMessages.INVALID_SHARED_VIEW_PASSWORD) { passwordDlg.value = true + + if (password.value) passwordError.value = 'Something went wrong. Please check your credentials.' } } } @@ -196,6 +201,10 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share } }) + watch(password, (next, prev) => { + if (next !== prev && passwordError.value) passwordError.value = null + }) + return { sharedView, sharedFormView, @@ -210,6 +219,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share formState, notFound, password, + passwordError, submitted, secondsRemain, passwordDlg, diff --git a/packages/nc-gui/pages/[projectType]/form/[viewId].vue b/packages/nc-gui/pages/[projectType]/form/[viewId].vue index bc9363ac4b..937abb9871 100644 --- a/packages/nc-gui/pages/[projectType]/form/[viewId].vue +++ b/packages/nc-gui/pages/[projectType]/form/[viewId].vue @@ -22,7 +22,7 @@ useSidebar('nc-left-sidebar', { hasSidebar: false }) const route = useRoute() -const { loadSharedView, sharedView, meta, notFound, password, passwordDlg } = useProvideSharedFormStore( +const { loadSharedView, sharedView, meta, notFound, password, passwordDlg, passwordError } = useProvideSharedFormStore( route.params.viewId as string, ) @@ -45,23 +45,28 @@ if (!notFound.value) { -
- This shared view is protected +
+ +

This shared view is protected

- + + +
{{ passwordError }}
+
+ - {{ $t('general.unlock') }} +
@@ -84,4 +89,17 @@ if (!notFound.value) { } } } + +.nc-modal-shared-form-password-dlg { + .ant-input-affix-wrapper, + .ant-input { + @apply !appearance-none my-1 border-1 border-solid border-primary border-opacity-50 rounded; + } + + .password { + input { + @apply !border-none !m-0; + } + } +}