fix: os image dropdown list
This commit is contained in:
@@ -43,6 +43,7 @@ const icons = {
|
|||||||
TencentCloud: React.createElement(IconFont, { type: 'icon-tencentcloud' }),
|
TencentCloud: React.createElement(IconFont, { type: 'icon-tencentcloud' }),
|
||||||
Nvidia: React.createElement(IconFont, { type: 'icon-nvidia' }),
|
Nvidia: React.createElement(IconFont, { type: 'icon-nvidia' }),
|
||||||
Ascend: React.createElement(IconFont, { type: 'icon-ascend' }),
|
Ascend: React.createElement(IconFont, { type: 'icon-ascend' }),
|
||||||
|
Catalog1: React.createElement(IconFont, { type: 'icon-catalog1' }),
|
||||||
AMD: React.createElement(IconFont, { type: 'icon-amd' }),
|
AMD: React.createElement(IconFont, { type: 'icon-amd' }),
|
||||||
KubernetesFilled: React.createElement(IconFont, { type: 'icon-k8s-filled' })
|
KubernetesFilled: React.createElement(IconFont, { type: 'icon-k8s-filled' })
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import { AutoComplete, Form, Spin } from 'antd';
|
import { AutoComplete, Form, Spin } from 'antd';
|
||||||
import type { AutoCompleteProps } from 'antd/lib';
|
import type { AutoCompleteProps } from 'antd/lib';
|
||||||
import classNames from 'classnames';
|
|
||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { SealFormItemProps } from './types';
|
import { SealFormItemProps } from './types';
|
||||||
import Wrapper from './wrapper';
|
import Wrapper from './wrapper';
|
||||||
import AutoCompleteLabel from './wrapper/auto-complete-label';
|
|
||||||
import SelectWrapper from './wrapper/select';
|
import SelectWrapper from './wrapper/select';
|
||||||
|
|
||||||
const SealAutoComplete: React.FC<
|
const SealAutoComplete: React.FC<
|
||||||
@@ -26,7 +24,6 @@ const SealAutoComplete: React.FC<
|
|||||||
...rest
|
...rest
|
||||||
} = props;
|
} = props;
|
||||||
const [isFocus, setIsFocus] = useState(false);
|
const [isFocus, setIsFocus] = useState(false);
|
||||||
const [_isFocus_, _setIsFocus_] = useState(false);
|
|
||||||
const inputRef = useRef<any>(null);
|
const inputRef = useRef<any>(null);
|
||||||
let status = '';
|
let status = '';
|
||||||
if (isInFormItems) {
|
if (isInFormItems) {
|
||||||
@@ -44,7 +41,6 @@ const SealAutoComplete: React.FC<
|
|||||||
if (!props.disabled && !isFocus) {
|
if (!props.disabled && !isFocus) {
|
||||||
inputRef.current?.focus?.();
|
inputRef.current?.focus?.();
|
||||||
setIsFocus(true);
|
setIsFocus(true);
|
||||||
_setIsFocus_(true);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,20 +49,17 @@ const SealAutoComplete: React.FC<
|
|||||||
if (trim) {
|
if (trim) {
|
||||||
value = value?.trim?.();
|
value = value?.trim?.();
|
||||||
}
|
}
|
||||||
_setIsFocus_(false);
|
|
||||||
props.onChange?.(value, option);
|
props.onChange?.(value, option);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnFocus = (e: any) => {
|
const handleOnFocus = (e: any) => {
|
||||||
setIsFocus(true);
|
setIsFocus(true);
|
||||||
_setIsFocus_(true);
|
|
||||||
props.onFocus?.(e);
|
props.onFocus?.(e);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnBlur = (e: any) => {
|
const handleOnBlur = (e: any) => {
|
||||||
if (!props.value) {
|
if (!props.value) {
|
||||||
setIsFocus(false);
|
setIsFocus(false);
|
||||||
_setIsFocus_(false);
|
|
||||||
}
|
}
|
||||||
e.target.value = e.target.value?.trim?.();
|
e.target.value = e.target.value?.trim?.();
|
||||||
props.onBlur?.(e);
|
props.onBlur?.(e);
|
||||||
@@ -86,39 +79,6 @@ const SealAutoComplete: React.FC<
|
|||||||
return addAfter;
|
return addAfter;
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderAutoCompleteLabel = () => {
|
|
||||||
console.log(
|
|
||||||
'renderAutoCompleteLabel===',
|
|
||||||
props.value,
|
|
||||||
props.showSearch,
|
|
||||||
_isFocus_,
|
|
||||||
isFocus
|
|
||||||
);
|
|
||||||
if (!props.showSearch || _isFocus_) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
let selectItem: {
|
|
||||||
label: React.ReactNode;
|
|
||||||
value: string | number;
|
|
||||||
} = props.options?.find((item: any) => item.value === props.value) as {
|
|
||||||
label: React.ReactNode;
|
|
||||||
value: string | number;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!selectItem) {
|
|
||||||
selectItem = { label: props.value, value: props.value };
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<AutoCompleteLabel
|
|
||||||
className={classNames({
|
|
||||||
disabled: props.disabled
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
{props.labelRender ? props.labelRender(selectItem) : selectItem.label}
|
|
||||||
</AutoCompleteLabel>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SelectWrapper style={style}>
|
<SelectWrapper style={style}>
|
||||||
<Wrapper
|
<Wrapper
|
||||||
|
|||||||
@@ -329,6 +329,7 @@ const ClusterCreate = () => {
|
|||||||
{currentStep === startStep && (
|
{currentStep === startStep && (
|
||||||
<ProviderCatalog
|
<ProviderCatalog
|
||||||
dataList={providerList}
|
dataList={providerList}
|
||||||
|
height={80}
|
||||||
onSelect={handleSelectProvider}
|
onSelect={handleSelectProvider}
|
||||||
clickable={true}
|
clickable={true}
|
||||||
current={extraData.provider}
|
current={extraData.provider}
|
||||||
|
|||||||
@@ -425,7 +425,6 @@ const PoolForm: React.FC<AddModalProps> = forwardRef((props, ref) => {
|
|||||||
showSearch
|
showSearch
|
||||||
allowClear
|
allowClear
|
||||||
onChange={handleOsImageChange}
|
onChange={handleOsImageChange}
|
||||||
filterOption={filterImageOption}
|
|
||||||
optionRender={(option) =>
|
optionRender={(option) =>
|
||||||
RenderOption({
|
RenderOption({
|
||||||
...option,
|
...option,
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ interface ProviderCatalogProps {
|
|||||||
cols?: number;
|
cols?: number;
|
||||||
current?: ProviderType | string;
|
current?: ProviderType | string;
|
||||||
clickable?: boolean;
|
clickable?: boolean;
|
||||||
|
height: string | number;
|
||||||
dataList: {
|
dataList: {
|
||||||
label: string;
|
label: string;
|
||||||
key: string;
|
key: string;
|
||||||
@@ -52,6 +53,7 @@ const ProviderCatalog: React.FC<ProviderCatalogProps> = ({
|
|||||||
cols = 3,
|
cols = 3,
|
||||||
dataList,
|
dataList,
|
||||||
clickable,
|
clickable,
|
||||||
|
height,
|
||||||
current
|
current
|
||||||
}) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
@@ -77,7 +79,7 @@ const ProviderCatalog: React.FC<ProviderCatalogProps> = ({
|
|||||||
<Wrapper $cols={cols}>
|
<Wrapper $cols={cols}>
|
||||||
{items?.map((action) => (
|
{items?.map((action) => (
|
||||||
<Card
|
<Card
|
||||||
height="80px"
|
height={height}
|
||||||
key={action.key}
|
key={action.key}
|
||||||
onClick={() => onSelect?.(action.key as string, action)}
|
onClick={() => onSelect?.(action.key as string, action)}
|
||||||
active={current === action.key}
|
active={current === action.key}
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ const SupportedHardware: React.FC<SupportedHardwareProps> = ({
|
|||||||
return (
|
return (
|
||||||
<ProviderCatalog
|
<ProviderCatalog
|
||||||
onSelect={onSelect}
|
onSelect={onSelect}
|
||||||
|
height={60}
|
||||||
current={current}
|
current={current}
|
||||||
dataList={supportedHardPlatforms}
|
dataList={supportedHardPlatforms}
|
||||||
clickable={clickable}
|
clickable={clickable}
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ export const clusterActionList = [
|
|||||||
label: 'resources.button.create',
|
label: 'resources.button.create',
|
||||||
provider: ProviderValueMap.Docker,
|
provider: ProviderValueMap.Docker,
|
||||||
locale: true,
|
locale: true,
|
||||||
icon: icons.Docker
|
icon: icons.DockerOutlined
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'register_cluster',
|
key: 'register_cluster',
|
||||||
@@ -174,7 +174,7 @@ export const clusterActionList = [
|
|||||||
label: 'clusters.button.addNodePool',
|
label: 'clusters.button.addNodePool',
|
||||||
provider: ProviderValueMap.DigitalOcean,
|
provider: ProviderValueMap.DigitalOcean,
|
||||||
locale: true,
|
locale: true,
|
||||||
icon: icons.Catalog
|
icon: icons.Catalog1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'delete',
|
key: 'delete',
|
||||||
|
|||||||
Reference in New Issue
Block a user