feat(web): api key
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { forwardRef, useImperativeHandle, useState } from 'react';
|
import { forwardRef, useImperativeHandle, useState } from 'react';
|
||||||
import { Switch, Button } from 'antd';
|
import { Switch, Button, Tooltip } from 'antd';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import type { ApiKey, ApiKeyModalRef } from '../types';
|
import type { ApiKey, ApiKeyModalRef } from '../types';
|
||||||
@@ -51,8 +51,8 @@ const ApiKeyDetailModal = forwardRef<ApiKeyModalRef, { handleCopy: (content: str
|
|||||||
{ key === 'created_at'
|
{ key === 'created_at'
|
||||||
? formatDateTime(data[key], 'YYYY-MM-DD HH:mm:ss')
|
? formatDateTime(data[key], 'YYYY-MM-DD HH:mm:ss')
|
||||||
: key === 'is_expired'
|
: key === 'is_expired'
|
||||||
? <Tag>{data[key] ? t('apiKey.inactive') : t('apiKey.active')}</Tag>
|
? <Tag color={data[key] ? 'error' : 'processing'}>{data[key] ? t('apiKey.inactive') : t('apiKey.active')}</Tag>
|
||||||
: String(data[key as keyof ApiKey])
|
: <Tooltip title={String(data[key as keyof ApiKey])}>{String(data[key as keyof ApiKey])}</Tooltip>
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -91,7 +91,7 @@ const ApiKeyDetailModal = forwardRef<ApiKeyModalRef, { handleCopy: (content: str
|
|||||||
<div className="rb:flex rb:justify-between rb:gap-5 rb:font-regular rb:text-[14px] rb:mt-3">
|
<div className="rb:flex rb:justify-between rb:gap-5 rb:font-regular rb:text-[14px] rb:mt-3">
|
||||||
<span className="rb:text-[#5B6167]">{t(`apiKey.expires_at`)}</span>
|
<span className="rb:text-[#5B6167]">{t(`apiKey.expires_at`)}</span>
|
||||||
<span>
|
<span>
|
||||||
{data.expires_at ? formatDateTime(data.expires_at as number, 'yyyy-MM-DD') : '-'}
|
{data.expires_at ? formatDateTime(data.expires_at as number, 'YYYY-MM-DD HH:mm:ss') : '-'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</>}
|
</>}
|
||||||
|
|||||||
@@ -72,12 +72,12 @@ const ApiKeyManagement: React.FC = () => {
|
|||||||
<div key={key} className={clsx("rb:flex rb:justify-between rb:gap-5 rb:font-regular rb:text-[14px]", {
|
<div key={key} className={clsx("rb:flex rb:justify-between rb:gap-5 rb:font-regular rb:text-[14px]", {
|
||||||
'rb:mt-3': index !== 0
|
'rb:mt-3': index !== 0
|
||||||
})}>
|
})}>
|
||||||
<span className="rb:text-[#5B6167]">{t(`apiKey.${key}`)}</span>
|
<span className="rb:text-[#5B6167] rb:w-20">{t(`apiKey.${key}`)}</span>
|
||||||
<span>
|
<span className="rb:flex-1 rb:text-left rb:py-px rb:rounded rb:font-medium">
|
||||||
{ key === 'created_at'
|
{ key === 'created_at'
|
||||||
? formatDateTime(apiKeyItem[key], 'YYYY-MM-DD HH:mm:ss')
|
? formatDateTime(apiKeyItem[key], 'YYYY-MM-DD HH:mm:ss')
|
||||||
: key === 'is_expired'
|
: key === 'is_expired'
|
||||||
? <Tag>{apiKeyItem[key] ? t('apiKey.inactive') : t('apiKey.active')}</Tag>
|
? <Tag color={apiKeyItem[key] ? 'error' : 'processing'}>{apiKeyItem[key] ? t('apiKey.inactive') : t('apiKey.active')}</Tag>
|
||||||
: String(apiKeyItem[key as keyof ApiKey])
|
: String(apiKeyItem[key as keyof ApiKey])
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ const ApiKeyModal = forwardRef<ApiKeyModalRef, ApiKeyModalProps>(({
|
|||||||
...values,
|
...values,
|
||||||
type: application.type,
|
type: application.type,
|
||||||
resource_id: application.id,
|
resource_id: application.id,
|
||||||
|
scopes: ['app']
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
handleClose()
|
handleClose()
|
||||||
|
|||||||
Reference in New Issue
Block a user