Skip to content

Commit

Permalink
perf: Introduction and layout of configuration items in the optimizat…
Browse files Browse the repository at this point in the history
…ion configuration center (#3789)

Signed-off-by: Zzm0809 <[email protected]>
Co-authored-by: Zzm0809 <[email protected]>
  • Loading branch information
Zzm0809 and Zzm0809 authored Sep 7, 2024
1 parent 0c35db8 commit ae45318
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
61 changes: 61 additions & 0 deletions dinky-web/src/components/Typography/MoreInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import { Flex, Typography } from 'antd';
import React, { useEffect, useState } from 'react';

const { Text } = Typography;

type MoreInfoProps = {
maxRows: number;
children: string;
type?: 'secondary' | 'success' | 'warning' | 'danger';
};

const MoreInfo: React.FC<MoreInfoProps> = (props) => {
const { maxRows, children, type = 'secondary' } = props;

const [expanded, setExpanded] = useState(false);
const [rows, setRows] = useState(maxRows);

useEffect(() => {
if (expanded) {
setRows(10);
}
}, [expanded]);

return (
<Flex gap={16} vertical>
<Typography.Paragraph
type={type}
ellipsis={{
tooltip: children,
rows,
expandable: true,
expanded,
onExpand: (_, info) => setExpanded(info.expanded)
}}
>
{children}
</Typography.Paragraph>
</Flex>
);
};

export default MoreInfo;
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { ProListMetas, ProListProps } from '@ant-design/pro-list';
import { ActionType } from '@ant-design/pro-table';
import { Descriptions, Input, Radio, RadioChangeEvent, Space, Switch } from 'antd';
import React, { useRef } from 'react';
import MoreInfo from '@/components/Typography/MoreInfo';

type GeneralConfigProps = {
data: BaseConfigProperties[];
Expand Down Expand Up @@ -127,7 +128,9 @@ const GeneralConfig: React.FC<GeneralConfigProps> = (props) => {
},
description: {
editable: false,
render: (dom: any, entity: BaseConfigProperties) => <>{entity.note}</>
render: (dom: any, entity: BaseConfigProperties) => (
<MoreInfo maxRows={1}>{entity.note}</MoreInfo>
)
},
content: {
dataIndex: 'value',
Expand Down

0 comments on commit ae45318

Please sign in to comment.