-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize the page for creating an obproxy cluster and handle some d…
…etails (#414)
- Loading branch information
1 parent
5f031a3
commit 1b54d37
Showing
13 changed files
with
291 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.preText { | ||
display: -webkit-box; | ||
overflow: hidden; | ||
-webkit-box-orient: vertical; | ||
text-overflow: ellipsis; | ||
} | ||
.tooltipContent { | ||
max-height: 400px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Tooltip | ||
title={ | ||
<pre className={styles.tooltipContent}> | ||
{typeof value === 'string' ? value : JSON.stringify(value, null, 4)} | ||
</pre> | ||
} | ||
> | ||
<pre | ||
className={cols ? styles.preText : ''} | ||
style={{ WebkitLineClamp: cols }} | ||
> | ||
{typeof value === 'string' ? value : JSON.stringify(value, null, 4)} | ||
</pre> | ||
</Tooltip> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<API.CreateClusterData>; | ||
}) { | ||
// 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 ( | ||
<div> | ||
{menu} | ||
<Divider style={{ margin: '10px 0' }} /> | ||
<div | ||
onClick={() => setVisible(true)} | ||
style={{ padding: '8px', cursor: 'pointer' }} | ||
> | ||
<PlusOutlined /> | ||
<span style={{ marginLeft: '6px' }}> | ||
{intl.formatMessage({ | ||
id: 'OBDashboard.Cluster.New.BasicInfo.AddNamespace', | ||
defaultMessage: '新增命名空间', | ||
})} | ||
</span> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
const addNSCallback = (newNS: string) => { | ||
form.setFieldValue('namespace', newNS); | ||
form.validateFields(['namespace']); | ||
getNS(); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Form.Item | ||
label={intl.formatMessage({ | ||
id: 'OBDashboard.Cluster.New.BasicInfo.Namespace', | ||
defaultMessage: '命名空间', | ||
})} | ||
name="namespace" | ||
validateTrigger="onBlur" | ||
validateFirst | ||
rules={[ | ||
{ | ||
required: true, | ||
message: intl.formatMessage({ | ||
id: 'OBDashboard.Cluster.New.BasicInfo.EnterANamespace', | ||
defaultMessage: '请输入命名空间', | ||
}), | ||
validateTrigger: 'onChange', | ||
}, | ||
resourceNameRule, | ||
]} | ||
> | ||
<Select | ||
showSearch | ||
placeholder={intl.formatMessage({ | ||
id: 'OBDashboard.Cluster.New.BasicInfo.PleaseSelect', | ||
defaultMessage: '请选择', | ||
})} | ||
optionFilterProp="label" | ||
filterOption={filterOption} | ||
dropdownRender={DropDownComponent} | ||
options={data} | ||
/> | ||
</Form.Item> | ||
<AddNSModal | ||
visible={visible} | ||
setVisible={setVisible} | ||
successCallback={addNSCallback} | ||
/> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.text { | ||
display: -webkit-box; | ||
overflow: hidden; | ||
-webkit-line-clamp: 7; | ||
-webkit-box-orient: vertical; | ||
text-overflow: ellipsis; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.