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:
@@ -91,19 +91,33 @@ export const stringifyCommand = (tokens?: string[]): string => {
|
|||||||
.join(' ');
|
.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',
|
label: 'common.button.edit',
|
||||||
key: 'edit',
|
key: 'edit',
|
||||||
locale: true,
|
locale: true,
|
||||||
access: 'canSeeAdmin',
|
|
||||||
icon: icons.EditOutlined
|
icon: icons.EditOutlined
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'common.button.delete',
|
label: 'common.button.delete',
|
||||||
key: 'delete',
|
key: 'delete',
|
||||||
locale: true,
|
locale: true,
|
||||||
access: 'canSeeAdmin',
|
|
||||||
icon: icons.DeleteOutlined,
|
icon: icons.DeleteOutlined,
|
||||||
danger: true
|
danger: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,13 @@ const GPUServiceTemplates: React.FC = () => {
|
|||||||
isInfiniteScroll: true,
|
isInfiniteScroll: true,
|
||||||
contentForDelete: intl.formatMessage({ id: 'gpuservice.template' }),
|
contentForDelete: intl.formatMessage({ id: 'gpuservice.template' }),
|
||||||
defaultQueryParams: {
|
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 } =
|
const { openTemplateModalStatus, openTemplateModal, closeTemplateModal } =
|
||||||
|
|||||||
Reference in New Issue
Block a user