2023-11-24 21:31:26 +00:00
|
|
|
import type {
|
|
|
|
UserProfileAttribute,
|
|
|
|
UserProfileConfig,
|
|
|
|
} from "@keycloak/keycloak-admin-client/lib/defs/userProfileMetadata";
|
2024-05-29 12:34:02 +00:00
|
|
|
import { ScrollForm } from "@keycloak/keycloak-ui-shared";
|
2022-03-16 09:32:23 +00:00
|
|
|
import {
|
|
|
|
AlertVariant,
|
|
|
|
Button,
|
|
|
|
Form,
|
|
|
|
PageSection,
|
|
|
|
} from "@patternfly/react-core";
|
2022-12-07 14:23:12 +00:00
|
|
|
import { flatten } from "flat";
|
2024-05-13 13:50:00 +00:00
|
|
|
import { useState } from "react";
|
2022-03-16 09:32:23 +00:00
|
|
|
import { FormProvider, useForm, useFormContext } from "react-hook-form";
|
2022-02-16 11:39:08 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2023-01-18 12:09:49 +00:00
|
|
|
import { Link, useNavigate } from "react-router-dom";
|
2024-05-08 08:23:43 +00:00
|
|
|
import { useAdminClient } from "../admin-client";
|
2022-12-07 14:23:12 +00:00
|
|
|
import { useAlerts } from "../components/alert/Alerts";
|
2023-05-24 12:11:06 +00:00
|
|
|
import { FixedButtonsGroup } from "../components/form/FixedButtonGroup";
|
2022-12-07 14:23:12 +00:00
|
|
|
import { ViewHeader } from "../components/view-header/ViewHeader";
|
2024-05-29 12:34:02 +00:00
|
|
|
import { useRealm } from "../context/realm-context/RealmContext";
|
2022-12-07 14:23:12 +00:00
|
|
|
import { convertToFormValues } from "../util";
|
2023-05-03 15:40:27 +00:00
|
|
|
import { useFetch } from "../utils/useFetch";
|
2024-05-29 12:34:02 +00:00
|
|
|
import useLocale from "../utils/useLocale";
|
2022-12-07 14:23:12 +00:00
|
|
|
import { useParams } from "../utils/useParams";
|
2024-05-29 12:34:02 +00:00
|
|
|
import "./realm-settings-section.css";
|
2022-12-07 14:23:12 +00:00
|
|
|
import type { AttributeParams } from "./routes/Attribute";
|
|
|
|
import { toUserProfile } from "./routes/UserProfile";
|
2023-05-03 13:51:02 +00:00
|
|
|
import { UserProfileProvider } from "./user-profile/UserProfileContext";
|
2022-12-07 14:23:12 +00:00
|
|
|
import { AttributeAnnotations } from "./user-profile/attribute/AttributeAnnotations";
|
2022-03-16 09:32:23 +00:00
|
|
|
import { AttributeGeneralSettings } from "./user-profile/attribute/AttributeGeneralSettings";
|
|
|
|
import { AttributePermission } from "./user-profile/attribute/AttributePermission";
|
|
|
|
import { AttributeValidations } from "./user-profile/attribute/AttributeValidations";
|
2024-06-18 07:06:10 +00:00
|
|
|
import { i18n } from "../i18n/i18n";
|
2022-02-16 11:39:08 +00:00
|
|
|
|
2024-03-04 11:39:20 +00:00
|
|
|
type TranslationForm = {
|
|
|
|
locale: string;
|
|
|
|
value: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
type Translations = {
|
|
|
|
key: string;
|
|
|
|
translations: TranslationForm[];
|
|
|
|
};
|
|
|
|
|
2022-11-16 14:19:09 +00:00
|
|
|
type IndexedAnnotations = {
|
|
|
|
key: string;
|
2023-01-26 09:31:07 +00:00
|
|
|
value?: Record<string, unknown>;
|
2022-11-16 14:19:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export type IndexedValidations = {
|
|
|
|
key: string;
|
2023-01-26 09:31:07 +00:00
|
|
|
value?: Record<string, unknown>;
|
2022-11-16 14:19:09 +00:00
|
|
|
};
|
|
|
|
|
2023-10-18 16:24:30 +00:00
|
|
|
type UserProfileAttributeFormFields = Omit<
|
2022-11-16 14:19:09 +00:00
|
|
|
UserProfileAttribute,
|
|
|
|
"validations" | "annotations"
|
|
|
|
> &
|
|
|
|
Attribute &
|
|
|
|
Permission & {
|
|
|
|
validations: IndexedValidations[];
|
|
|
|
annotations: IndexedAnnotations[];
|
2023-10-18 16:24:30 +00:00
|
|
|
hasSelector: boolean;
|
|
|
|
hasRequiredScopes: boolean;
|
2022-11-16 14:19:09 +00:00
|
|
|
};
|
2022-03-16 09:32:23 +00:00
|
|
|
|
2022-03-31 13:28:48 +00:00
|
|
|
type Attribute = {
|
2022-03-16 09:32:23 +00:00
|
|
|
roles: string[];
|
2022-03-31 13:28:48 +00:00
|
|
|
scopes: string[];
|
|
|
|
isRequired: boolean;
|
2022-03-16 09:32:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
type Permission = {
|
|
|
|
view: PermissionView[];
|
|
|
|
edit: PermissionEdit[];
|
|
|
|
};
|
|
|
|
|
|
|
|
type PermissionView = [
|
|
|
|
{
|
|
|
|
adminView: boolean;
|
|
|
|
userView: boolean;
|
2023-07-11 14:03:21 +00:00
|
|
|
},
|
2022-03-16 09:32:23 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
type PermissionEdit = [
|
|
|
|
{
|
|
|
|
adminEdit: boolean;
|
|
|
|
userEdit: boolean;
|
2023-07-11 14:03:21 +00:00
|
|
|
},
|
2022-03-16 09:32:23 +00:00
|
|
|
];
|
|
|
|
|
2022-11-16 14:19:09 +00:00
|
|
|
export const USERNAME_EMAIL = ["username", "email"];
|
|
|
|
|
2022-03-16 09:32:23 +00:00
|
|
|
const CreateAttributeFormContent = ({
|
2024-03-04 11:39:20 +00:00
|
|
|
onHandlingTranslationsData,
|
|
|
|
onHandlingGeneratedDisplayName,
|
2022-03-16 09:32:23 +00:00
|
|
|
save,
|
|
|
|
}: {
|
|
|
|
save: (profileConfig: UserProfileConfig) => void;
|
2024-03-04 11:39:20 +00:00
|
|
|
onHandlingTranslationsData: (translationsData: Translations) => void;
|
|
|
|
onHandlingGeneratedDisplayName: (generatedDisplayName: string) => void;
|
2022-03-16 09:32:23 +00:00
|
|
|
}) => {
|
2023-09-08 13:17:17 +00:00
|
|
|
const { t } = useTranslation();
|
2022-03-16 09:32:23 +00:00
|
|
|
const form = useFormContext();
|
2022-03-31 13:28:48 +00:00
|
|
|
const { realm, attributeName } = useParams<AttributeParams>();
|
|
|
|
const editMode = attributeName ? true : false;
|
2022-02-16 11:39:08 +00:00
|
|
|
|
2024-03-04 11:39:20 +00:00
|
|
|
const handleTranslationsData = (translationsData: Translations) => {
|
|
|
|
onHandlingTranslationsData(translationsData);
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleGeneratedDisplayName = (generatedDisplayName: string) => {
|
|
|
|
onHandlingGeneratedDisplayName(generatedDisplayName);
|
|
|
|
};
|
|
|
|
|
2022-02-16 11:39:08 +00:00
|
|
|
return (
|
2022-03-16 09:32:23 +00:00
|
|
|
<UserProfileProvider>
|
|
|
|
<ScrollForm
|
2023-11-14 11:04:55 +00:00
|
|
|
label={t("jumpToSection")}
|
2022-03-16 09:32:23 +00:00
|
|
|
sections={[
|
2024-03-04 11:39:20 +00:00
|
|
|
{
|
|
|
|
title: t("generalSettings"),
|
|
|
|
panel: (
|
|
|
|
<AttributeGeneralSettings
|
|
|
|
onHandlingTranslationData={handleTranslationsData}
|
|
|
|
onHandlingGeneratedDisplayName={handleGeneratedDisplayName}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
},
|
2022-05-30 11:07:33 +00:00
|
|
|
{ title: t("permission"), panel: <AttributePermission /> },
|
|
|
|
{ title: t("validations"), panel: <AttributeValidations /> },
|
|
|
|
{ title: t("annotations"), panel: <AttributeAnnotations /> },
|
2022-03-16 09:32:23 +00:00
|
|
|
]}
|
2022-05-30 11:07:33 +00:00
|
|
|
/>
|
2022-03-16 09:32:23 +00:00
|
|
|
<Form onSubmit={form.handleSubmit(save)}>
|
2023-05-24 12:11:06 +00:00
|
|
|
<FixedButtonsGroup name="attribute-settings">
|
2022-03-16 09:32:23 +00:00
|
|
|
<Button
|
|
|
|
variant="primary"
|
|
|
|
type="submit"
|
|
|
|
data-testid="attribute-create"
|
|
|
|
>
|
2023-09-14 09:01:15 +00:00
|
|
|
{editMode ? t("save") : t("create")}
|
2022-03-16 09:32:23 +00:00
|
|
|
</Button>
|
|
|
|
<Link
|
|
|
|
to={toUserProfile({ realm, tab: "attributes" })}
|
|
|
|
data-testid="attribute-cancel"
|
|
|
|
className="kc-attributeCancel"
|
|
|
|
>
|
2023-09-14 09:01:15 +00:00
|
|
|
{t("cancel")}
|
2022-03-16 09:32:23 +00:00
|
|
|
</Link>
|
2023-05-24 12:11:06 +00:00
|
|
|
</FixedButtonsGroup>
|
2022-03-16 09:32:23 +00:00
|
|
|
</Form>
|
|
|
|
</UserProfileProvider>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function NewAttributeSettings() {
|
2024-05-08 08:23:43 +00:00
|
|
|
const { adminClient } = useAdminClient();
|
2024-03-04 11:39:20 +00:00
|
|
|
const { realm: realmName, attributeName } = useParams<AttributeParams>();
|
2024-05-29 12:34:02 +00:00
|
|
|
const { realmRepresentation: realm } = useRealm();
|
2023-10-18 16:24:30 +00:00
|
|
|
const form = useForm<UserProfileAttributeFormFields>();
|
2023-09-08 13:17:17 +00:00
|
|
|
const { t } = useTranslation();
|
2024-05-13 13:50:00 +00:00
|
|
|
const combinedLocales = useLocale();
|
2022-08-16 13:09:14 +00:00
|
|
|
const navigate = useNavigate();
|
2022-03-16 09:32:23 +00:00
|
|
|
const { addAlert, addError } = useAlerts();
|
|
|
|
const [config, setConfig] = useState<UserProfileConfig | null>(null);
|
2022-03-31 13:28:48 +00:00
|
|
|
const editMode = attributeName ? true : false;
|
2024-03-04 11:39:20 +00:00
|
|
|
const [translationsData, setTranslationsData] = useState<Translations>({
|
|
|
|
key: "",
|
|
|
|
translations: [],
|
|
|
|
});
|
|
|
|
const [generatedDisplayName, setGeneratedDisplayName] = useState<string>("");
|
2022-03-31 13:28:48 +00:00
|
|
|
|
2024-04-19 19:40:49 +00:00
|
|
|
useFetch(
|
|
|
|
async () => {
|
|
|
|
const translationsToSave: any[] = [];
|
|
|
|
await Promise.all(
|
|
|
|
combinedLocales.map(async (selectedLocale) => {
|
|
|
|
try {
|
|
|
|
const translations =
|
|
|
|
await adminClient.realms.getRealmLocalizationTexts({
|
|
|
|
realm: realmName,
|
|
|
|
selectedLocale,
|
|
|
|
});
|
|
|
|
|
|
|
|
const formData = form.getValues();
|
|
|
|
const formattedKey = formData.displayName?.substring(
|
|
|
|
2,
|
|
|
|
formData.displayName.length - 1,
|
|
|
|
);
|
|
|
|
const filteredTranslations: Array<{
|
|
|
|
locale: string;
|
|
|
|
value: string;
|
|
|
|
}> = [];
|
|
|
|
const allTranslations = Object.entries(translations).map(
|
|
|
|
([key, value]) => ({
|
|
|
|
key,
|
|
|
|
value,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
|
|
|
|
allTranslations.forEach((translation) => {
|
|
|
|
if (translation.key === formattedKey) {
|
|
|
|
filteredTranslations.push({
|
|
|
|
locale: selectedLocale,
|
|
|
|
value: translation.value,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const translationToSave: any = {
|
|
|
|
key: formattedKey,
|
|
|
|
translations: filteredTranslations,
|
|
|
|
};
|
|
|
|
|
|
|
|
translationsToSave.push(translationToSave);
|
|
|
|
} catch (error) {
|
|
|
|
console.error(
|
|
|
|
`Error fetching translations for ${selectedLocale}:`,
|
|
|
|
error,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
return translationsToSave;
|
|
|
|
},
|
|
|
|
(translationsToSaveData) => {
|
|
|
|
setTranslationsData(() => ({
|
|
|
|
key: translationsToSaveData[0].key,
|
|
|
|
translations: translationsToSaveData.flatMap(
|
|
|
|
(translationData) => translationData.translations,
|
|
|
|
),
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
[combinedLocales],
|
|
|
|
);
|
|
|
|
|
2022-03-16 09:32:23 +00:00
|
|
|
useFetch(
|
2022-06-13 11:10:11 +00:00
|
|
|
() => adminClient.users.getProfile(),
|
2022-03-31 13:28:48 +00:00
|
|
|
(config) => {
|
2022-03-16 09:32:23 +00:00
|
|
|
setConfig(config);
|
2022-03-31 13:28:48 +00:00
|
|
|
const {
|
|
|
|
annotations,
|
|
|
|
validations,
|
|
|
|
permissions,
|
|
|
|
selector,
|
|
|
|
required,
|
2024-02-12 16:31:11 +00:00
|
|
|
multivalued,
|
2022-03-31 13:28:48 +00:00
|
|
|
...values
|
2023-10-18 16:24:30 +00:00
|
|
|
} = config.attributes!.find(
|
|
|
|
(attribute) => attribute.name === attributeName,
|
|
|
|
) || { permissions: { edit: ["admin"] } };
|
|
|
|
convertToFormValues(
|
|
|
|
{
|
|
|
|
...values,
|
|
|
|
hasSelector: typeof selector !== "undefined",
|
|
|
|
hasRequiredScopes: typeof required?.scopes !== "undefined",
|
|
|
|
},
|
|
|
|
form.setValue,
|
|
|
|
);
|
2022-03-31 13:28:48 +00:00
|
|
|
Object.entries(
|
2023-07-11 14:03:21 +00:00
|
|
|
flatten<any, any>({ permissions, selector, required }, { safe: true }),
|
2023-01-26 09:31:07 +00:00
|
|
|
).map(([key, value]) => form.setValue(key as any, value));
|
2022-11-16 14:19:09 +00:00
|
|
|
form.setValue(
|
|
|
|
"annotations",
|
|
|
|
Object.entries(annotations || {}).map(([key, value]) => ({
|
|
|
|
key,
|
2023-07-18 11:40:53 +00:00
|
|
|
value: value as Record<string, unknown>,
|
2023-07-11 14:03:21 +00:00
|
|
|
})),
|
2022-11-16 14:19:09 +00:00
|
|
|
);
|
|
|
|
form.setValue(
|
|
|
|
"validations",
|
|
|
|
Object.entries(validations || {}).map(([key, value]) => ({
|
|
|
|
key,
|
2023-08-31 09:32:39 +00:00
|
|
|
value: value as Record<string, unknown>,
|
2023-07-11 14:03:21 +00:00
|
|
|
})),
|
2022-11-16 14:19:09 +00:00
|
|
|
);
|
2022-03-31 13:28:48 +00:00
|
|
|
form.setValue("isRequired", required !== undefined);
|
2024-02-12 16:31:11 +00:00
|
|
|
form.setValue("multivalued", multivalued === true);
|
2022-03-16 09:32:23 +00:00
|
|
|
},
|
2023-07-11 14:03:21 +00:00
|
|
|
[],
|
2022-03-16 09:32:23 +00:00
|
|
|
);
|
|
|
|
|
2024-03-04 11:39:20 +00:00
|
|
|
const saveTranslations = async () => {
|
|
|
|
try {
|
2024-04-19 19:40:49 +00:00
|
|
|
const nonEmptyTranslations = translationsData.translations.map(
|
|
|
|
async (translation) => {
|
2024-03-04 11:39:20 +00:00
|
|
|
try {
|
|
|
|
await adminClient.realms.addLocalization(
|
|
|
|
{
|
|
|
|
realm: realmName,
|
|
|
|
selectedLocale: translation.locale,
|
|
|
|
key: translationsData.key,
|
|
|
|
},
|
|
|
|
translation.value,
|
|
|
|
);
|
|
|
|
} catch (error) {
|
|
|
|
console.error(`Error saving translation for ${translation.locale}`);
|
|
|
|
}
|
2024-04-19 19:40:49 +00:00
|
|
|
},
|
|
|
|
);
|
2024-03-04 11:39:20 +00:00
|
|
|
await Promise.all(nonEmptyTranslations);
|
|
|
|
} catch (error) {
|
|
|
|
console.error(`Error saving translations: ${error}`);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-10-18 16:24:30 +00:00
|
|
|
const save = async ({
|
|
|
|
hasSelector,
|
|
|
|
hasRequiredScopes,
|
|
|
|
...formFields
|
|
|
|
}: UserProfileAttributeFormFields) => {
|
|
|
|
if (!hasSelector) {
|
|
|
|
delete formFields.selector;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasRequiredScopes) {
|
|
|
|
delete formFields.required?.scopes;
|
|
|
|
}
|
|
|
|
|
|
|
|
const validations = formFields.validations.reduce(
|
2022-11-16 14:19:09 +00:00
|
|
|
(prevValidations, currentValidations) => {
|
|
|
|
prevValidations[currentValidations.key] =
|
2023-07-18 09:27:08 +00:00
|
|
|
currentValidations.value || {};
|
2022-11-16 14:19:09 +00:00
|
|
|
return prevValidations;
|
|
|
|
},
|
2023-07-11 14:03:21 +00:00
|
|
|
{} as Record<string, unknown>,
|
2022-11-16 14:19:09 +00:00
|
|
|
);
|
|
|
|
|
2023-10-18 16:24:30 +00:00
|
|
|
const annotations = formFields.annotations.reduce(
|
2022-03-16 09:32:23 +00:00
|
|
|
(obj, item) => Object.assign(obj, { [item.key]: item.value }),
|
2023-07-11 14:03:21 +00:00
|
|
|
{},
|
2022-03-16 09:32:23 +00:00
|
|
|
);
|
|
|
|
|
2022-03-31 13:28:48 +00:00
|
|
|
const patchAttributes = () =>
|
2024-03-04 11:39:20 +00:00
|
|
|
(config?.attributes || []).map((attribute) => {
|
2022-03-31 13:28:48 +00:00
|
|
|
if (attribute.name !== attributeName) {
|
|
|
|
return attribute;
|
|
|
|
}
|
|
|
|
|
2022-06-13 09:42:17 +00:00
|
|
|
delete attribute.required;
|
2022-03-31 13:28:48 +00:00
|
|
|
return Object.assign(
|
|
|
|
{
|
|
|
|
...attribute,
|
|
|
|
name: attributeName,
|
2023-10-18 16:24:30 +00:00
|
|
|
displayName: formFields.displayName!,
|
|
|
|
selector: formFields.selector,
|
|
|
|
permissions: formFields.permissions!,
|
2024-02-12 16:31:11 +00:00
|
|
|
multivalued: formFields.multivalued,
|
2022-03-31 13:28:48 +00:00
|
|
|
annotations,
|
2022-11-16 14:19:09 +00:00
|
|
|
validations,
|
2022-03-31 13:28:48 +00:00
|
|
|
},
|
2023-10-18 16:24:30 +00:00
|
|
|
formFields.isRequired ? { required: formFields.required } : undefined,
|
|
|
|
formFields.group ? { group: formFields.group } : { group: null },
|
2022-03-31 13:28:48 +00:00
|
|
|
);
|
|
|
|
});
|
2022-03-16 09:32:23 +00:00
|
|
|
|
2022-03-31 13:28:48 +00:00
|
|
|
const addAttribute = () =>
|
2024-03-04 11:39:20 +00:00
|
|
|
(config?.attributes || []).concat([
|
2022-03-31 13:28:48 +00:00
|
|
|
Object.assign(
|
|
|
|
{
|
2023-10-18 16:24:30 +00:00
|
|
|
name: formFields.name,
|
2024-03-04 11:39:20 +00:00
|
|
|
displayName: formFields.displayName! || generatedDisplayName,
|
2023-10-18 16:24:30 +00:00
|
|
|
required: formFields.isRequired ? formFields.required : undefined,
|
|
|
|
selector: formFields.selector,
|
|
|
|
permissions: formFields.permissions!,
|
2024-02-12 16:31:11 +00:00
|
|
|
multivalued: formFields.multivalued,
|
2022-03-31 13:28:48 +00:00
|
|
|
annotations,
|
2023-04-21 12:29:06 +00:00
|
|
|
validations,
|
2022-03-31 13:28:48 +00:00
|
|
|
},
|
2023-10-18 16:24:30 +00:00
|
|
|
formFields.isRequired ? { required: formFields.required } : undefined,
|
|
|
|
formFields.group ? { group: formFields.group } : undefined,
|
2022-03-31 13:28:48 +00:00
|
|
|
),
|
|
|
|
] as UserProfileAttribute);
|
|
|
|
|
2024-03-04 11:39:20 +00:00
|
|
|
if (realm?.internationalizationEnabled) {
|
|
|
|
const hasNonEmptyTranslations = translationsData.translations.some(
|
|
|
|
(translation) => translation.value.trim() !== "",
|
|
|
|
);
|
|
|
|
|
2024-07-01 08:48:10 +00:00
|
|
|
if (!hasNonEmptyTranslations && !formFields.displayName) {
|
2024-03-04 11:39:20 +00:00
|
|
|
addError("createAttributeError", t("translationError"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2022-03-16 09:32:23 +00:00
|
|
|
|
|
|
|
try {
|
2024-03-04 11:39:20 +00:00
|
|
|
const updatedAttributes = editMode ? patchAttributes() : addAttribute();
|
|
|
|
|
2022-03-16 09:32:23 +00:00
|
|
|
await adminClient.users.updateProfile({
|
2022-06-13 11:10:11 +00:00
|
|
|
...config,
|
2022-03-31 13:28:48 +00:00
|
|
|
attributes: updatedAttributes as UserProfileAttribute[],
|
2024-03-04 11:39:20 +00:00
|
|
|
realm: realmName,
|
2022-03-16 09:32:23 +00:00
|
|
|
});
|
|
|
|
|
2024-03-04 11:39:20 +00:00
|
|
|
await saveTranslations();
|
2024-06-18 07:06:10 +00:00
|
|
|
i18n.reloadResources();
|
2024-03-04 11:39:20 +00:00
|
|
|
navigate(toUserProfile({ realm: realmName, tab: "attributes" }));
|
2022-03-16 09:32:23 +00:00
|
|
|
|
2023-09-25 07:06:56 +00:00
|
|
|
addAlert(t("createAttributeSuccess"), AlertVariant.success);
|
2022-03-16 09:32:23 +00:00
|
|
|
} catch (error) {
|
2023-09-25 07:06:56 +00:00
|
|
|
addError("createAttributeError", error);
|
2022-03-16 09:32:23 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<FormProvider {...form}>
|
|
|
|
<ViewHeader
|
2022-03-31 13:28:48 +00:00
|
|
|
titleKey={editMode ? attributeName : t("createAttribute")}
|
|
|
|
subKey={editMode ? "" : t("createAttributeSubTitle")}
|
2022-03-16 09:32:23 +00:00
|
|
|
/>
|
|
|
|
<PageSection variant="light">
|
2024-03-04 11:39:20 +00:00
|
|
|
<CreateAttributeFormContent
|
|
|
|
save={() => form.handleSubmit(save)()}
|
|
|
|
onHandlingTranslationsData={setTranslationsData}
|
|
|
|
onHandlingGeneratedDisplayName={setGeneratedDisplayName}
|
|
|
|
/>
|
2022-03-16 09:32:23 +00:00
|
|
|
</PageSection>
|
|
|
|
</FormProvider>
|
2022-02-16 11:39:08 +00:00
|
|
|
);
|
|
|
|
}
|