feat(gpu-service): clone an instance template into the caller's scope

Add a Clone action to instance template cards. It reuses the create
flow prefilled from the source, dropping the source id and ownership so
the backend assigns a fresh id and scopes the copy to the caller's own
principal. Clone is offered on every visible template — including
admin-curated Global rows a non-admin can otherwise only view — so
users can fork a Global preset into their own organization without
admin involvement.

The prefilled name defaults to a `-clone` suffix (trimmed to the
63-char limit) so cloning within the same scope doesn't collide on the
unique name. Edit/Delete remain gated on ownership; Clone is always
available.
This commit is contained in:
gitlawr
2026-07-08 16:27:40 +08:00
committed by jialin
parent fdafdfc3d1
commit c025257fea
9 changed files with 72 additions and 12 deletions
@@ -1,4 +1,3 @@
import { PageAction } from '@/config';
import { PageActionType } from '@/config/types';
import { Form } from 'antd';
import { forwardRef, useEffect, useImperativeHandle } from 'react';
@@ -26,11 +25,13 @@ const GPUServiceTemplateForm: React.FC<TemplateFormProps> = forwardRef(
return;
}
if (action === PageAction.EDIT && currentData) {
// Prefill on Edit and on Clone (Create carrying a source row).
// A plain Create opens with no ``currentData`` and keeps the
// blank ``initialValues``.
if (currentData) {
form.setFieldsValue({
...currentData
});
return;
}
}, [action, currentData, form, open]);