MSP-3106 refactor applications page
This commit is contained in:
1 parent
aa6853211b
commit
67ee8aec3a
16 files changed
+1068
-527
No files matched your search
@@ -1,7 +1,10 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.applications-page {
|
||||
height: 100%;
|
||||
height: 100vh;
|
||||
.column-content {
|
||||
max-height: 100vh;
|
||||
}
|
||||
.three-columns {
|
||||
display: flex;
|
||||
background: #fff;
|
||||
|
||||
@@ -1,39 +1,57 @@
|
||||
export interface ApplicationsGroupType {
|
||||
createdAt: string,
|
||||
description: string,
|
||||
domainId: number,
|
||||
id: number,
|
||||
name: string,
|
||||
updatedAt: string
|
||||
createdAt: string
|
||||
description: string
|
||||
domainId: number
|
||||
id: number
|
||||
name: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export type NewApplicationsGroupType = Omit<ApplicationsGroupType, 'id' | 'createdAt' | 'updatedAt'>
|
||||
export type UpdateApplicationsGroupType = Omit<ApplicationsGroupType, 'createdAt' | 'updatedAt'>
|
||||
export type NewApplicationsGroupType = Omit<
|
||||
ApplicationsGroupType,
|
||||
'id' | 'createdAt' | 'updatedAt'
|
||||
>
|
||||
export type UpdateApplicationsGroupType = Omit<
|
||||
ApplicationsGroupType,
|
||||
'createdAt' | 'updatedAt'
|
||||
>
|
||||
|
||||
export interface ApplicationsServiceType {
|
||||
app:ApplicationAppType
|
||||
tokens: ApplicationTokenType[]
|
||||
app: ApplicationAppType
|
||||
tokens: ApplicationTokenType[]
|
||||
}
|
||||
|
||||
export type NewApplicationTokenType = Omit<ApplicationTokenType, 'createdAt' | 'token'>
|
||||
export interface ApplicationAppType {
|
||||
createdAt: string,
|
||||
description: string,
|
||||
id: number,
|
||||
name: string,
|
||||
serviceId: number,
|
||||
type: string,
|
||||
updatedAt: string
|
||||
export type NewApplicationTokenType = {
|
||||
appId: number
|
||||
expireTimeMs: number
|
||||
}
|
||||
|
||||
export interface ApplicationAppType {
|
||||
createdAt: string
|
||||
description: string
|
||||
id: number
|
||||
name: string
|
||||
serviceId: number
|
||||
type: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export type UpdateApplicationAppType = Omit<ApplicationAppType, 'createdAt' | 'updatedAt'>
|
||||
export type NewApplicationAppType = Omit<ApplicationAppType, 'id' | 'createdAt' | 'updatedAt'>
|
||||
export type UpdateApplicationAppType = Omit<
|
||||
ApplicationAppType,
|
||||
'createdAt' | 'updatedAt'
|
||||
>
|
||||
export type NewApplicationAppType = Omit<
|
||||
ApplicationAppType,
|
||||
'id' | 'createdAt' | 'updatedAt'
|
||||
>
|
||||
export type RevokeTokenType = {
|
||||
appId: number
|
||||
tokens: string[]
|
||||
}
|
||||
|
||||
export interface ApplicationTokenType {
|
||||
appId: number,
|
||||
createdAt: string,
|
||||
expireTimeMs: number,
|
||||
token: string
|
||||
appId: number
|
||||
createdAt: string
|
||||
expireTime: number
|
||||
token: string
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ const ApplicationsPage = () => {
|
||||
const { id: selectedItemId = '' } = useParams()
|
||||
const [searchParams, setSearchParams] = useSearchParams('')
|
||||
const { hasPermission } = useRole()
|
||||
const [currentApplicationsApp, setCurrentApplicationsApp] = useState(0)
|
||||
|
||||
const {
|
||||
data: applicationsGroup = [],
|
||||
@@ -55,6 +56,7 @@ const ApplicationsPage = () => {
|
||||
applicationsGroupApi.useRemoveApplicationsGroupMutation()
|
||||
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
||||
// const hasRevokePermission = hasPermission(PermissionKeysType.write)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
@@ -128,21 +130,36 @@ const ApplicationsPage = () => {
|
||||
message.info('Сервис успешно отредактирован')
|
||||
}
|
||||
|
||||
const handleRemoveApplicationsGtoup = () => {
|
||||
deleteApplicationsGroup([Number(selectedItemId)])
|
||||
.unwrap()
|
||||
.then(() => message.success('Элемент удален'))
|
||||
.catch(() => message.info('Ошибка удаления элемента'))
|
||||
}
|
||||
|
||||
const renderMainContent = () => {
|
||||
if (!selectedItemId) {
|
||||
return <EmptyData />
|
||||
}
|
||||
return <ApplicationsContent id={Number(selectedItemId)} />
|
||||
|
||||
return (
|
||||
<ApplicationsContent
|
||||
selectedItemId={Number(selectedItemId)}
|
||||
currentApplicationsApp={currentApplicationsApp}
|
||||
setCurrentApplicationsApp={setCurrentApplicationsApp}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="applications-page ">
|
||||
<main className="applications-page">
|
||||
<div className="applications-page__wrap three-columns">
|
||||
<Column
|
||||
title="Группа приложений"
|
||||
onUpdateItem={updateApplicationModal}
|
||||
showUpdateBtn={!!selectedItemId}
|
||||
onAddItem={addApplicationModal}
|
||||
onRemoveItem={() => deleteApplicationsGroup([Number(selectedItemId)])}
|
||||
onRemoveItem={handleRemoveApplicationsGtoup}
|
||||
items={filterFirstColumnItems(
|
||||
applicationsGroup as unknown as ColumnItem<ApplicationsGroupType>[],
|
||||
searchValue
|
||||
@@ -151,8 +168,9 @@ const ApplicationsPage = () => {
|
||||
searchValue={searchValue}
|
||||
selectedItemId={selectedItemId}
|
||||
setSelectedItemId={(itemId) => {
|
||||
setCurrentApplicationsApp(0)
|
||||
setSelectedItemId(
|
||||
`${routePaths.applications}`,
|
||||
`${routePaths.applicationsGroup}`,
|
||||
itemId,
|
||||
searchValue,
|
||||
navigate
|
||||
|
||||
Reference in new issue
Block a user