|
43 | 43 | class="text-green-500"
|
44 | 44 | spellcheck="false"
|
45 | 45 | placeholder="Enter organization slug"
|
| 46 | + @blur="handleOrganizationValidation(org.id)" |
46 | 47 | >
|
47 | 48 | <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> |
50 | 55 | </template>
|
51 | 56 | </el-input>
|
52 | 57 | <i
|
|
55 | 60 | @click="removeOrganization(org.id)"
|
56 | 61 | />
|
57 | 62 | </div>
|
| 63 | + <span |
| 64 | + v-if="org.touched && !org.valid" |
| 65 | + class="el-form-item__error" |
| 66 | + >Organization slug is not valid</span |
| 67 | + > |
58 | 68 | </el-form-item>
|
59 | 69 | <a
|
60 | 70 | class="cursor-pointer text-sm font-medium text-primary-900"
|
|
81 | 91 | v-model="user.username"
|
82 | 92 | spellcheck="false"
|
83 | 93 | placeholder="Enter user slug"
|
| 94 | + @blur="handleUserValidation(user.id)" |
84 | 95 | >
|
85 | 96 | <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> |
88 | 103 | </template>
|
89 | 104 | </el-input>
|
90 | 105 | <i
|
|
93 | 108 | @click="removeUser(user.id)"
|
94 | 109 | />
|
95 | 110 | </div>
|
| 111 | + <span |
| 112 | + v-if="user.touched && !user.valid" |
| 113 | + class="el-form-item__error" |
| 114 | + >User slug is not valid</span |
| 115 | + > |
96 | 116 | </el-form-item>
|
97 | 117 | <a
|
98 | 118 | class="cursor-pointer text-sm font-medium text-primary-900"
|
|
105 | 125 | <div>
|
106 | 126 | <el-button
|
107 | 127 | class="btn btn--primary mr-2"
|
108 |
| - :disabled="connectDisabled" |
| 128 | + :disabled="connectDisabled || loading" |
| 129 | + :loading="loading" |
109 | 130 | @click="save"
|
110 | 131 | >
|
111 | 132 | <app-i18n code="common.connect"></app-i18n>
|
112 | 133 | </el-button>
|
113 | 134 | <el-button
|
114 | 135 | class="btn btn--secondary"
|
| 136 | + :disabled="loading" |
115 | 137 | @click="cancel"
|
116 | 138 | >
|
117 | 139 | <app-i18n code="common.cancel"></app-i18n>
|
@@ -141,11 +163,16 @@ export default {
|
141 | 163 | (i) => i.platform === 'devto'
|
142 | 164 | ).image,
|
143 | 165 | users: [],
|
144 |
| - organizations: [] |
| 166 | + organizations: [], |
| 167 | + loading: false |
145 | 168 | }
|
146 | 169 | },
|
147 | 170 | computed: {
|
148 | 171 | connectDisabled() {
|
| 172 | + if (!this.isValid) { |
| 173 | + return true |
| 174 | + } |
| 175 | +
|
149 | 176 | const validUsers = this.users.filter(
|
150 | 177 | (u) => !!u.username
|
151 | 178 | )
|
@@ -387,35 +414,22 @@ export default {
|
387 | 414 | },
|
388 | 415 |
|
389 | 416 | async save() {
|
| 417 | + this.loading = true |
| 418 | +
|
390 | 419 | const relevantOrganizations =
|
391 | 420 | this.organizations.filter((o) => !!o.username)
|
392 | 421 | const relevantUsers = this.users.filter(
|
393 | 422 | (u) => !!u.username
|
394 | 423 | )
|
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 |
402 | 428 | )
|
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 | + }) |
416 | 430 |
|
417 |
| - this.isVisible = false |
418 |
| - } |
| 431 | + this.isVisible = false |
| 432 | + this.loading = false |
419 | 433 | }
|
420 | 434 | }
|
421 | 435 | }
|
|
0 commit comments