From c4c6a03f6167c26631d6ffeb72c26c90a4c09010 Mon Sep 17 00:00:00 2001 From: seaislee1209 Date: Sat, 28 Mar 2026 23:07:16 +0800 Subject: [PATCH] refactor: remove old project/policy dialogs from IAMUserList All project management and policy operations now handled in the unified UserPoliciesView page. Removed unused dialogs, variables, and functions from IAMUserList. Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/views/iam/IAMUserList.vue | 311 +------------------------ 1 file changed, 3 insertions(+), 308 deletions(-) diff --git a/frontend/src/views/iam/IAMUserList.vue b/frontend/src/views/iam/IAMUserList.vue index 937b444..76375c1 100644 --- a/frontend/src/views/iam/IAMUserList.vue +++ b/frontend/src/views/iam/IAMUserList.vue @@ -53,7 +53,7 @@ @@ -76,7 +76,6 @@ - - -
- - - - - - -
-
-
授权策略(可多选,不选则仅加入监测不授权):
- - 方舟/Seedance 完整权限 - 方舟体验权限(API Key 管理需要) - 方舟只读 - 对象存储完整权限 - 对象存储只读 - 自管理密钥 - - 确认添加 -
-
- 全部开启监测 - 全部关闭监测 -
- - - - - - - - - - - - - - - - -
- - - - - - - -
- 方舟/Seedance 完整权限 - 方舟体验权限(API Key 管理需要) - 方舟只读 - 对象存储完整权限 - 对象存储只读 - 自管理密钥 -
-
- -
- @@ -284,40 +202,6 @@ - - - - - -
- - - - - - 附加 -
- - - - - - - - - - -
@@ -488,16 +372,6 @@ async function handleEnable(row) { } } -// Global policy options -const globalPolicyOptions = [ - { value: 'ArkFullAccess', label: 'ArkFullAccess(方舟/Seedance 完整权限)' }, - { value: 'ArkExperienceAccess', label: 'ArkExperienceAccess(方舟体验权限)' }, - { value: 'ArkReadOnlyAccess', label: 'ArkReadOnlyAccess(方舟只读)' }, - { value: 'TOSFullAccess', label: 'TOSFullAccess(对象存储完整权限)' }, - { value: 'TOSReadOnlyAccess', label: 'TOSReadOnlyAccess(对象存储只读)' }, - { value: 'AccessKeySelfManageAccess', label: 'AccessKeySelfManageAccess(自管理密钥)' }, -] - // Toggle Volcengine console login async function toggleVolcLogin(row) { const action = row.volc_login_allowed ? '关闭' : '开启' @@ -547,22 +421,9 @@ async function handleEditProfile() { } } -// Policies -const policiesVisible = ref(false) -const policiesUser = ref(null) -const policies = ref([]) -const policiesLoading = ref(false) -const policyToAttach = ref('') +// (Policies dialog removed - now in UserPoliciesView) -// Projects dialog -const projectsDialogVisible = ref(false) -const projectsUser = ref(null) -const userProjects = ref([]) -const projectsDialogLoading = ref(false) -const projectToAdd = ref('') -const projectPoliciesToAttach = ref([]) -const volcProjects = ref([]) -const volcProjectsLoading = ref(false) +// (Projects dialog removed - now in UserPoliciesView) // --- Allocate --- const maxDeduct = computed(() => { @@ -618,126 +479,6 @@ function openConfig(row) { configVisible.value = true } -// --- Projects Dialog --- -async function loadVolcProjects() { - volcProjectsLoading.value = true - try { - const { data } = await api.get('/api/v1/projects/') - volcProjects.value = data - } catch (e) { - ElMessage.error(e.response?.data?.message || '获取火山项目列表失败') - } finally { - volcProjectsLoading.value = false - } -} - -async function openProjectsDialog(row) { - projectsUser.value = row - projectsDialogVisible.value = true - projectToAdd.value = '' - await loadUserProjects(row.id) - if (volcProjects.value.length === 0) loadVolcProjects() -} - -async function loadUserProjects(userId) { - projectsDialogLoading.value = true - try { - const { data } = await api.get(`/api/v1/iam-users/${userId}/projects/`) - userProjects.value = data - } catch (e) { - ElMessage.error('获取项目列表失败') - userProjects.value = [] - } finally { - projectsDialogLoading.value = false - } -} - -async function handleAddProject() { - if (!projectToAdd.value) return - try { - const { data } = await api.post(`/api/v1/iam-users/${projectsUser.value.id}/projects/add/`, { - project_name: projectToAdd.value, - policies: projectPoliciesToAttach.value, - }) - const policyMsg = data.attached_policies?.length - ? `,已授权 ${data.attached_policies.length} 个策略` - : '' - ElMessage.success(`已添加${policyMsg}`) - projectToAdd.value = '' - projectPoliciesToAttach.value = [] - await loadUserProjects(projectsUser.value.id) - await loadUsers() - } catch (e) { - ElMessage.error(e.response?.data?.message || '添加失败') - } -} - -async function handleToggleProject(row, val) { - try { - await api.put(`/api/v1/iam-users/${projectsUser.value.id}/projects/${row.id}/`, { - monitor_enabled: val, - }) - await loadUserProjects(projectsUser.value.id) - await loadUsers() - } catch (e) { - ElMessage.error('切换失败') - } -} - -// === Project Policies === -const projectPolicyVisible = ref(false) -const projectPolicyProject = ref(null) -const projectPolicySelected = ref([]) -const projectPolicySaving = ref(false) - -function openProjectPolicies(row) { - projectPolicyProject.value = row - projectPolicySelected.value = [...(row.attached_policies || [])] - projectPolicyVisible.value = true -} - -async function handleSaveProjectPolicies() { - projectPolicySaving.value = true - try { - const { data } = await api.put( - `/api/v1/iam-users/${projectsUser.value.id}/projects/${projectPolicyProject.value.id}/policies/`, - { policies: projectPolicySelected.value } - ) - ElMessage.success(data.message || '已更新') - projectPolicyVisible.value = false - await loadUserProjects(projectsUser.value.id) - } catch (e) { - ElMessage.error(e.response?.data?.message || '更新失败') - } finally { - projectPolicySaving.value = false - } -} - -async function handleRemoveProject(row) { - await ElMessageBox.confirm(`确定移除项目 "${row.project_name}" 吗?`, '确认', { type: 'warning' }) - try { - await api.delete(`/api/v1/iam-users/${projectsUser.value.id}/projects/${row.id}/delete/`) - ElMessage.success('已移除') - await loadUserProjects(projectsUser.value.id) - await loadUsers() - } catch (e) { - ElMessage.error('移除失败') - } -} - -async function handleToggleAll(enable) { - try { - const { data } = await api.post(`/api/v1/iam-users/${projectsUser.value.id}/projects/toggle-all/`, { - monitor_enabled: enable, - }) - ElMessage.success(data.message) - await loadUserProjects(projectsUser.value.id) - await loadUsers() - } catch (e) { - ElMessage.error('操作失败') - } -} - function addStep() { if (!newStep.value || newStep.value < 1 || newStep.value > 99) { ElMessage.warning('请输入 1-99 之间的百分比') @@ -822,52 +563,6 @@ async function openQuotaHistory(row) { } } -// --- Policies --- -async function openPolicies(row) { - policiesUser.value = row - policiesVisible.value = true - policiesLoading.value = true - policyToAttach.value = '' - try { - const { data } = await api.get(`/api/v1/iam-users/${row.id}/policies/`) - policies.value = data.policies || [] - } catch (e) { - ElMessage.error(e.response?.data?.message || '获取权限失败') - policies.value = [] - } finally { - policiesLoading.value = false - } -} - -async function handleAttachPolicy() { - if (!policyToAttach.value) return - try { - await api.post(`/api/v1/iam-users/${policiesUser.value.id}/policies/attach/`, { - policy_name: policyToAttach.value, - policy_type: 'System', - }) - ElMessage.success(`已附加 ${policyToAttach.value}`) - policyToAttach.value = '' - await openPolicies(policiesUser.value) - } catch (e) { - ElMessage.error(e.response?.data?.message || '附加失败') - } -} - -async function handleDetachPolicy(row) { - await ElMessageBox.confirm(`确定移除策略 "${row.PolicyName}" 吗?`, '确认移除', { type: 'warning' }) - try { - await api.post(`/api/v1/iam-users/${policiesUser.value.id}/policies/detach/`, { - policy_name: row.PolicyName, - policy_type: row.PolicyType, - }) - ElMessage.success(`已移除 ${row.PolicyName}`) - await openPolicies(policiesUser.value) - } catch (e) { - ElMessage.error(e.response?.data?.message || '移除失败') - } -} - // --- Create User --- async function handleCreate() { if (!createForm.value.username) {