@@ -3,6 +3,7 @@ import { useI18n } from 'vue-i18n'
33import { reactive , ref } from ' vue'
44import type { Suite } from ' @/views/types'
55import { API } from ' @/views/net'
6+ import { ElMessage } from ' element-plus'
67import type { FormInstance , FormRules } from ' element-plus'
78
89const { t } = useI18n ()
@@ -34,6 +35,8 @@ const importSuiteFormSubmit = async (formEl: FormInstance | undefined) => {
3435 API .ImportTestSuite (importSuiteForm , () => {
3536 emit (' created' )
3637 formEl .resetFields ()
38+ }, (e ) => {
39+ ElMessage .error (e )
3740 })
3841 }
3942 })
@@ -59,64 +62,71 @@ function loadStores() {
5962loadStores ()
6063
6164const importSourceKinds = [{
62- " name" : " Postman" ,
63- " value" : " postman"
65+ " name" : " Postman" ,
66+ " value" : " postman" ,
67+ " description" : " https://api.postman.com/collections/xxx"
6468}, {
65- " name" : " Native" ,
66- " value" : " native"
69+ " name" : " Native" ,
70+ " value" : " native" ,
71+ " description" : " http://your-server/api/v1/suites/xxx/yaml?x-store-name=xxx"
6772}]
73+ const placeholderOfImportURL = ref (" " )
74+ const kindChanged = (e ) => {
75+ importSourceKinds .forEach (k => {
76+ if (k .value === e ) {
77+ placeholderOfImportURL .value = k .description
78+ }
79+ });
80+ }
6881 </script >
6982
7083<template >
71- <el-dialog :modelValue =" visible" title =" Import Test Suite" width =" 30%" draggable >
72- <span >Supported source URL: Postman collection share link</span >
73- <template #footer >
74- <span class =" dialog-footer" >
75- <el-form
76- :rules =" importSuiteFormRules"
77- :model =" importSuiteForm"
78- ref =" importSuiteFormRef"
79- status-icon label-width =" 120px" >
80- <el-form-item label =" Location" prop =" store" >
81- <el-select v-model =" importSuiteForm.store" class =" m-2"
82- test-id =" suite-import-form-store"
83- filterable
84- default-first-option
85- placeholder =" Storage Location" >
86- <el-option
87- v-for =" item in stores"
88- :key =" item.name"
89- :label =" item.name"
90- :value =" item.name"
91- />
92- </el-select >
93- </el-form-item >
94- <el-form-item label =" Kind" prop =" kind" >
95- <el-select v-model =" importSuiteForm.kind" class =" m-2"
96- filterable =true
84+ <el-dialog :modelValue =" visible" title =" Import Test Suite" width =" 40%"
85+ draggable destroy-on-close >
86+ <el-form
87+ :rules =" importSuiteFormRules"
88+ :model =" importSuiteForm"
89+ ref =" importSuiteFormRef"
90+ status-icon label-width =" 85px" >
91+ <el-form-item label =" Location" prop =" store" >
92+ <el-select v-model =" importSuiteForm.store" class =" m-2"
93+ test-id =" suite-import-form-store"
94+ filterable
95+ default-first-option
96+ placeholder =" Storage Location" >
97+ <el-option
98+ v-for =" item in stores"
99+ :key =" item.name"
100+ :label =" item.name"
101+ :value =" item.name"
102+ />
103+ </el-select >
104+ </el-form-item >
105+ <el-form-item label =" Kind" prop =" kind" >
106+ <el-select v-model =" importSuiteForm.kind" class =" m-2"
107+ filterable
108+ @change =" kindChanged"
97109 test-id =" suite-import-form-kind"
98- default-first-option = true
99- placeholder =" Kind" size = " middle " >
110+ default-first-option
111+ placeholder =" Kind" >
100112 <el-option
101113 v-for =" item in importSourceKinds"
102114 :key =" item.name"
103115 :label =" item.name"
104116 :value =" item.value"
105117 />
106- </el-select >
107- </el-form-item >
108- <el-form-item label =" URL" prop =" url" >
109- <el-input v-model =" importSuiteForm.url" test-id =" suite-import-form-api" placeholder =" https://api.postman.com/collections/xxx" />
110- </el-form-item >
111- <el-form-item >
112- <el-button
113- type =" primary"
114- @click =" importSuiteFormSubmit(importSuiteFormRef)"
115- test-id =" suite-import-submit"
116- >{{ t('button.import') }}</el-button >
117- </el-form-item >
118- </el-form >
119- </span >
120- </template >
118+ </el-select >
119+ </el-form-item >
120+ <el-form-item label =" URL" prop =" url" >
121+ <el-input v-model =" importSuiteForm.url" test-id =" suite-import-form-api" :placeholder =" placeholderOfImportURL" />
122+ </el-form-item >
123+ <el-form-item >
124+ <el-button
125+ type =" primary"
126+ @click =" importSuiteFormSubmit(importSuiteFormRef)"
127+ test-id =" suite-import-submit"
128+ >{{ t('button.import') }}</el-button >
129+ </el-form-item >
130+ </el-form >
121131 </el-dialog >
122132</template >
0 commit comments