Skip to content

Commit

Permalink
feat: add expiration tag in cluster list (#167)
Browse files Browse the repository at this point in the history
Signed-off-by: liuying <liu.ying@99cloud.net>

Signed-off-by: liuying <liu.ying@99cloud.net>
  • Loading branch information
lysign authored Sep 22, 2022
1 parent d7648f6 commit 75fafb2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/Tables/Base/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ const BaseTable = (props) => {
isStatus = false,
extraNameIndex,
extraNameCopyable,
extraRender,
...rest
} = column;

Expand Down Expand Up @@ -474,9 +475,12 @@ const BaseTable = (props) => {
if (value && value !== '-') {
return (
<>
<Paragraph {...nameProps}>
{render ? render(value, record) : value}
</Paragraph>
<div style={{ display: 'flex' }}>
<Paragraph {...nameProps}>
{render ? render(value, record) : value}
</Paragraph>
{extraRender?.(value, record)}
</div>
{extraNameIndex ? (
<Paragraph {...extraProps}>{extraVal}</Paragraph>
) : (
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@
"Download": "Download",
"Update Cluster License": "Update Cluster License",
"License Expiration Time": "License Expiration Time",
"License Expiration": "License Expiration",
"Please keep the CPU architecture consistent!": "Please keep the CPU architecture consistent!",
"The selected node and schema are inconsistent": "The selected node and schema are inconsistent",
"The backup path needs to be created on each node and mounted to a shared file path (such as NFS)": "The backup path needs to be created on each node and mounted to a shared file path (such as NFS)",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@
"Update Cluster License": "更新集群证书",
"View KubeConfig File": "查看 Kubeconfig 文件",
"License Expiration Time": "证书过期时间",
"License Expiration": "证书过期",
"Please keep the CPU architecture consistent!": "请保持 CPU 架构的一致性!",
"The selected node and schema are inconsistent": "选择的节点和架构不一致",
"The backup path needs to be created on each node and mounted to a shared file path (such as NFS)": "备份路径需要在每个节点上自行创建,并将路径该挂载到共享的文件路径(如 NFS)",
Expand Down
22 changes: 22 additions & 0 deletions src/resources/cluster.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import React from 'react';
import { Link } from 'react-router-dom';
import { getRoles, nodeEnum } from 'resources/node';
import RenderOption from 'components/RenderOption';
import { Tag } from 'antd';
import { checkExpired } from 'utils';
import moment from 'moment';

export const clusterParams = {
offline: true,
Expand Down Expand Up @@ -267,6 +270,25 @@ export const columns = [
isHideable: true,
copyable: true,
render: (name) => <Link to={`/cluster/${name}`}>{name}</Link>,
extraRender: (name, data) => {
let isExpired = null;
if (data.licenseExpirationTime) {
const date = moment(data.licenseExpirationTime)
.subtract(1, 'day')
.format('YYYY-MM-DD HH:mm:ss');
isExpired = !checkExpired(date);
}

return (
<>
{isExpired ? (
<Tag style={{ marginLeft: '12px' }} color={'red'} key={name}>
{t('License Expiration')}
</Tag>
) : null}
</>
);
},
},
{
title: t('Region'),
Expand Down

0 comments on commit 75fafb2

Please sign in to comment.