MSP-3289 update Token table layout
This commit is contained in:
1 parent
e063e3ca69
commit
358531bead
1 file changed
+34
-32
@@ -1,20 +1,22 @@
|
|||||||
import { CopyOutlined, DeleteOutlined } from '@ant-design/icons'
|
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 { ColumnsType } from 'antd/es/table'
|
||||||
import ClipboardJS from 'clipboard'
|
import ClipboardJS from 'clipboard'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import 'dayjs/locale/ru'
|
import 'dayjs/locale/ru'
|
||||||
import duration from 'dayjs/plugin/duration'
|
import duration from 'dayjs/plugin/duration'
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
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 { useEffect, useState } from 'react'
|
||||||
import { useForm } from 'react-hook-form'
|
import { useForm } from 'react-hook-form'
|
||||||
|
|
||||||
|
import { dateFormats } from '@constants/date.ts'
|
||||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
import Modal from '@widgets/Modal'
|
||||||
|
|
||||||
// import CanEdit from '@components/CanEdit'
|
import CanEdit from '@components/CanEdit'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ApplicationTokenType,
|
ApplicationTokenType,
|
||||||
NewApplicationTokenType
|
NewApplicationTokenType
|
||||||
@@ -22,9 +24,10 @@ import {
|
|||||||
|
|
||||||
import tokensApi from '@services/tokensService.ts'
|
import tokensApi from '@services/tokensService.ts'
|
||||||
|
|
||||||
import './tokens.scss'
|
|
||||||
import CanEdit from '@components/CanEdit'
|
|
||||||
import { dateFormats } from '@constants/date.ts'
|
import './tokens.scss';
|
||||||
|
|
||||||
|
|
||||||
const { FormSelect } = FormComponents
|
const { FormSelect } = FormComponents
|
||||||
const { EmptyData } = Layout
|
const { EmptyData } = Layout
|
||||||
@@ -110,6 +113,11 @@ const TokenContent = ({ id }: TokenPropTypes) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<ApplicationTokenType> = [
|
const columns: ColumnsType<ApplicationTokenType> = [
|
||||||
|
{
|
||||||
|
title: 'ID',
|
||||||
|
dataIndex: 'appId',
|
||||||
|
key: 'appId'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'Токен',
|
title: 'Токен',
|
||||||
dataIndex: 'token',
|
dataIndex: 'token',
|
||||||
@@ -121,7 +129,9 @@ const TokenContent = ({ id }: TokenPropTypes) => {
|
|||||||
dataIndex: 'createdAt',
|
dataIndex: 'createdAt',
|
||||||
key: 'createdAt',
|
key: 'createdAt',
|
||||||
render: (record) => {
|
render: (record) => {
|
||||||
const formatTime = dayjs(record.createdAt).format(dateFormats.fullFormat)
|
const formatTime = dayjs(record.createdAt).format(
|
||||||
|
dateFormats.fullFormat
|
||||||
|
)
|
||||||
return <div>{formatTime}</div>
|
return <div>{formatTime}</div>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -150,33 +160,24 @@ const TokenContent = ({ id }: TokenPropTypes) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Скопировать',
|
title: 'Действия',
|
||||||
dataIndex: 'token',
|
dataIndex: 'token',
|
||||||
key: 'copyToken',
|
key: 'actions',
|
||||||
align: 'center',
|
render: (value) => {
|
||||||
render: (record) => {
|
|
||||||
return (
|
return (
|
||||||
<Button className="copy-btn" data-clipboard-text={record}>
|
<Button.Group>
|
||||||
<CopyOutlined />
|
<Tooltip title="Скопировать">
|
||||||
</Button>
|
<Button icon={<CopyOutlined />} data-clipboard-text={value} />
|
||||||
)
|
</Tooltip>
|
||||||
}
|
<Tooltip title="Удалить">
|
||||||
},
|
<Popconfirm
|
||||||
{
|
title="Закончить эту сессию?"
|
||||||
title: 'Отозвать',
|
onConfirm={() => handleRevokeToken(value)}
|
||||||
dataIndex: 'appId',
|
>
|
||||||
key: 'recall',
|
<Button icon={<DeleteOutlined />} />
|
||||||
align: 'center',
|
</Popconfirm>
|
||||||
render: (_, record) => {
|
</Tooltip>
|
||||||
return (
|
</Button.Group>
|
||||||
<Popconfirm
|
|
||||||
title="Закончить эту сессию?"
|
|
||||||
onConfirm={() => handleRevokeToken(record)}
|
|
||||||
>
|
|
||||||
<Button danger>
|
|
||||||
<DeleteOutlined />
|
|
||||||
</Button>
|
|
||||||
</Popconfirm>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,6 +221,7 @@ const TokenContent = ({ id }: TokenPropTypes) => {
|
|||||||
<section className="token-content">
|
<section className="token-content">
|
||||||
<div className="token-content__wrap">
|
<div className="token-content__wrap">
|
||||||
<header className="token-content__header">
|
<header className="token-content__header">
|
||||||
|
<h3>Токены</h3>
|
||||||
<CanEdit>
|
<CanEdit>
|
||||||
<Button
|
<Button
|
||||||
className="applications-content__add-btn"
|
className="applications-content__add-btn"
|
||||||
|
|||||||
Reference in new issue
Block a user