Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b782f3538 | ||
|
|
19d3a12469 | ||
|
|
151be0e635 |
No files matched your search
@@ -1,3 +1,10 @@
|
|||||||
|
## 0.12.2
|
||||||
|
- Добавлена возможность копирования конфига
|
||||||
|
## 0.12.1
|
||||||
|
- Исправлен шрифт в редакторах кода
|
||||||
|
- Исправлены перерисовки экрана "Модули"
|
||||||
|
## 0.12.0
|
||||||
|
- Добавлена страница редактирования/создания конфига
|
||||||
## 0.11.5
|
## 0.11.5
|
||||||
- Обновлена библиотека isp-ui-kit
|
- Обновлена библиотека isp-ui-kit
|
||||||
- Убраны лишние столбцы на странице токенов
|
- Убраны лишние столбцы на странице токенов
|
||||||
|
|||||||
Generated
+38
-2
@@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "isp-admin-ui",
|
"name": "isp-admin-ui",
|
||||||
"version": "0.11.5",
|
"version": "0.12.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "isp-admin-ui",
|
"name": "isp-admin-ui",
|
||||||
"version": "0.11.5",
|
"version": "0.12.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
||||||
"@codemirror/lang-json": "^6.0.1",
|
"@codemirror/lang-json": "^6.0.1",
|
||||||
|
"@monaco-editor/react": "^4.6.0",
|
||||||
"@reduxjs/toolkit": "^2.2.3",
|
"@reduxjs/toolkit": "^2.2.3",
|
||||||
"@types/react-router-dom": "^5.3.3",
|
"@types/react-router-dom": "^5.3.3",
|
||||||
"@uiw/react-codemirror": "^4.21.25",
|
"@uiw/react-codemirror": "^4.21.25",
|
||||||
@@ -2961,6 +2962,30 @@
|
|||||||
"@lezer/common": "^1.0.0"
|
"@lezer/common": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@monaco-editor/loader": {
|
||||||
|
"version": "1.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@monaco-editor/loader/-/loader-1.4.0.tgz",
|
||||||
|
"integrity": "sha512-00ioBig0x642hytVspPl7DbQyaSWRaolYie/UFNjoTdvoKPzo6xrXLhTk9ixgIKcLH5b5vDOjVNiGyY+uDCUlg==",
|
||||||
|
"dependencies": {
|
||||||
|
"state-local": "^1.0.6"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"monaco-editor": ">= 0.21.0 < 1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@monaco-editor/react": {
|
||||||
|
"version": "4.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@monaco-editor/react/-/react-4.6.0.tgz",
|
||||||
|
"integrity": "sha512-RFkU9/i7cN2bsq/iTkurMWOEErmYcY6JiQI3Jn+WeR/FGISH8JbHERjpS9oRuSOPvDMJI0Z8nJeKkbOs9sBYQw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@monaco-editor/loader": "^1.4.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"monaco-editor": ">= 0.25.0 < 1",
|
||||||
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
||||||
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@nodelib/fs.scandir": {
|
"node_modules/@nodelib/fs.scandir": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||||
@@ -8246,6 +8271,12 @@
|
|||||||
"node": "*"
|
"node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/monaco-editor": {
|
||||||
|
"version": "0.49.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.49.0.tgz",
|
||||||
|
"integrity": "sha512-2I8/T3X/hLxB2oPHgqcNYUVdA/ZEFShT7IAujifIPMfKkNbLOqY8XCoyHCXrsdjb36dW9MwoTwBCFpXKMwNwaQ==",
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
"node_modules/ms": {
|
"node_modules/ms": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
@@ -10338,6 +10369,11 @@
|
|||||||
"deprecated": "Please use @jridgewell/sourcemap-codec instead",
|
"deprecated": "Please use @jridgewell/sourcemap-codec instead",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/state-local": {
|
||||||
|
"version": "1.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/state-local/-/state-local-1.0.7.tgz",
|
||||||
|
"integrity": "sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w=="
|
||||||
|
},
|
||||||
"node_modules/stream-browserify": {
|
"node_modules/stream-browserify": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz",
|
||||||
|
|||||||
+2
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "isp-admin-ui",
|
"name": "isp-admin-ui",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.11.5",
|
"version": "0.12.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
||||||
"@codemirror/lang-json": "^6.0.1",
|
"@codemirror/lang-json": "^6.0.1",
|
||||||
|
"@monaco-editor/react": "^4.6.0",
|
||||||
"@reduxjs/toolkit": "^2.2.3",
|
"@reduxjs/toolkit": "^2.2.3",
|
||||||
"@types/react-router-dom": "^5.3.3",
|
"@types/react-router-dom": "^5.3.3",
|
||||||
"@uiw/react-codemirror": "^4.21.25",
|
"@uiw/react-codemirror": "^4.21.25",
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
import { ConfigType, ModuleType } from '@pages/ModulesPage/module.type.ts'
|
||||||
|
|
||||||
export interface ActiveConfigurationsTablePropsType {
|
export interface ActiveConfigurationsTablePropsType {
|
||||||
isActiveTable?: boolean
|
isActiveTable?: boolean
|
||||||
data: ConfigType[]
|
data: ConfigType[]
|
||||||
handleShowConfig: (config: ConfigType) => void
|
handleShowConfig: (config: ConfigType) => void
|
||||||
handleShowCompareModal: (config: ConfigType) => void
|
handleShowCompareModal: (config: ConfigType) => void
|
||||||
|
currentModule?: ModuleType
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,8 @@ import './active-configurations-table.scss'
|
|||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import CanEdit from '@components/CanEdit'
|
import CanEdit from '@components/CanEdit'
|
||||||
import { dateFormats } from '@constants/date.ts'
|
import { dateFormats } from '@constants/date.ts'
|
||||||
|
import { routePaths } from '@routes/routePaths.ts'
|
||||||
|
import { useNavigate, useParams } from 'react-router-dom'
|
||||||
|
|
||||||
|
|
||||||
const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> =
|
const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> =
|
||||||
@@ -24,7 +26,8 @@ const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> =
|
|||||||
isActiveTable = false,
|
isActiveTable = false,
|
||||||
handleShowConfig,
|
handleShowConfig,
|
||||||
handleShowCompareModal,
|
handleShowCompareModal,
|
||||||
data
|
data,
|
||||||
|
currentModule = {}
|
||||||
}) => {
|
}) => {
|
||||||
const [editKeyConfig, setEditKeyConfig] = useState<string>('')
|
const [editKeyConfig, setEditKeyConfig] = useState<string>('')
|
||||||
const [tempEditValues, setTempEditValues] = useState<any>()
|
const [tempEditValues, setTempEditValues] = useState<any>()
|
||||||
@@ -32,7 +35,8 @@ const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> =
|
|||||||
const [createUpdateConfig] = configApi.useCreateUpdateConfigMutation()
|
const [createUpdateConfig] = configApi.useCreateUpdateConfigMutation()
|
||||||
const [markConfigAsActive] = configApi.useMarkConfigAsActiveMutation()
|
const [markConfigAsActive] = configApi.useMarkConfigAsActiveMutation()
|
||||||
const [deleteConfig] = configApi.useDeleteConfigMutation()
|
const [deleteConfig] = configApi.useDeleteConfigMutation()
|
||||||
|
const navigate = useNavigate()
|
||||||
|
const {id: moduleId} = useParams()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (inputRefs.current[editKeyConfig]) {
|
if (inputRefs.current[editKeyConfig]) {
|
||||||
@@ -198,9 +202,7 @@ const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> =
|
|||||||
{!isActiveTable && <CanEdit>
|
{!isActiveTable && <CanEdit>
|
||||||
<Button
|
<Button
|
||||||
className="configurations__buttons__new-config-brn"
|
className="configurations__buttons__new-config-brn"
|
||||||
onClick={() => {
|
onClick={() => navigate(`/${moduleId}/${routePaths.configEditor}/new`, {state: currentModule})}
|
||||||
// TODO создание новой конфигурации
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Создать
|
Создать
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { EditorState, EditorView } from '@uiw/react-codemirror'
|
import { EditorState, EditorView } from '@uiw/react-codemirror'
|
||||||
import { Button, Spin, Table } from 'antd'
|
import { Button, Spin, Table } from 'antd'
|
||||||
import { ColumnsType } from 'antd/es/table'
|
import { ColumnsType } from 'antd/es/table'
|
||||||
import { FC, useState } from 'react'
|
import { FC, memo, useState } from 'react'
|
||||||
import CodeMirrorMerge from 'react-codemirror-merge'
|
import CodeMirrorMerge from 'react-codemirror-merge'
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
import Modal from '@widgets/Modal'
|
||||||
@@ -114,4 +114,4 @@ const CompareVersionModal: FC<CompareVersionModalPropsType> = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CompareVersionModal
|
export default memo(CompareVersionModal)
|
||||||
@@ -5,5 +5,5 @@ import { JSONSchema } from '@pages/ModulesPage/module.type.ts'
|
|||||||
|
|
||||||
export interface ConfigSchemaModalPropsType
|
export interface ConfigSchemaModalPropsType
|
||||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||||
schema: JSONSchema
|
schema?: JSONSchema
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { FC } from 'react'
|
import { FC, memo } from 'react'
|
||||||
|
|
||||||
import JsonSchemaViewer from '@widgets/JSONViewer'
|
import JsonSchemaViewer from '@widgets/JSONViewer'
|
||||||
import Modal from '@widgets/Modal'
|
import Modal from '@widgets/Modal'
|
||||||
@@ -7,12 +7,12 @@ import { ConfigSchemaModalPropsType } from '@components/ConfigSchemaModal/config
|
|||||||
|
|
||||||
import './config-schema-modal.scss'
|
import './config-schema-modal.scss'
|
||||||
|
|
||||||
|
|
||||||
const ConfigSchemaModal: FC<ConfigSchemaModalPropsType> = ({
|
const ConfigSchemaModal: FC<ConfigSchemaModalPropsType> = ({
|
||||||
open,
|
open,
|
||||||
onClose,
|
onClose,
|
||||||
schema
|
schema = {}
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="config-schema-modal">
|
<div className="config-schema-modal">
|
||||||
<Modal title="Текущая схема" open={open} onClose={onClose}>
|
<Modal title="Текущая схема" open={open} onClose={onClose}>
|
||||||
@@ -22,4 +22,4 @@ const ConfigSchemaModal: FC<ConfigSchemaModalPropsType> = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ConfigSchemaModal
|
export default memo(ConfigSchemaModal)
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import { FC } from 'react'
|
||||||
|
import { ConfigurationEditorPropsType } from '@pages/ConfigurationEditorPage'
|
||||||
|
import Editor from '@monaco-editor/react'
|
||||||
|
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||||
|
import { message } from 'antd'
|
||||||
|
|
||||||
|
const ConfigurationEditorCode: FC<ConfigurationEditorPropsType> = ({setDisableBtn= () => {}, bufConfig, setBufConfig }) => {
|
||||||
|
const debounce = (func: (...args: any[]) => void, wait: number) => {
|
||||||
|
let timeout: NodeJS.Timeout
|
||||||
|
return (...args: []) => {
|
||||||
|
clearTimeout(timeout)
|
||||||
|
timeout = setTimeout(() => {
|
||||||
|
func.apply(this, [...args])
|
||||||
|
}, wait)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const debouncedHandleError = debounce(() => {
|
||||||
|
message.error('Невалидный JSON объект')
|
||||||
|
}, 500)
|
||||||
|
|
||||||
|
const handleChange = (data: string | undefined) => {
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
try {
|
||||||
|
const newData = {
|
||||||
|
...bufConfig,
|
||||||
|
data: {...JSON.parse(data) }
|
||||||
|
} as ConfigType
|
||||||
|
setDisableBtn(false)
|
||||||
|
setBufConfig(newData)
|
||||||
|
} catch (error) {
|
||||||
|
debouncedHandleError()
|
||||||
|
setDisableBtn(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const editorValue = JSON.stringify(bufConfig?.data, null, '\t')
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Editor
|
||||||
|
width="auto"
|
||||||
|
height="100vh"
|
||||||
|
language="json"
|
||||||
|
theme="vs-white"
|
||||||
|
value={editorValue}
|
||||||
|
onChange={handleChange}
|
||||||
|
options={{
|
||||||
|
minimap: {
|
||||||
|
enabled: false
|
||||||
|
},
|
||||||
|
fontSize: 16,
|
||||||
|
}}
|
||||||
|
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ConfigurationEditorCode
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
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 { useParams } from 'react-router-dom'
|
||||||
|
|
||||||
|
const ConfigurationEditorForm: FC<ConfigurationEditorPropsType> = ({
|
||||||
|
bufConfig ={},
|
||||||
|
JsonSchema,
|
||||||
|
setBufConfig,
|
||||||
|
}) => {
|
||||||
|
const Form = withTheme(AntDTheme)
|
||||||
|
const sortProps = (a, b) => a.name.localeCompare(b.name)
|
||||||
|
|
||||||
|
const [formState, setFormState] = useState(bufConfig.data)
|
||||||
|
const [activeTabKey, setActiveTabKey] = useState()
|
||||||
|
const {id} = useParams()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if(!equal(formState, bufConfig.data)) {
|
||||||
|
setFormState(bufConfig.data)
|
||||||
|
}
|
||||||
|
}, [bufConfig.data])
|
||||||
|
|
||||||
|
const uiSchema: UiSchema = {
|
||||||
|
'ui:submitButtonOptions': {
|
||||||
|
norender: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const onFormChange = data => {
|
||||||
|
if(!equal(data.formData, bufConfig.data)) {
|
||||||
|
const newData = {
|
||||||
|
...bufConfig,
|
||||||
|
data: { ...data.formData }
|
||||||
|
}
|
||||||
|
if(!equal(newData, bufConfig.data)) {
|
||||||
|
setBufConfig(newData)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleTabsChange = e => {
|
||||||
|
setActiveTabKey(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
const ObjectFieldTemplate = (props) => {
|
||||||
|
const {
|
||||||
|
properties,
|
||||||
|
idSchema,
|
||||||
|
schema: { properties: schemaProperties }
|
||||||
|
} = props
|
||||||
|
properties.sort(sortProps)
|
||||||
|
|
||||||
|
if (idSchema.$id === 'root') {
|
||||||
|
const propsComplex: [] = []
|
||||||
|
const propsSimple: [] = []
|
||||||
|
|
||||||
|
properties.forEach((prop) => {
|
||||||
|
const fieldType = schemaProperties[prop.name].type
|
||||||
|
if (!fieldType || fieldType === 'array' || fieldType === 'object') {
|
||||||
|
propsComplex.push(prop)
|
||||||
|
} else {
|
||||||
|
propsSimple.push(prop)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
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,
|
||||||
|
})),
|
||||||
|
]} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return properties.map((element) => element.content)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="configuration-editor-page__form">
|
||||||
|
<Form
|
||||||
|
formContext={{
|
||||||
|
// labelCol: { span: 8 },
|
||||||
|
// wrapperCol: { span: 30 },
|
||||||
|
// layout: 'horizontal'
|
||||||
|
}}
|
||||||
|
uiSchema={uiSchema}
|
||||||
|
templates={{ ObjectFieldTemplate }}
|
||||||
|
validator={validator}
|
||||||
|
schema={JsonSchema?.schema}
|
||||||
|
formData={id === 'new' ? {} : formState}
|
||||||
|
onChange={onFormChange}
|
||||||
|
></Form>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ConfigurationEditorForm
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { FC } from 'react'
|
||||||
|
import {ConfigurationEditorPropsType} from '@pages/ConfigurationEditorPage'
|
||||||
|
import { ReactJsonView } from 'isp-ui-kit'
|
||||||
|
import {Spin} from 'antd'
|
||||||
|
import { cleanEmptyParamsObject } from '@utils/objectUtils.ts'
|
||||||
|
|
||||||
|
const ConfigurationEditorJson: FC<ConfigurationEditorPropsType> = ({ bufConfig = {}, setBufConfig, isCurrentConfigLoading, JsonSchema}) => {
|
||||||
|
if (isCurrentConfigLoading) {
|
||||||
|
return <Spin className="spin" />
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ReactJsonView
|
||||||
|
displayDataTypes={false}
|
||||||
|
displayObjectSize={false}
|
||||||
|
name={null}
|
||||||
|
enableClipboard={true}
|
||||||
|
iconStyle="square"
|
||||||
|
onEdit={({updated_src}: any) => {
|
||||||
|
const newData = {
|
||||||
|
...bufConfig,
|
||||||
|
data: { ...updated_src }
|
||||||
|
}
|
||||||
|
setBufConfig(cleanEmptyParamsObject(newData))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
src={bufConfig.data}
|
||||||
|
sortKeys={true}
|
||||||
|
collapsed={1}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ConfigurationEditorJson
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ReactJsonView } from 'isp-ui-kit'
|
import { ReactJsonView } from 'isp-ui-kit'
|
||||||
import { FC } from 'react'
|
import { FC, memo } from 'react'
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
import Modal from '@widgets/Modal'
|
||||||
|
|
||||||
@@ -33,4 +33,4 @@ const ConfigurationPreviewModal: FC<ConfigurationPreviewModalPropsType> = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ConfigurationPreviewModal
|
export default memo(ConfigurationPreviewModal)
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { Button } from 'antd'
|
||||||
|
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'> {
|
||||||
|
handleSaveClick: (upVersion?: number, unsafe?: boolean) => void
|
||||||
|
setBufConfig: Dispatch<SetStateAction<ConfigType | undefined>>
|
||||||
|
currentConfig: ConfigType | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
const ConfirmConfigModal: FC<ConfirmModalProps> = ({
|
||||||
|
currentConfig,
|
||||||
|
setBufConfig,
|
||||||
|
handleSaveClick,
|
||||||
|
onClose = () => null,
|
||||||
|
open
|
||||||
|
}) => {
|
||||||
|
const { id = '' } = useParams()
|
||||||
|
const isNew = id === 'new' ? '' : id
|
||||||
|
|
||||||
|
const {
|
||||||
|
data
|
||||||
|
} = configServiceApi.useGetConfigByIdQuery(isNew)
|
||||||
|
|
||||||
|
|
||||||
|
const onConfirmHandler = () => {
|
||||||
|
setBufConfig(currentConfig)
|
||||||
|
onClose()
|
||||||
|
}
|
||||||
|
|
||||||
|
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>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default ConfirmConfigModal
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
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 columns = [
|
||||||
|
{
|
||||||
|
dataIndex: 'key',
|
||||||
|
key: 'key',
|
||||||
|
render: (text: string) => <span style={{ color: 'red' }}>{text}</span>
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataIndex: 'value',
|
||||||
|
key: 'value'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
const data = Object.keys(details).map((key) => ({
|
||||||
|
key,
|
||||||
|
value: details[key]
|
||||||
|
}))
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal title="Несоотвествия схемы конфигурации" open={open}
|
||||||
|
onClose={onClose}>
|
||||||
|
<div>
|
||||||
|
<Table columns={columns} dataSource={data} showHeader={false} pagination={false} />
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ErrorConfigModal
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { Tabs } from 'antd'
|
||||||
|
import { memo } from 'react'
|
||||||
|
import { useNavigate, useParams } from 'react-router-dom'
|
||||||
|
|
||||||
|
import ModuleTabContent from '@widgets/ModuleTabContent'
|
||||||
|
|
||||||
|
import { ModuleTabsPropsType } from '@components/ModuleTabs/module-tabs.type.ts'
|
||||||
|
|
||||||
|
|
||||||
|
const secondColumnItems = [
|
||||||
|
{
|
||||||
|
key: 'configurations',
|
||||||
|
name: 'Конфигурации'
|
||||||
|
},
|
||||||
|
{ key: 'connections', name: 'Подключения' }
|
||||||
|
]
|
||||||
|
|
||||||
|
const ModuleTabs = ({
|
||||||
|
activeTab,
|
||||||
|
setActiveTab,
|
||||||
|
currentModule
|
||||||
|
}: ModuleTabsPropsType) => {
|
||||||
|
const navigate = useNavigate()
|
||||||
|
const { id: selectedItemId = '' } = useParams()
|
||||||
|
return (
|
||||||
|
<Tabs
|
||||||
|
activeKey={activeTab}
|
||||||
|
onChange={(activeKey) => {
|
||||||
|
setActiveTab(activeKey)
|
||||||
|
const path = `${selectedItemId}/${activeKey}`
|
||||||
|
navigate(path)
|
||||||
|
}}
|
||||||
|
className="modules-page__tabs"
|
||||||
|
items={secondColumnItems.map((item) => {
|
||||||
|
return {
|
||||||
|
disabled: selectedItemId === '',
|
||||||
|
label: item.name,
|
||||||
|
key: item.key,
|
||||||
|
children: (
|
||||||
|
<div className="modules-page__content">
|
||||||
|
<ModuleTabContent
|
||||||
|
selectedItemId={selectedItemId}
|
||||||
|
currentModule={currentModule}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default memo(ModuleTabs)
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
||||||
|
|
||||||
|
export interface ModuleTabsPropsType {
|
||||||
|
activeTab: string
|
||||||
|
setActiveTab: (key: string) => void
|
||||||
|
currentModule: ModuleType | undefined
|
||||||
|
}
|
||||||
@@ -18,10 +18,13 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
font-size: 19px;
|
font-size: 19px;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
font-family: PT Sans, sans-serif;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
margin:0;
|
margin:0;
|
||||||
padding:0;
|
padding:0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
font-family: PT Sans, sans-serif;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.app{
|
.app{
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ type PathKeys =
|
|||||||
| 'deleteConfig'
|
| 'deleteConfig'
|
||||||
| 'markConfigAsActive'
|
| 'markConfigAsActive'
|
||||||
| 'getUI'
|
| 'getUI'
|
||||||
|
| 'getByModuleId'
|
||||||
|
|
||||||
export const apiPaths: Record<PathKeys, string> = {
|
export const apiPaths: Record<PathKeys, string> = {
|
||||||
baseUrl: '/api/kkd-configuration-service',
|
baseUrl: '/api/kkd-configuration-service',
|
||||||
@@ -100,6 +101,7 @@ export const apiPaths: Record<PathKeys, string> = {
|
|||||||
// ======= MODULES ======
|
// ======= MODULES ======
|
||||||
getModules: '/module/get_modules_info',
|
getModules: '/module/get_modules_info',
|
||||||
deleteModule: '/module/delete_module',
|
deleteModule: '/module/delete_module',
|
||||||
|
getByModuleId: '/schema/get_by_module_id',
|
||||||
// ======= SERVICE ======
|
// ======= SERVICE ======
|
||||||
getServiceById: '/service/get_service_by_id',
|
getServiceById: '/service/get_service_by_id',
|
||||||
getAllService: '/service/get_service',
|
getAllService: '/service/get_service',
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
@import "../../constants/style/styleConst";
|
||||||
|
|
||||||
|
.configuration-editor-page {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background: white;
|
||||||
|
height: 100%;
|
||||||
|
-ms-overflow-style: none; /* IE и Edge */
|
||||||
|
scrollbar-width: none;
|
||||||
|
border-left: 1px solid $border-color;
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.react-json-view {
|
||||||
|
margin: $basic-margin *3 0 $basic-margin *2 0;
|
||||||
|
}
|
||||||
|
&__header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: $basic-padding *2 $basic-padding;
|
||||||
|
border-bottom: 1px solid $border-color;
|
||||||
|
}
|
||||||
|
&__controll{
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__save-btn {
|
||||||
|
width: auto;
|
||||||
|
margin-left: $basic-margin;
|
||||||
|
}
|
||||||
|
&__content {
|
||||||
|
padding: $basic-padding * 3 $basic-padding;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rjsf {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.ant-form-item-label {
|
||||||
|
text-align: start;
|
||||||
|
}
|
||||||
|
.ant-tabs-right {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.ant-col-8 .ant-form-item-label {
|
||||||
|
margin-right: $basic-margin *2;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
.ant-btn-group {
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
.ant-row .ant-row-end {
|
||||||
|
width: 60px;
|
||||||
|
margin: 0 0 $basic-margin auto !important;
|
||||||
|
}
|
||||||
|
&__form {
|
||||||
|
padding: $basic-padding;
|
||||||
|
}
|
||||||
|
.modal__wrap {
|
||||||
|
min-height: 110px;
|
||||||
|
}
|
||||||
|
.confirm-btn {
|
||||||
|
width: 190px;
|
||||||
|
}
|
||||||
|
.confirm-btn, .danger {
|
||||||
|
margin-right: $basic-margin;
|
||||||
|
}
|
||||||
|
.error-data {
|
||||||
|
color: red;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,209 @@
|
|||||||
|
import { RollbackOutlined } from '@ant-design/icons'
|
||||||
|
import { Button, Dropdown, MenuProps, message, Radio, RadioChangeEvent, Spin } from 'antd'
|
||||||
|
import { Dispatch, FC, SetStateAction, useEffect, useState } from 'react'
|
||||||
|
import { useLocation, useNavigate, useParams } from 'react-router-dom'
|
||||||
|
|
||||||
|
import ConfigurationEditorCode from '@components/ConfigurationEditorCode'
|
||||||
|
import ConfigurationEditorJson from '@components/ConfigurationEditorJson'
|
||||||
|
|
||||||
|
import configServiceApi from '@services/configService.ts'
|
||||||
|
import modulesServiceApi from '@services/modulesService.ts'
|
||||||
|
|
||||||
|
import './configuration-editor-page.scss'
|
||||||
|
import ConfigSchemaModal from '@components/ConfigSchemaModal'
|
||||||
|
import { cleanEmptyParamsObject, sortObject } from '@utils/objectUtils.ts'
|
||||||
|
import { ConfigType, ResponseSchemaType } from '@pages/ModulesPage/module.type.ts'
|
||||||
|
import ConfirmConfigModal from '@components/ConfirmConfigModal/ConfirmConfigModal.tsx'
|
||||||
|
import ErrorConfigModal from '@components/ErrorConfigModal/ErrorConfigModal.tsx'
|
||||||
|
|
||||||
|
export interface ConfigurationEditorPropsType {
|
||||||
|
JsonSchema?: ResponseSchemaType
|
||||||
|
bufConfig?: ConfigType
|
||||||
|
setBufConfig: Dispatch<SetStateAction<ConfigType | undefined>>
|
||||||
|
isCurrentConfigLoading: boolean
|
||||||
|
setDisableBtn?: Dispatch<SetStateAction<boolean>>
|
||||||
|
}
|
||||||
|
|
||||||
|
const ConfigurationEditorPage: FC = () => {
|
||||||
|
const navigate = useNavigate()
|
||||||
|
const { moduleId = '' } = useParams()
|
||||||
|
const { id = '' } = useParams()
|
||||||
|
const isNew = id === 'new'
|
||||||
|
const { data: JsonSchema, isLoading: isLoadingJsonSchema } =
|
||||||
|
modulesServiceApi.useGetByModuleIdQuery(moduleId)
|
||||||
|
const {
|
||||||
|
data: currentConfig,
|
||||||
|
isLoading: isCurrentConfigLoading,
|
||||||
|
} = configServiceApi.useGetConfigByIdQuery(id)
|
||||||
|
const [createUpdateConfig] = configServiceApi.useCreateUpdateConfigMutation()
|
||||||
|
const { state } = useLocation()
|
||||||
|
const [showConfirmModal, setShowConfirmModal] = useState(false)
|
||||||
|
const [showSchemeModal, setShowSchemeModal] = useState(false)
|
||||||
|
const [radioValue, setRadioValue] = useState('json')
|
||||||
|
const [bufConfig, setBufConfig] = useState<ConfigType>()
|
||||||
|
const [detailsErrors, setDetailsError] = useState({ details: {}, isOpenDetailsErrorModal: false })
|
||||||
|
const [disableBtn, setDisableBtn] = useState(false)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setBufConfig(isNew ? {} : sortObject(currentConfig))
|
||||||
|
}, [isCurrentConfigLoading])
|
||||||
|
|
||||||
|
const itemsSaveBtn = [
|
||||||
|
{
|
||||||
|
key: 'save',
|
||||||
|
label: 'Сохранить'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'unsafe',
|
||||||
|
label: 'Сохранить небезопасно'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
const onSaveBtn: MenuProps['onClick'] = (e, upVersion = undefined) => {
|
||||||
|
const isUnsafe = e.key === 'unsafe'
|
||||||
|
handleSaveClick(upVersion, isUnsafe)
|
||||||
|
}
|
||||||
|
|
||||||
|
const onRadioChange = (e: RadioChangeEvent) => {
|
||||||
|
setRadioValue(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSaveClick = (upVersion?: number, unsafe?: boolean) => {
|
||||||
|
let newData = {}
|
||||||
|
if (bufConfig) {
|
||||||
|
if (isNew) {
|
||||||
|
newData = {
|
||||||
|
name: state.name,
|
||||||
|
moduleId: moduleId,
|
||||||
|
id: '',
|
||||||
|
version: 0,
|
||||||
|
data: bufConfig.data,
|
||||||
|
unsafe: unsafe
|
||||||
|
} as ConfigType
|
||||||
|
}
|
||||||
|
if (currentConfig) {
|
||||||
|
newData = {
|
||||||
|
...bufConfig,
|
||||||
|
version: upVersion ? upVersion : currentConfig.version,
|
||||||
|
unsafe: unsafe
|
||||||
|
} as ConfigType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
createUpdateConfig(cleanEmptyParamsObject(newData))
|
||||||
|
.unwrap()
|
||||||
|
.then(({ id }) => {
|
||||||
|
message.success('Конфигурация успешно сохранена')
|
||||||
|
isNew && navigate(`/${moduleId}/configEditor/${id}`)
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
if (e.data.errorCode === 2004) {
|
||||||
|
setShowConfirmModal(true)
|
||||||
|
}
|
||||||
|
if (e.data.errorCode === 2003) {
|
||||||
|
setDetailsError({ details: e.data.details, isOpenDetailsErrorModal: true })
|
||||||
|
}
|
||||||
|
if (e.data.errorCode === 400) {
|
||||||
|
message.error('Невалидный JSON объект')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLoadingJsonSchema || isCurrentConfigLoading) {
|
||||||
|
return <Spin className="spin" />
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const renderContent = () => {
|
||||||
|
|
||||||
|
switch (radioValue) {
|
||||||
|
// case 'form':
|
||||||
|
// return (
|
||||||
|
// <ConfigurationEditorForm
|
||||||
|
// bufConfig={bufConfig}
|
||||||
|
// setBufConfig={setBufConfig}
|
||||||
|
// isCurrentConfigLoading={isCurrentConfigLoading}
|
||||||
|
// />
|
||||||
|
// )
|
||||||
|
case 'json':
|
||||||
|
return (
|
||||||
|
<ConfigurationEditorJson
|
||||||
|
bufConfig={bufConfig}
|
||||||
|
setBufConfig={setBufConfig}
|
||||||
|
isCurrentConfigLoading={isCurrentConfigLoading}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
case 'code':
|
||||||
|
return (
|
||||||
|
<ConfigurationEditorCode
|
||||||
|
setDisableBtn={setDisableBtn}
|
||||||
|
bufConfig={bufConfig}
|
||||||
|
setBufConfig={setBufConfig}
|
||||||
|
isCurrentConfigLoading={isCurrentConfigLoading}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className="configuration-editor-page">
|
||||||
|
<section className="configuration-editor-page__header">
|
||||||
|
<Button onClick={() => navigate(-1)}>
|
||||||
|
<RollbackOutlined />
|
||||||
|
Назад
|
||||||
|
</Button>
|
||||||
|
<div className="configuration-editor-page__controll">
|
||||||
|
<Button
|
||||||
|
disabled={!JsonSchema}
|
||||||
|
className="configurations____buttons__show-schema-btn"
|
||||||
|
onClick={() => setShowSchemeModal(true)}
|
||||||
|
>
|
||||||
|
Текущая схема конфигурации
|
||||||
|
</Button>
|
||||||
|
<Dropdown.Button
|
||||||
|
onClick={() => {
|
||||||
|
handleSaveClick()
|
||||||
|
navigate(`/modules/${moduleId}/configurations`)
|
||||||
|
}}
|
||||||
|
disabled={disableBtn}
|
||||||
|
type="primary"
|
||||||
|
className="configuration-editor-page__save-btn"
|
||||||
|
menu={{ items: itemsSaveBtn, onClick: onSaveBtn }}
|
||||||
|
>
|
||||||
|
Сохранить и выйти
|
||||||
|
</Dropdown.Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
<div className="configuration-editor-page__content">
|
||||||
|
<Radio.Group defaultValue="json" size="large" onChange={onRadioChange}>
|
||||||
|
<Radio.Button disabled value="form">Форма</Radio.Button>
|
||||||
|
<Radio.Button disabled={disableBtn} value="json">JSON</Radio.Button>
|
||||||
|
<Radio.Button value="code">Редактор кода</Radio.Button>
|
||||||
|
</Radio.Group>
|
||||||
|
|
||||||
|
{renderContent()}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<ConfigSchemaModal
|
||||||
|
schema={JsonSchema?.schema}
|
||||||
|
open={showSchemeModal}
|
||||||
|
onClose={() => setShowSchemeModal(false)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ConfirmConfigModal
|
||||||
|
currentConfig={currentConfig}
|
||||||
|
setBufConfig={setBufConfig}
|
||||||
|
open={showConfirmModal}
|
||||||
|
handleSaveClick={handleSaveClick}
|
||||||
|
onClose={() => setShowConfirmModal(false)} />
|
||||||
|
|
||||||
|
<ErrorConfigModal details={detailsErrors.details} open={detailsErrors.isOpenDetailsErrorModal}
|
||||||
|
onClose={() => setDetailsError({details: {}, isOpenDetailsErrorModal: false })} />
|
||||||
|
|
||||||
|
</main>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ConfigurationEditorPage
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Button, Spin } from 'antd'
|
import { Button, Spin } from 'antd'
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
import { memo, useEffect, useMemo, useState } from 'react'
|
||||||
import { Outlet, useNavigate, useParams } from 'react-router-dom'
|
import { Outlet, useNavigate, useParams } from 'react-router-dom'
|
||||||
|
|
||||||
import ActiveConfigurationsTable from '@components/ActiveConfigurationsTable'
|
import ActiveConfigurationsTable from '@components/ActiveConfigurationsTable'
|
||||||
@@ -26,7 +26,7 @@ const Configurations = () => {
|
|||||||
data: modulesList = [],
|
data: modulesList = [],
|
||||||
isLoading: isModulesLoading,
|
isLoading: isModulesLoading,
|
||||||
isError: isModulesError
|
isError: isModulesError
|
||||||
} = modulesServiceApi.useGetModulesQuery('modules')
|
} = modulesServiceApi.useGetModulesQuery('configurations')
|
||||||
const { id: selectedItemId = '', configId = '' } = useParams()
|
const { id: selectedItemId = '', configId = '' } = useParams()
|
||||||
const {
|
const {
|
||||||
data = { originalResponse: [], activeConfigs: [], inactiveConfigs: [] },
|
data = { originalResponse: [], activeConfigs: [], inactiveConfigs: [] },
|
||||||
@@ -101,6 +101,7 @@ const Configurations = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<ActiveConfigurationsTable
|
<ActiveConfigurationsTable
|
||||||
|
currentModule={currentModule}
|
||||||
isActiveTable
|
isActiveTable
|
||||||
data={isError ? [] : activeConfigs}
|
data={isError ? [] : activeConfigs}
|
||||||
handleShowConfig={(config) => {
|
handleShowConfig={(config) => {
|
||||||
@@ -113,6 +114,7 @@ const Configurations = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ActiveConfigurationsTable
|
<ActiveConfigurationsTable
|
||||||
|
currentModule={currentModule}
|
||||||
data={isError ? [] : inactiveConfigs}
|
data={isError ? [] : inactiveConfigs}
|
||||||
handleShowConfig={(config) => {
|
handleShowConfig={(config) => {
|
||||||
setCurrentConfig(config)
|
setCurrentConfig(config)
|
||||||
@@ -127,4 +129,4 @@ const Configurations = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Configurations
|
export default memo(Configurations)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Spin, Table, Tag, Tooltip } from 'antd'
|
import { Spin, Table, Tag, Tooltip } from 'antd'
|
||||||
import { ColumnsType } from 'antd/es/table'
|
import { ColumnsType } from 'antd/es/table'
|
||||||
import { useEffect, useState } from 'react'
|
import { memo, useEffect, useState } from 'react'
|
||||||
import { useNavigate, useParams } from 'react-router-dom'
|
import { useNavigate, useParams } from 'react-router-dom'
|
||||||
|
|
||||||
import { AddressType, EndpointType, ModuleStatusType, ModuleType } from '@pages/ModulesPage/module.type.ts'
|
import { AddressType, EndpointType, ModuleStatusType, ModuleType } from '@pages/ModulesPage/module.type.ts'
|
||||||
@@ -148,4 +148,4 @@ const Connections = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Connections
|
export default memo(Connections)
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
import { ExclamationCircleOutlined } from '@ant-design/icons'
|
import { ExclamationCircleOutlined } from '@ant-design/icons'
|
||||||
import { Badge, List, message, Spin, Tabs, Tag, Tooltip } from 'antd'
|
import { Badge, List, message, Spin, Tag, Tooltip } from 'antd'
|
||||||
import { compareVersions } from 'compare-versions'
|
import { compareVersions } from 'compare-versions'
|
||||||
import { Layout } from 'isp-ui-kit'
|
import { Layout } from 'isp-ui-kit'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import {
|
import {
|
||||||
createSearchParams,
|
createSearchParams,
|
||||||
Outlet,
|
|
||||||
useLocation,
|
useLocation,
|
||||||
useNavigate,
|
useNavigate,
|
||||||
useParams,
|
useParams,
|
||||||
useSearchParams
|
useSearchParams
|
||||||
} from 'react-router-dom'
|
} from 'react-router-dom'
|
||||||
|
|
||||||
|
import ModuleTabs from '@components/ModuleTabs'
|
||||||
|
|
||||||
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
||||||
|
|
||||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
||||||
@@ -26,7 +27,8 @@ import { PermissionKeysType } from '@type/roles.type.ts'
|
|||||||
|
|
||||||
import './modules-page.scss'
|
import './modules-page.scss'
|
||||||
|
|
||||||
const { Column, EmptyData, NoData } = Layout
|
|
||||||
|
const { Column } = Layout
|
||||||
|
|
||||||
const ModulesPage = () => {
|
const ModulesPage = () => {
|
||||||
const [activeTab, setActiveTab] = useState('configurations')
|
const [activeTab, setActiveTab] = useState('configurations')
|
||||||
@@ -107,7 +109,7 @@ const ModulesPage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const versionCompare = (versions: string[]) => {
|
const versionCompare = (versions: string[]) => {
|
||||||
const sorted = versions?.sort(compareVersions)
|
const sorted = (versions || ['']).sort(compareVersions)
|
||||||
const firstVersion = sorted[0]
|
const firstVersion = sorted[0]
|
||||||
for (let i = 1; i < sorted.length; i++) {
|
for (let i = 1; i < sorted.length; i++) {
|
||||||
if (compareVersions(firstVersion, sorted[i]) !== 0) {
|
if (compareVersions(firstVersion, sorted[i]) !== 0) {
|
||||||
@@ -118,7 +120,7 @@ const ModulesPage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getLastVersion = (versions: string[]) => {
|
const getLastVersion = (versions: string[]) => {
|
||||||
const sorted = versions?.sort(compareVersions)
|
const sorted = (versions || ['']).sort(compareVersions)
|
||||||
return sorted[sorted.length - 1]
|
return sorted[sorted.length - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,86 +128,65 @@ const ModulesPage = () => {
|
|||||||
return <Spin />
|
return <Spin />
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentRole = ModulesList
|
const currentModule = ModulesList.find(
|
||||||
? ModulesList.find(
|
(item: ModuleType) => item.id.toString() === selectedItemId
|
||||||
(item: ModuleType) => item.id.toString() === selectedItemId
|
)
|
||||||
)
|
|
||||||
: null
|
|
||||||
|
|
||||||
const renderItems = (item: ModuleType) => {
|
const renderItems = (item: ModuleType) => {
|
||||||
const isSame = versionCompare(item.status.map((i) => i.version))
|
const isSame = versionCompare(item?.status?.map((i) => i.version))
|
||||||
const textTooltip = isSame
|
const textTooltip = isSame
|
||||||
? 'Активны экземпляры одинаковых версий'
|
? 'Активны экземпляры одинаковых версий'
|
||||||
: 'Активны экземпляры разных версий'
|
: 'Активны экземпляры разных версий'
|
||||||
const lastVersion = getLastVersion(item.status.map((i) => i.version))
|
const lastVersion = getLastVersion(item.status?.map((i) => i.version))
|
||||||
|
|
||||||
const renderVersion = () => {
|
const renderVersion = () => {
|
||||||
if (!isSame && lastVersion) {
|
if (!isSame && lastVersion) {
|
||||||
return (
|
return (
|
||||||
<Tag icon={<ExclamationCircleOutlined />} color="warning">
|
<Tag icon={<ExclamationCircleOutlined />} color="warning">
|
||||||
{lastVersion}
|
{lastVersion}
|
||||||
</Tag>
|
</Tag>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
if (isSame && lastVersion) {
|
||||||
|
return <Tag color="default">{lastVersion}</Tag>
|
||||||
|
}
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
if (isSame && lastVersion) {
|
|
||||||
return <Tag color="default">{lastVersion}</Tag>
|
|
||||||
}
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<List.Item>
|
<List.Item>
|
||||||
<Tooltip mouseEnterDelay={1} title={item.name}>
|
<Tooltip mouseEnterDelay={1} title={item.name}>
|
||||||
<List.Item.Meta
|
<List.Item.Meta
|
||||||
title={
|
title={
|
||||||
<div className="module-item__name">
|
<div className="module-item__name">
|
||||||
<span>{item.name}</span>
|
<span>{item.name}</span>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
overlayInnerStyle={{ width: '300px' }}
|
overlayInnerStyle={{ width: '300px' }}
|
||||||
title={textTooltip}
|
title={textTooltip}
|
||||||
>
|
>
|
||||||
{renderVersion()}
|
{renderVersion()}
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
description={
|
description={
|
||||||
<div className="module-item__content">
|
<div className="module-item__content">
|
||||||
<span className="module-item__content__description">
|
<span className="module-item__content__description">
|
||||||
активные экземпляры:
|
активные экземпляры:
|
||||||
</span>
|
</span>
|
||||||
<Badge
|
<Badge
|
||||||
size="small"
|
size="small"
|
||||||
showZero
|
showZero
|
||||||
count={(item.status && item.status.length) || 0}
|
count={(item.status && item.status.length) || 0}
|
||||||
color={!item.status || !item.status.length ? '' : 'cyan'}
|
color={!item.status || !item.status.length ? '' : 'cyan'}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</List.Item>
|
</List.Item>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderMainContent = () => {
|
|
||||||
if (!selectedItemId) {
|
|
||||||
return <EmptyData />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!currentRole) {
|
|
||||||
return <NoData />
|
|
||||||
}
|
|
||||||
|
|
||||||
return <Outlet />
|
|
||||||
}
|
|
||||||
const secondColumnItems = [
|
|
||||||
{
|
|
||||||
key: 'configurations',
|
|
||||||
name: 'Конфигурации'
|
|
||||||
},
|
|
||||||
{ key: 'connections', name: 'Подключения' }
|
|
||||||
]
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="modules-page three-columns">
|
<section className="modules-page three-columns">
|
||||||
<Column
|
<Column
|
||||||
@@ -220,24 +201,10 @@ const ModulesPage = () => {
|
|||||||
selectedItemId={selectedItemId}
|
selectedItemId={selectedItemId}
|
||||||
setSelectedItemId={setSelectedItemId}
|
setSelectedItemId={setSelectedItemId}
|
||||||
/>
|
/>
|
||||||
<Tabs
|
<ModuleTabs
|
||||||
activeKey={activeTab}
|
currentModule={currentModule}
|
||||||
onChange={(activeKey) => {
|
activeTab={activeTab}
|
||||||
setActiveTab(activeKey)
|
setActiveTab={setActiveTab}
|
||||||
const path = `${selectedItemId}/${activeKey}`
|
|
||||||
navigate(path)
|
|
||||||
}}
|
|
||||||
className="modules-page__tabs"
|
|
||||||
items={secondColumnItems.map((item) => {
|
|
||||||
return {
|
|
||||||
disabled: selectedItemId === '',
|
|
||||||
label: item.name,
|
|
||||||
key: item.key,
|
|
||||||
children: (
|
|
||||||
<div className="modules-page__content">{renderMainContent()}</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})}
|
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export interface ConfigType {
|
|||||||
updatedAt: string
|
updatedAt: string
|
||||||
valid: boolean
|
valid: boolean
|
||||||
version: number
|
version: number
|
||||||
|
unsafe?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface JSONSchema {
|
export interface JSONSchema {
|
||||||
@@ -88,6 +89,14 @@ export interface ModuleType {
|
|||||||
configSchema: JSONSchema
|
configSchema: JSONSchema
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ResponseSchemaType {
|
||||||
|
createdAt: string,
|
||||||
|
id: string,
|
||||||
|
moduleId: string,
|
||||||
|
schema: JSONSchema,
|
||||||
|
updatedAt: string,
|
||||||
|
version: string
|
||||||
|
}
|
||||||
export interface ConfigResponse {
|
export interface ConfigResponse {
|
||||||
originalResponse: ConfigType[]
|
originalResponse: ConfigType[]
|
||||||
activeConfigs: ConfigType[]
|
activeConfigs: ConfigType[]
|
||||||
|
|||||||
@@ -2,11 +2,9 @@
|
|||||||
|
|
||||||
.modules-page {
|
.modules-page {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
&__tabs {
|
&__tabs {
|
||||||
padding: 0 $basic-padding*2 $basic-padding*2;
|
padding: 0 $basic-padding*2;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow-x: scroll;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ant-tag {
|
.ant-tag {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { lazy, Suspense } from 'react'
|
|||||||
import { Navigate, Route, Routes } from 'react-router-dom'
|
import { Navigate, Route, Routes } from 'react-router-dom'
|
||||||
|
|
||||||
import LayoutComponent from '@components/Layout'
|
import LayoutComponent from '@components/Layout'
|
||||||
// Составная часть основной страницы, поэтому без lazy
|
// Составная часть основной страницы, поэтому без lazy
|
||||||
import Configurations from '@pages/ConfigurationsPage'
|
import Configurations from '@pages/ConfigurationsPage'
|
||||||
import Connections from '@pages/ConnectionsPage'
|
import Connections from '@pages/ConnectionsPage'
|
||||||
|
|
||||||
@@ -25,6 +25,8 @@ const AppAccessPage = lazy(() => import('@pages/AppAccessPage'))
|
|||||||
const ModulesPage = lazy(() => import('@pages/ModulesPage'))
|
const ModulesPage = lazy(() => import('@pages/ModulesPage'))
|
||||||
const ApplicationsPage = lazy(() => import('@pages/ApplicationsPage'))
|
const ApplicationsPage = lazy(() => import('@pages/ApplicationsPage'))
|
||||||
const AllVersionsPage = lazy(() => import('@pages/AllVersionsPage'))
|
const AllVersionsPage = lazy(() => import('@pages/AllVersionsPage'))
|
||||||
|
const ConfigurationEditorPage = lazy(
|
||||||
|
() => import('@pages/ConfigurationEditorPage'))
|
||||||
|
|
||||||
const Routers = () => {
|
const Routers = () => {
|
||||||
return (
|
return (
|
||||||
@@ -149,6 +151,14 @@ const Routers = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route path={`:moduleId/${routePaths.configEditor}/:id`}
|
||||||
|
element={
|
||||||
|
<Suspense fallback={<Spin />}>
|
||||||
|
<ConfigurationEditorPage />
|
||||||
|
</Suspense>
|
||||||
|
}>
|
||||||
|
|
||||||
|
</Route>
|
||||||
<Route
|
<Route
|
||||||
path={routePaths.modules}
|
path={routePaths.modules}
|
||||||
element={
|
element={
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ type RoutePaths =
|
|||||||
| 'connections'
|
| 'connections'
|
||||||
| 'configurations'
|
| 'configurations'
|
||||||
| 'allVersions'
|
| 'allVersions'
|
||||||
|
| 'configEditor'
|
||||||
|
|
||||||
export const routePaths: Record<RoutePaths, string> = {
|
export const routePaths: Record<RoutePaths, string> = {
|
||||||
home: '/',
|
home: '/',
|
||||||
@@ -34,5 +35,6 @@ export const routePaths: Record<RoutePaths, string> = {
|
|||||||
application: 'application',
|
application: 'application',
|
||||||
connections: 'connections',
|
connections: 'connections',
|
||||||
configurations: 'configurations',
|
configurations: 'configurations',
|
||||||
allVersions: ':configId/all_versions'
|
allVersions: ':configId/all_versions',
|
||||||
|
configEditor: 'configEditor',
|
||||||
}
|
}
|
||||||
@@ -63,8 +63,8 @@ const configServiceApi = createApi({
|
|||||||
invalidatesTags: () => ['versions']
|
invalidatesTags: () => ['versions']
|
||||||
}),
|
}),
|
||||||
deleteConfig: builder.mutation<void, string>({
|
deleteConfig: builder.mutation<void, string>({
|
||||||
query: (id) => ({ url: apiPaths.deleteVersion, data: [id] }),
|
query: (id) => ({ url: apiPaths.deleteConfig, data: [id] }),
|
||||||
invalidatesTags: () => ['versions']
|
invalidatesTags: () => ['configs']
|
||||||
}),
|
}),
|
||||||
markConfigAsActive: builder.mutation<void, string>({
|
markConfigAsActive: builder.mutation<void, string>({
|
||||||
query: (id) => ({ url: apiPaths.markConfigAsActive, data: { id } }),
|
query: (id) => ({ url: apiPaths.markConfigAsActive, data: { id } }),
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import { createApi } from '@reduxjs/toolkit/query/react'
|
import { createApi } from '@reduxjs/toolkit/query/react'
|
||||||
|
|
||||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||||
|
|
||||||
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
import { ModuleType, ResponseSchemaType } from '@pages/ModulesPage/module.type.ts'
|
||||||
|
|
||||||
import { axiosBaseQuery } from '@utils/apiUtils.ts'
|
import { axiosBaseQuery } from '@utils/apiUtils.ts'
|
||||||
|
|
||||||
|
|
||||||
const modulesServiceApi = createApi({
|
const modulesServiceApi = createApi({
|
||||||
reducerPath: 'modulesServiceApi',
|
reducerPath: 'modulesServiceApi',
|
||||||
refetchOnFocus: true,
|
refetchOnFocus: false,
|
||||||
tagTypes: ['modules'],
|
tagTypes: ['modules', 'schema'],
|
||||||
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseConfigUrl }),
|
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseConfigUrl }),
|
||||||
endpoints: (builder) => ({
|
endpoints: (builder) => ({
|
||||||
getModules: builder.query<ModuleType[], string>({
|
getModules: builder.query<ModuleType[], string>({
|
||||||
@@ -22,7 +22,14 @@ const modulesServiceApi = createApi({
|
|||||||
data: [id]
|
data: [id]
|
||||||
}),
|
}),
|
||||||
invalidatesTags: ['modules']
|
invalidatesTags: ['modules']
|
||||||
})
|
}),
|
||||||
|
getByModuleId: builder.query<ResponseSchemaType, string>({
|
||||||
|
query: (moduleId) => ({
|
||||||
|
url: apiPaths.getByModuleId,
|
||||||
|
data: { moduleId }
|
||||||
|
}),
|
||||||
|
providesTags: () => ['schema'],
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -16,4 +16,36 @@ const sortObject = (obj: any): any => {
|
|||||||
return sorted
|
return sorted
|
||||||
}
|
}
|
||||||
|
|
||||||
export { sortObject }
|
function isEmpty(value: unknown): boolean {
|
||||||
|
return value === undefined ||
|
||||||
|
value === null ||
|
||||||
|
(typeof value === 'string' && value.trim() === '') ||
|
||||||
|
(typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanEmptyParamsObject(obj: any): any {
|
||||||
|
if (typeof obj !== 'object' || obj === null) {
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(obj)) {
|
||||||
|
return obj
|
||||||
|
.map(cleanEmptyParamsObject)
|
||||||
|
.filter(item => !isEmpty(item))
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.keys(obj).reduce((acc, key) => {
|
||||||
|
if (key === 'data') {
|
||||||
|
acc[key] = obj[key]
|
||||||
|
} else {
|
||||||
|
const value = cleanEmptyParamsObject(obj[key])
|
||||||
|
if (!isEmpty(value)) {
|
||||||
|
acc[key] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}, {} as Record<string, unknown>)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export { sortObject, cleanEmptyParamsObject }
|
||||||
@@ -5,9 +5,10 @@ import {
|
|||||||
EyeOutlined,
|
EyeOutlined,
|
||||||
HistoryOutlined,
|
HistoryOutlined,
|
||||||
SwapOutlined,
|
SwapOutlined,
|
||||||
EllipsisOutlined
|
EllipsisOutlined,
|
||||||
|
CopyOutlined
|
||||||
} from '@ant-design/icons'
|
} from '@ant-design/icons'
|
||||||
import { Button, Dropdown, Popconfirm, Tooltip } from 'antd'
|
import { Button, Dropdown, message, Popconfirm, Tooltip } from 'antd'
|
||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
|
|
||||||
@@ -15,6 +16,9 @@ import { ActiveTableActionButtonsPropsType } from './active-table-action-buttons
|
|||||||
|
|
||||||
import './active-table-action-buttons.scss'
|
import './active-table-action-buttons.scss'
|
||||||
import CanEdit from '@components/CanEdit'
|
import CanEdit from '@components/CanEdit'
|
||||||
|
import { routePaths } from '@routes/routePaths.ts'
|
||||||
|
import configServiceApi from '@services/configService.ts'
|
||||||
|
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||||
|
|
||||||
const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
||||||
({
|
({
|
||||||
@@ -26,10 +30,25 @@ const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
|||||||
handleMarkConfigActive
|
handleMarkConfigActive
|
||||||
}) => {
|
}) => {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
const [createUpdateConfig] = configServiceApi.useCreateUpdateConfigMutation()
|
||||||
|
|
||||||
const navigateToAllVersion = () => navigate(`${record.id}/all_versions`)
|
const navigateToAllVersion = () => navigate(`${record.id}/all_versions`)
|
||||||
|
|
||||||
const renderDropDown = (record: any) => {
|
const copyConfig = () => {
|
||||||
|
const newConfig = {
|
||||||
|
name: `${record.name} (copy)`,
|
||||||
|
moduleId: record.moduleId,
|
||||||
|
id: '',
|
||||||
|
version: 0,
|
||||||
|
data: record.data
|
||||||
|
} as ConfigType
|
||||||
|
createUpdateConfig(newConfig)
|
||||||
|
.unwrap()
|
||||||
|
.then(() => message.success('Конфиг успешно скопирован'))
|
||||||
|
.catch(() => message.error('Не удалось скопировать конфиг'))
|
||||||
|
}
|
||||||
|
|
||||||
|
const renderDropDownNoActive = (record: any) => {
|
||||||
return (
|
return (
|
||||||
<div className="dropdown">
|
<div className="dropdown">
|
||||||
<Tooltip key="1" title="Сравнение версий">
|
<Tooltip key="1" title="Сравнение версий">
|
||||||
@@ -42,6 +61,9 @@ const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
|||||||
<Button onClick={navigateToAllVersion} icon={<HistoryOutlined />} />
|
<Button onClick={navigateToAllVersion} icon={<HistoryOutlined />} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<CanEdit>
|
<CanEdit>
|
||||||
|
<Tooltip key="4" title="Копировать конфиг">
|
||||||
|
<Button icon={<CopyOutlined />} onClick={copyConfig} />
|
||||||
|
</Tooltip>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title="Вы действительно хотите удалить выбранный конфиг?"
|
title="Вы действительно хотите удалить выбранный конфиг?"
|
||||||
onConfirm={() => handleDeleteConfig(record)}
|
onConfirm={() => handleDeleteConfig(record)}
|
||||||
@@ -55,23 +77,33 @@ const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const renderDropDownActive = (record: any) => {
|
||||||
|
return (
|
||||||
|
<div className="dropdown">
|
||||||
|
<Tooltip key="1" title="Сравнение версий">
|
||||||
|
<Button
|
||||||
|
onClick={() => handleShowCompareModal(record)}
|
||||||
|
icon={<SwapOutlined />}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip key="2" title="Просмотр истории">
|
||||||
|
<Button onClick={navigateToAllVersion} icon={<HistoryOutlined />} />
|
||||||
|
</Tooltip>
|
||||||
|
<CanEdit>
|
||||||
|
<Tooltip key="4" title="Копировать конфиг">
|
||||||
|
<Button icon={<CopyOutlined />} onClick={copyConfig} />
|
||||||
|
</Tooltip>
|
||||||
|
</CanEdit>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const renderAdditionalButtons = () => {
|
const renderAdditionalButtons = () => {
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
return (
|
return (
|
||||||
<>
|
<Dropdown dropdownRender={() => renderDropDownActive(record)}>
|
||||||
<Tooltip key="1" title="Сравнение версий">
|
<Button icon={<EllipsisOutlined />} />
|
||||||
<Button
|
</Dropdown>
|
||||||
onClick={() => handleShowCompareModal(record)}
|
|
||||||
icon={<SwapOutlined />}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip key="2" title="Просмотр истории">
|
|
||||||
<Button
|
|
||||||
onClick={navigateToAllVersion}
|
|
||||||
icon={<HistoryOutlined />}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,8 +114,8 @@ const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
|||||||
<Button onClick={() => handleMarkConfigActive(record)} icon={<AlertOutlined />} />
|
<Button onClick={() => handleMarkConfigActive(record)} icon={<AlertOutlined />} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</CanEdit>
|
</CanEdit>
|
||||||
<Dropdown dropdownRender={() => renderDropDown(record)}>
|
<Dropdown dropdownRender={() => renderDropDownNoActive(record)}>
|
||||||
<Button icon={<EllipsisOutlined />} />
|
<Button icon={<EllipsisOutlined />} />
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
@@ -91,18 +123,20 @@ const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
|||||||
return (
|
return (
|
||||||
<div className="active-configurations-table-actions-field">
|
<div className="active-configurations-table-actions-field">
|
||||||
<Button.Group className="button_group">
|
<Button.Group className="button_group">
|
||||||
<Tooltip title="Просмотр">
|
<Tooltip title="Просмотр">
|
||||||
<Button
|
<Button
|
||||||
onClick={() => handleShowConfig(record)}
|
onClick={() => handleShowConfig(record)}
|
||||||
icon={<EyeOutlined />}
|
icon={<EyeOutlined />}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
|
||||||
<CanEdit>
|
|
||||||
<Tooltip title="Редактировать">
|
|
||||||
<Button icon={<EditOutlined />} />
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</CanEdit>
|
<CanEdit>
|
||||||
{renderAdditionalButtons()}
|
<Tooltip title="Редактировать">
|
||||||
|
<Button onClick={() => {
|
||||||
|
navigate(`/${record.moduleId}/${routePaths.configEditor}/${record.id}`, { state: record })
|
||||||
|
}} icon={<EditOutlined />} />
|
||||||
|
</Tooltip>
|
||||||
|
</CanEdit>
|
||||||
|
{renderAdditionalButtons()}
|
||||||
</Button.Group>
|
</Button.Group>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { Layout } from 'isp-ui-kit'
|
||||||
|
import { memo } from 'react'
|
||||||
|
import { Outlet } from 'react-router-dom'
|
||||||
|
|
||||||
|
import { ModuleTabContentPropsType } from '@widgets/ModuleTabContent/module-tab-content.type.ts'
|
||||||
|
|
||||||
|
|
||||||
|
const { EmptyData, NoData } = Layout
|
||||||
|
|
||||||
|
const ModuleTabContent = ({
|
||||||
|
selectedItemId,
|
||||||
|
currentModule
|
||||||
|
}: ModuleTabContentPropsType) => {
|
||||||
|
if (!selectedItemId) {
|
||||||
|
return <EmptyData />
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!currentModule) {
|
||||||
|
return <NoData />
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Outlet />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default memo(ModuleTabContent)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
||||||
|
|
||||||
|
export interface ModuleTabContentPropsType {
|
||||||
|
selectedItemId: string
|
||||||
|
currentModule: ModuleType | undefined
|
||||||
|
}
|
||||||
Reference in new issue
Block a user