Skip to content

Commit 2f42e97

Browse files
committed
Tweak devto integration error handling
1 parent 42034f0 commit 2f42e97

File tree

2 files changed

+60
-39
lines changed

2 files changed

+60
-39
lines changed

frontend/src/assets/scss/layout.scss

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,26 +132,33 @@ hr {
132132
font-weight: 500;
133133
}
134134

135+
.el-loading-mask {
136+
@apply bg-transparent;
137+
138+
.el-loading-spinner {
139+
@apply relative flex items-center justify-center h-full top-auto mt-auto;
140+
141+
.circular {
142+
@apply h-6 w-6;
143+
}
144+
145+
.path {
146+
stroke: #E94F2E;
147+
}
148+
}
149+
}
150+
135151
.app-page-spinner {
136152
display: flex;
137153
justify-content: center;
138154
align-items: center;
139155
min-height: 10rem;
140156

141-
.el-loading-mask {
142-
@apply bg-transparent;
143-
}
144-
.el-loading-spinner {
145-
@apply relative flex items-center justify-center h-full top-auto mt-auto;
146-
.circular {
147-
@apply w-10 h-10;
148-
}
157+
.el-loading-spinner .circular {
158+
@apply w-10 h-10;
149159
}
150160
}
151161

152-
.el-loading-spinner .path {
153-
stroke: #E94F2E;
154-
}
155162

156163
.app-divider {
157164
display: table;

frontend/src/modules/integration/components/devto-integration-widget.vue

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@
4343
class="text-green-500"
4444
spellcheck="false"
4545
placeholder="Enter organization slug"
46+
@blur="handleOrganizationValidation(org.id)"
4647
>
4748
<template #prepend>dev.to/</template>
48-
<template v-if="org.validating" #suffix>
49-
<i class="el-input__icon el-icon-loading" />
49+
<template #suffix>
50+
<div
51+
v-if="org.validating"
52+
v-loading="org.validating"
53+
class="flex items-center justify-center w-6 h-6"
54+
></div>
5055
</template>
5156
</el-input>
5257
<i
@@ -55,6 +60,11 @@
5560
@click="removeOrganization(org.id)"
5661
/>
5762
</div>
63+
<span
64+
v-if="org.touched && !org.valid"
65+
class="el-form-item__error"
66+
>Organization slug is not valid</span
67+
>
5868
</el-form-item>
5969
<a
6070
class="cursor-pointer text-sm font-medium text-primary-900"
@@ -81,10 +91,15 @@
8191
v-model="user.username"
8292
spellcheck="false"
8393
placeholder="Enter user slug"
94+
@blur="handleUserValidation(user.id)"
8495
>
8596
<template #prepend>dev.to/</template>
86-
<template v-if="user.validating" #suffix>
87-
<i class="el-input__icon el-icon-loading" />
97+
<template #suffix>
98+
<div
99+
v-if="user.validating"
100+
v-loading="user.validating"
101+
class="flex items-center justify-center w-6 h-6"
102+
></div>
88103
</template>
89104
</el-input>
90105
<i
@@ -93,6 +108,11 @@
93108
@click="removeUser(user.id)"
94109
/>
95110
</div>
111+
<span
112+
v-if="user.touched && !user.valid"
113+
class="el-form-item__error"
114+
>User slug is not valid</span
115+
>
96116
</el-form-item>
97117
<a
98118
class="cursor-pointer text-sm font-medium text-primary-900"
@@ -105,13 +125,15 @@
105125
<div>
106126
<el-button
107127
class="btn btn--primary mr-2"
108-
:disabled="connectDisabled"
128+
:disabled="connectDisabled || loading"
129+
:loading="loading"
109130
@click="save"
110131
>
111132
<app-i18n code="common.connect"></app-i18n>
112133
</el-button>
113134
<el-button
114135
class="btn btn--secondary"
136+
:disabled="loading"
115137
@click="cancel"
116138
>
117139
<app-i18n code="common.cancel"></app-i18n>
@@ -141,11 +163,16 @@ export default {
141163
(i) => i.platform === 'devto'
142164
).image,
143165
users: [],
144-
organizations: []
166+
organizations: [],
167+
loading: false
145168
}
146169
},
147170
computed: {
148171
connectDisabled() {
172+
if (!this.isValid) {
173+
return true
174+
}
175+
149176
const validUsers = this.users.filter(
150177
(u) => !!u.username
151178
)
@@ -387,35 +414,22 @@ export default {
387414
},
388415
389416
async save() {
417+
this.loading = true
418+
390419
const relevantOrganizations =
391420
this.organizations.filter((o) => !!o.username)
392421
const relevantUsers = this.users.filter(
393422
(u) => !!u.username
394423
)
395-
396-
const promises = [
397-
...relevantOrganizations.map((o) =>
398-
this.handleOrganizationValidation(o.id)
399-
),
400-
...relevantUsers.map((u) =>
401-
this.handleUserValidation(u.id)
424+
await this.doDevtoConnect({
425+
users: relevantUsers.map((u) => u.username),
426+
organizations: relevantOrganizations.map(
427+
(o) => o.username
402428
)
403-
]
404-
405-
if (promises.length > 0) {
406-
await Promise.all(promises)
407-
}
408-
409-
if (this.isValid) {
410-
await this.doDevtoConnect({
411-
users: relevantUsers.map((u) => u.username),
412-
organizations: relevantOrganizations.map(
413-
(o) => o.username
414-
)
415-
})
429+
})
416430
417-
this.isVisible = false
418-
}
431+
this.isVisible = false
432+
this.loading = false
419433
}
420434
}
421435
}

0 commit comments

Comments
 (0)