Merge branch 'MSP-3289_fix-to-prod__profile-modules-apps' into 'MSP-3288_fix-to-prod'
Resolve MSP-3289 "Fix to prod profile modules apps" See merge request isp/isp-admin-ui!27
This commit is contained in:
commit
058e4d6a11
31 files changed
+1513
-2750
No files matched your search
Generated
+1126
-2496
File diff suppressed because it is too large.
Load diff
+6
-2
@@ -5,7 +5,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
"build": "tsc && vite build && node generateVersionFile.cjs",
|
||||
"build": "vite build && node generateVersionFile.cjs",
|
||||
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||
"preview": "vite preview",
|
||||
"fix:prettier": "prettier --write \"src/**/*.{ts,tsx, js}\"",
|
||||
@@ -14,9 +14,9 @@
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
||||
"@codemirror/lang-json": "^6.0.1",
|
||||
"@reduxjs/toolkit": "^2.2.3",
|
||||
"@stoplight/json-schema-viewer": "^4.16.0",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
"@uiw/react-codemirror": "^4.21.25",
|
||||
"axios": "^1.6.8",
|
||||
@@ -24,6 +24,8 @@
|
||||
"compare-versions": "^6.1.0",
|
||||
"dayjs": "^1.11.10",
|
||||
"isp-ui-kit": "github:txix-open/isp-ui-kit",
|
||||
"json-schema-view-js": "^2.0.1",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"react": "^18.2.0",
|
||||
"react-codemirror-merge": "^4.21.25",
|
||||
"react-dom": "^18.2.0",
|
||||
@@ -36,6 +38,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
||||
"@types/lodash.clonedeep": "^4.5.9",
|
||||
"@types/node": "^20.12.4",
|
||||
"@types/react": "^18.2.74",
|
||||
"@types/react-dom": "^18.2.24",
|
||||
@@ -60,6 +63,7 @@
|
||||
"terser": "^5.30.3",
|
||||
"typescript": "^5.4.3",
|
||||
"vite": "^5.2.8",
|
||||
"vite-plugin-node-polyfills": "^0.21.0",
|
||||
"vite-plugin-style-import": "^2.0.0",
|
||||
"vite-plugin-svgr": "^4.2.0",
|
||||
"vite-tsconfig-paths": "^4.3.2"
|
||||
|
||||
@@ -10,7 +10,15 @@
|
||||
&__table {
|
||||
&__name-field {
|
||||
input {
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
width: 100%;
|
||||
|
||||
&:focus-visible {
|
||||
padding: $basic-padding;
|
||||
border-radius: 4px;
|
||||
outline: 1px solid $blue-color;
|
||||
}
|
||||
}
|
||||
|
||||
display: flex;
|
||||
|
||||
@@ -16,6 +16,7 @@ import { ColumnsType } from 'antd/es/table'
|
||||
import './active-configurations-table.scss'
|
||||
import dayjs from 'dayjs'
|
||||
import CanEdit from '@components/CanEdit'
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
|
||||
const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> =
|
||||
@@ -167,7 +168,7 @@ const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> =
|
||||
key: 'updatedAt',
|
||||
align: 'center',
|
||||
render: (value: string) => {
|
||||
return dayjs(value).format('HH:mm:ss DD.MM.YYYY')
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
import { ApplicationsGroupType } from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
export type AppGroupModalType = Omit<
|
||||
ModalPropsType,
|
||||
'onOk' | 'children'
|
||||
> & {
|
||||
appGroup?: ApplicationsGroupType
|
||||
onOk: (data: ApplicationsGroupType) => void
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import { FormComponents } from 'isp-ui-kit'
|
||||
import { FC, useEffect } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
|
||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import { AppGroupModalType } from '@components/AppGroupModal/app-group-modal.type.ts'
|
||||
|
||||
import { ApplicationsGroupType } from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
|
||||
const { FormInput, FormTextArea } = FormComponents
|
||||
|
||||
const AppGroupModal: FC<AppGroupModalType> = ({
|
||||
title,
|
||||
onClose,
|
||||
onOk,
|
||||
open,
|
||||
appGroup,
|
||||
|
||||
}) => {
|
||||
const { handleSubmit, control, reset } = useForm<ApplicationsGroupType>({
|
||||
mode: 'onChange',
|
||||
defaultValues: appGroup
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
reset(appGroup)
|
||||
}, [open])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
onOk={handleSubmit(onOk)}
|
||||
title={title}
|
||||
open={open}
|
||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
||||
onClose={onClose}
|
||||
>
|
||||
<form>
|
||||
<FormInput
|
||||
control={control}
|
||||
name="name"
|
||||
label="Наименование"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<FormTextArea
|
||||
autoSize={{ minRows: 2, maxRows: 6 }}
|
||||
control={control}
|
||||
label="Описание"
|
||||
name="description"
|
||||
/>
|
||||
</form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
export default AppGroupModal
|
||||
@@ -0,0 +1,8 @@
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
import { ApplicationAppType } from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
export type AppModalType = Omit<ModalPropsType, 'onOk' | 'children'> & {
|
||||
app?: ApplicationAppType
|
||||
onOk: (data: ApplicationAppType) => void
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { FormComponents } from 'isp-ui-kit'
|
||||
import { FC, useEffect } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
|
||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
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 { handleSubmit, control, reset } = useForm<ApplicationAppType>({
|
||||
mode: 'onChange',
|
||||
defaultValues: app
|
||||
})
|
||||
useEffect(() => {
|
||||
reset(app)
|
||||
}, [open])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
onOk={handleSubmit(onOk)}
|
||||
title={title}
|
||||
open={open}
|
||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
||||
onClose={onClose}
|
||||
>
|
||||
<form>
|
||||
<FormInput
|
||||
control={control}
|
||||
name="name"
|
||||
label="Наименование"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<FormTextArea
|
||||
autoSize={{ minRows: 2, maxRows: 6 }}
|
||||
control={control}
|
||||
label="Описание"
|
||||
name="description"
|
||||
/>
|
||||
</form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
export default AppModal
|
||||
@@ -1,15 +1,11 @@
|
||||
import { LinkOutlined } from '@ant-design/icons'
|
||||
import { List, message, Spin, Tooltip } from 'antd'
|
||||
import { FormComponents, Layout } from 'isp-ui-kit'
|
||||
import { Layout } from 'isp-ui-kit'
|
||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
||||
import { Dispatch, FC, SetStateAction, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { Dispatch, FC, SetStateAction, useMemo, useState } from 'react'
|
||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
||||
|
||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import AppModal from '@components/AppModal'
|
||||
import TokenContent from '@components/TokenContent'
|
||||
|
||||
import {
|
||||
@@ -28,7 +24,7 @@ import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import './applications-content.scss'
|
||||
|
||||
const { FormInput } = FormComponents
|
||||
|
||||
const { EmptyData, Column } = Layout
|
||||
|
||||
interface ApplicationsContentPropTypes {
|
||||
@@ -41,10 +37,12 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
||||
selectedItemId,
|
||||
setCurrentApplicationsApp
|
||||
}) => {
|
||||
const { data: applications, isLoading: isLoadingApplicationsContent = [] } =
|
||||
applicationsApi.useGetApplicationsByServiceIdQuery({
|
||||
id: selectedItemId
|
||||
})
|
||||
const {
|
||||
data: applications = [],
|
||||
isLoading: isLoadingApplicationsContent = []
|
||||
} = applicationsApi.useGetApplicationsByServiceIdQuery({
|
||||
id: selectedItemId
|
||||
})
|
||||
|
||||
const [createApplicationService] =
|
||||
applicationsApi.useCreateApplicationServiceMutation()
|
||||
@@ -61,13 +59,13 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
||||
const navigate = useNavigate()
|
||||
const { appId = '' } = useParams()
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
control: controlApplicationApp,
|
||||
reset
|
||||
} = useForm<ApplicationAppType>({
|
||||
mode: 'onChange'
|
||||
})
|
||||
const currentApp = useMemo(() => {
|
||||
const element = applications.find(
|
||||
(application) => application.app.id.toString() === appId
|
||||
)
|
||||
return element ? element.app : undefined
|
||||
}, [applications, appId])
|
||||
|
||||
const updateApplicationModal = () => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
@@ -88,35 +86,31 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
||||
return <TokenContent key={appId} id={Number(appId)} />
|
||||
}
|
||||
|
||||
const handleUpdateApplicationApp = (data: UpdateApplicationAppType) => {
|
||||
const currentElement = applications?.filter(
|
||||
(el) => el.app.id === Number(appId)
|
||||
)[0].app
|
||||
if (currentElement) {
|
||||
const handleUpdateApplicationApp = (data: ApplicationAppType) => {
|
||||
if (currentApp) {
|
||||
const updateApplications: UpdateApplicationAppType = {
|
||||
id: currentElement.id,
|
||||
id: currentApp.id,
|
||||
name: data.name,
|
||||
description: data.description
|
||||
? data.description
|
||||
: currentElement.description,
|
||||
: currentApp.description,
|
||||
serviceId: selectedItemId,
|
||||
type: 'SYSTEM'
|
||||
}
|
||||
updateApplication({ ...currentElement, ...updateApplications })
|
||||
updateApplication({ ...currentApp, ...updateApplications })
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: false
|
||||
})
|
||||
reset()
|
||||
message.info('Элемент сохранен')
|
||||
message.success('Элемент сохранен')
|
||||
})
|
||||
.catch(() => message.error('Ошибка обновления элемента'))
|
||||
}
|
||||
}
|
||||
|
||||
const handleCreateApplicationApp = (data: NewApplicationAppType) => {
|
||||
const handleCreateApplicationApp = (data: ApplicationAppType) => {
|
||||
const newApplicationApp: NewApplicationAppType = {
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
@@ -126,19 +120,18 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
||||
|
||||
createApplicationService(newApplicationApp)
|
||||
.unwrap()
|
||||
.then(message.info('Элемент сохранен'))
|
||||
.then(message.success('Элемент сохранен'))
|
||||
.catch((e) => message.error(e))
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: false
|
||||
})
|
||||
reset()
|
||||
}
|
||||
const handleRemoveApplicationApp = (id: number) =>
|
||||
removeApplicationsService([id])
|
||||
.unwrap()
|
||||
.then(() => message.success('Элемент удален'))
|
||||
.catch(() => message.info('Ошибка удаления элемента'))
|
||||
.catch(() => message.error('Ошибка удаления элемента'))
|
||||
|
||||
const renderColumnItems = (item: ColumnItem<any>) => {
|
||||
return (
|
||||
@@ -202,60 +195,29 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
||||
}}
|
||||
/>
|
||||
{renderTokenContent()}
|
||||
|
||||
<Modal
|
||||
onOk={handleSubmit(handleUpdateApplicationApp)}
|
||||
title="Редактировать"
|
||||
<AppModal
|
||||
app={currentApp}
|
||||
onOk={handleUpdateApplicationApp}
|
||||
title="Редактировать приложение"
|
||||
open={showApplicationsModal.updateModal}
|
||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
||||
onClose={() =>
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: false
|
||||
})
|
||||
}
|
||||
>
|
||||
<form>
|
||||
<FormInput
|
||||
control={controlApplicationApp}
|
||||
name="name"
|
||||
label="Наименование"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<FormInput
|
||||
control={controlApplicationApp}
|
||||
label="Описание"
|
||||
name="description"
|
||||
/>
|
||||
</form>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
onOk={handleSubmit(handleCreateApplicationApp)}
|
||||
title="Добавить"
|
||||
/>
|
||||
<AppModal
|
||||
onOk={handleCreateApplicationApp}
|
||||
title="Добавить приложение"
|
||||
open={showApplicationsModal.addModal}
|
||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
||||
onClose={() =>
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: false
|
||||
})
|
||||
}
|
||||
>
|
||||
<form>
|
||||
<FormInput
|
||||
control={controlApplicationApp}
|
||||
name="name"
|
||||
label="Наименование"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<FormInput
|
||||
control={controlApplicationApp}
|
||||
label="Описание"
|
||||
name="description"
|
||||
/>
|
||||
</form>
|
||||
</Modal>
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import { VersionType } from '@type/version.type'
|
||||
|
||||
import './compare-version-modal.scss'
|
||||
import dayjs from 'dayjs'
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
|
||||
const Original = CodeMirrorMerge.Original
|
||||
@@ -52,7 +53,7 @@ const CompareVersionModal: FC<CompareVersionModalPropsType> = ({
|
||||
title: 'Создано',
|
||||
dataIndex: 'createdAt',
|
||||
render: (value: string) => {
|
||||
return dayjs(value).format('HH:mm:ss DD.MM.YYYY')
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { JsonSchemaViewer } from '@stoplight/json-schema-viewer'
|
||||
import { FC } from 'react'
|
||||
|
||||
import JsonSchemaViewer from '@widgets/JSONViewer'
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import { ConfigSchemaModalPropsType } from '@components/ConfigSchemaModal/config-schema-moda.type.ts'
|
||||
|
||||
import './config-schema-modal.scss'
|
||||
|
||||
|
||||
const ConfigSchemaModal: FC<ConfigSchemaModalPropsType> = ({
|
||||
open,
|
||||
onClose,
|
||||
@@ -15,13 +16,7 @@ const ConfigSchemaModal: FC<ConfigSchemaModalPropsType> = ({
|
||||
return (
|
||||
<div className="config-schema-modal">
|
||||
<Modal title="Текущая схема конфигурации" open={open} onClose={onClose}>
|
||||
<JsonSchemaViewer
|
||||
viewMode="view"
|
||||
className="json-schema-view"
|
||||
schema={schema}
|
||||
emptyText="No schema defined"
|
||||
defaultExpandedDepth={99}
|
||||
/>
|
||||
<JsonSchemaViewer schema={schema} />
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import {
|
||||
AppstoreAddOutlined,
|
||||
LockOutlined,
|
||||
LogoutOutlined,
|
||||
ProductOutlined,
|
||||
ProfileOutlined
|
||||
} from '@ant-design/icons'
|
||||
import { ConfigProvider, Layout, Menu, Spin } from 'antd'
|
||||
import type { MenuProps } from 'antd'
|
||||
import { ConfigProvider, Layout, Menu, Spin } from 'antd'
|
||||
import { useContext, useEffect, useState } from 'react'
|
||||
import { Navigate, Outlet, useLocation, useNavigate } from 'react-router-dom'
|
||||
|
||||
@@ -24,7 +23,6 @@ import {
|
||||
import { LocalStorage } from '@utils/localStorageUtils.ts'
|
||||
|
||||
import { useAppDispatch, useAppSelector } from '@hooks/redux.ts'
|
||||
import useLogout from '@hooks/useLogout.tsx'
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import { fetchProfile, fetchUI } from '@stores/redusers/ActionCreators.ts'
|
||||
@@ -55,7 +53,6 @@ const LayoutComponent = () => {
|
||||
const { theme } = useContext(ConfigProvider.ConfigContext)
|
||||
|
||||
const userToken = LocalStorage.get(localStorageKeys.USER_TOKEN)
|
||||
const { logoutUser } = useLogout()
|
||||
|
||||
const hideItem = (permission: PermissionKeysType | PermissionKeysType[]) => {
|
||||
if (Array.isArray(permission)) {
|
||||
@@ -70,21 +67,9 @@ const LayoutComponent = () => {
|
||||
const menuItems: MenuItemType[] = [
|
||||
{
|
||||
label: firstName || '',
|
||||
key: 'userManagement',
|
||||
key: 'profile',
|
||||
className: 'user-item',
|
||||
icon: <DefaultUser />,
|
||||
children: [
|
||||
{
|
||||
label: 'Профиль',
|
||||
key: 'profile',
|
||||
icon: <ProfileOutlined />
|
||||
},
|
||||
{
|
||||
label: 'Выход',
|
||||
key: 'logout',
|
||||
icon: <LogoutOutlined />
|
||||
}
|
||||
]
|
||||
icon: <DefaultUser />
|
||||
},
|
||||
{
|
||||
label: 'Группы приложений',
|
||||
@@ -159,15 +144,14 @@ const LayoutComponent = () => {
|
||||
if (menuItem) {
|
||||
setSelectedMenuKeys([menuItem.key])
|
||||
setOpenKeys(menuItem.parent)
|
||||
} else {
|
||||
setSelectedMenuKeys([])
|
||||
setOpenKeys([])
|
||||
}
|
||||
}, [location])
|
||||
|
||||
const handlerOnClickMenu: MenuProps['onClick'] = ({ key }): void => {
|
||||
switch (key) {
|
||||
case MenuItemKeysType.logout: {
|
||||
logoutUser()
|
||||
break
|
||||
}
|
||||
case MenuItemKeysType.profile: {
|
||||
navigate(routePaths.profile)
|
||||
break
|
||||
|
||||
@@ -20,7 +20,7 @@ export enum MenuItemLabelsType {
|
||||
profile = 'Профиль',
|
||||
modules = 'Модули',
|
||||
logout = 'Выход',
|
||||
applications_group = 'Группа приложений'
|
||||
applications_group = 'Группы приложений'
|
||||
}
|
||||
|
||||
interface MenuItem {
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
import { CopyOutlined, DeleteOutlined } from '@ant-design/icons'
|
||||
import { Button, message, Popconfirm, Spin, Table } from 'antd'
|
||||
import { Button, message, Popconfirm, Spin, Table, Tooltip } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import ClipboardJS from 'clipboard'
|
||||
import dayjs from 'dayjs'
|
||||
import 'dayjs/locale/ru'
|
||||
import duration from 'dayjs/plugin/duration'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
import { Layout, FormComponents } from 'isp-ui-kit'
|
||||
import { FormComponents, Layout } from 'isp-ui-kit'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
// import CanEdit from '@components/CanEdit'
|
||||
import CanEdit from '@components/CanEdit'
|
||||
|
||||
import {
|
||||
ApplicationTokenType,
|
||||
NewApplicationTokenType
|
||||
@@ -22,8 +24,10 @@ import {
|
||||
|
||||
import tokensApi from '@services/tokensService.ts'
|
||||
|
||||
import './tokens.scss'
|
||||
import CanEdit from '@components/CanEdit'
|
||||
|
||||
|
||||
import './tokens.scss';
|
||||
|
||||
|
||||
const { FormSelect } = FormComponents
|
||||
const { EmptyData } = Layout
|
||||
@@ -76,7 +80,7 @@ const TokenContent = ({ id }: TokenPropTypes) => {
|
||||
.then(() => {
|
||||
setShowApplicationsModal(false)
|
||||
reset()
|
||||
message.info('Элемент добавлен')
|
||||
message.success('Элемент добавлен')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Ошибка добавления элемента')
|
||||
@@ -105,10 +109,15 @@ const TokenContent = ({ id }: TokenPropTypes) => {
|
||||
revokeToken(currentRemoveToken)
|
||||
.unwrap()
|
||||
.then(() => message.success('Элемент удален'))
|
||||
.catch(() => message.info('Ошибка удаления элемента'))
|
||||
.catch(() => message.error('Ошибка удаления элемента'))
|
||||
}
|
||||
|
||||
const columns: ColumnsType<ApplicationTokenType> = [
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'appId',
|
||||
key: 'appId'
|
||||
},
|
||||
{
|
||||
title: 'Токен',
|
||||
dataIndex: 'token',
|
||||
@@ -120,8 +129,9 @@ const TokenContent = ({ id }: TokenPropTypes) => {
|
||||
dataIndex: 'createdAt',
|
||||
key: 'createdAt',
|
||||
render: (record) => {
|
||||
const FULL_DATE_FORMAT = 'DD-MM-YYYY/HH:mm'
|
||||
const formatTime = dayjs(record.createdAt).format(FULL_DATE_FORMAT)
|
||||
const formatTime = dayjs(record.createdAt).format(
|
||||
dateFormats.fullFormat
|
||||
)
|
||||
return <div>{formatTime}</div>
|
||||
}
|
||||
},
|
||||
@@ -142,42 +152,32 @@ const TokenContent = ({ id }: TokenPropTypes) => {
|
||||
dataIndex: 'expireTime',
|
||||
key: 'expireTime',
|
||||
render: (value, record) => {
|
||||
const FULL_DATE_FORMAT = 'DD-MM-YYYY, HH:mm'
|
||||
const formatTime = dayjs(record.createdAt)
|
||||
.add(record.expireTime)
|
||||
.format(FULL_DATE_FORMAT)
|
||||
.format(dateFormats.fullFormat)
|
||||
|
||||
return value > 0 ? <span>{formatTime}</span> : <span> Никогда </span>
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Скопировать',
|
||||
title: 'Действия',
|
||||
dataIndex: 'token',
|
||||
key: 'copyToken',
|
||||
align: 'center',
|
||||
render: (record) => {
|
||||
key: 'actions',
|
||||
render: (value) => {
|
||||
return (
|
||||
<Button className="copy-btn" data-clipboard-text={record}>
|
||||
<CopyOutlined />
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Отозвать',
|
||||
dataIndex: 'appId',
|
||||
key: 'recall',
|
||||
align: 'center',
|
||||
render: (_, record) => {
|
||||
return (
|
||||
<Popconfirm
|
||||
title="Закончить эту сессию?"
|
||||
onConfirm={() => handleRevokeToken(record)}
|
||||
>
|
||||
<Button danger>
|
||||
<DeleteOutlined />
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
<Button.Group>
|
||||
<Tooltip title="Скопировать">
|
||||
<Button icon={<CopyOutlined />} data-clipboard-text={value} />
|
||||
</Tooltip>
|
||||
<Tooltip title="Удалить">
|
||||
<Popconfirm
|
||||
title="Закончить эту сессию?"
|
||||
onConfirm={() => handleRevokeToken(value)}
|
||||
>
|
||||
<Button icon={<DeleteOutlined />} />
|
||||
</Popconfirm>
|
||||
</Tooltip>
|
||||
</Button.Group>
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -221,6 +221,7 @@ const TokenContent = ({ id }: TokenPropTypes) => {
|
||||
<section className="token-content">
|
||||
<div className="token-content__wrap">
|
||||
<header className="token-content__header">
|
||||
<h3>Токены</h3>
|
||||
<CanEdit>
|
||||
<Button
|
||||
className="applications-content__add-btn"
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
min-width: 500px;
|
||||
}
|
||||
|
||||
.wrap {
|
||||
padding: 2 * $basic-padding;
|
||||
border: 1px solid #F0F0F0;
|
||||
.ant-btn:focus-visible{
|
||||
outline: none !important;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
type FormattersKey = 'fullFormat'
|
||||
|
||||
|
||||
export const dateFormats:Record<FormattersKey,string> = {
|
||||
fullFormat: 'DD.MM.YYYY HH:mm:ss'
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
import { VersionType } from '@type/version.type.ts'
|
||||
|
||||
import './all-versions-page.scss'
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
|
||||
const AllVersionsPage = () => {
|
||||
@@ -157,7 +158,7 @@ const AllVersionsPage = () => {
|
||||
title: 'Создано',
|
||||
dataIndex: 'createdAt',
|
||||
render: (value: string) => {
|
||||
return dayjs(value).format('HH:mm:ss DD.MM.YYYY')
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -27,4 +27,8 @@
|
||||
box-shadow: inset -1px 0px 0px $border-color;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.modal__wrap{
|
||||
min-width: 350px;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,15 @@
|
||||
import { List, message, Spin, Tooltip } from 'antd'
|
||||
import { Layout, FormComponents } from 'isp-ui-kit'
|
||||
import { Layout } from 'isp-ui-kit'
|
||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
||||
|
||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import ApplicationsContent from '@components/ApplicationsContent'
|
||||
import AppGroupModal from 'src/components/AppGroupModal'
|
||||
|
||||
import {
|
||||
NewApplicationsGroupType,
|
||||
ApplicationsGroupType,
|
||||
NewApplicationsGroupType,
|
||||
UpdateApplicationsGroupType
|
||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
@@ -30,8 +26,8 @@ import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
import './applications-page.scss'
|
||||
|
||||
|
||||
const { Column, EmptyData } = Layout
|
||||
const { FormInput } = FormComponents
|
||||
|
||||
const ApplicationsPage = () => {
|
||||
const navigate = useNavigate()
|
||||
@@ -68,9 +64,12 @@ const ApplicationsPage = () => {
|
||||
updateModal: false
|
||||
})
|
||||
const searchValue = searchParams.get('search') || ''
|
||||
const { handleSubmit, control, reset } = useForm<ApplicationsGroupType>({
|
||||
mode: 'onChange'
|
||||
})
|
||||
|
||||
const currentAppGroup = useMemo(
|
||||
() =>
|
||||
applicationsGroup.find((group) => group.id.toString() === selectedItemId),
|
||||
[applicationsGroup, selectedItemId]
|
||||
)
|
||||
|
||||
if (isErrorApplicationsGroup) {
|
||||
return <EmptyData />
|
||||
@@ -107,22 +106,31 @@ const ApplicationsPage = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const handleAddApplicationGroup = (data: any) => {
|
||||
const handleAddApplicationGroup = (data: ApplicationsGroupType) => {
|
||||
const newService: NewApplicationsGroupType = {
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
domainId: 2
|
||||
}
|
||||
createApplicationsGroup(newService)
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: false
|
||||
})
|
||||
reset()
|
||||
message.info('Сервис успешно создан')
|
||||
.unwrap()
|
||||
.then((res) => {
|
||||
setSelectedItemId(
|
||||
`${routePaths.applicationsGroup}`,
|
||||
res.id.toString(),
|
||||
searchValue,
|
||||
navigate
|
||||
)
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: false
|
||||
})
|
||||
message.success('Группа приложений успешно создана')
|
||||
})
|
||||
.catch(() => message.error('Не удалось создать группу приложений'))
|
||||
}
|
||||
|
||||
const handleUpdateApplicationsGroup = (data: NewApplicationsGroupType) => {
|
||||
const handleUpdateApplicationsGroup = (data: ApplicationsGroupType) => {
|
||||
const updateService: UpdateApplicationsGroupType = {
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
@@ -130,21 +138,20 @@ const ApplicationsPage = () => {
|
||||
id: Number(selectedItemId)
|
||||
}
|
||||
|
||||
updateApplicationsGroup(updateService)
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: false
|
||||
})
|
||||
|
||||
reset()
|
||||
message.info('Сервис успешно отредактирован')
|
||||
updateApplicationsGroup(updateService).unwrap().then(()=>{
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: false
|
||||
})
|
||||
message.success('Группа приложений успешно отредактирована')
|
||||
}).catch(()=> message.error('Не удалось отредактировать группу приложений'))
|
||||
}
|
||||
|
||||
const handleRemoveApplicationsGtoup = () => {
|
||||
deleteApplicationsGroup([Number(selectedItemId)])
|
||||
.unwrap()
|
||||
.then(() => message.success('Элемент удален'))
|
||||
.catch(() => message.info('Ошибка удаления элемента'))
|
||||
.catch(() => message.error('Ошибка удаления элемента'))
|
||||
}
|
||||
|
||||
const renderMainContent = () => {
|
||||
@@ -188,52 +195,29 @@ const ApplicationsPage = () => {
|
||||
onChangeSearchValue={(value) => setSearchValue(value, setSearchParams)}
|
||||
/>
|
||||
{renderMainContent()}
|
||||
|
||||
<Modal
|
||||
onOk={handleSubmit(handleAddApplicationGroup)}
|
||||
title="Добавить"
|
||||
<AppGroupModal
|
||||
onOk={handleAddApplicationGroup}
|
||||
title="Добавить группу приложений"
|
||||
open={showApplicationsModal.addModal}
|
||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
||||
onClose={() =>
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: false
|
||||
})
|
||||
}
|
||||
>
|
||||
<form>
|
||||
<FormInput
|
||||
control={control}
|
||||
name="name"
|
||||
label="Наименование"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<FormInput control={control} label="Описание" name="description" />
|
||||
</form>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
onOk={handleSubmit(handleUpdateApplicationsGroup)}
|
||||
title="Редактировать"
|
||||
/>
|
||||
<AppGroupModal
|
||||
appGroup={currentAppGroup}
|
||||
title="Редактировать группу приложений"
|
||||
onOk={handleUpdateApplicationsGroup}
|
||||
open={showApplicationsModal.updateModal}
|
||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
||||
onClose={() =>
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: false
|
||||
})
|
||||
}
|
||||
>
|
||||
<form>
|
||||
<FormInput
|
||||
control={control}
|
||||
name="name"
|
||||
label="Наименование"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<FormInput control={control} label="Описание" name="description" />
|
||||
</form>
|
||||
</Modal>
|
||||
/>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { injectStyles } from '@stoplight/mosaic'
|
||||
import { Button, Spin } from 'antd'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { Outlet, useNavigate, useParams } from 'react-router-dom'
|
||||
@@ -72,7 +71,7 @@ const Configurations = () => {
|
||||
if (configId) {
|
||||
return <Outlet />
|
||||
}
|
||||
injectStyles()
|
||||
|
||||
return (
|
||||
<section className="configurations">
|
||||
<ConfigurationPreviewModal
|
||||
@@ -95,6 +94,7 @@ const Configurations = () => {
|
||||
)}
|
||||
<div className="configurations__buttons">
|
||||
<Button
|
||||
disabled={!currentModule?.configSchema}
|
||||
className="configurations____buttons__show-schema-btn"
|
||||
onClick={() => setIsModalOpen(true)}
|
||||
>
|
||||
|
||||
@@ -16,6 +16,7 @@ import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
import './connections.scss'
|
||||
import dayjs from 'dayjs'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
const Connections = () => {
|
||||
const { data: ConnectionsList = [], isLoading: isModulesLoading } =
|
||||
@@ -51,7 +52,7 @@ const Connections = () => {
|
||||
}
|
||||
|
||||
const formatFullDate = (obj: string) =>
|
||||
dayjs(obj).format('YYYY-MM-DD, HH:mm:ss')
|
||||
dayjs(obj).format(dateFormats.fullFormat)
|
||||
|
||||
const keySelector = ({
|
||||
address: { ip, port },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Button, Descriptions } from 'antd'
|
||||
import { Button, Descriptions, Popconfirm } from 'antd'
|
||||
import { useState } from 'react'
|
||||
|
||||
import PermissionList from '@widgets/PermissionList'
|
||||
@@ -18,7 +18,7 @@ const ProfilePage = () => {
|
||||
const { logoutUser, isLoading } = useLogout()
|
||||
|
||||
return (
|
||||
<section className="profile-page wrap">
|
||||
<section className="profile-page">
|
||||
<ChangePasswordModal
|
||||
onClose={() => setIsModalOpen(false)}
|
||||
open={isModalOpen}
|
||||
@@ -34,18 +34,22 @@ const ProfilePage = () => {
|
||||
<RoleList userRoles={profile.roles} />
|
||||
<PermissionList permissions={profile.permissions} />
|
||||
<div className="profile-page__actions">
|
||||
<Button
|
||||
loading={isLoading}
|
||||
disabled={isLoading}
|
||||
className="profile-page__actions__exit-btn"
|
||||
type="primary"
|
||||
onClick={logoutUser}
|
||||
<Popconfirm
|
||||
okText="Выйти"
|
||||
cancelText="Отмена"
|
||||
title="Вы действительно хотите выйти из профиля?"
|
||||
onConfirm={logoutUser}
|
||||
>
|
||||
Выход
|
||||
</Button>
|
||||
<Button
|
||||
loading={isLoading}
|
||||
disabled={isLoading}
|
||||
className="profile-page__actions__exit-btn"
|
||||
>
|
||||
Выход
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
<Button
|
||||
className="profile-page__actions__change-pass-btn"
|
||||
type="primary"
|
||||
onClick={() => setIsModalOpen(true)}
|
||||
>
|
||||
Сменить пароль
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
@import '../../constants/style/styleConst';
|
||||
|
||||
.profile-page {
|
||||
height: 100%;
|
||||
height: 100vh;
|
||||
overflow: auto;
|
||||
border: 1px solid #F0F0F0;
|
||||
padding: $basic-padding * 2;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -16,6 +16,8 @@ import { LogType } from '@type/log.type'
|
||||
import { PermissionKeysType } from '@type/roles.type'
|
||||
|
||||
import './security-log-page.scss'
|
||||
import dayjs from 'dayjs'
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
const limit = 10
|
||||
|
||||
@@ -75,8 +77,7 @@ const SecurityLogPage = () => {
|
||||
dataIndex: 'createdAt',
|
||||
key: 'createdAt',
|
||||
render: (value) => {
|
||||
const date = new Date(value)
|
||||
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -29,6 +29,8 @@ import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
import { SessionType } from '@type/session.type'
|
||||
|
||||
import './sessions-page.scss'
|
||||
import dayjs from 'dayjs'
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
const limit = 10
|
||||
|
||||
@@ -69,7 +71,7 @@ const SessionsPage = () => {
|
||||
revokeSession(id)
|
||||
.unwrap()
|
||||
.then(() => message.success('Сессия успешно завершена'))
|
||||
.catch(() => message.info('Не удалось завершить сессию'))
|
||||
.catch(() => message.error('Не удалось завершить сессию'))
|
||||
}
|
||||
|
||||
if (isLoading || !data) {
|
||||
@@ -96,8 +98,7 @@ const SessionsPage = () => {
|
||||
dataIndex: 'createdAt',
|
||||
key: 'createdAt',
|
||||
render: (value) => {
|
||||
const date = new Date(value)
|
||||
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -105,8 +106,7 @@ const SessionsPage = () => {
|
||||
dataIndex: 'expiredAt',
|
||||
key: 'expiredAt',
|
||||
render: (value) => {
|
||||
const date = new Date(value)
|
||||
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { ArrowLeftOutlined, SaveOutlined } from '@ant-design/icons'
|
||||
import { Button, message, Spin } from 'antd'
|
||||
import dayjs from 'dayjs'
|
||||
import { FormComponents } from 'isp-ui-kit'
|
||||
import { useEffect } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||
|
||||
import { findExclusiveRole } from '@utils/roleUtils.ts'
|
||||
@@ -23,6 +25,7 @@ import { LabelItem } from 'isp-ui-kit/dist/FormComponents/formTypes'
|
||||
|
||||
import './user-editor.scss'
|
||||
|
||||
|
||||
const UserEditor = () => {
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
@@ -75,7 +78,7 @@ const UserEditor = () => {
|
||||
const exclusiveRole = findExclusiveRole(roles, value.roles as number[])
|
||||
if (exclusiveRole) {
|
||||
if (value.roles && value.roles.length > 1) {
|
||||
message.info(
|
||||
message.error(
|
||||
<>
|
||||
Роль: <strong>{exclusiveRole.name}</strong> несовместима с
|
||||
другими ролями
|
||||
@@ -166,9 +169,7 @@ const UserEditor = () => {
|
||||
{state.lastSessionCreatedAt && (
|
||||
<>
|
||||
Последняя сессия
|
||||
{new Date(state.lastSessionCreatedAt).toLocaleDateString()}
|
||||
|
||||
{new Date(state.lastSessionCreatedAt).toLocaleTimeString()}
|
||||
{dayjs(state.lastSessionCreatedAt).format(dateFormats.fullFormat)}
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
|
||||
@@ -25,6 +25,8 @@ import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
import { UserType } from '@type/user.type.ts'
|
||||
|
||||
import './users-page.scss'
|
||||
import dayjs from 'dayjs'
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
const UsersPage = () => {
|
||||
const { data: allUsers = [], isLoading: isUsersLoading } =
|
||||
@@ -124,7 +126,7 @@ const UsersPage = () => {
|
||||
dataIndex: 'lastSessionCreatedAt',
|
||||
key: 'lastSessionCreatedAt',
|
||||
render: (value: string) =>
|
||||
value ? new Date(value).toLocaleDateString() : ''
|
||||
value ? dayjs(value).format(dateFormats.fullFormat) : ''
|
||||
},
|
||||
{
|
||||
dataIndex: 'actions',
|
||||
|
||||
@@ -17,7 +17,7 @@ const applicationsGroupApi = createApi({
|
||||
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }),
|
||||
endpoints: (builder) => ({
|
||||
getApplicationsGroupByDomainId: builder.query<
|
||||
ApplicationsGroupType,
|
||||
ApplicationsGroupType[],
|
||||
{ id: number }
|
||||
>({
|
||||
query: (id) => ({
|
||||
|
||||
Vendored
+1
-1
@@ -1,3 +1,3 @@
|
||||
/// <reference types="vite/client" />
|
||||
declare const APP_VERSION: string
|
||||
declare module '@stoplight/json-schema-viewer'
|
||||
declare module 'json-schema-view-js'
|
||||
@@ -0,0 +1,53 @@
|
||||
import RefParser from '@apidevtools/json-schema-ref-parser'
|
||||
import JSONSchemaView from 'json-schema-view-js'
|
||||
import cloneDeep from 'lodash.clonedeep'
|
||||
import React, { useEffect, useRef } from 'react'
|
||||
|
||||
import 'json-schema-view-js/dist/style.min.css'
|
||||
|
||||
interface JsonSchemaViewerProps {
|
||||
schema: object
|
||||
}
|
||||
|
||||
const JsonSchemaViewer: React.FC<JsonSchemaViewerProps> = ({ schema }) => {
|
||||
const myRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const schemas = cloneDeep(schema)
|
||||
let isMounted = true
|
||||
|
||||
RefParser.dereference(
|
||||
schemas,
|
||||
{
|
||||
dereference: {
|
||||
circular: true
|
||||
}
|
||||
},
|
||||
(err: any, dereferencedSchema: any) => {
|
||||
if (isMounted) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
} else {
|
||||
const view = new JSONSchemaView(dereferencedSchema, 3)
|
||||
if (myRef.current) {
|
||||
myRef.current.appendChild(view.render())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return () => {
|
||||
isMounted = false
|
||||
if (myRef.current) {
|
||||
while (myRef.current.firstChild) {
|
||||
myRef.current.removeChild(myRef.current.firstChild)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [schema])
|
||||
|
||||
return <div ref={myRef} />
|
||||
}
|
||||
|
||||
export default JsonSchemaViewer
|
||||
+4
-15
@@ -1,6 +1,6 @@
|
||||
import legacy from '@vitejs/plugin-legacy'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
||||
import svgr from 'vite-plugin-svgr'
|
||||
|
||||
import tsconfigPaths from 'vite-tsconfig-paths'
|
||||
@@ -16,22 +16,11 @@ export default defineConfig(({ mode }) => {
|
||||
APP_VERSION: JSON.stringify(process.env.npm_package_version)
|
||||
},
|
||||
build: {
|
||||
sourcemap:true,
|
||||
minify: 'terser',
|
||||
outDir: 'build',
|
||||
chunkSizeWarningLimit: 1600,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
if (id.includes('node_modules')) {
|
||||
return id
|
||||
.toString()
|
||||
.split('node_modules/')[1]
|
||||
.split('/')[0]
|
||||
.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
commonjsOptions: { transformMixedEsModules: true },
|
||||
},
|
||||
server: {
|
||||
watch: {
|
||||
@@ -44,6 +33,6 @@ export default defineConfig(({ mode }) => {
|
||||
'/api': env.PROXY_URL
|
||||
}
|
||||
},
|
||||
plugins: [react(), svgr(), legacy(), tsconfigPaths()]
|
||||
plugins: [react(), svgr(), tsconfigPaths(), nodePolyfills()]
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user