diff --git a/ui/src/components/AlertDrawer/index.tsx b/ui/src/components/AlertDrawer/index.tsx index ebdf9e8bc..149bb376e 100644 --- a/ui/src/components/AlertDrawer/index.tsx +++ b/ui/src/components/AlertDrawer/index.tsx @@ -13,7 +13,13 @@ export default function AlertDrawer({ ...props }: AlertRuleDrawerProps) { return ( - + {props.children}
{footer ? ( diff --git a/ui/src/components/PreText/index.less b/ui/src/components/PreText/index.less new file mode 100644 index 000000000..3152663b0 --- /dev/null +++ b/ui/src/components/PreText/index.less @@ -0,0 +1,9 @@ +.preText { + display: -webkit-box; + overflow: hidden; + -webkit-box-orient: vertical; + text-overflow: ellipsis; +} +.tooltipContent { + max-height: 400px; +} diff --git a/ui/src/components/PreText/index.tsx b/ui/src/components/PreText/index.tsx new file mode 100644 index 000000000..1c5b8270e --- /dev/null +++ b/ui/src/components/PreText/index.tsx @@ -0,0 +1,26 @@ +import { Tooltip } from 'antd'; +import styles from './index.less'; + +interface PreTextProps { + cols?: number; + value: object | string; +} + +export default function PreText({ cols, value }: PreTextProps) { + return ( + + {typeof value === 'string' ? value : JSON.stringify(value, null, 4)} + + } + > +
+        {typeof value === 'string' ? value : JSON.stringify(value, null, 4)}
+      
+
+ ); +} diff --git a/ui/src/components/SelectNSFromItem/index.tsx b/ui/src/components/SelectNSFromItem/index.tsx new file mode 100644 index 000000000..ae4d75157 --- /dev/null +++ b/ui/src/components/SelectNSFromItem/index.tsx @@ -0,0 +1,91 @@ +import { intl } from '@/utils/intl'; +import { PlusOutlined } from '@ant-design/icons'; +import { useRequest } from 'ahooks'; +import { Divider, Form, Select } from 'antd'; +import type { FormInstance } from 'antd/lib/form'; + +import AddNSModal from '@/components/customModal/AddNSModal'; +import { resourceNameRule } from '@/constants/rules'; +import { getNameSpaces } from '@/services'; +import { useState } from 'react'; +export default function SelectNSFromItem({ + form, +}: { + form: FormInstance; +}) { + // control the modal for adding a new namespace + const [visible, setVisible] = useState(false); + const { data, run: getNS } = useRequest(getNameSpaces); + + const filterOption = ( + input: string, + option: { label: string; value: string }, + ) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase()); + const DropDownComponent = (menu: any) => { + return ( +
+ {menu} + +
setVisible(true)} + style={{ padding: '8px', cursor: 'pointer' }} + > + + + {intl.formatMessage({ + id: 'OBDashboard.Cluster.New.BasicInfo.AddNamespace', + defaultMessage: '新增命名空间', + })} + +
+
+ ); + }; + const addNSCallback = (newNS: string) => { + form.setFieldValue('namespace', newNS); + form.validateFields(['namespace']); + getNS(); + }; + + return ( + <> + + +