From bb2d8867116f4f974a8339949801010d85a0669a Mon Sep 17 00:00:00 2001 From: Lin Wang Date: Wed, 13 Sep 2023 17:21:34 +0800 Subject: [PATCH] feat: make workspace permission first row deletable for workspace create (#151) Signed-off-by: Lin Wang --- .../components/workspace_creator/workspace_creator.tsx | 1 + .../public/components/workspace_creator/workspace_form.tsx | 5 ++++- .../workspace_creator/workspace_permission_setting_panel.tsx | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/workspace/public/components/workspace_creator/workspace_creator.tsx b/src/plugins/workspace/public/components/workspace_creator/workspace_creator.tsx index fd8460e30a90..20b91f949422 100644 --- a/src/plugins/workspace/public/components/workspace_creator/workspace_creator.tsx +++ b/src/plugins/workspace/public/components/workspace_creator/workspace_creator.tsx @@ -75,6 +75,7 @@ export const WorkspaceCreator = () => { application={application} onSubmit={handleWorkspaceFormSubmit} opType={WORKSPACE_OP_TYPE_CREATE} + permissionFirstRowDeletable /> )} diff --git a/src/plugins/workspace/public/components/workspace_creator/workspace_form.tsx b/src/plugins/workspace/public/components/workspace_creator/workspace_form.tsx index 59a75940accb..2719c88ea4aa 100644 --- a/src/plugins/workspace/public/components/workspace_creator/workspace_form.tsx +++ b/src/plugins/workspace/public/components/workspace_creator/workspace_form.tsx @@ -112,6 +112,7 @@ interface WorkspaceFormProps { onSubmit?: (formData: WorkspaceFormSubmitData) => void; defaultValues?: WorkspaceFormData; opType?: string; + permissionFirstRowDeletable?: boolean; } export const WorkspaceForm = ({ @@ -119,6 +120,7 @@ export const WorkspaceForm = ({ onSubmit, defaultValues, opType, + permissionFirstRowDeletable, }: WorkspaceFormProps) => { const workspaceId = defaultValues?.id; const workspaceNameReadOnly = @@ -140,7 +142,7 @@ export const WorkspaceForm = ({ >( defaultValues?.permissions && defaultValues.permissions.length > 0 ? defaultValues.permissions - : [{}] + : [] ); const [formErrors, setFormErrors] = useState({}); @@ -477,6 +479,7 @@ export const WorkspaceForm = ({ errors={formErrors.permissions} value={permissionSettings} onChange={setPermissionSettings} + firstRowDeletable={permissionFirstRowDeletable} /> diff --git a/src/plugins/workspace/public/components/workspace_creator/workspace_permission_setting_panel.tsx b/src/plugins/workspace/public/components/workspace_creator/workspace_permission_setting_panel.tsx index 99d3faeecca8..58e7fab0906b 100644 --- a/src/plugins/workspace/public/components/workspace_creator/workspace_permission_setting_panel.tsx +++ b/src/plugins/workspace/public/components/workspace_creator/workspace_permission_setting_panel.tsx @@ -218,12 +218,14 @@ interface WorkspacePermissionSettingPanelProps { errors?: string[]; value?: Array>; onChange?: (value: Array>) => void; + firstRowDeletable?: boolean; } export const WorkspacePermissionSettingPanel = ({ errors, value, onChange, + firstRowDeletable, }: WorkspacePermissionSettingPanelProps) => { const valueRef = useRef(value); valueRef.current = value; @@ -286,7 +288,7 @@ export const WorkspacePermissionSettingPanel = ({