Chore: Replace role layout ee_else_ce imports with useEnterprise

This commit is contained in:
Gustav Hansen 2023-06-13 06:49:02 +02:00
parent a1fbbee8f7
commit 005f91bdcc
5 changed files with 41 additions and 32 deletions

View File

@ -4,3 +4,5 @@ export const FORM_INITIAL_VALUES = {
email: '',
roles: [],
};
export const ROLE_LAYOUT = [];

View File

@ -25,10 +25,9 @@ import {
} from '@strapi/helper-plugin';
import { useMutation } from 'react-query';
import roleSettingsForm from 'ee_else_ce/pages/SettingsPage/pages/Users/ListPage/ModalForm/utils/roleSettingsForm';
import MagicLink from 'ee_else_ce/pages/SettingsPage/pages/Users/components/MagicLink';
import { FORM_INITIAL_VALUES } from './constants';
import { FORM_INITIAL_VALUES, ROLE_LAYOUT } from './constants';
import SelectRoles from '../../components/SelectRoles';
import layout from './utils/layout';
import schema from './utils/schema';
@ -43,7 +42,19 @@ const ModalForm = ({ onSuccess, onToggle }) => {
const toggleNotification = useNotification();
const { lockApp, unlockApp } = useOverlayBlocker();
const { post } = useFetchClient();
const formDataModel = useEnterprise(
const roleRowLayout = useEnterprise(
ROLE_LAYOUT,
async () =>
(
await import(
'../../../../../../../../ee/admin/pages/SettingsPage/pages/Users/ListPage/ModalForm/constants'
)
).ROLE_LAYOUT,
{
defaultValue: [],
}
);
const initialValues = useEnterprise(
FORM_INITIAL_VALUES,
async () =>
(
@ -138,7 +149,7 @@ const ModalForm = ({ onSuccess, onToggle }) => {
</Breadcrumbs>
</ModalHeader>
<Formik
initialValues={formDataModel}
initialValues={initialValues}
onSubmit={handleSubmit}
validationSchema={schema}
validateOnChange={false}
@ -195,7 +206,7 @@ const ModalForm = ({ onSuccess, onToggle }) => {
value={values.roles}
/>
</GridItem>
{roleSettingsForm.map((row) => {
{roleRowLayout.map((row) => {
return row.map((input) => {
return (
<GridItem key={input.name} {...input.size}>

View File

@ -5,3 +5,26 @@ export const FORM_INITIAL_VALUES = {
}
: {}),
};
export const ROLE_LAYOUT = [
...(window.strapi.features.isEnabled(window.strapi.features.SSO)
? [
{
intlLabel: {
id: 'Settings.permissions.users.form.sso',
defaultMessage: 'Connect with SSO',
},
hint: {
id: 'Settings.permissions.users.form.sso.description',
defaultMessage: 'When enabled (ON), users can login via SSO',
},
name: 'useSSORegistration',
type: 'bool',
size: {
col: 6,
xs: 12,
},
},
]
: []),
];

View File

@ -1,24 +0,0 @@
const form = window.strapi.features.isEnabled(window.strapi.features.SSO)
? [
[
{
intlLabel: {
id: 'Settings.permissions.users.form.sso',
defaultMessage: 'Connect with SSO',
},
hint: {
id: 'Settings.permissions.users.form.sso.description',
defaultMessage: 'When enabled (ON), users can login via SSO',
},
name: 'useSSORegistration',
type: 'bool',
size: {
col: 6,
xs: 12,
},
},
],
]
: [];
export default form;