Skip to content

Commit e9dd49f

Browse files
authored
UI declutter stepper (#2017)
* stepper ui changes * refine in background when done extracting * fix updating person & drop temp tables manually * move refine reload logic to mining panel * await function refineReloadContacts * remove async keyword * ui changes: remove title, remove button, bigger title, * remove unused code * improve ui styling, spacing * refactor: reduce cognitive complexity * refactor, fix ui
1 parent 342dbdd commit e9dd49f

File tree

1 file changed

+42
-34
lines changed

1 file changed

+42
-34
lines changed

frontend/src/components/Mining/StepperPanels/SourcePanel.vue

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<template>
2-
<div class="flex flex-col items-center space-y-6 p-6">
3-
<span class="text-xl">{{ t('title') }}</span>
2+
<template v-if="!showOtherSources">
3+
<div class="flex flex-col items-center gap-8">
4+
<h2 class="text-xl">{{ t('title_add_existing') }}</h2>
45

5-
<template v-if="!showOtherSources">
66
<Select
77
v-model="sourceModel"
88
:options="sourceOptions"
9-
class="w-full max-w-lg"
9+
class="w-full max-w-xl"
1010
option-label="email"
1111
:placeholder="t('email_address')"
1212
:pt="{
@@ -30,11 +30,10 @@
3030
</template>
3131
</Select>
3232

33-
<div class="flex flex-col min-[1129px]:flex-row gap-2 w-full max-w-lg">
33+
<div class="flex flex-col min-[1129px]:flex-row gap-2 w-full max-w-xl">
3434
<Button
3535
id="mine-source"
3636
class="w-full"
37-
severity="secondary"
3837
:disabled="!sourceModel"
3938
:label="t('mine_new_source')"
4039
outlined
@@ -49,12 +48,13 @@
4948
@click="extractContacts"
5049
/>
5150
</div>
52-
</template>
51+
</div>
52+
</template>
5353

54-
<template v-else>
55-
<div
56-
class="flex flex-col min-[1129px]:flex-row flex-wrap gap-2 w-full max-w-4xl justify-center"
57-
>
54+
<template v-else>
55+
<div class="flex flex-col items-center gap-8">
56+
<h2 class="text-xl">{{ t('title_add_new') }}</h2>
57+
<div class="flex flex-col min-[1129px]:flex-row flex-wrap gap-2">
5858
<oauth-source icon="pi pi-google" label="Google" source="google" />
5959
<oauth-source
6060
icon="pi pi-microsoft"
@@ -74,8 +74,8 @@
7474
/>
7575
<importFileDialog ref="importFileDialogRef" />
7676
</div>
77-
</template>
78-
</div>
77+
</div>
78+
</template>
7979
</template>
8080

8181
<script setup lang="ts">
@@ -122,28 +122,34 @@ function getIcon(type: string) {
122122
}
123123
}
124124
125+
async function fetchMiningSourcesAndHandleSource() {
126+
await $leadminerStore.fetchMiningSources();
127+
128+
const selectedSource = source
129+
? $leadminerStore.getMiningSourceByEmail(source as string)
130+
: null;
131+
132+
if (selectedSource) {
133+
const newQuery = { ...useRoute().query };
134+
delete newQuery.source;
135+
useRouter().replace({ query: newQuery });
136+
onSourceChange(selectedSource);
137+
} else {
138+
sourceModel.value = sourceOptions?.value[0];
139+
}
140+
}
141+
125142
onMounted(async () => {
126143
try {
127-
await $leadminerStore.fetchMiningSources();
128-
129-
const selectedSource = source
130-
? $leadminerStore.getMiningSourceByEmail(source as string)
131-
: null;
132-
133-
if (selectedSource) {
134-
const newQuery = { ...useRoute().query };
135-
delete newQuery.source;
136-
useRouter().replace({ query: newQuery });
137-
onSourceChange(selectedSource);
138-
} else {
139-
sourceModel.value = sourceOptions?.value[0];
140-
}
144+
await fetchMiningSourcesAndHandleSource();
141145
} catch (error) {
142-
if (error instanceof FetchError && error.response?.status === 401) {
143-
throw error;
144-
} else {
145-
throw new Error(t('fetch_sources_failed'));
146-
}
146+
throw error instanceof FetchError && error.response?.status === 401
147+
? error
148+
: new Error(t('fetch_sources_failed'));
149+
}
150+
151+
if (sourceOptions.value.length === 0) {
152+
showOtherSources.value = true;
147153
}
148154
149155
watch(sourceModel, (miningSource) => {
@@ -163,7 +169,8 @@ defineExpose({
163169
<i18n lang="json">
164170
{
165171
"en": {
166-
"title": "Mine contacts from",
172+
"title_add_new": "Choose your mining source",
173+
"title_add_existing": "Mine from",
167174
"mine_existing_source": "Mine from existing source",
168175
"mine_new_source": "Mine from another source",
169176
"fetch_sources_failed": "Failed to fetch mining sources",
@@ -173,7 +180,8 @@ defineExpose({
173180
"import_csv_excel": "Import CSV or Excel"
174181
},
175182
"fr": {
176-
"title": "Extraire des contacts depuis",
183+
"title_add_new": "Extraire des contacts depuis",
184+
"title_add_existing": "Extraire depuis",
177185
"mine_existing_source": "Extraire depuis une source existante",
178186
"mine_new_source": "Extraire depuis une autre source",
179187
"fetch_sources_failed": "Échec de la récupération des sources de minage",

0 commit comments

Comments
 (0)