2024-10-18 07:21:12: merge [main:5410dbee742841318d58b4865020b1b33dd6c586];
This commit is contained in:
1 parent
ae26c073e1
commit
3ddbdbda6d
60 files changed
+1595
-747
No files matched your search
@@ -1,223 +1,227 @@
|
||||
import { CheckOutlined, CloseOutlined, EditOutlined } from '@ant-design/icons'
|
||||
import { Button, message, Table, Tag, Tooltip } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import dayjs from 'dayjs'
|
||||
import { FC, useEffect, useRef, useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
import ActiveTableActionButtons from '@widgets/ActiveTableActionButtons'
|
||||
|
||||
import {
|
||||
ActiveConfigurationsTablePropsType
|
||||
} from '@components/ActiveConfigurationsTable/active-configurations-table.type.ts'
|
||||
import { ActiveConfigurationsTablePropsType } from '@components/ActiveConfigurationsTable/active-configurations-table.type.ts'
|
||||
import CanEdit from '@components/CanEdit'
|
||||
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import configApi from '@services/configService.ts'
|
||||
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import './active-configurations-table.scss'
|
||||
import dayjs from 'dayjs'
|
||||
import CanEdit from '@components/CanEdit'
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> = ({
|
||||
isActiveTable = false,
|
||||
handleShowConfig,
|
||||
handleShowCompareModal,
|
||||
data,
|
||||
currentModule = {}
|
||||
}) => {
|
||||
const [editKeyConfig, setEditKeyConfig] = useState<string>('')
|
||||
const [tempEditValues, setTempEditValues] = useState<any>()
|
||||
const inputRefs = useRef<Record<string, HTMLInputElement | null>>({})
|
||||
const [createUpdateConfig] = configApi.useCreateUpdateConfigMutation()
|
||||
const [markConfigAsActive] = configApi.useMarkConfigAsActiveMutation()
|
||||
const [deleteConfig] = configApi.useDeleteConfigMutation()
|
||||
const navigate = useNavigate()
|
||||
const { id: moduleId } = useParams()
|
||||
|
||||
const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> =
|
||||
({
|
||||
isActiveTable = false,
|
||||
handleShowConfig,
|
||||
handleShowCompareModal,
|
||||
data,
|
||||
currentModule = {}
|
||||
}) => {
|
||||
const [editKeyConfig, setEditKeyConfig] = useState<string>('')
|
||||
const [tempEditValues, setTempEditValues] = useState<any>()
|
||||
const inputRefs = useRef<Record<string, HTMLInputElement | null>>({})
|
||||
const [createUpdateConfig] = configApi.useCreateUpdateConfigMutation()
|
||||
const [markConfigAsActive] = configApi.useMarkConfigAsActiveMutation()
|
||||
const [deleteConfig] = configApi.useDeleteConfigMutation()
|
||||
const navigate = useNavigate()
|
||||
const {id: moduleId} = useParams()
|
||||
|
||||
useEffect(() => {
|
||||
if (inputRefs.current[editKeyConfig]) {
|
||||
inputRefs.current[editKeyConfig]?.focus()
|
||||
}
|
||||
}, [editKeyConfig])
|
||||
const handleEditStart = (record: ConfigType) => {
|
||||
setEditKeyConfig(record.id)
|
||||
setTempEditValues({
|
||||
...tempEditValues,
|
||||
[record.id]: record.name
|
||||
} as ConfigType)
|
||||
useEffect(() => {
|
||||
if (inputRefs.current[editKeyConfig]) {
|
||||
inputRefs.current[editKeyConfig]?.focus()
|
||||
}
|
||||
}, [editKeyConfig])
|
||||
const handleEditStart = (record: ConfigType) => {
|
||||
setEditKeyConfig(record.id)
|
||||
setTempEditValues({
|
||||
...tempEditValues,
|
||||
[record.id]: record.name
|
||||
} as ConfigType)
|
||||
}
|
||||
|
||||
const handleCancelEdit = (record: ConfigType) => {
|
||||
setEditKeyConfig('')
|
||||
setTempEditValues({
|
||||
...tempEditValues,
|
||||
[record.id]: record.name
|
||||
} as ConfigType)
|
||||
}
|
||||
const handleCancelEdit = (record: ConfigType) => {
|
||||
setEditKeyConfig('')
|
||||
setTempEditValues({
|
||||
...tempEditValues,
|
||||
[record.id]: record.name
|
||||
} as ConfigType)
|
||||
}
|
||||
|
||||
const handleSaveEdit = (record: ConfigType) => {
|
||||
const sendData = { ...record, name: tempEditValues[record.id] }
|
||||
createUpdateConfig(sendData)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно сохранен')
|
||||
setEditKeyConfig('')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось сохранить элемент')
|
||||
})
|
||||
}
|
||||
const handleDeleteConfig = (record: ConfigType) => {
|
||||
deleteConfig(record.id)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно удален')
|
||||
setEditKeyConfig('')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось удалить элемент')
|
||||
})
|
||||
}
|
||||
const handleSaveEdit = (record: ConfigType) => {
|
||||
const sendData = { ...record, name: tempEditValues[record.id] }
|
||||
createUpdateConfig(sendData)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно сохранен')
|
||||
setEditKeyConfig('')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось сохранить элемент')
|
||||
})
|
||||
}
|
||||
const handleDeleteConfig = (record: ConfigType) => {
|
||||
deleteConfig(record.id)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно удален')
|
||||
setEditKeyConfig('')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось удалить элемент')
|
||||
})
|
||||
}
|
||||
|
||||
const handleMarkConfigActive = (record: ConfigType) => {
|
||||
markConfigAsActive(record.id)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно обновлен')
|
||||
setEditKeyConfig('')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось обновить элемент')
|
||||
})
|
||||
}
|
||||
const handleMarkConfigActive = (record: ConfigType) => {
|
||||
markConfigAsActive(record.id)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно обновлен')
|
||||
setEditKeyConfig('')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось обновить элемент')
|
||||
})
|
||||
}
|
||||
|
||||
const renderNameField = (value: string, record: ConfigType) => {
|
||||
const canEdit = editKeyConfig === record.id
|
||||
const inputValue = canEdit ? tempEditValues[record.id] : value
|
||||
const renderNameField = (value: string, record: ConfigType) => {
|
||||
const canEdit = editKeyConfig === record.id
|
||||
const inputValue = canEdit ? tempEditValues[record.id] : value
|
||||
|
||||
return (
|
||||
<div className="active-configurations-table__table__name-field">
|
||||
<input
|
||||
ref={(inputRef) => (inputRefs.current[record.id] = inputRef)}
|
||||
onChange={(event) => {
|
||||
const { value } = event.target
|
||||
setTempEditValues({ ...tempEditValues, [record.id]: value })
|
||||
}}
|
||||
disabled={!canEdit}
|
||||
value={inputValue}
|
||||
/>
|
||||
{canEdit ? (
|
||||
<div className="active-configurations-table__table__name-field__actions">
|
||||
<Tooltip title="Сохранить">
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => handleSaveEdit(record)}
|
||||
icon={<CheckOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title="Отменить">
|
||||
<Button
|
||||
onClick={() => handleCancelEdit(record)}
|
||||
icon={<CloseOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
) : (
|
||||
<CanEdit>
|
||||
<Tooltip title="Редактировать название">
|
||||
<Button
|
||||
onClick={() => handleEditStart(record)}
|
||||
icon={<EditOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</CanEdit>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const columns: ColumnsType<ConfigType> = [
|
||||
{
|
||||
title: 'Наименование',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
render: renderNameField,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: 'Версия',
|
||||
dataIndex: 'version',
|
||||
key: 'version',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: 'Статус',
|
||||
dataIndex: 'valid',
|
||||
key: 'version',
|
||||
align: 'center',
|
||||
render: (value: boolean) => {
|
||||
if (value) {
|
||||
return <Tag color="success">Корректная</Tag>
|
||||
}
|
||||
return <Tag color="error">Некорректная</Tag>
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Дата обновления',
|
||||
dataIndex: 'updatedAt',
|
||||
key: 'updatedAt',
|
||||
align: 'center',
|
||||
render: (value: string) => {
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Действия',
|
||||
dataIndex: 'actions',
|
||||
key: 'actions',
|
||||
align: 'center',
|
||||
render: (_: unknown, record: ConfigType) => (
|
||||
<ActiveTableActionButtons
|
||||
isActive={isActiveTable}
|
||||
handleShowConfig={handleShowConfig}
|
||||
handleShowCompareModal={handleShowCompareModal}
|
||||
handleDeleteConfig={handleDeleteConfig}
|
||||
handleMarkConfigActive={handleMarkConfigActive}
|
||||
record={record}
|
||||
/>
|
||||
)
|
||||
}
|
||||
]
|
||||
const className = `active-configurations-table__table ${isActiveTable ? 'active-config' : ''}`
|
||||
return (
|
||||
<div className="active-configurations-table">
|
||||
<div className="active-configurations-table__buttons">
|
||||
<h2 className="active-configurations-table__title">
|
||||
{isActiveTable ? 'Активная' : 'Остальные'}
|
||||
</h2>
|
||||
{!isActiveTable && <CanEdit>
|
||||
<Button
|
||||
className="configurations__buttons__new-config-brn"
|
||||
onClick={() => navigate(`/${moduleId}/${routePaths.configEditor}/new`, {state: currentModule})}
|
||||
>
|
||||
Создать
|
||||
</Button>
|
||||
</CanEdit>}
|
||||
</div>
|
||||
<Table
|
||||
rowHoverable={false}
|
||||
className={className}
|
||||
rowKey={(record) => record.id}
|
||||
pagination={false}
|
||||
columns={columns}
|
||||
dataSource={data}
|
||||
<div className="active-configurations-table__table__name-field">
|
||||
<input
|
||||
ref={(inputRef) => (inputRefs.current[record.id] = inputRef)}
|
||||
onChange={(event) => {
|
||||
const { value } = event.target
|
||||
setTempEditValues({ ...tempEditValues, [record.id]: value })
|
||||
}}
|
||||
disabled={!canEdit}
|
||||
value={inputValue}
|
||||
/>
|
||||
{canEdit ? (
|
||||
<div className="active-configurations-table__table__name-field__actions">
|
||||
<Tooltip title="Сохранить">
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => handleSaveEdit(record)}
|
||||
icon={<CheckOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title="Отменить">
|
||||
<Button
|
||||
onClick={() => handleCancelEdit(record)}
|
||||
icon={<CloseOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
) : (
|
||||
<CanEdit>
|
||||
<Tooltip title="Редактировать название">
|
||||
<Button
|
||||
onClick={() => handleEditStart(record)}
|
||||
icon={<EditOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</CanEdit>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const columns: ColumnsType<ConfigType> = [
|
||||
{
|
||||
title: 'Наименование',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
render: renderNameField,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: 'Версия',
|
||||
dataIndex: 'version',
|
||||
key: 'version',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: 'Статус',
|
||||
dataIndex: 'valid',
|
||||
key: 'version',
|
||||
align: 'center',
|
||||
render: (value: boolean) => {
|
||||
if (value) {
|
||||
return <Tag color="success">Корректная</Tag>
|
||||
}
|
||||
return <Tag color="error">Некорректная</Tag>
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Дата обновления',
|
||||
dataIndex: 'updatedAt',
|
||||
key: 'updatedAt',
|
||||
align: 'center',
|
||||
render: (value: string) => {
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Действия',
|
||||
dataIndex: 'actions',
|
||||
key: 'actions',
|
||||
align: 'center',
|
||||
render: (_: unknown, record: ConfigType) => (
|
||||
<ActiveTableActionButtons
|
||||
isActive={isActiveTable}
|
||||
handleShowConfig={handleShowConfig}
|
||||
handleShowCompareModal={handleShowCompareModal}
|
||||
handleDeleteConfig={handleDeleteConfig}
|
||||
handleMarkConfigActive={handleMarkConfigActive}
|
||||
record={record}
|
||||
/>
|
||||
)
|
||||
}
|
||||
]
|
||||
const className = `active-configurations-table__table ${isActiveTable ? 'active-config' : ''}`
|
||||
return (
|
||||
<div className="active-configurations-table">
|
||||
<div className="active-configurations-table__buttons">
|
||||
<h2 className="active-configurations-table__title">
|
||||
{isActiveTable ? 'Активная' : 'Остальные'}
|
||||
</h2>
|
||||
{!isActiveTable && (
|
||||
<CanEdit>
|
||||
<Button
|
||||
className="configurations__buttons__new-config-brn"
|
||||
onClick={() =>
|
||||
navigate(`/${moduleId}/${routePaths.configEditor}/new`, {
|
||||
state: currentModule
|
||||
})
|
||||
}
|
||||
>
|
||||
Создать
|
||||
</Button>
|
||||
</CanEdit>
|
||||
)}
|
||||
</div>
|
||||
<Table
|
||||
rowHoverable={false}
|
||||
className={className}
|
||||
rowKey={(record) => record.id}
|
||||
pagination={false}
|
||||
columns={columns}
|
||||
dataSource={data}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ActiveConfigurationsTable
|
||||
@@ -2,10 +2,7 @@ import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
import { ApplicationsGroupType } from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
export type AppGroupModalType = Omit<
|
||||
ModalPropsType,
|
||||
'onOk' | 'children'
|
||||
> & {
|
||||
export type AppGroupModalType = Omit<ModalPropsType, 'onOk' | 'children'> & {
|
||||
appGroup?: ApplicationsGroupType
|
||||
onOk: (data: ApplicationsGroupType) => void
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import { AppGroupModalType } from '@components/AppGroupModal/app-group-modal.typ
|
||||
|
||||
import { ApplicationsGroupType } from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
|
||||
const { FormInput, FormTextArea } = FormComponents
|
||||
|
||||
const AppGroupModal: FC<AppGroupModalType> = ({
|
||||
@@ -18,8 +17,7 @@ const AppGroupModal: FC<AppGroupModalType> = ({
|
||||
onClose,
|
||||
onOk,
|
||||
open,
|
||||
appGroup,
|
||||
|
||||
appGroup
|
||||
}) => {
|
||||
const { handleSubmit, control, reset } = useForm<ApplicationsGroupType>({
|
||||
mode: 'onChange',
|
||||
|
||||
@@ -10,10 +10,9 @@ import { AppModalType } from '@components/AppModal/app-group-modal.type.ts'
|
||||
|
||||
import { ApplicationAppType } from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
|
||||
const { FormInput, FormTextArea } = FormComponents
|
||||
|
||||
const AppModal: FC<AppModalType> = ({ title,onOk, onClose, open, app }) => {
|
||||
const AppModal: FC<AppModalType> = ({ title, onOk, onClose, open, app }) => {
|
||||
const { handleSubmit, control, reset } = useForm<ApplicationAppType>({
|
||||
mode: 'onChange',
|
||||
defaultValues: app
|
||||
|
||||
@@ -24,7 +24,6 @@ import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import './applications-content.scss'
|
||||
|
||||
|
||||
const { EmptyData, Column } = Layout
|
||||
|
||||
interface ApplicationsContentPropTypes {
|
||||
@@ -134,7 +133,9 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент удален')
|
||||
navigate(`${routePaths.applicationsGroup}/${selectedItemId}/${routePaths.application}`)
|
||||
navigate(
|
||||
`${routePaths.applicationsGroup}/${selectedItemId}/${routePaths.application}`
|
||||
)
|
||||
})
|
||||
.catch(() => message.error('Ошибка удаления элемента'))
|
||||
|
||||
@@ -142,7 +143,10 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
||||
return (
|
||||
<List.Item>
|
||||
<Tooltip mouseEnterDelay={1.3} title={item.name}>
|
||||
<List.Item.Meta title={item.name} description={<span>id: {item.id}</span>}/>
|
||||
<List.Item.Meta
|
||||
title={item.name}
|
||||
description={<span>id: {item.id}</span>}
|
||||
/>
|
||||
<div
|
||||
className="link-btn"
|
||||
onClick={(e) => {
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
import { message } from 'antd'
|
||||
import { FormComponents } from 'isp-ui-kit'
|
||||
import { FC, useEffect, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import {
|
||||
ChangePasswordModalProps,
|
||||
ChangePasswordModalType
|
||||
} from '@components/ChangePasswordModal/change-password-modal.type.ts'
|
||||
import { apiService } from '@services/apiService.ts'
|
||||
|
||||
import { ChangeProfilePassword } from '@pages/ProfilePage/profile-page.type.ts'
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
import { message } from 'antd'
|
||||
|
||||
import useLogout from '@hooks/useLogout.tsx'
|
||||
|
||||
import { apiService } from '@services/apiService.ts'
|
||||
|
||||
const { FormInputPassword } = FormComponents
|
||||
const ChangePasswordModal: FC<ChangePasswordModalProps> = ({
|
||||
open,
|
||||
onClose
|
||||
}) => {
|
||||
open,
|
||||
onClose
|
||||
}) => {
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
@@ -36,10 +40,10 @@ const ChangePasswordModal: FC<ChangePasswordModalProps> = ({
|
||||
const onSubmit = async (formValue: ChangePasswordModalType) => {
|
||||
setLoading(true)
|
||||
try {
|
||||
await apiService.post<ChangeProfilePassword>(
|
||||
apiPaths.changePassword,
|
||||
{ oldPassword: formValue.oldPassword, newPassword: formValue.newPassword }
|
||||
)
|
||||
await apiService.post<ChangeProfilePassword>(apiPaths.changePassword, {
|
||||
oldPassword: formValue.oldPassword,
|
||||
newPassword: formValue.newPassword
|
||||
})
|
||||
await logoutUser()
|
||||
message.success('Пароль успешно изменен')
|
||||
clearErrors('oldPassword')
|
||||
@@ -115,4 +119,3 @@ const ChangePasswordModal: FC<ChangePasswordModalProps> = ({
|
||||
)
|
||||
}
|
||||
export default ChangePasswordModal
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { EditorState, EditorView } from '@uiw/react-codemirror'
|
||||
import { Button, Spin, Table } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import dayjs from 'dayjs'
|
||||
import { FC, memo, useContext, useState } from 'react'
|
||||
import CodeMirrorMerge from 'react-codemirror-merge'
|
||||
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import { CompareVersionModalPropsType } from '@components/CompareVersionModal/compare-version-modal.type'
|
||||
@@ -15,23 +18,21 @@ import { useAppSelector } from '@hooks/redux.ts'
|
||||
import configServiceApi from '@services/configService.ts'
|
||||
import userServiceApi from '@services/userService.ts'
|
||||
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
import { VersionType } from '@type/version.type'
|
||||
|
||||
import './compare-version-modal.scss'
|
||||
import dayjs from 'dayjs'
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
|
||||
const Original = CodeMirrorMerge.Original
|
||||
const Modified = CodeMirrorMerge.Modified
|
||||
|
||||
const CompareVersionModal: FC<CompareVersionModalPropsType> = ({
|
||||
open,
|
||||
onClose,
|
||||
config,
|
||||
currentConfigId
|
||||
}) => {
|
||||
open,
|
||||
onClose,
|
||||
config,
|
||||
currentConfigId
|
||||
}) => {
|
||||
const [selectedItem, setSelectedItem] = useState<VersionType>()
|
||||
const { data: versions = [], isLoading: isVersionLoading } =
|
||||
configServiceApi.useGetAllVersionQuery(currentConfigId)
|
||||
@@ -73,13 +74,21 @@ const CompareVersionModal: FC<CompareVersionModalPropsType> = ({
|
||||
]
|
||||
return (
|
||||
<div className="compare-version-modal">
|
||||
<Modal title="Выберите версию для сравнения" open={open} onClose={onClose}>
|
||||
<Modal
|
||||
title="Выберите версию для сравнения"
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
>
|
||||
{selectedItem ? (
|
||||
<div className="compare-version-modal__content">
|
||||
<Button onClick={() => setSelectedItem(undefined)}>Назад</Button>
|
||||
<div className="compare-version-modal__header">
|
||||
<span> Версия: {selectedItem.configVersion}</span>
|
||||
<span>{config?.version ? `Текущая версия : ${config?.version}` : `Версия: ${config?.configVersion}`}</span>
|
||||
<span>
|
||||
{config?.version
|
||||
? `Текущая версия : ${config?.version}`
|
||||
: `Версия: ${config?.configVersion}`}
|
||||
</span>
|
||||
</div>
|
||||
<CodeMirrorMerge
|
||||
orientation="a-b"
|
||||
|
||||
@@ -2,7 +2,6 @@ import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
import { JSONSchema } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
|
||||
export interface ConfigSchemaModalPropsType
|
||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
schema?: JSONSchema
|
||||
|
||||
@@ -12,7 +12,6 @@ const ConfigSchemaModal: FC<ConfigSchemaModalPropsType> = ({
|
||||
onClose,
|
||||
schema = {}
|
||||
}) => {
|
||||
|
||||
return (
|
||||
<div className="config-schema-modal">
|
||||
<Modal title="Текущая схема" open={open} onClose={onClose}>
|
||||
|
||||
@@ -1,48 +1,53 @@
|
||||
import { FC, useContext } from 'react'
|
||||
import { ConfigurationEditorPropsType } from '@pages/ConfigurationEditorPage'
|
||||
import Editor, { loader } from '@monaco-editor/react'
|
||||
import * as monaco from 'monaco-editor'
|
||||
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'
|
||||
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker'
|
||||
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker'
|
||||
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'
|
||||
import { FC, useContext } from 'react'
|
||||
|
||||
import { ConfigurationEditorPropsType } from '@pages/ConfigurationEditorPage/ConfigurationEditor.type.ts'
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
import * as monaco from 'monaco-editor'
|
||||
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
||||
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
||||
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
|
||||
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
|
||||
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
||||
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'
|
||||
|
||||
const ConfigurationEditorCode: FC<ConfigurationEditorPropsType> = ({setDisableBtn= () => {}, bufConfig, setBufConfig }) => {
|
||||
const ConfigurationEditorCode: FC<ConfigurationEditorPropsType> = ({
|
||||
setDisableBtn = () => {},
|
||||
bufConfig,
|
||||
setBufConfig
|
||||
}) => {
|
||||
const { changeTheme } = useContext(Context)
|
||||
|
||||
self.MonacoEnvironment = {
|
||||
getWorker(_, label) {
|
||||
if (label === 'json') {
|
||||
return new jsonWorker();
|
||||
return new jsonWorker()
|
||||
}
|
||||
if (label === 'css' || label === 'scss' || label === 'less') {
|
||||
return new cssWorker();
|
||||
return new cssWorker()
|
||||
}
|
||||
if (label === 'html' || label === 'handlebars' || label === 'razor') {
|
||||
return new htmlWorker();
|
||||
return new htmlWorker()
|
||||
}
|
||||
if (label === 'typescript' || label === 'javascript') {
|
||||
return new tsWorker();
|
||||
return new tsWorker()
|
||||
}
|
||||
return new editorWorker();
|
||||
},
|
||||
};
|
||||
return new editorWorker()
|
||||
}
|
||||
}
|
||||
|
||||
loader.config({ monaco });
|
||||
loader.config({ monaco })
|
||||
|
||||
loader.init().then();
|
||||
loader.init().then()
|
||||
|
||||
const handleChange = (data: string | undefined) => {
|
||||
|
||||
if (data) {
|
||||
try {
|
||||
const newData = {
|
||||
...bufConfig,
|
||||
data: {...JSON.parse(data) }
|
||||
data: { ...JSON.parse(data) }
|
||||
} as ConfigType
|
||||
setDisableBtn(false)
|
||||
setBufConfig(newData)
|
||||
@@ -52,7 +57,7 @@ const ConfigurationEditorCode: FC<ConfigurationEditorPropsType> = ({setDisableBt
|
||||
}
|
||||
}
|
||||
|
||||
const editorValue = JSON.stringify(bufConfig?.data, null, '\t')
|
||||
const editorValue = JSON.stringify(bufConfig?.data, null, '\t')
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -67,12 +72,11 @@ const ConfigurationEditorCode: FC<ConfigurationEditorPropsType> = ({setDisableBt
|
||||
minimap: {
|
||||
enabled: false
|
||||
},
|
||||
fontSize: 16,
|
||||
fontSize: 16
|
||||
}}
|
||||
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ConfigurationEditorCode
|
||||
export default ConfigurationEditorCode
|
||||
@@ -1,30 +1,55 @@
|
||||
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons'
|
||||
import { Theme as AntDTheme } from '@rjsf/antd'
|
||||
import { withTheme } from '@rjsf/core'
|
||||
import { UiSchema } from '@rjsf/utils'
|
||||
import validator from '@rjsf/validator-ajv8'
|
||||
import { FC, useEffect, useState } from 'react'
|
||||
|
||||
import { ConfigurationEditorPropsType } from '@pages/ConfigurationEditorPage'
|
||||
import { Tabs } from 'antd'
|
||||
import equal from 'deep-equal'
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
Tabs,
|
||||
Tooltip,
|
||||
Form as FormAntd,
|
||||
Collapse,
|
||||
Typography,
|
||||
Space
|
||||
} from 'antd'
|
||||
import equal from 'deep-equal'
|
||||
import { createRef, FC, memo, useEffect, useState } from 'react'
|
||||
import { useParams } from 'react-router-dom'
|
||||
|
||||
import {
|
||||
ArrayFieldTemplatePropsType,
|
||||
ConfigurationEditorPropsType,
|
||||
DescriptionPropsType,
|
||||
ErrorsObjType,
|
||||
FieldTemplatePropsType,
|
||||
ObjectFieldTemplatePropertyType,
|
||||
ObjectFieldTemplatePropsType,
|
||||
SortPropType
|
||||
} from '@pages/ConfigurationEditorPage/ConfigurationEditor.type.ts'
|
||||
import { ResponseSchemaType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import { cleanEmptyParamsObject } from '@utils/objectUtils.ts'
|
||||
|
||||
const { Text: AntdText } = Typography
|
||||
|
||||
const ConfigurationEditorForm: FC<ConfigurationEditorPropsType> = ({
|
||||
bufConfig ={},
|
||||
JsonSchema,
|
||||
setBufConfig,
|
||||
}) => {
|
||||
bufConfig = {},
|
||||
jsonSchema = {},
|
||||
submitRef
|
||||
}) => {
|
||||
const Form = withTheme(AntDTheme)
|
||||
const sortProps = (a, b) => a.name.localeCompare(b.name)
|
||||
const sortProps = (a: SortPropType, b: SortPropType) =>
|
||||
a.name.localeCompare(b.name)
|
||||
|
||||
const [formState, setFormState] = useState(bufConfig.data)
|
||||
const [activeTabKey, setActiveTabKey] = useState()
|
||||
const {id} = useParams()
|
||||
const { id } = useParams()
|
||||
const formRef = createRef<any>()
|
||||
|
||||
useEffect(() => {
|
||||
if(!equal(formState, bufConfig.data)) {
|
||||
setFormState(bufConfig.data)
|
||||
}
|
||||
if (!equal(formState, bufConfig.data)) {
|
||||
setFormState(bufConfig.data)
|
||||
}
|
||||
}, [bufConfig.data])
|
||||
|
||||
const uiSchema: UiSchema = {
|
||||
@@ -33,37 +58,206 @@ const ConfigurationEditorForm: FC<ConfigurationEditorPropsType> = ({
|
||||
}
|
||||
}
|
||||
|
||||
const onFormChange = data => {
|
||||
if(!equal(data.formData, bufConfig.data)) {
|
||||
const newData = {
|
||||
...bufConfig,
|
||||
data: { ...data.formData }
|
||||
}
|
||||
if(!equal(newData, bufConfig.data)) {
|
||||
setBufConfig(newData)
|
||||
}
|
||||
|
||||
const onSubmit = (data: any) => {
|
||||
if (!submitRef) return
|
||||
if (
|
||||
!formRef.current.validateFormWithFormData(formRef.current.state.formData)
|
||||
) {
|
||||
submitRef.current = data
|
||||
} else {
|
||||
submitRef.current = data.formData
|
||||
}
|
||||
}
|
||||
|
||||
const handleTabsChange = e => {
|
||||
setActiveTabKey(e)
|
||||
const forceSubmit = () => {
|
||||
if (formRef.current) {
|
||||
const formData = formRef.current.state.formData
|
||||
|
||||
onSubmit(cleanEmptyParamsObject(formData))
|
||||
}
|
||||
}
|
||||
|
||||
const ObjectFieldTemplate = (props) => {
|
||||
const onFormChange = () => {
|
||||
if (!formRef.current) return
|
||||
if (
|
||||
formRef.current.validateFormWithFormData(formRef.current.state.formData)
|
||||
) {
|
||||
formRef?.current?.submit()
|
||||
} else {
|
||||
forceSubmit()
|
||||
}
|
||||
}
|
||||
|
||||
const Description: FC<DescriptionPropsType> = ({ description }) =>
|
||||
description ? (
|
||||
<span>
|
||||
|
||||
<Tooltip title={description}></Tooltip>
|
||||
</span>
|
||||
) : null
|
||||
|
||||
const getDepth = (id: string) => {
|
||||
if (!id) {
|
||||
return 0
|
||||
}
|
||||
return id.split('_').length
|
||||
}
|
||||
|
||||
const getName = (id: string) => {
|
||||
if (!id) {
|
||||
return ''
|
||||
}
|
||||
const arr = id.split('_')
|
||||
return `#${arr[arr.length - 1] || ''}`
|
||||
}
|
||||
|
||||
const FieldTemplate: FC<FieldTemplatePropsType> = (props) => {
|
||||
const {
|
||||
id,
|
||||
classNames,
|
||||
label,
|
||||
rawHelp,
|
||||
required,
|
||||
rawDescription,
|
||||
rawErrors,
|
||||
children,
|
||||
displayLabel,
|
||||
schema
|
||||
} = props
|
||||
|
||||
const isObject = schema.type === 'object'
|
||||
const depth = getDepth(id)
|
||||
const name = label || getName(id)
|
||||
|
||||
// Проверяем на наличие ошибок и формируем их вывод
|
||||
const errorMessages = rawErrors ? rawErrors.join('\n') : null
|
||||
|
||||
// Объекты и массивы - Обработка по глубине
|
||||
if (isObject && depth !== 1) {
|
||||
const title = (
|
||||
<div className={required ? 'ant-form-item-required' : ''}>
|
||||
{depth !== 2 && <AntdText strong>{name}</AntdText>}
|
||||
{errorMessages && (
|
||||
<AntdText type="danger">{` (${errorMessages})`}</AntdText>
|
||||
)}
|
||||
{depth !== 2 && <Description description={rawDescription} />}
|
||||
</div>
|
||||
)
|
||||
|
||||
if (depth === 2 || schema.dynamic) {
|
||||
return (
|
||||
<div style={{ width: '100%' }}>
|
||||
{!schema.dynamic && title}
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Collapse className="collapse" defaultActiveKey={depth > 1 ? '' : id}>
|
||||
<Collapse.Panel
|
||||
key={id}
|
||||
className="configEditor_collapseObject"
|
||||
header={title}
|
||||
>
|
||||
{children}
|
||||
</Collapse.Panel>
|
||||
</Collapse>
|
||||
)
|
||||
}
|
||||
|
||||
// Для остальных типов возвращаем форму с элементами
|
||||
return (
|
||||
<FormAntd.Item
|
||||
className={classNames}
|
||||
validateStatus={errorMessages ? 'error' : undefined}
|
||||
help={errorMessages || undefined}
|
||||
extra={rawHelp}
|
||||
required={required}
|
||||
label={
|
||||
displayLabel && !schema.dynamic ? (
|
||||
<>
|
||||
{name}
|
||||
<Description description={rawDescription} />
|
||||
</>
|
||||
) : null
|
||||
}
|
||||
>
|
||||
{children}
|
||||
</FormAntd.Item>
|
||||
)
|
||||
}
|
||||
|
||||
const ArrayFieldTemplate: FC<ArrayFieldTemplatePropsType> = ({
|
||||
items,
|
||||
onAddClick,
|
||||
canAdd,
|
||||
title,
|
||||
idSchema,
|
||||
schema: { description }
|
||||
}) => {
|
||||
return (
|
||||
<Collapse defaultActiveKey={idSchema.$id}>
|
||||
<Collapse.Panel
|
||||
key={idSchema.$id}
|
||||
className="collapseArray"
|
||||
header={
|
||||
<Space
|
||||
direction="horizontal"
|
||||
style={{ justifyContent: 'space-between', width: '100%' }}
|
||||
>
|
||||
<Space direction="horizontal">
|
||||
<AntdText>{title}</AntdText>
|
||||
<Badge count={items ? items.length : 0} showZero />
|
||||
<Description description={description} />
|
||||
</Space>
|
||||
{canAdd && (
|
||||
<Button
|
||||
type="link"
|
||||
icon={<PlusOutlined />}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onAddClick(e as unknown as MouseEvent)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
{items &&
|
||||
items.map((element) => (
|
||||
<div key={element.index} className="collapseArray_item">
|
||||
<div className="collapseArray_item_content">
|
||||
{element.children}
|
||||
</div>
|
||||
<Button
|
||||
type="link"
|
||||
icon={<DeleteOutlined />}
|
||||
onClick={element.onDropIndexClick(element.index)}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</Collapse.Panel>
|
||||
</Collapse>
|
||||
)
|
||||
}
|
||||
|
||||
const ObjectFieldTemplate: FC<ObjectFieldTemplatePropsType> = (props) => {
|
||||
const {
|
||||
properties,
|
||||
idSchema,
|
||||
schema: { properties: schemaProperties }
|
||||
schema: { properties: schemaProperties },
|
||||
activeTabKey,
|
||||
handleTabsChange
|
||||
} = props
|
||||
properties.sort(sortProps)
|
||||
|
||||
properties.sort(sortProps)
|
||||
if (idSchema.$id === 'root') {
|
||||
const propsComplex: [] = []
|
||||
const propsSimple: [] = []
|
||||
const propsComplex: ObjectFieldTemplatePropertyType[] = []
|
||||
const propsSimple: ObjectFieldTemplatePropertyType[] = []
|
||||
|
||||
properties.forEach((prop) => {
|
||||
const fieldType = schemaProperties[prop.name].type
|
||||
const fieldType = schemaProperties[prop.name]?.type
|
||||
if (!fieldType || fieldType === 'array' || fieldType === 'object') {
|
||||
propsComplex.push(prop)
|
||||
} else {
|
||||
@@ -72,41 +266,67 @@ const ConfigurationEditorForm: FC<ConfigurationEditorPropsType> = ({
|
||||
})
|
||||
|
||||
return (
|
||||
<Tabs activeKey={activeTabKey} tabPosition="right" onChange={handleTabsChange} items={[
|
||||
...(propsSimple.length ? [{
|
||||
label: 'Остальные',
|
||||
key: 'General',
|
||||
children: propsSimple.map((element) => element.content),
|
||||
}] : []),
|
||||
...propsComplex.map((element) => ({
|
||||
label: schemaProperties[element.name]?.title || element.name,
|
||||
key: element.name,
|
||||
children: element.content,
|
||||
})),
|
||||
]} />
|
||||
<Tabs
|
||||
activeKey={activeTabKey}
|
||||
tabPosition="right"
|
||||
onChange={handleTabsChange}
|
||||
items={[
|
||||
...(propsSimple.length
|
||||
? [
|
||||
{
|
||||
label: 'Остальные',
|
||||
key: 'General',
|
||||
children: propsSimple.map((element) => element.content)
|
||||
}
|
||||
]
|
||||
: []),
|
||||
...propsComplex.map((element) => ({
|
||||
label: schemaProperties[element.name]?.title || element.name,
|
||||
key: element.name,
|
||||
children: element.content
|
||||
}))
|
||||
]}
|
||||
/>
|
||||
)
|
||||
}
|
||||
return <>{properties.map((element) => element.content)}</>
|
||||
}
|
||||
|
||||
return properties.map((element) => element.content)
|
||||
const transformErrors = (errors: ErrorsObjType[]): ErrorsObjType[] => {
|
||||
if (errors.length > 0) {
|
||||
errors.forEach((error) => {
|
||||
error.message = 'Поле является обязательным'
|
||||
})
|
||||
}
|
||||
|
||||
return errors
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="configuration-editor-page__form">
|
||||
<Form
|
||||
formContext={{
|
||||
// labelCol: { span: 8 },
|
||||
// wrapperCol: { span: 30 },
|
||||
// layout: 'horizontal'
|
||||
labelCol: { span: 8 },
|
||||
wrapperCol: { span: 30 },
|
||||
layout: 'vertical'
|
||||
}}
|
||||
uiSchema={uiSchema}
|
||||
templates={{ ObjectFieldTemplate }}
|
||||
templates={{
|
||||
ObjectFieldTemplate: ObjectFieldTemplate as any,
|
||||
FieldTemplate: FieldTemplate as any,
|
||||
ArrayFieldTemplate: ArrayFieldTemplate as any
|
||||
}}
|
||||
ref={formRef}
|
||||
transformErrors={transformErrors as any}
|
||||
schema={jsonSchema?.schema as ResponseSchemaType}
|
||||
onSubmit={onSubmit}
|
||||
validator={validator}
|
||||
schema={JsonSchema?.schema}
|
||||
formData={id === 'new' ? {} : formState}
|
||||
formData={id === 'new' ? {} : formState}
|
||||
onChange={onFormChange}
|
||||
showErrorList={false}
|
||||
></Form>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default ConfigurationEditorForm
|
||||
export default memo(ConfigurationEditorForm)
|
||||
@@ -1,11 +1,18 @@
|
||||
import { FC, useContext } from 'react'
|
||||
import {ConfigurationEditorPropsType} from '@pages/ConfigurationEditorPage'
|
||||
import { Spin } from 'antd'
|
||||
import { ReactJsonView } from 'isp-ui-kit'
|
||||
import {Spin} from 'antd'
|
||||
import { FC, useContext } from 'react'
|
||||
|
||||
import { ConfigurationEditorPropsType } from '@pages/ConfigurationEditorPage/ConfigurationEditor.type.ts'
|
||||
|
||||
import { cleanEmptyParamsObject } from '@utils/objectUtils.ts'
|
||||
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
const ConfigurationEditorJson: FC<ConfigurationEditorPropsType> = ({ bufConfig = {}, setBufConfig, isCurrentConfigLoading}) => {
|
||||
const ConfigurationEditorJson: FC<ConfigurationEditorPropsType> = ({
|
||||
bufConfig = {},
|
||||
setBufConfig,
|
||||
isCurrentConfigLoading
|
||||
}) => {
|
||||
const { changeTheme } = useContext(Context)
|
||||
if (isCurrentConfigLoading) {
|
||||
return <Spin className="spin" />
|
||||
@@ -21,15 +28,15 @@ const ConfigurationEditorJson: FC<ConfigurationEditorPropsType> = ({ bufConfig =
|
||||
|
||||
return (
|
||||
<ReactJsonView
|
||||
theme={ changeTheme ? 'twilight' : ''}
|
||||
onAdd={({updated_src}: any) => handleEdit(updated_src)}
|
||||
onDelete={({updated_src}: any) => handleEdit(updated_src)}
|
||||
theme={changeTheme ? 'twilight' : ''}
|
||||
onAdd={({ updated_src }: any) => handleEdit(updated_src)}
|
||||
onDelete={({ updated_src }: any) => handleEdit(updated_src)}
|
||||
displayDataTypes={false}
|
||||
displayObjectSize={false}
|
||||
name={null}
|
||||
enableClipboard={true}
|
||||
iconStyle="square"
|
||||
onEdit={({updated_src}: any) => handleEdit(updated_src)}
|
||||
onEdit={({ updated_src }: any) => handleEdit(updated_src)}
|
||||
src={bufConfig.data}
|
||||
sortKeys={true}
|
||||
collapsed={1}
|
||||
|
||||
@@ -5,9 +5,9 @@ import Modal from '@widgets/Modal'
|
||||
|
||||
import { ConfigurationPreviewModalPropsType } from '@components/ConfigurationPreviewModal/configuration-preview-modal.type.ts'
|
||||
|
||||
import './configuration-preview-modal.scss'
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
import './configuration-preview-modal.scss'
|
||||
|
||||
const ConfigurationPreviewModal: FC<ConfigurationPreviewModalPropsType> = ({
|
||||
versionCompare = false,
|
||||
@@ -24,7 +24,7 @@ const ConfigurationPreviewModal: FC<ConfigurationPreviewModalPropsType> = ({
|
||||
<div className="configuration-preview-modal">
|
||||
<Modal title={configName || ''} open={open} onClose={onClose}>
|
||||
<ReactJsonView
|
||||
theme={ changeTheme ? 'twilight' : ''}
|
||||
theme={changeTheme ? 'twilight' : ''}
|
||||
src={data}
|
||||
name={false}
|
||||
sortKeys={true}
|
||||
|
||||
@@ -1,33 +1,31 @@
|
||||
import { Button } from 'antd'
|
||||
import { Dispatch, FC, SetStateAction } from 'react'
|
||||
import { useParams } from 'react-router-dom'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
import { Dispatch, FC, SetStateAction } from 'react'
|
||||
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
import { useParams } from 'react-router-dom'
|
||||
|
||||
import configServiceApi from '@services/configService.ts'
|
||||
|
||||
|
||||
interface ConfirmModalProps
|
||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
interface ConfirmModalProps extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
handleSaveClick: (upVersion?: number, unsafe?: boolean) => void
|
||||
setBufConfig: Dispatch<SetStateAction<ConfigType | undefined>>
|
||||
currentConfig: ConfigType | undefined
|
||||
}
|
||||
|
||||
const ConfirmConfigModal: FC<ConfirmModalProps> = ({
|
||||
currentConfig,
|
||||
setBufConfig,
|
||||
handleSaveClick,
|
||||
onClose = () => null,
|
||||
open
|
||||
}) => {
|
||||
currentConfig,
|
||||
setBufConfig,
|
||||
handleSaveClick,
|
||||
onClose = () => null,
|
||||
open
|
||||
}) => {
|
||||
const { id = '' } = useParams()
|
||||
const isNew = id === 'new' ? '' : id
|
||||
|
||||
const {
|
||||
data
|
||||
} = configServiceApi.useGetConfigByIdQuery(isNew)
|
||||
|
||||
const { data } = configServiceApi.useGetConfigByIdQuery(isNew)
|
||||
|
||||
const onConfirmHandler = () => {
|
||||
setBufConfig(currentConfig)
|
||||
@@ -35,14 +33,26 @@ const ConfirmConfigModal: FC<ConfirmModalProps> = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal title="Версия конфигурации была кем-то изменена" open={open}
|
||||
onClose={onClose}>
|
||||
<Button className="confirm-btn danger" type="primary" danger onClick={() => {
|
||||
handleSaveClick(data && data.version)
|
||||
onClose()
|
||||
}}>Сохранить принудительно</Button>
|
||||
<Button className="confirm-btn" type="primary" onClick={onConfirmHandler}>Принять изменения</Button>
|
||||
<Modal
|
||||
title="Версия конфигурации была кем-то изменена"
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
>
|
||||
<Button
|
||||
className="confirm-btn danger"
|
||||
type="primary"
|
||||
danger
|
||||
onClick={() => {
|
||||
handleSaveClick(data && data.version)
|
||||
onClose()
|
||||
}}
|
||||
>
|
||||
Сохранить принудительно
|
||||
</Button>
|
||||
<Button className="confirm-btn" type="primary" onClick={onConfirmHandler}>
|
||||
Принять изменения
|
||||
</Button>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
export default ConfirmConfigModal
|
||||
export default ConfirmConfigModal
|
||||
@@ -1,15 +1,19 @@
|
||||
import { Table } from 'antd'
|
||||
import { FC } from 'react'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
import { FC } from 'react'
|
||||
import { Table } from 'antd'
|
||||
|
||||
interface ErrorConfigModalProps
|
||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
details?: { [key: string]: string }
|
||||
}
|
||||
|
||||
const ErrorConfigModal: FC<ErrorConfigModalProps> = ({ details = {}, onClose, open }) => {
|
||||
|
||||
const ErrorConfigModal: FC<ErrorConfigModalProps> = ({
|
||||
details = {},
|
||||
onClose,
|
||||
open
|
||||
}) => {
|
||||
const columns = [
|
||||
{
|
||||
dataIndex: 'key',
|
||||
@@ -28,13 +32,21 @@ const ErrorConfigModal: FC<ErrorConfigModalProps> = ({ details = {}, onClose, op
|
||||
}))
|
||||
|
||||
return (
|
||||
<Modal title="Несоотвествия схемы конфигурации" open={open}
|
||||
onClose={onClose}>
|
||||
<Modal
|
||||
title="Несоотвествия схемы конфигурации"
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
>
|
||||
<div>
|
||||
<Table columns={columns} dataSource={data} showHeader={false} pagination={false} />
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={data}
|
||||
showHeader={false}
|
||||
pagination={false}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
export default ErrorConfigModal
|
||||
export default ErrorConfigModal
|
||||
@@ -98,29 +98,29 @@ const LayoutComponent = () => {
|
||||
className: hideItem([
|
||||
PermissionKeysType.user_view,
|
||||
PermissionKeysType.session_view,
|
||||
PermissionKeysType.role_view,
|
||||
PermissionKeysType.role_view
|
||||
]),
|
||||
icon: <ProfileOutlined />,
|
||||
children: [
|
||||
{
|
||||
label: 'Пользователи',
|
||||
key: 'users',
|
||||
className: hideItem(PermissionKeysType.user_view),
|
||||
className: hideItem(PermissionKeysType.user_view)
|
||||
},
|
||||
{
|
||||
label: 'Пользовательские сессии',
|
||||
key: 'sessions',
|
||||
className: hideItem(PermissionKeysType.session_view),
|
||||
className: hideItem(PermissionKeysType.session_view)
|
||||
},
|
||||
{
|
||||
label: 'Просмотр журналов ИБ',
|
||||
key: 'securityLog',
|
||||
className: hideItem(PermissionKeysType.security_log_view),
|
||||
className: hideItem(PermissionKeysType.security_log_view)
|
||||
},
|
||||
{
|
||||
label: 'Роли',
|
||||
key: 'roles',
|
||||
className: hideItem(PermissionKeysType.role_view),
|
||||
className: hideItem(PermissionKeysType.role_view)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import ModuleTabContent from '@widgets/ModuleTabContent'
|
||||
|
||||
import { ModuleTabsPropsType } from '@components/ModuleTabs/module-tabs.type.ts'
|
||||
|
||||
|
||||
const secondColumnItems = [
|
||||
{
|
||||
key: 'configurations',
|
||||
|
||||
@@ -6,7 +6,6 @@ import roleApi from '@services/roleService.ts'
|
||||
|
||||
import './role-list.scss'
|
||||
|
||||
|
||||
const RoleList = ({ userRoles }: RoleListProps) => {
|
||||
const { data: roles = [], isLoading, isError } = roleApi.useGetAllRolesQuery()
|
||||
const roleIds = new Set(userRoles)
|
||||
|
||||
@@ -19,7 +19,6 @@ import { PermissionKeysType, RoleType } from '@type/roles.type.ts'
|
||||
|
||||
import './roles-content.scss'
|
||||
|
||||
|
||||
const newRole: Partial<RoleType> = {
|
||||
externalGroup: '',
|
||||
name: '',
|
||||
|
||||
Reference in new issue
Block a user