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.
This commit is contained in:
gitlawr
2026-05-28 18:16:15 +08:00
committed by jialin
parent f99621ec92
commit d3a3d4e96e
2 changed files with 24 additions and 4 deletions
@@ -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
}
+7 -1
View File
@@ -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 } =