Complete main UI #37
@@ -2,13 +2,13 @@ import { PropsWithChildren } from 'react'
|
||||
import { hasPathPermission, hasPermission } from '@/util/auth'
|
||||
|
||||
interface PermissionProps extends PropsWithChildren {
|
||||
operationCode?: string
|
||||
operationCode?: string[]
|
||||
path?: string
|
||||
}
|
||||
|
||||
const Permission = (props: PermissionProps) => {
|
||||
if (
|
||||
(!props.operationCode || hasPermission(props.operationCode)) &&
|
||||
(!props.operationCode || props.operationCode.some(hasPermission)) &&
|
||||
(!props.path || hasPathPermission(props.path))
|
||||
) {
|
||||
return props.children
|
||||
|
||||
@@ -106,7 +106,7 @@ const Group = () => {
|
||||
render: (value, record) => (
|
||||
<>
|
||||
<AntdSpace size={'middle'}>
|
||||
<Permission operationCode={'system:group:modify:status'}>
|
||||
<Permission operationCode={['system:group:modify:status']}>
|
||||
{value ? (
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
@@ -123,7 +123,7 @@ const Group = () => {
|
||||
</a>
|
||||
)}
|
||||
</Permission>
|
||||
<Permission operationCode={'system:group:modify:one'}>
|
||||
<Permission operationCode={['system:group:modify:one']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnEditBtnClick(record)}
|
||||
@@ -131,7 +131,7 @@ const Group = () => {
|
||||
编辑
|
||||
</a>
|
||||
</Permission>
|
||||
<Permission operationCode={'system:group:delete:one'}>
|
||||
<Permission operationCode={['system:group:delete:one']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnDeleteBtnClick(record)}
|
||||
@@ -495,7 +495,7 @@ const Group = () => {
|
||||
|
||||
const toolbar = (
|
||||
<FlexBox direction={'horizontal'} gap={10}>
|
||||
<Permission operationCode={'system:group:add:one'}>
|
||||
<Permission operationCode={['system:group:add:one']}>
|
||||
<Card style={{ overflow: 'inherit', flex: '0 0 auto' }}>
|
||||
<AntdButton
|
||||
type={'primary'}
|
||||
|
||||
@@ -98,7 +98,7 @@ const Role = () => {
|
||||
render: (value, record) => (
|
||||
<>
|
||||
<AntdSpace size={'middle'}>
|
||||
<Permission operationCode={'system:role:modify:status'}>
|
||||
<Permission operationCode={['system:role:modify:status']}>
|
||||
{value ? (
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
@@ -115,7 +115,7 @@ const Role = () => {
|
||||
</a>
|
||||
)}
|
||||
</Permission>
|
||||
<Permission operationCode={'system:role:modify:one'}>
|
||||
<Permission operationCode={['system:role:modify:one']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnEditBtnClick(record)}
|
||||
@@ -123,7 +123,7 @@ const Role = () => {
|
||||
编辑
|
||||
</a>
|
||||
</Permission>
|
||||
<Permission operationCode={'system:role:delete:one'}>
|
||||
<Permission operationCode={['system:role:delete:one']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnDeleteBtnClick(record)}
|
||||
@@ -504,7 +504,7 @@ const Role = () => {
|
||||
|
||||
const toolbar = (
|
||||
<FlexBox direction={'horizontal'} gap={10}>
|
||||
<Permission operationCode={'system:role:add:one'}>
|
||||
<Permission operationCode={['system:role:add:one']}>
|
||||
<Card style={{ overflow: 'inherit', flex: '0 0 auto' }}>
|
||||
<AntdButton
|
||||
type={'primary'}
|
||||
|
||||
@@ -51,7 +51,7 @@ const Base = () => {
|
||||
loading={loading}
|
||||
onReset={handleOnReset}
|
||||
onSave={handleOnSave}
|
||||
modifyOperationCode={'system:settings:modify:base'}
|
||||
modifyOperationCode={['system:settings:modify:base']}
|
||||
>
|
||||
<AntdForm
|
||||
form={baseForm}
|
||||
|
||||
@@ -106,7 +106,7 @@ const Mail = () => {
|
||||
loading={loading}
|
||||
onReset={handleOnReset}
|
||||
onSave={handleOnSave}
|
||||
modifyOperationCode={'system:settings:modify:mail'}
|
||||
modifyOperationCode={['system:settings:modify:mail']}
|
||||
expand={
|
||||
<AntdButton onClick={handleOnTest} title={'测试'}>
|
||||
<Icon component={IconOxygenTest} />
|
||||
|
||||
@@ -106,7 +106,7 @@ const SensitiveWord = () => {
|
||||
loading={loading}
|
||||
onReset={handleOnReset}
|
||||
onSave={handleOnSave}
|
||||
modifyOperationCode={'system:settings:modify:sensitive'}
|
||||
modifyOperationCode={['system:settings:modify:sensitive']}
|
||||
>
|
||||
<AntdTransfer
|
||||
listStyle={{ width: '100%', height: 400 }}
|
||||
|
||||
@@ -15,7 +15,7 @@ interface SettingsCardProps extends PropsWithChildren {
|
||||
icon: IconComponent
|
||||
title: string
|
||||
loading?: boolean
|
||||
modifyOperationCode?: string
|
||||
modifyOperationCode?: string[]
|
||||
expand?: ReactNode
|
||||
onReset?: () => void
|
||||
onSave?: () => void
|
||||
@@ -57,15 +57,15 @@ const Settings = () => {
|
||||
<HideScrollbar isShowVerticalScrollbar autoHideWaitingTime={1000}>
|
||||
<FlexBox direction={'horizontal'} className={'root-content'}>
|
||||
<FlexBox className={'root-col'}>
|
||||
<Permission operationCode={'system:settings:query:base'}>
|
||||
<Permission operationCode={['system:settings:query:base']}>
|
||||
<Base />
|
||||
</Permission>
|
||||
<Permission operationCode={'system:settings:query:sensitive'}>
|
||||
<Permission operationCode={['system:settings:query:sensitive']}>
|
||||
<SensitiveWord />
|
||||
</Permission>
|
||||
</FlexBox>
|
||||
<FlexBox className={'root-col'}>
|
||||
<Permission operationCode={'system:settings:query:mail'}>
|
||||
<Permission operationCode={['system:settings:query:mail']}>
|
||||
<Mail />
|
||||
</Permission>
|
||||
</FlexBox>
|
||||
|
||||
@@ -47,15 +47,15 @@ const Statistics = () => {
|
||||
<FitFullscreen data-component={'system-statistics'}>
|
||||
<HideScrollbar isShowVerticalScrollbar autoHideWaitingTime={1000}>
|
||||
<FlexBox direction={'horizontal'} className={'root-content'}>
|
||||
<Permission operationCode={'system:statistics:query:usage'}>
|
||||
<Permission operationCode={['system:statistics:query:usage']}>
|
||||
<OnlineInfo />
|
||||
<ActiveInfo />
|
||||
</Permission>
|
||||
<Permission operationCode={'system:statistics:query:base'}>
|
||||
<Permission operationCode={['system:statistics:query:base']}>
|
||||
<HardwareInfo />
|
||||
<SoftwareInfo />
|
||||
</Permission>
|
||||
<Permission operationCode={'system:statistics:query:real'}>
|
||||
<Permission operationCode={['system:statistics:query:real']}>
|
||||
<CPUInfo />
|
||||
<StorageInfo />
|
||||
</Permission>
|
||||
|
||||
@@ -8,7 +8,8 @@ import {
|
||||
DATABASE_SELECT_SUCCESS,
|
||||
DATABASE_UPDATE_SUCCESS
|
||||
} from '@/constants/common.constants'
|
||||
import { utcToLocalTime } from '@/util/datetime.tsx'
|
||||
import { utcToLocalTime } from '@/util/datetime'
|
||||
import { hasPermission } from '@/util/auth'
|
||||
import {
|
||||
r_sys_tool_base_add,
|
||||
r_sys_tool_base_delete,
|
||||
@@ -125,14 +126,14 @@ const Base = () => {
|
||||
<>
|
||||
操作
|
||||
{!Object.keys(hasEdited).length && (
|
||||
<>
|
||||
<Permission operationCode={['system:tool:add:base']}>
|
||||
{' '}
|
||||
(
|
||||
<a style={{ color: COLOR_PRODUCTION }} onClick={handleOnAddBtnClick}>
|
||||
新增
|
||||
</a>
|
||||
)
|
||||
</>
|
||||
</Permission>
|
||||
)}
|
||||
</>
|
||||
),
|
||||
@@ -142,15 +143,17 @@ const Base = () => {
|
||||
<>
|
||||
<AntdSpace size={'middle'}>
|
||||
{!record.compiled && !Object.keys(hasEdited).length && (
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnCompileBtnClick(record)}
|
||||
>
|
||||
编译
|
||||
</a>
|
||||
<Permission operationCode={['system:tool:modify:base']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnCompileBtnClick(record)}
|
||||
>
|
||||
编译
|
||||
</a>
|
||||
</Permission>
|
||||
)}
|
||||
{hasEdited[record.id] && (
|
||||
<Permission operationCode={'system:tool:modify:base'}>
|
||||
<Permission operationCode={['system:tool:modify:base']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnSaveBtnClick(record)}
|
||||
@@ -160,7 +163,7 @@ const Base = () => {
|
||||
</Permission>
|
||||
)}
|
||||
{!Object.keys(hasEdited).length && (
|
||||
<Permission operationCode={'system:tool:modify:base'}>
|
||||
<Permission operationCode={['system:tool:modify:base']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnEditBtnClick(record)}
|
||||
@@ -169,7 +172,7 @@ const Base = () => {
|
||||
</a>
|
||||
</Permission>
|
||||
)}
|
||||
<Permission operationCode={'system:tool:delete:base'}>
|
||||
<Permission operationCode={['system:tool:delete:base']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnDeleteBtnClick(record)}
|
||||
@@ -652,14 +655,14 @@ const Base = () => {
|
||||
<>
|
||||
操作
|
||||
{!Object.keys(hasEdited).length && (
|
||||
<>
|
||||
<Permission operationCode={['system:tool:modify:base']}>
|
||||
{' '}
|
||||
(
|
||||
<a style={{ color: COLOR_PRODUCTION }} onClick={handleOnAddFile}>
|
||||
新增
|
||||
</a>
|
||||
)
|
||||
</>
|
||||
</Permission>
|
||||
)}
|
||||
</>
|
||||
),
|
||||
@@ -669,16 +672,21 @@ const Base = () => {
|
||||
render: (_, record) => (
|
||||
<>
|
||||
<AntdSpace size={'middle'}>
|
||||
<Permission operationCode={'system:tool:modify:category'}>
|
||||
<Permission
|
||||
operationCode={[
|
||||
'system:tool:query:base',
|
||||
'system:tool:modify:base'
|
||||
]}
|
||||
>
|
||||
<a
|
||||
onClick={handleOnEditFile(record.name)}
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
>
|
||||
编辑
|
||||
{hasPermission('system:tool:modify:base') ? '编辑' : '查看'}
|
||||
</a>
|
||||
</Permission>
|
||||
{!Object.keys(hasEdited).length && (
|
||||
<Permission operationCode={'system:tool:modify:category'}>
|
||||
<Permission operationCode={['system:tool:modify:base']}>
|
||||
<a
|
||||
onClick={handleOnRenameFile(record.name)}
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
@@ -688,7 +696,7 @@ const Base = () => {
|
||||
</Permission>
|
||||
)}
|
||||
{!Object.keys(hasEdited).length && (
|
||||
<Permission operationCode={'system:tool:delete:category'}>
|
||||
<Permission operationCode={['system:tool:delete:base']}>
|
||||
<a
|
||||
onClick={handleOnDeleteFile(record.name)}
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
@@ -880,6 +888,9 @@ const Base = () => {
|
||||
}
|
||||
|
||||
const handleOnChangeFileContent = (_content: string, _fileName: string, files: IFiles) => {
|
||||
if (!hasPermission('system:tool:modify:base')) {
|
||||
return
|
||||
}
|
||||
setEditingFiles({ ...editingFiles, [editingBaseId]: files })
|
||||
if (!hasEdited[editingBaseId]) {
|
||||
setHasEdited({ ...hasEdited, [editingBaseId]: true })
|
||||
@@ -978,7 +989,11 @@ const Base = () => {
|
||||
onChangeFileContent={handleOnChangeFileContent}
|
||||
showFileSelector={false}
|
||||
tsconfig={tsconfig}
|
||||
readonly={isLoading || baseDetailLoading[editingBaseId]}
|
||||
readonly={
|
||||
isLoading ||
|
||||
baseDetailLoading[editingBaseId] ||
|
||||
!hasPermission('system:tool:modify:base')
|
||||
}
|
||||
/>
|
||||
<div className={'close-editor-btn'} onClick={handleOnCloseBtnClick}>
|
||||
<Icon component={IconOxygenClose} />
|
||||
|
||||
@@ -73,11 +73,15 @@ const Category = () => {
|
||||
{
|
||||
title: (
|
||||
<>
|
||||
操作 (
|
||||
<a style={{ color: COLOR_PRODUCTION }} onClick={handleOnAddBtnClick}>
|
||||
新增
|
||||
</a>
|
||||
)
|
||||
操作
|
||||
<Permission operationCode={['system:tool:add:category']}>
|
||||
{' '}
|
||||
(
|
||||
<a style={{ color: COLOR_PRODUCTION }} onClick={handleOnAddBtnClick}>
|
||||
新增
|
||||
</a>
|
||||
)
|
||||
</Permission>
|
||||
</>
|
||||
),
|
||||
dataIndex: 'enable',
|
||||
@@ -86,7 +90,7 @@ const Category = () => {
|
||||
render: (_, record) => (
|
||||
<>
|
||||
<AntdSpace size={'middle'}>
|
||||
<Permission operationCode={'system:tool:modify:category'}>
|
||||
<Permission operationCode={['system:tool:modify:category']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnEditBtnClick(record)}
|
||||
@@ -94,7 +98,7 @@ const Category = () => {
|
||||
编辑
|
||||
</a>
|
||||
</Permission>
|
||||
<Permission operationCode={'system:tool:delete:category'}>
|
||||
<Permission operationCode={['system:tool:delete:category']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnDeleteBtnClick(record)}
|
||||
|
||||
@@ -8,7 +8,8 @@ import {
|
||||
DATABASE_SELECT_SUCCESS,
|
||||
DATABASE_UPDATE_SUCCESS
|
||||
} from '@/constants/common.constants'
|
||||
import { utcToLocalTime } from '@/util/datetime.tsx'
|
||||
import { utcToLocalTime } from '@/util/datetime'
|
||||
import { hasPermission } from '@/util/auth'
|
||||
import {
|
||||
r_sys_tool_template_update,
|
||||
r_sys_tool_template_delete,
|
||||
@@ -31,7 +32,6 @@ import HideScrollbar from '@/components/common/HideScrollbar'
|
||||
import Card from '@/components/common/Card'
|
||||
import CodeEditor from '@/components/Playground/CodeEditor'
|
||||
import Permission from '@/components/common/Permission'
|
||||
import { useState } from 'react'
|
||||
|
||||
const Template = () => {
|
||||
const blocker = useBlocker(
|
||||
@@ -125,14 +125,14 @@ const Template = () => {
|
||||
<>
|
||||
操作
|
||||
{!Object.keys(hasEdited).length && (
|
||||
<>
|
||||
<Permission operationCode={['system:tool:add:template']}>
|
||||
{' '}
|
||||
(
|
||||
<a style={{ color: COLOR_PRODUCTION }} onClick={handleOnAddBtnClick}>
|
||||
新增
|
||||
</a>
|
||||
)
|
||||
</>
|
||||
</Permission>
|
||||
)}
|
||||
</>
|
||||
),
|
||||
@@ -142,7 +142,7 @@ const Template = () => {
|
||||
<>
|
||||
<AntdSpace size={'middle'}>
|
||||
{hasEdited[record.id] && (
|
||||
<Permission operationCode={'system:tool:modify:base'}>
|
||||
<Permission operationCode={['system:tool:modify:template']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnSaveBtnClick(record)}
|
||||
@@ -152,7 +152,7 @@ const Template = () => {
|
||||
</Permission>
|
||||
)}
|
||||
{!Object.keys(hasEdited).length && (
|
||||
<Permission operationCode={'system:tool:modify:base'}>
|
||||
<Permission operationCode={['system:tool:modify:template']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnEditBtnClick(record)}
|
||||
@@ -161,7 +161,7 @@ const Template = () => {
|
||||
</a>
|
||||
</Permission>
|
||||
)}
|
||||
<Permission operationCode={'system:tool:delete:base'}>
|
||||
<Permission operationCode={['system:tool:delete:template']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnDeleteBtnClick(record)}
|
||||
@@ -498,14 +498,14 @@ const Template = () => {
|
||||
<>
|
||||
操作
|
||||
{!Object.keys(hasEdited).length && (
|
||||
<>
|
||||
<Permission operationCode={['system:tool:modify:template']}>
|
||||
{' '}
|
||||
(
|
||||
<a style={{ color: COLOR_PRODUCTION }} onClick={handleOnAddFile}>
|
||||
新增
|
||||
</a>
|
||||
)
|
||||
</>
|
||||
</Permission>
|
||||
)}
|
||||
</>
|
||||
),
|
||||
@@ -515,16 +515,21 @@ const Template = () => {
|
||||
render: (_, record) => (
|
||||
<>
|
||||
<AntdSpace size={'middle'}>
|
||||
<Permission operationCode={'system:tool:modify:category'}>
|
||||
<Permission
|
||||
operationCode={[
|
||||
'system:tool:query:template',
|
||||
'system:tool:modify:template'
|
||||
]}
|
||||
>
|
||||
<a
|
||||
onClick={handleOnEditFile(record.name)}
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
>
|
||||
编辑
|
||||
{hasPermission('system:tool:modify:template') ? '编辑' : '查看'}
|
||||
</a>
|
||||
</Permission>
|
||||
{!Object.keys(hasEdited).length && (
|
||||
<Permission operationCode={'system:tool:modify:category'}>
|
||||
<Permission operationCode={['system:tool:modify:template']}>
|
||||
<a
|
||||
onClick={handleOnRenameFile(record.name)}
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
@@ -534,7 +539,7 @@ const Template = () => {
|
||||
</Permission>
|
||||
)}
|
||||
{!Object.keys(hasEdited).length && (
|
||||
<Permission operationCode={'system:tool:delete:category'}>
|
||||
<Permission operationCode={['system:tool:delete:template']}>
|
||||
<a
|
||||
onClick={handleOnDeleteFile(record.name)}
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
@@ -729,6 +734,9 @@ const Template = () => {
|
||||
}
|
||||
|
||||
const handleOnChangeFileContent = (_content: string, _fileName: string, files: IFiles) => {
|
||||
if (!hasPermission('system:tool:modify:template')) {
|
||||
return
|
||||
}
|
||||
setEditingFiles({ ...editingFiles, [editingTemplateId]: files })
|
||||
if (!hasEdited[editingTemplateId]) {
|
||||
setHasEdited({ ...hasEdited, [editingTemplateId]: true })
|
||||
@@ -865,7 +873,11 @@ const Template = () => {
|
||||
onChangeFileContent={handleOnChangeFileContent}
|
||||
showFileSelector={false}
|
||||
tsconfig={tsconfig}
|
||||
readonly={isLoading || templateDetailLoading[editingTemplateId]}
|
||||
readonly={
|
||||
isLoading ||
|
||||
templateDetailLoading[editingTemplateId] ||
|
||||
!hasPermission('system:tool:modify:template')
|
||||
}
|
||||
/>
|
||||
<div className={'close-editor-btn'} onClick={handleOnCloseBtnClick}>
|
||||
<Icon component={IconOxygenClose} />
|
||||
|
||||
@@ -195,7 +195,7 @@ const User = () => {
|
||||
render: (_, record) => (
|
||||
<>
|
||||
<AntdSpace size={'middle'}>
|
||||
<Permission operationCode={'system:user:modify:password'}>
|
||||
<Permission operationCode={['system:user:modify:password']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnChangePasswordBtnClick(record)}
|
||||
@@ -203,7 +203,7 @@ const User = () => {
|
||||
修改密码
|
||||
</a>
|
||||
</Permission>
|
||||
<Permission operationCode={'system:user:modify:one'}>
|
||||
<Permission operationCode={['system:user:modify:one']}>
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
onClick={handleOnEditBtnClick(record)}
|
||||
@@ -211,7 +211,7 @@ const User = () => {
|
||||
编辑
|
||||
</a>
|
||||
</Permission>
|
||||
<Permission operationCode={'system:user:delete:one'}>
|
||||
<Permission operationCode={['system:user:delete:one']}>
|
||||
{record.id !== '0' && (
|
||||
<a
|
||||
style={{ color: COLOR_PRODUCTION }}
|
||||
@@ -888,7 +888,7 @@ const User = () => {
|
||||
|
||||
const toolbar = (
|
||||
<FlexBox direction={'horizontal'} gap={10}>
|
||||
<Permission operationCode={'system:user:add:one'}>
|
||||
<Permission operationCode={['system:user:add:one']}>
|
||||
<Card style={{ overflow: 'inherit', flex: '0 0 auto' }}>
|
||||
<AntdButton
|
||||
type={'primary'}
|
||||
|
||||
Reference in New Issue
Block a user