Skip to content

Commit 27ae647

Browse files
committed
fix(types): refine request signature tab typing
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent f207790 commit 27ae647

1 file changed

Lines changed: 36 additions & 9 deletions

File tree

src/components/RightSidebar/RequestSignatureTab.vue

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@
125125
</NcFormBox>
126126
<SigningProgress
127127
v-if="showSigningProgress"
128-
:status="signingProgressStatus"
128+
:status="signingProgressStatus ?? FILE_STATUS.SIGNING_IN_PROGRESS"
129129
:status-text="signingProgressStatusText"
130-
:progress="signingProgress"
130+
:progress="signingProgress ?? undefined"
131131
:is-loading="hasLoading" />
132132
<NcFormBox v-if="filesStore.canSign()" class="action-form-box">
133133
<NcButton
@@ -281,6 +281,7 @@ import axios from '@nextcloud/axios'
281281
import { getCapabilities } from '@nextcloud/capabilities'
282282
import { showError, showSuccess } from '@nextcloud/dialogs'
283283
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
284+
import type { Event as NextcloudEvent, EventHandler } from '@nextcloud/event-bus'
284285
import { loadState } from '@nextcloud/initial-state'
285286
import { generateOcsUrl, generateUrl } from '@nextcloud/router'
286287
@@ -316,11 +317,29 @@ import { useSignStore } from '../../store/sign.js'
316317
import { useUserConfigStore } from '../../store/userconfig.js'
317318
import { startLongPolling } from '../../services/longPolling'
318319
import { useSigningOrder } from '../../composables/useSigningOrder.js'
320+
import type { NextcloudCapabilities } from '../../types/capabilities'
319321
320322
defineOptions({
321323
name: 'RequestSignatureTab',
322324
})
323325
326+
type SigningProgressData = {
327+
total: number
328+
signed: number
329+
files?: Array<{
330+
uuid: string
331+
name: string
332+
signedCount: number
333+
totalSigners: number
334+
isSigned: boolean
335+
}>
336+
signers?: Array<{
337+
id: string | number
338+
displayName: string
339+
signed: boolean
340+
}>
341+
}
342+
324343
const props = withDefaults(defineProps<{
325344
useModal?: boolean
326345
}>(), {
@@ -330,8 +349,11 @@ const props = withDefaults(defineProps<{
330349
const filesStore = useFilesStore()
331350
const signStore = useSignStore()
332351
const sidebarStore = useSidebarStore()
333-
const userConfigStore = useUserConfigStore()
352+
const userConfigStore = useUserConfigStore() as ReturnType<typeof useUserConfigStore> & {
353+
files_list_signer_identify_tab?: string
354+
}
334355
const { normalizeSigningOrders, recalculateSigningOrders } = useSigningOrder()
356+
const capabilities = getCapabilities() as NextcloudCapabilities
335357
336358
const hasLoading = ref(false)
337359
const signerToEdit = ref<Record<string, any>>({})
@@ -346,7 +368,7 @@ const preserveOrder = ref(false)
346368
const showOrderDiagram = ref(false)
347369
const showEnvelopeFilesDialog = ref(false)
348370
const adminSignatureFlow = ref(loadState('libresign', 'signature_flow', 'none'))
349-
const signingProgress = ref<number | null>(null)
371+
const signingProgress = ref<SigningProgressData | null>(null)
350372
const signingProgressStatus = ref<number | null>(null)
351373
const signingProgressStatusText = ref('')
352374
const stopPollingFunction = ref<null | (() => void)>(null)
@@ -386,6 +408,7 @@ const envelopeFilesCount = computed(() => filesStore.getFile()?.filesCount || 0)
386408
const size = computed(() => window.matchMedia('(max-width: 512px)').matches ? 'full' : 'normal')
387409
const modalTitle = computed(() => Object.keys(signerToEdit.value).length > 0 ? t('libresign', 'Edit signer') : t('libresign', 'Add new signer'))
388410
const showSigningProgress = computed(() => signingProgressStatus.value === FILE_STATUS.SIGNING_IN_PROGRESS)
411+
const currentFile = computed(() => filesStore.getFile())
389412
390413
function isSignerSigned(signer: any) {
391414
if (Array.isArray(signer?.signed)) {
@@ -672,7 +695,7 @@ function getSvgIcon(name: string) {
672695
}
673696
674697
function isSignElementsAvailable() {
675-
return getCapabilities()?.libresign?.config?.['sign-elements']?.['is-available'] === true
698+
return capabilities.libresign?.config?.['sign-elements']?.['is-available'] === true
676699
}
677700
678701
function closeModal() {
@@ -875,7 +898,7 @@ async function save() {
875898
hasLoading.value = true
876899
try {
877900
await filesStore.saveOrUpdateSignatureRequest({})
878-
emit('libresign:show-visible-elements')
901+
emit('libresign:show-visible-elements', new CustomEvent('libresign:show-visible-elements'))
879902
} catch (error: any) {
880903
if (error.response?.data?.ocs?.data?.message) {
881904
showError(error.response.data.ocs.data.message)
@@ -980,7 +1003,11 @@ watch(() => filesStore.selectedFileId, (newFileId) => {
9801003
}
9811004
}, { immediate: true })
9821005
983-
watch(() => filesStore.currentFile?.status, (newStatus) => {
1006+
const handleEditSigner = ((event: NextcloudEvent) => {
1007+
editSigner((event as CustomEvent<any>).detail)
1008+
}) as EventHandler<NextcloudEvent>
1009+
1010+
watch(() => currentFile.value?.status, (newStatus) => {
9841011
if (newStatus === FILE_STATUS.SIGNING_IN_PROGRESS) {
9851012
startSigningProgressPolling()
9861013
} else if (stopPollingFunction.value) {
@@ -989,14 +1016,14 @@ watch(() => filesStore.currentFile?.status, (newStatus) => {
9891016
})
9901017
9911018
onMounted(() => {
992-
subscribe('libresign:edit-signer', editSigner)
1019+
subscribe('libresign:edit-signer', handleEditSigner)
9931020
filesStore.disableIdentifySigner()
9941021
activeTab.value = userConfigStore.files_list_signer_identify_tab || ''
9951022
syncPreserveOrderWithFile()
9961023
})
9971024
9981025
onBeforeUnmount(() => {
999-
unsubscribe('libresign:edit-signer')
1026+
unsubscribe('libresign:edit-signer', handleEditSigner)
10001027
if (stopPollingFunction.value) {
10011028
stopSigningProgressPolling()
10021029
}

0 commit comments

Comments
 (0)