Port resource edit from Account Console to new form controls (#27417)
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
parent
77c4cee4d0
commit
82b697400f
1 changed files with 8 additions and 11 deletions
|
@ -1,9 +1,9 @@
|
|||
import { Button, Form, FormGroup, Modal } from "@patternfly/react-core";
|
||||
import { Button, Form, Modal } from "@patternfly/react-core";
|
||||
import { Fragment, useEffect } from "react";
|
||||
import { FormProvider, useFieldArray, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { KeycloakTextInput, SelectControl, useAlerts } from "ui-shared";
|
||||
import { SelectControl, TextControl, useAlerts } from "ui-shared";
|
||||
import { updatePermissions } from "../api";
|
||||
import type { Permission, Resource } from "../api/representations";
|
||||
import { useEnvironment } from "../root/KeycloakContext";
|
||||
|
@ -28,7 +28,7 @@ export const EditTheResource = ({
|
|||
const { addAlert, addError } = useAlerts();
|
||||
|
||||
const form = useForm<FormValues>();
|
||||
const { control, register, reset, handleSubmit } = form;
|
||||
const { control, reset, handleSubmit } = form;
|
||||
|
||||
const { fields } = useFieldArray<FormValues>({
|
||||
control,
|
||||
|
@ -73,14 +73,11 @@ export const EditTheResource = ({
|
|||
<FormProvider {...form}>
|
||||
{fields.map((p, index) => (
|
||||
<Fragment key={p.id}>
|
||||
<FormGroup label={t("user")} fieldId={`user-${p.id}`}>
|
||||
<KeycloakTextInput
|
||||
id={`user-${p.id}`}
|
||||
type="text"
|
||||
{...register(`permissions.${index}.username`)}
|
||||
isDisabled
|
||||
/>
|
||||
</FormGroup>
|
||||
<TextControl
|
||||
name={`permissions.${index}.username`}
|
||||
label={t("user")}
|
||||
isDisabled
|
||||
/>
|
||||
<SelectControl
|
||||
id={`permissions-${p.id}`}
|
||||
name={`permissions.${index}.scopes`}
|
||||
|
|
Loading…
Reference in a new issue