Skip to content

Commit

Permalink
feat: make workspace permission first row deletable for workspace cre…
Browse files Browse the repository at this point in the history
…ate (#151) (#154)

(cherry picked from commit bb2d886)

Signed-off-by: Lin Wang <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 0f704e6 commit 5856461
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const WorkspaceCreator = () => {
application={application}
onSubmit={handleWorkspaceFormSubmit}
opType={WORKSPACE_OP_TYPE_CREATE}
permissionFirstRowDeletable
/>
)}
</EuiPageContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ interface WorkspaceFormProps {
onSubmit?: (formData: WorkspaceFormSubmitData) => void;
defaultValues?: WorkspaceFormData;
opType?: string;
permissionFirstRowDeletable?: boolean;
}

export const WorkspaceForm = ({
application,
onSubmit,
defaultValues,
opType,
permissionFirstRowDeletable,
}: WorkspaceFormProps) => {
const workspaceId = defaultValues?.id;
const workspaceNameReadOnly =
Expand All @@ -140,7 +142,7 @@ export const WorkspaceForm = ({
>(
defaultValues?.permissions && defaultValues.permissions.length > 0
? defaultValues.permissions
: [{}]
: []
);

const [formErrors, setFormErrors] = useState<WorkspaceFormErrors>({});
Expand Down Expand Up @@ -477,6 +479,7 @@ export const WorkspaceForm = ({
errors={formErrors.permissions}
value={permissionSettings}
onChange={setPermissionSettings}
firstRowDeletable={permissionFirstRowDeletable}
/>
</EuiPanel>
<EuiSpacer />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,14 @@ interface WorkspacePermissionSettingPanelProps {
errors?: string[];
value?: Array<Partial<WorkspacePermissionSetting>>;
onChange?: (value: Array<Partial<WorkspacePermissionSetting>>) => void;
firstRowDeletable?: boolean;
}

export const WorkspacePermissionSettingPanel = ({
errors,
value,
onChange,
firstRowDeletable,
}: WorkspacePermissionSettingPanelProps) => {
const valueRef = useRef(value);
valueRef.current = value;
Expand Down Expand Up @@ -286,7 +288,7 @@ export const WorkspacePermissionSettingPanel = ({
<WorkspacePermissionSettingInput
{...item}
index={index}
deletable={index !== 0}
deletable={firstRowDeletable || index !== 0}
onDelete={handleDelete}
onTypeChange={handleTypeChange}
onGroupOrUserIdChange={handleGroupOrUserIdChange}
Expand Down

0 comments on commit 5856461

Please sign in to comment.