diff --git a/frontend/src/components/mining/PassiveMiningDialog.vue b/frontend/src/components/mining/PassiveMiningDialog.vue index 2b927c0aa..cf7d6376f 100644 --- a/frontend/src/components/mining/PassiveMiningDialog.vue +++ b/frontend/src/components/mining/PassiveMiningDialog.vue @@ -34,6 +34,7 @@ const miningSource = ref(); const $leadminerStore = useLeadminerStore(); const $supabase = useSupabaseClient(); +const $toast = useToast(); const { t } = useI18n({ useScope: 'local', @@ -54,15 +55,25 @@ function closePassiveMiningDialog() { async function enablePassiveMining() { if (miningSource.value) { - const { error } = await $supabase - // @ts-expect-error: Issue with nuxt/supabase - .schema('private') - .from('mining_sources') - .update({ passive_mining: true }) - .match({ email: miningSource.value.email }); + try { + const { error } = await $supabase + // @ts-expect-error: Issue with nuxt/supabase + .schema('private') + .from('mining_sources') + .update({ passive_mining: true }) + .match({ email: miningSource.value.email }); - if (error) { - throw error; + if (error) { + throw error; + } + } catch (error) { + $toast.add({ + severity: 'error', + summary: t('passive_mining_update_failed'), + detail: (error as Error).message, + life: 4500, + }); + return; } } closePassiveMiningDialog(); @@ -75,14 +86,15 @@ async function enablePassiveMining() { "header": "Continuous Contact Extraction", "paragraph_1": "New contacts found in incoming emails will be automatically saved.", "paragraph_2": "Enable continuous contact extraction from future emails?", - "yes_enable": "Yes, enable" + "yes_enable": "Yes, enable", + "passive_mining_update_failed": "Unable to update continuous mining" }, "fr": { "header": "Extraction continue des contacts", "paragraph_1": "Les nouveaux contacts trouvés dans les e-mails entrants seront automatiquement enregistrés.", "paragraph_2": "Activer l'extraction continue des contacts à partir des futurs e-mails ?", - - "yes_enable": "Oui, activer" + "yes_enable": "Oui, activer", + "passive_mining_update_failed": "Impossible de mettre à jour l'extraction continue" } } diff --git a/frontend/src/components/mining/stepper-panels/mine/MinePanel.vue b/frontend/src/components/mining/stepper-panels/mine/MinePanel.vue index 48cbc4bcd..7daae4857 100644 --- a/frontend/src/components/mining/stepper-panels/mine/MinePanel.vue +++ b/frontend/src/components/mining/stepper-panels/mine/MinePanel.vue @@ -47,8 +47,10 @@ v-if="!$leadminerStore.activeMiningTask" id="mine-stepper-start-button" :disabled=" + (sourceType === 'email' && $leadminerStore.isLoadingBoxes) || (sourceType === 'email' && - ($leadminerStore.isLoadingBoxes || totalEmails === 0)) || + totalEmails === 0 && + !$leadminerStore.googleContactsSyncEnabled) || $leadminerStore.isLoadingStartMining " :loading="$leadminerStore.isLoadingStartMining" @@ -397,11 +399,12 @@ function openMiningSettings() { } async function startMiningBoxes() { - if ( + const hasCheckedBoxes = Object.keys(selectedBoxes.value).filter( (key) => selectedBoxes.value[key].checked && key !== '', - ).length === 0 - ) { + ).length > 0; + + if (!hasCheckedBoxes && !$leadminerStore.googleContactsSyncEnabled) { openMiningSettings(); $toast.add({ severity: 'error', diff --git a/frontend/src/components/senders/EmailSenderManagement.vue b/frontend/src/components/senders/EmailSenderManagement.vue index aac0a3e94..8a52aa8a9 100644 --- a/frontend/src/components/senders/EmailSenderManagement.vue +++ b/frontend/src/components/senders/EmailSenderManagement.vue @@ -7,6 +7,10 @@ import { useSmtpSendersStore } from '~/stores/smtp-senders'; import AddEmailSenderDialog from './AddEmailSenderDialog.vue'; import type { SmtpSender } from '@/types/smtp-senders'; +defineProps<{ + hideAddButton?: boolean; +}>(); + const { t } = useI18n({ useScope: 'local' }); const { t: globalT } = useI18n({ useScope: 'global' }); const $confirm = useConfirm(); @@ -22,6 +26,8 @@ function openAddDialog() { showAddDialog.value = true; } +defineExpose({ openAddDialog }); + function openEditDialog(sender: SmtpSender) { editingSender.value = sender; showAddDialog.value = true; @@ -86,7 +92,7 @@ onMounted(() => {