Skip to content

Commit 829e06f

Browse files
author
tingfuyeh
committed
Merge branch 'dev/poc'
2 parents 08b43a1 + dcf6d38 commit 829e06f

File tree

7 files changed

+124
-46
lines changed

7 files changed

+124
-46
lines changed

web/src/polaris/administration/breaker/operations/Create.tsx

Lines changed: 79 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,26 @@ export default purify(function CustomRoutePage(props: DuckCmpProps<CreateDuck>)
155155
<Card.Body title='主调服务'>
156156
<Form style={{ padding: '0px', backgroundColor: 'inherit' }}>
157157
<FormField field={sourceNamespace} label='命名空间' required>
158-
<TeaSelect
159-
value={sourceNamespace.getValue()}
158+
<AutoComplete
160159
options={[
161-
{ text: '全部命名空间', value: '*', disabled: destinationNamespace.getValue() === '*' },
162-
...(data?.namespaceList || []),
160+
...new Set([
161+
{
162+
text: '全部命名空间',
163+
value: '*',
164+
disabled: destinationNamespace.getValue() === '*',
165+
},
166+
...(sourceNamespace.getValue()
167+
? [
168+
{
169+
text: `(输入值)${sourceNamespace.getValue()}`,
170+
value: sourceNamespace.getValue(),
171+
},
172+
]
173+
: []),
174+
...data?.namespaceList,
175+
]),
163176
]}
177+
tips='没有匹配的命名空间名称'
164178
onChange={value => {
165179
if (value === '*') {
166180
sourceNamespace.setValue('*')
@@ -170,13 +184,26 @@ export default purify(function CustomRoutePage(props: DuckCmpProps<CreateDuck>)
170184
sourceNamespace.setValue(value)
171185
sourceService.setValue('')
172186
}}
173-
searchable
174-
type={'simulate'}
175-
appearance={'button'}
176-
matchButtonWidth
177-
placeholder='请选择命名空间'
178-
style={{ width: '80%', maxWidth: '600px' }}
179-
/>
187+
>
188+
{ref => (
189+
<TeaInput
190+
ref={ref}
191+
value={
192+
sourceNamespace.getValue() === '*' ? '全部命名空间' : sourceNamespace.getValue()
193+
}
194+
onChange={value => {
195+
if (value === '*') {
196+
sourceNamespace.setValue('*')
197+
sourceService.setValue('*')
198+
return
199+
}
200+
sourceNamespace.setValue(value)
201+
sourceService.setValue('')
202+
}}
203+
style={{ width: '80%', maxWidth: '600px' }}
204+
/>
205+
)}
206+
</AutoComplete>
180207
</FormField>
181208
<FormField field={sourceService} label='服务名称' required>
182209
<AutoComplete
@@ -203,6 +230,7 @@ export default purify(function CustomRoutePage(props: DuckCmpProps<CreateDuck>)
203230
onChange={value => {
204231
sourceService.setValue(value)
205232
}}
233+
disabled={sourceNamespace.getValue() === '*'}
206234
style={{ width: '80%', maxWidth: '600px' }}
207235
/>
208236
)}
@@ -222,12 +250,26 @@ export default purify(function CustomRoutePage(props: DuckCmpProps<CreateDuck>)
222250
<Card.Body title='被调服务'>
223251
<Form style={{ padding: '0px', backgroundColor: 'inherit' }}>
224252
<FormField field={destinationNamespace} label='命名空间' required>
225-
<TeaSelect
226-
value={destinationNamespace.getValue()}
253+
<AutoComplete
227254
options={[
228-
{ text: '全部命名空间', value: '*', disabled: sourceNamespace.getValue() === '*' },
229-
...(data?.namespaceList || []),
255+
...new Set([
256+
{
257+
text: '全部命名空间',
258+
value: '*',
259+
disabled: sourceNamespace.getValue() === '*',
260+
},
261+
...(destinationNamespace.getValue()
262+
? [
263+
{
264+
text: `(输入值)${destinationNamespace.getValue()}`,
265+
value: destinationNamespace.getValue(),
266+
},
267+
]
268+
: []),
269+
...data?.namespaceList,
270+
]),
230271
]}
272+
tips='没有匹配的命名空间名称'
231273
onChange={value => {
232274
if (value === '*') {
233275
destinationNamespace.setValue('*')
@@ -237,13 +279,28 @@ export default purify(function CustomRoutePage(props: DuckCmpProps<CreateDuck>)
237279
destinationNamespace.setValue(value)
238280
destinationService.setValue('')
239281
}}
240-
searchable
241-
type={'simulate'}
242-
appearance={'button'}
243-
matchButtonWidth
244-
placeholder='请选择命名空间'
245-
style={{ width: '80%', maxWidth: '600px' }}
246-
/>
282+
>
283+
{ref => (
284+
<TeaInput
285+
ref={ref}
286+
value={
287+
destinationNamespace.getValue() === '*'
288+
? '全部命名空间'
289+
: destinationNamespace.getValue()
290+
}
291+
onChange={value => {
292+
if (value === '*') {
293+
destinationNamespace.setValue('*')
294+
destinationService.setValue('*')
295+
return
296+
}
297+
destinationNamespace.setValue(value)
298+
destinationService.setValue('')
299+
}}
300+
style={{ width: '80%', maxWidth: '600px' }}
301+
/>
302+
)}
303+
</AutoComplete>
247304
</FormField>
248305
<FormField field={destinationService} label='服务名称' required>
249306
<AutoComplete

web/src/polaris/namespace/getColumns.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ export default ({ duck: { creators } }: DuckCmpProps<NamespacePageDuck>): Column
4242
)
4343
},
4444
},
45+
{
46+
key: 'sync_to_global_registry',
47+
header: '同步全局注册中心',
48+
render: x => <Text>{x.sync_to_global_registry ? '开启' : '关闭' || '-'}</Text>,
49+
},
4550
{
4651
key: 'commnet',
4752
header: '描述',

web/src/polaris/namespace/model.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface CreateNamespaceParams {
1616
user_ids?: string[]
1717
group_ids?: string[]
1818
service_export_to?: string[]
19+
sync_to_global_registry?: boolean
1920
}
2021
export interface CreateNamespaceResult {
2122
namespace: Namespace
@@ -29,6 +30,7 @@ export interface ModifyNamespaceParams {
2930
remove_user_ids?: string[]
3031
remove_group_ids?: string[]
3132
service_export_to?: string[]
33+
sync_to_global_registry?: boolean
3234
}
3335
export interface ModifyNamespaceResult {
3436
size: number

web/src/polaris/namespace/operation/Create.tsx

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import { DuckCmpProps, purify } from 'saga-duck'
33
import Duck from './CreateDuck'
4-
import { Form, Button, Icon, FormItem, Radio, RadioGroup, SelectMultiple } from 'tea-component'
4+
import { Form, Button, Icon, FormItem, Radio, RadioGroup, SelectMultiple, Switch } from 'tea-component'
55
import Dialog from '@src/polaris/common/duckComponents/Dialog'
66
import FormField from '@src/polaris/common/duckComponents/form/Field'
77
import Input from '@src/polaris/common/duckComponents/form/Input'
@@ -37,11 +37,12 @@ const CreateForm = purify(function CreateForm(props: DuckCmpProps<Duck>) {
3737
} = duck
3838

3939
const formApi = form.getAPI(store, dispatch)
40-
const { name, comment, service_export_to, visibilityMode } = formApi.getFields([
40+
const { name, comment, service_export_to, visibilityMode, sync_to_global_registry } = formApi.getFields([
4141
'name',
4242
'comment',
4343
'service_export_to',
4444
'visibilityMode',
45+
'sync_to_global_registry',
4546
])
4647
const options = selectors.options(store)
4748
const [showAdvance, setShowAdvance] = React.useState(false)
@@ -71,17 +72,15 @@ const CreateForm = purify(function CreateForm(props: DuckCmpProps<Duck>) {
7172

7273
{showAdvance && (
7374
<>
74-
{options.authOpen && (
75-
<FormItem label={'授权'}>
76-
<ResourcePrincipalAuth
77-
userDuck={userSelect}
78-
userGroupDuck={userGroupSelect}
79-
duck={duck}
80-
store={store}
81-
dispatch={dispatch}
82-
/>
83-
</FormItem>
84-
)}
75+
<FormItem
76+
label={'同步全局注册中心'}
77+
tips={'开启后该命名空间下全部服务将均注册至全局注册中心相同命名空间下'}
78+
>
79+
<Switch
80+
value={sync_to_global_registry.getValue()}
81+
onChange={v => sync_to_global_registry.setValue(v)}
82+
></Switch>
83+
</FormItem>
8584
<FormItem label={'服务可见性'} tips={'当前命名空间下的服务被允许可见的命名空间列表'} required>
8685
<section style={{ marginBottom: '15px' }}>
8786
<RadioGroup
@@ -111,6 +110,17 @@ const CreateForm = purify(function CreateForm(props: DuckCmpProps<Duck>) {
111110
></SelectMultiple>
112111
)}
113112
</FormItem>
113+
{options.authOpen && (
114+
<FormItem label={'授权'}>
115+
<ResourcePrincipalAuth
116+
userDuck={userSelect}
117+
userGroupDuck={userGroupSelect}
118+
duck={duck}
119+
store={store}
120+
dispatch={dispatch}
121+
/>
122+
</FormItem>
123+
)}
114124
</>
115125
)}
116126
</>

web/src/polaris/namespace/operation/CreateDuck.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export default class CreateDuck extends FormDialog {
7070
remove_user_ids: removeUserIds,
7171
remove_group_ids: removeGroupIds,
7272
service_export_to,
73+
sync_to_global_registry: values.sync_to_global_registry,
7374
},
7475
]),
7576
)
@@ -83,6 +84,7 @@ export default class CreateDuck extends FormDialog {
8384
user_ids: userIds,
8485
group_ids: groupIds,
8586
service_export_to,
87+
sync_to_global_registry: values.sync_to_global_registry,
8688
},
8789
]),
8890
)
@@ -169,6 +171,7 @@ export interface Values {
169171
groupIds: string[]
170172
service_export_to?: string[]
171173
visibilityMode?: string
174+
sync_to_global_registry: boolean
172175
}
173176
class CreateForm extends Form {
174177
Values: Values

web/src/polaris/service/operation/Create.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,6 @@ const CreateForm = purify(function CreateForm(props: DuckCmpProps<Duck>) {
104104
</Button>
105105
{showAdvance && (
106106
<>
107-
{options.authOpen && (
108-
<FormItem label={'授权'}>
109-
<ResourcePrincipalAuth
110-
userDuck={userSelect}
111-
userGroupDuck={userGroupSelect}
112-
duck={duck}
113-
store={store}
114-
dispatch={dispatch}
115-
/>
116-
</FormItem>
117-
)}
118107
<FormItem
119108
label={'可见性'}
120109
tips={'当前服务允许可见的命名空间列表,当与命名空间的服务可见性冲突时,优先使用该选项配置'}
@@ -148,6 +137,17 @@ const CreateForm = purify(function CreateForm(props: DuckCmpProps<Duck>) {
148137
></SelectMultiple>
149138
)}
150139
</FormItem>
140+
{options.authOpen && (
141+
<FormItem label={'授权'}>
142+
<ResourcePrincipalAuth
143+
userDuck={userSelect}
144+
userGroupDuck={userGroupSelect}
145+
duck={duck}
146+
store={store}
147+
dispatch={dispatch}
148+
/>
149+
</FormItem>
150+
)}
151151
</>
152152
)}
153153
</>

web/src/polaris/service/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface Namespace {
3232
total_health_instance_count?: number
3333
total_instance_count?: number
3434
service_export_to?: string[]
35+
sync_to_global_registry: boolean
3536
}
3637

3738
export const READ_ONLY_NAMESPACE = BuildConfig.readonlyNamespace

0 commit comments

Comments
 (0)