feat: expose MinIO operator console
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { useState } from 'react'
|
||||
|
||||
import { openInternalSurface } from '@/api/modules/internal-surfaces'
|
||||
import { PERM, requirePermission } from '@/auth/permissions'
|
||||
import { PageHeader } from '@/components/page-header'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/components/ui/card'
|
||||
import { handleApiError } from '@/lib/errors'
|
||||
|
||||
export const Route = createFileRoute('/_authed/minio-console')({
|
||||
beforeLoad: () => requirePermission(PERM.MINIO_CONSOLE_ACCESS),
|
||||
component: MinioConsolePage,
|
||||
})
|
||||
|
||||
function MinioConsolePage() {
|
||||
const [busy, setBusy] = useState(false)
|
||||
|
||||
const open = async () => {
|
||||
setBusy(true)
|
||||
const tab = window.open('about:blank', '_blank')
|
||||
|
||||
try {
|
||||
const res = await openInternalSurface('minio-console')
|
||||
if (tab) {
|
||||
tab.opener = null
|
||||
tab.location.replace(res.data.url)
|
||||
} else {
|
||||
window.location.assign(res.data.url)
|
||||
}
|
||||
} catch (error) {
|
||||
tab?.close()
|
||||
handleApiError(error)
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PageHeader
|
||||
title="对象存储管理台"
|
||||
description="在浏览器中检查和管理 MinIO 对象存储"
|
||||
/>
|
||||
<Card className="max-w-lg">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">打开管理台</CardTitle>
|
||||
<CardDescription>
|
||||
将在新标签页中打开。平台入口链接一次性有效、60 秒内过期,会话约
|
||||
30 分钟后失效。
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<p className="text-muted-foreground text-sm">
|
||||
平台权限仅控制管理台入口。打开后仍需使用 MinIO
|
||||
凭据登录;对象删除和权限修改可能影响线上文件访问。
|
||||
</p>
|
||||
<Button onClick={open} disabled={busy}>
|
||||
{busy ? '正在打开…' : '打开对象存储管理台'}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user