mirror of
https://github.com/strapi/strapi.git
synced 2025-11-17 18:51:22 +00:00
wip
This commit is contained in:
parent
87b8a3b4e2
commit
9f7208db9d
@ -1,36 +1,33 @@
|
|||||||
import React, { useState, useRef } from 'react';
|
|
||||||
import { Header } from '@buffetjs/custom';
|
|
||||||
import { Padded } from '@buffetjs/core';
|
import { Padded } from '@buffetjs/core';
|
||||||
import moment from 'moment';
|
|
||||||
import { Formik } from 'formik';
|
|
||||||
import { get, isEmpty } from 'lodash';
|
|
||||||
import { useIntl } from 'react-intl';
|
|
||||||
import { HeaderLayout, Button } from '@strapi/parts';
|
|
||||||
import { AddIcon, EditIcon } from '@strapi/icons';
|
|
||||||
import {
|
import {
|
||||||
BaselineAlignment,
|
BaselineAlignment,
|
||||||
CheckPagePermissions,
|
CheckPagePermissions,
|
||||||
request,
|
request,
|
||||||
useTracking,
|
|
||||||
useNotification,
|
useNotification,
|
||||||
useOverlayBlocker,
|
useOverlayBlocker,
|
||||||
|
useTracking,
|
||||||
} from '@strapi/helper-plugin';
|
} from '@strapi/helper-plugin';
|
||||||
|
import { Button, HeaderLayout, Stack } from '@strapi/parts';
|
||||||
|
import { Formik } from 'formik';
|
||||||
|
import { get, isEmpty } from 'lodash';
|
||||||
|
import moment from 'moment';
|
||||||
|
import React, { useRef, useState } from 'react';
|
||||||
|
import { useIntl } from 'react-intl';
|
||||||
import { useHistory, useRouteMatch } from 'react-router-dom';
|
import { useHistory, useRouteMatch } from 'react-router-dom';
|
||||||
import adminPermissions from '../../../../../admin/src/permissions';
|
|
||||||
import { useFetchPermissionsLayout, useFetchRole } from '../../../../../admin/src/hooks';
|
|
||||||
import PageTitle from '../../../../../admin/src/components/SettingsPageTitle';
|
|
||||||
import FormCard from '../../../../../admin/src/components/FormBloc';
|
import FormCard from '../../../../../admin/src/components/FormBloc';
|
||||||
import { ButtonWithNumber } from '../../../../../admin/src/components/Roles';
|
import { ButtonWithNumber } from '../../../../../admin/src/components/Roles';
|
||||||
import SizedInput from '../../../../../admin/src/components/SizedInput';
|
|
||||||
import Permissions from '../../../../../admin/src/components/Roles/Permissions';
|
import Permissions from '../../../../../admin/src/components/Roles/Permissions';
|
||||||
|
import PageTitle from '../../../../../admin/src/components/SettingsPageTitle';
|
||||||
|
import SizedInput from '../../../../../admin/src/components/SizedInput';
|
||||||
|
import { useFetchPermissionsLayout, useFetchRole } from '../../../../../admin/src/hooks';
|
||||||
|
import adminPermissions from '../../../../../admin/src/permissions';
|
||||||
import schema from './utils/schema';
|
import schema from './utils/schema';
|
||||||
|
|
||||||
const CreatePage = () => {
|
const CreatePage = () => {
|
||||||
const toggleNotification = useNotification();
|
const toggleNotification = useNotification();
|
||||||
const { lockApp, unlockApp } = useOverlayBlocker();
|
const { lockApp, unlockApp } = useOverlayBlocker();
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const [isSubmiting, setIsSubmiting] = useState(false);
|
const [, setIsSubmiting] = useState(false);
|
||||||
const { replace } = useHistory();
|
const { replace } = useHistory();
|
||||||
const permissionsRef = useRef();
|
const permissionsRef = useRef();
|
||||||
const { trackUsage } = useTracking();
|
const { trackUsage } = useTracking();
|
||||||
@ -39,31 +36,6 @@ const CreatePage = () => {
|
|||||||
const { isLoading: isLayoutLoading, data: permissionsLayout } = useFetchPermissionsLayout();
|
const { isLoading: isLayoutLoading, data: permissionsLayout } = useFetchPermissionsLayout();
|
||||||
const { permissions: rolePermissions, isLoading: isRoleLoading } = useFetchRole(id);
|
const { permissions: rolePermissions, isLoading: isRoleLoading } = useFetchRole(id);
|
||||||
|
|
||||||
const headerActions = (handleSubmit, handleReset) => [
|
|
||||||
{
|
|
||||||
label: formatMessage({
|
|
||||||
id: 'app.components.Button.reset',
|
|
||||||
defaultMessage: 'Reset',
|
|
||||||
}),
|
|
||||||
onClick: () => {
|
|
||||||
handleReset();
|
|
||||||
permissionsRef.current.resetForm();
|
|
||||||
},
|
|
||||||
color: 'cancel',
|
|
||||||
type: 'button',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: formatMessage({
|
|
||||||
id: 'app.components.Button.save',
|
|
||||||
defaultMessage: 'Save',
|
|
||||||
}),
|
|
||||||
onClick: handleSubmit,
|
|
||||||
color: 'success',
|
|
||||||
type: 'submit',
|
|
||||||
isLoading: isSubmiting,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const handleCreateRoleSubmit = data => {
|
const handleCreateRoleSubmit = data => {
|
||||||
lockApp();
|
lockApp();
|
||||||
setIsSubmiting(true);
|
setIsSubmiting(true);
|
||||||
@ -145,29 +117,36 @@ const CreatePage = () => {
|
|||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<>
|
<>
|
||||||
<HeaderLayout
|
<HeaderLayout
|
||||||
primaryAction={<Button startIcon={<AddIcon />}>Add an entry</Button>}
|
primaryAction={
|
||||||
secondaryAction={
|
<Stack horizontal size={2}>
|
||||||
<Button variant="tertiary" startIcon={<EditIcon />}>
|
<Button
|
||||||
Edit
|
onClick={() => {
|
||||||
|
handleReset();
|
||||||
|
permissionsRef.current.resetForm();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{formatMessage({
|
||||||
|
id: 'app.components.Button.reset',
|
||||||
|
defaultMessage: 'Reset',
|
||||||
|
})}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button onClick={handleSubmit}>
|
||||||
|
{formatMessage({
|
||||||
|
id: 'app.components.Button.save',
|
||||||
|
defaultMessage: 'Save',
|
||||||
|
})}
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
}
|
}
|
||||||
title="Other CT"
|
title={formatMessage({
|
||||||
subtitle="36 entries found"
|
|
||||||
as="h1"
|
|
||||||
/>
|
|
||||||
<Header
|
|
||||||
title={{
|
|
||||||
label: formatMessage({
|
|
||||||
id: 'Settings.roles.create.title',
|
id: 'Settings.roles.create.title',
|
||||||
defaultMessage: 'Create a role',
|
defaultMessage: 'Create a role',
|
||||||
}),
|
})}
|
||||||
}}
|
subtitle={formatMessage({
|
||||||
content={formatMessage({
|
|
||||||
id: 'Settings.roles.create.description',
|
id: 'Settings.roles.create.description',
|
||||||
defaultMessage: 'Define the rights given to the role',
|
defaultMessage: 'Define the rights given to the role',
|
||||||
})}
|
})}
|
||||||
actions={headerActions(handleSubmit, handleReset)}
|
as="h1"
|
||||||
isLoading={isLayoutLoading}
|
|
||||||
/>
|
/>
|
||||||
<BaselineAlignment top size="3px" />
|
<BaselineAlignment top size="3px" />
|
||||||
<FormCard
|
<FormCard
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user