From d3a3d4e96e7ea159badb1b75041aac08461ee143 Mon Sep 17 00:00:00 2001 From: gitlawr Date: Thu, 28 May 2026 16:42:59 +0800 Subject: [PATCH] feat(templates): fix unresponsive action dropdown for non-admin Two changes that together restore the per-row Edit / Delete menu for non-admin users: - ``templateActions`` drops the blanket ``access: 'canSeeAdmin'`` gate on every menu item. With the gate on, non-admin callers got an empty filtered menu, so clicking the "..." did nothing. - The management page passes ``mine=true`` to the list API. The endpoint now drops Global rows for non-admin callers (rows they can't edit anyway), so the dropdown shows up only on rows the caller may manage. The GPU-instance create picker reuses the same API without ``mine``, keeping Global presets visible there. --- .../gpu-service/templates/config/index.tsx | 20 ++++++++++++++++--- src/pages/gpu-service/templates/index.tsx | 8 +++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/pages/gpu-service/templates/config/index.tsx b/src/pages/gpu-service/templates/config/index.tsx index 1f0d5b09..9e67fa79 100644 --- a/src/pages/gpu-service/templates/config/index.tsx +++ b/src/pages/gpu-service/templates/config/index.tsx @@ -91,19 +91,33 @@ export const stringifyCommand = (tokens?: string[]): string => { .join(' '); }; -export const templateActions = [ +// No ``access`` gates on these menu items: the management page +// queries the list API with ``mine=true``, so every row already +// belongs to a scope the caller can manage — no per-item filtering +// needed here. +// +// ``icon`` is narrowed to ``any`` so the inferred declaration type +// for the array doesn't reach into +// ``@ant-design/icons/lib/components/AntdIcon`` (the internal path +// the antd icon component types live at). The other fields keep +// their precise types. +export const templateActions: Array<{ + label: string; + key: string; + locale: boolean; + icon: any; + danger?: boolean; +}> = [ { label: 'common.button.edit', key: 'edit', locale: true, - access: 'canSeeAdmin', icon: icons.EditOutlined }, { label: 'common.button.delete', key: 'delete', locale: true, - access: 'canSeeAdmin', icon: icons.DeleteOutlined, danger: true } diff --git a/src/pages/gpu-service/templates/index.tsx b/src/pages/gpu-service/templates/index.tsx index 94ac6966..483992e6 100644 --- a/src/pages/gpu-service/templates/index.tsx +++ b/src/pages/gpu-service/templates/index.tsx @@ -45,7 +45,13 @@ const GPUServiceTemplates: React.FC = () => { isInfiniteScroll: true, contentForDelete: intl.formatMessage({ id: 'gpuservice.template' }), defaultQueryParams: { - perPage: 24 + perPage: 24, + // Management view: drop Global rows for non-admin callers — the + // page is a CRUD surface, and admin-curated Global templates + // they can't edit only add visual noise. The instance-create + // picker (uses ``useQueryTemplates`` separately) doesn't set + // this and so still sees Global presets. + mine: true } }); const { openTemplateModalStatus, openTemplateModal, closeTemplateModal } =