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:
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user