feat: enhance storage engine connectivity check with auto-creation of buckets
- Updated the StorageCheckResponse to include a new field `bucket_created` to indicate if a bucket was automatically created during the connectivity check. - Modified the MinIO connectivity check logic to attempt auto-creation of the bucket if it does not exist, setting a public-read policy if successful. - Adjusted the frontend to reflect the new response structure, updating the UI to display a 'created' status when a bucket is auto-created. These changes improve the user experience by providing clear feedback on bucket creation during storage checks, enhancing the overall functionality of the storage engine settings.
This commit is contained in:
@@ -227,6 +227,7 @@ export interface StorageCheckRequest {
|
||||
export interface StorageCheckResponse {
|
||||
ok: boolean
|
||||
message: string
|
||||
bucket_created?: boolean
|
||||
}
|
||||
|
||||
export function checkStorageEngine(req: StorageCheckRequest): Promise<{ data: StorageCheckResponse }> {
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
</div>
|
||||
<div v-if="minioEnvAvailable" class="test-bar">
|
||||
<t-button size="small" variant="outline" :loading="checkingMinio" @click="onCheckMinio">测试连接</t-button>
|
||||
<span v-if="minioCheckResult" :class="['test-msg', minioCheckResult.ok ? 'success' : 'error']">
|
||||
<span v-if="minioCheckResult" :class="['test-msg', minioCheckResult.ok ? (minioCheckResult.bucket_created ? 'created' : 'success') : 'error']">
|
||||
{{ minioCheckResult.message }}
|
||||
</span>
|
||||
</div>
|
||||
@@ -192,7 +192,7 @@
|
||||
</div>
|
||||
<div class="test-bar">
|
||||
<t-button size="small" variant="outline" :loading="checkingMinio" @click="onCheckMinio">测试连接</t-button>
|
||||
<span v-if="minioCheckResult" :class="['test-msg', minioCheckResult.ok ? 'success' : 'error']">
|
||||
<span v-if="minioCheckResult" :class="['test-msg', minioCheckResult.ok ? (minioCheckResult.bucket_created ? 'created' : 'success') : 'error']">
|
||||
{{ minioCheckResult.message }}
|
||||
</span>
|
||||
</div>
|
||||
@@ -408,7 +408,7 @@ const saveMessage = ref('')
|
||||
const saveSuccess = ref(false)
|
||||
|
||||
const checkingMinio = ref(false)
|
||||
const minioCheckResult = ref<{ ok: boolean; message: string } | null>(null)
|
||||
const minioCheckResult = ref<{ ok: boolean; message: string; bucket_created?: boolean } | null>(null)
|
||||
const checkingCos = ref(false)
|
||||
const cosCheckResult = ref<{ ok: boolean; message: string } | null>(null)
|
||||
const checkingTos = ref(false)
|
||||
@@ -569,6 +569,10 @@ async function onCheckMinio() {
|
||||
const payload = buildPayload()
|
||||
const res = await checkStorageEngine({ provider: 'minio', minio: payload.minio })
|
||||
minioCheckResult.value = res?.data ?? { ok: false, message: '未知错误' }
|
||||
// Refresh bucket list if a new bucket was auto-created
|
||||
if (res?.data?.bucket_created) {
|
||||
loadMinioBuckets()
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
minioCheckResult.value = { ok: false, message: e instanceof Error ? e.message : '请求失败' }
|
||||
} finally {
|
||||
@@ -834,6 +838,10 @@ onMounted(loadAll)
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
&.created {
|
||||
color: #fa8c16;
|
||||
}
|
||||
|
||||
&.error {
|
||||
color: #ff4d4f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user