Skip to content

Commit

Permalink
Merge branch 'master' into fix/dashboard-co-test
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI committed Mar 21, 2024
2 parents 862cf8a + a714008 commit ee38052
Show file tree
Hide file tree
Showing 14 changed files with 262 additions and 68 deletions.
31 changes: 31 additions & 0 deletions ui/src/components/IconTip/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.ob-cloud-icon-tip {
.anticon-question-circle {
color: rgba(0, 0, 0, 45%);
margin-left: 4px;
}

&.small {
font-size: 12px;
}

&.large {
font-size: 16px;
}
}

.ob-cloud-base-tip {
color: rgba(0, 0, 0, 45%);

.anticon-exclamation-circle {
color: rgba(0, 0, 0, 45%);
margin-right: 2px;
}

&.small {
font-size: 12px;
}

&.large {
font-size: 16px;
}
}
89 changes: 89 additions & 0 deletions ui/src/components/IconTip/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import {
ExclamationCircleOutlined,
QuestionCircleOutlined,
} from '@ant-design/icons';
import type { TooltipProps } from 'antd';
import { Tooltip } from 'antd';
import classnames from 'classnames';
import React from 'react';
import './index.less';

interface IProps {
content?: string | React.ReactNode;
tip?: string | React.ReactNode;
size?: 'small' | 'middle' | 'large';
className?: string;
style?: React.CSSProperties;
contentProps?: React.HTMLAttributes<HTMLSpanElement>;
tipProps?: TooltipProps;
icon?: React.ReactNode;
iconProps?: {
style?: React.CSSProperties;
className?: string;
};
}

const InternalIconTip = (props: IProps) => {
const {
content,
tip,
className,
style,
size,
contentProps,
tipProps,
iconProps,
icon,
} = props;

return (
<span
className={classnames({
'ob-cloud-icon-tip': true,
small: size === 'small',
large: size === 'large',
className: !!className,
[className]: !!className,
})}
style={style}
>
<span {...contentProps}> {content}</span>
<Tooltip title={tip} {...tipProps}>
{icon || <QuestionCircleOutlined {...iconProps} />}
</Tooltip>
</span>
);
};

const BaseTip = (props: Omit<IProps, 'tip' | 'tipProps'>) => {
const { content, size, className, style, contentProps, iconProps, icon } =
props;

return (
<span
className={classnames({
'ob-cloud-base-tip': true,
small: size === 'small',
large: size === 'large',
className: !!className,
[className]: !!className,
})}
style={style}
>
{icon || <ExclamationCircleOutlined {...iconProps} />}
<span {...contentProps}> {content}</span>
</span>
);
};

type InternalIconTipType = typeof InternalIconTip;

export interface IconTipInstance extends InternalIconTipType {
BaseTip: typeof BaseTip;
}

const IconTip = InternalIconTip as IconTipInstance;

IconTip.BaseTip = BaseTip;

export default IconTip;
17 changes: 12 additions & 5 deletions ui/src/components/MonitorComp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useState } from 'react';

import type { QueryRangeType } from '@/components/MonitorDetail';
import { getAllMetrics } from '@/services';
import IconTip from '../IconTip';
import LineGraph,{ LineGraphProps,MetricType } from './LineGraph';
import styles from './index.less';

Expand Down Expand Up @@ -96,10 +97,14 @@ export default function MonitorComp({
(graphContainer: any, graphIdx: number) => (
<Card className={styles.monitorItem} key={graphIdx}>
<div className={styles.graphHeader}>
<span className={styles.graphHeaderText}>
{graphContainer.name}
{graphContainer.metrics[0].unit &&
`(
<IconTip
tip={graphContainer.description}
style={{fontSize:16}}
content={
<span className={styles.graphHeaderText}>
{graphContainer.name}
{graphContainer.metrics[0].unit &&
`(
${graphContainer.metrics[0].unit}
${
(graphContainer.metrics[0].unit && type) ===
Expand All @@ -113,7 +118,9 @@ export default function MonitorComp({
: ''
}
)`}
</span>
</span>
}
/>
{/* <Tooltip title="放大查看">
<FullscreenOutlined
className={styles.fullscreen}
Expand Down
9 changes: 7 additions & 2 deletions ui/src/components/customModal/AddZoneModal.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { intl } from '@/utils/intl';
import { Form, Input, InputNumber, message } from 'antd';
import { Form, Input, message } from 'antd';

import { RULER_ZONE } from '@/constants/rules';
import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { addObzone } from '@/services';
import InputNumber from '../InputNumber';
import type { CommonModalType } from '.';
import CustomModal from '.';
import NodeSelector from '../NodeSelector';
Expand All @@ -26,7 +27,10 @@ export default function AddZoneModal({
} catch (err) {}
};

const handleCancel = () => setVisible(false);
const handleCancel = () =>{
form.resetFields();
setVisible(false);
}
const onFinish = async (values: any) => {
const [namespace, name] = getNSName();
const res = await addObzone({ namespace, name, ...values });
Expand Down Expand Up @@ -55,6 +59,7 @@ export default function AddZoneModal({
form={form}
name="dynamic_form_nest_item"
onFinish={onFinish}
initialValues={{ replicas: 1 }}
style={{ maxWidth: 600 }}
autoComplete="off"
>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/customModal/ModifyUnitDetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export default function ModifyUnitDetailModal({
key={index}
name={item.zone}
isEdit={Boolean(editZone)}
formName={[item.zone, 'priority']}
priorityName={[item.zone, 'priority']}
checked={item.checked!}
obZoneResource={
essentialParameter.obZoneResourceMap[item.zone]
Expand Down
6 changes: 5 additions & 1 deletion ui/src/i18n/strings/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -653,5 +653,9 @@
"Dashboard.src.constants.rules.TheResourceNameMayBe": "The resource name may be spliced into the domain name and must conform to the domain name format.",
"Dashboard.src.constants.rules.EnterAZoneName": "Enter a zone name",
"Dashboard.src.constants.rules.TheFirstCharacterMustBe": "The first character must be a letter or an underscore and cannot contain-",
"Dashboard.Detail.NewBackup.BakMethodsList.ConfigureAtLeastOneFull": "Configure at least one full backup"
"Dashboard.Detail.NewBackup.BakMethodsList.ConfigureAtLeastOneFull": "Configure at least one full backup",
"Dashboard.Detail.Overview.BasicInfo.ReplicaDistribution": "Replica distribution",
"Dashboard.Tenant.New.ResourcePools.SelectTheZoneToDeploy": "Select the Zone to deploy the resource pool",
"Dashboard.Tenant.New.ResourcePools.ResourceUnitSpecifications": "Resource Unit specifications",
"Dashboard.Tenant.New.SelectAtLeastOneZone": "Select at least one Zone"
}
6 changes: 5 additions & 1 deletion ui/src/i18n/strings/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -653,5 +653,9 @@
"Dashboard.src.constants.rules.TheResourceNameMayBe": "资源名可能拼接到域名中,需要符合域名格式",
"Dashboard.src.constants.rules.EnterAZoneName": "请输入zone名称",
"Dashboard.src.constants.rules.TheFirstCharacterMustBe": "首字符必须是字母或者下划线,不能包含 -",
"Dashboard.Detail.NewBackup.BakMethodsList.ConfigureAtLeastOneFull": "至少配置 1 个全量备份"
"Dashboard.Detail.NewBackup.BakMethodsList.ConfigureAtLeastOneFull": "至少配置 1 个全量备份",
"Dashboard.Detail.Overview.BasicInfo.ReplicaDistribution": "副本分布",
"Dashboard.Tenant.New.ResourcePools.SelectTheZoneToDeploy": "选择要部署资源池的 Zone",
"Dashboard.Tenant.New.ResourcePools.ResourceUnitSpecifications": "资源单元规格",
"Dashboard.Tenant.New.SelectAtLeastOneZone": "至少选择一个Zone"
}
19 changes: 10 additions & 9 deletions ui/src/pages/Tenant/Detail/Overview/BasicInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,23 @@ export default function BasicInfo({
id: 'Dashboard.Detail.Overview.BasicInfo.TenantRole',
defaultMessage: '租户角色',
}),
unitNumber: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.NumberOfUnits',
defaultMessage: 'unit 数量',
charset: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.CharacterSet',
defaultMessage: '字符集',
}),
status: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.Status',
defaultMessage: '状态',
}),
locality: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.Priority',
defaultMessage: '优先级',
unitNumber: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.NumberOfUnits',
defaultMessage: 'unit 数量',
}),
charset: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.CharacterSet',
defaultMessage: '字符集',
locality: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.ReplicaDistribution',
defaultMessage: '副本分布',
}),
primaryZone: 'PrimaryZone',
};
const SourceConfig = {
primaryTenant: intl.formatMessage({
Expand Down
24 changes: 17 additions & 7 deletions ui/src/pages/Tenant/New/ResourcePools.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import InputNumber from '@/components/InputNumber';
import { SUFFIX_UNIT } from '@/constants';
import { intl } from '@/utils/intl';
import { Card,Col,Form,Row,Tooltip } from 'antd';
import { Card, Col, Form, Row, Tooltip } from 'antd';
import { FormInstance } from 'antd/lib/form';
import { useEffect,useState } from 'react';
import { useEffect, useState } from 'react';
import ZoneItem from '../ZoneItem';
import { findMinParameter,modifyZoneCheckedStatus } from '../helper';
import { findMinParameter, modifyZoneCheckedStatus } from '../helper';
import styles from './index.less';

interface ResourcePoolsProps {
Expand Down Expand Up @@ -33,14 +33,18 @@ export default function ResourcePools({
const [selectZones, setSelectZones] = useState<string[]>([]);

const checkBoxOnChange = (checked: boolean, name: string) => {
form.setFieldValue(['pools', name, 'checked'], checked);
if (!checked) {
form.setFieldValue(['pools', name, 'priority'], undefined);
setSelectZones(selectZones.filter((zone) => zone !== name));
} else {
// form.setFieldValue(['pools',name])
setSelectZones([...selectZones, name]);
}
setClusterList(
modifyZoneCheckedStatus(clusterList, name, checked, { id: selectClusterId }),
modifyZoneCheckedStatus(clusterList, name, checked, {
id: selectClusterId,
}),
);
};
const targetZoneList = clusterList
Expand Down Expand Up @@ -75,23 +79,29 @@ export default function ResourcePools({
<Row>
<h3>
{intl.formatMessage({
id: 'Dashboard.Tenant.New.ResourcePools.ZonePriority',
defaultMessage: 'Zone优先级',
id: 'Dashboard.Tenant.New.ResourcePools.SelectTheZoneToDeploy',
defaultMessage: '选择要部署资源池的 Zone',
})}
</h3>
{targetZoneList.map((item, index) => (
<ZoneItem
key={index}
name={item.zone}
checked={item.checked!}
checkedFormName={['pools', item.zone, 'checked']}
obZoneResource={essentialParameter.obZoneResourceMap[item.zone]}
checkBoxOnChange={checkBoxOnChange}
/>
))}
</Row>
)}

<h3>Unit config</h3>
<h3>
{intl.formatMessage({
id: 'Dashboard.Tenant.New.ResourcePools.ResourceUnitSpecifications',
defaultMessage: '资源单元规格',
})}
</h3>
<div className={styles.unitConfigContainer}>
<Row gutter={[16, 32]}>
<Col span={8}>
Expand Down
Loading

0 comments on commit ee38052

Please sign in to comment.