Skip to content

Commit

Permalink
Merge branch 'dev/poc'
Browse files Browse the repository at this point in the history
  • Loading branch information
tingfuyeh committed Oct 18, 2024
2 parents 08b43a1 + dcf6d38 commit 829e06f
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 46 deletions.
101 changes: 79 additions & 22 deletions web/src/polaris/administration/breaker/operations/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,26 @@ export default purify(function CustomRoutePage(props: DuckCmpProps<CreateDuck>)
<Card.Body title='主调服务'>
<Form style={{ padding: '0px', backgroundColor: 'inherit' }}>
<FormField field={sourceNamespace} label='命名空间' required>
<TeaSelect
value={sourceNamespace.getValue()}
<AutoComplete
options={[
{ text: '全部命名空间', value: '*', disabled: destinationNamespace.getValue() === '*' },
...(data?.namespaceList || []),
...new Set([
{
text: '全部命名空间',
value: '*',
disabled: destinationNamespace.getValue() === '*',
},
...(sourceNamespace.getValue()
? [
{
text: `(输入值)${sourceNamespace.getValue()}`,
value: sourceNamespace.getValue(),
},
]
: []),
...data?.namespaceList,
]),
]}
tips='没有匹配的命名空间名称'
onChange={value => {
if (value === '*') {
sourceNamespace.setValue('*')
Expand All @@ -170,13 +184,26 @@ export default purify(function CustomRoutePage(props: DuckCmpProps<CreateDuck>)
sourceNamespace.setValue(value)
sourceService.setValue('')
}}
searchable
type={'simulate'}
appearance={'button'}
matchButtonWidth
placeholder='请选择命名空间'
style={{ width: '80%', maxWidth: '600px' }}
/>
>
{ref => (
<TeaInput
ref={ref}
value={
sourceNamespace.getValue() === '*' ? '全部命名空间' : sourceNamespace.getValue()
}
onChange={value => {
if (value === '*') {
sourceNamespace.setValue('*')
sourceService.setValue('*')
return
}
sourceNamespace.setValue(value)
sourceService.setValue('')
}}
style={{ width: '80%', maxWidth: '600px' }}
/>
)}
</AutoComplete>
</FormField>
<FormField field={sourceService} label='服务名称' required>
<AutoComplete
Expand All @@ -203,6 +230,7 @@ export default purify(function CustomRoutePage(props: DuckCmpProps<CreateDuck>)
onChange={value => {
sourceService.setValue(value)
}}
disabled={sourceNamespace.getValue() === '*'}
style={{ width: '80%', maxWidth: '600px' }}
/>
)}
Expand All @@ -222,12 +250,26 @@ export default purify(function CustomRoutePage(props: DuckCmpProps<CreateDuck>)
<Card.Body title='被调服务'>
<Form style={{ padding: '0px', backgroundColor: 'inherit' }}>
<FormField field={destinationNamespace} label='命名空间' required>
<TeaSelect
value={destinationNamespace.getValue()}
<AutoComplete
options={[
{ text: '全部命名空间', value: '*', disabled: sourceNamespace.getValue() === '*' },
...(data?.namespaceList || []),
...new Set([
{
text: '全部命名空间',
value: '*',
disabled: sourceNamespace.getValue() === '*',
},
...(destinationNamespace.getValue()
? [
{
text: `(输入值)${destinationNamespace.getValue()}`,
value: destinationNamespace.getValue(),
},
]
: []),
...data?.namespaceList,
]),
]}
tips='没有匹配的命名空间名称'
onChange={value => {
if (value === '*') {
destinationNamespace.setValue('*')
Expand All @@ -237,13 +279,28 @@ export default purify(function CustomRoutePage(props: DuckCmpProps<CreateDuck>)
destinationNamespace.setValue(value)
destinationService.setValue('')
}}
searchable
type={'simulate'}
appearance={'button'}
matchButtonWidth
placeholder='请选择命名空间'
style={{ width: '80%', maxWidth: '600px' }}
/>
>
{ref => (
<TeaInput
ref={ref}
value={
destinationNamespace.getValue() === '*'
? '全部命名空间'
: destinationNamespace.getValue()
}
onChange={value => {
if (value === '*') {
destinationNamespace.setValue('*')
destinationService.setValue('*')
return
}
destinationNamespace.setValue(value)
destinationService.setValue('')
}}
style={{ width: '80%', maxWidth: '600px' }}
/>
)}
</AutoComplete>
</FormField>
<FormField field={destinationService} label='服务名称' required>
<AutoComplete
Expand Down
5 changes: 5 additions & 0 deletions web/src/polaris/namespace/getColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export default ({ duck: { creators } }: DuckCmpProps<NamespacePageDuck>): Column
)
},
},
{
key: 'sync_to_global_registry',
header: '同步全局注册中心',
render: x => <Text>{x.sync_to_global_registry ? '开启' : '关闭' || '-'}</Text>,
},
{
key: 'commnet',
header: '描述',
Expand Down
2 changes: 2 additions & 0 deletions web/src/polaris/namespace/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface CreateNamespaceParams {
user_ids?: string[]
group_ids?: string[]
service_export_to?: string[]
sync_to_global_registry?: boolean
}
export interface CreateNamespaceResult {
namespace: Namespace
Expand All @@ -29,6 +30,7 @@ export interface ModifyNamespaceParams {
remove_user_ids?: string[]
remove_group_ids?: string[]
service_export_to?: string[]
sync_to_global_registry?: boolean
}
export interface ModifyNamespaceResult {
size: number
Expand Down
36 changes: 23 additions & 13 deletions web/src/polaris/namespace/operation/Create.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { DuckCmpProps, purify } from 'saga-duck'
import Duck from './CreateDuck'
import { Form, Button, Icon, FormItem, Radio, RadioGroup, SelectMultiple } from 'tea-component'
import { Form, Button, Icon, FormItem, Radio, RadioGroup, SelectMultiple, Switch } from 'tea-component'
import Dialog from '@src/polaris/common/duckComponents/Dialog'
import FormField from '@src/polaris/common/duckComponents/form/Field'
import Input from '@src/polaris/common/duckComponents/form/Input'
Expand Down Expand Up @@ -37,11 +37,12 @@ const CreateForm = purify(function CreateForm(props: DuckCmpProps<Duck>) {
} = duck

const formApi = form.getAPI(store, dispatch)
const { name, comment, service_export_to, visibilityMode } = formApi.getFields([
const { name, comment, service_export_to, visibilityMode, sync_to_global_registry } = formApi.getFields([
'name',
'comment',
'service_export_to',
'visibilityMode',
'sync_to_global_registry',
])
const options = selectors.options(store)
const [showAdvance, setShowAdvance] = React.useState(false)
Expand Down Expand Up @@ -71,17 +72,15 @@ const CreateForm = purify(function CreateForm(props: DuckCmpProps<Duck>) {

{showAdvance && (
<>
{options.authOpen && (
<FormItem label={'授权'}>
<ResourcePrincipalAuth
userDuck={userSelect}
userGroupDuck={userGroupSelect}
duck={duck}
store={store}
dispatch={dispatch}
/>
</FormItem>
)}
<FormItem
label={'同步全局注册中心'}
tips={'开启后该命名空间下全部服务将均注册至全局注册中心相同命名空间下'}
>
<Switch
value={sync_to_global_registry.getValue()}
onChange={v => sync_to_global_registry.setValue(v)}
></Switch>
</FormItem>
<FormItem label={'服务可见性'} tips={'当前命名空间下的服务被允许可见的命名空间列表'} required>
<section style={{ marginBottom: '15px' }}>
<RadioGroup
Expand Down Expand Up @@ -111,6 +110,17 @@ const CreateForm = purify(function CreateForm(props: DuckCmpProps<Duck>) {
></SelectMultiple>
)}
</FormItem>
{options.authOpen && (
<FormItem label={'授权'}>
<ResourcePrincipalAuth
userDuck={userSelect}
userGroupDuck={userGroupSelect}
duck={duck}
store={store}
dispatch={dispatch}
/>
</FormItem>
)}
</>
)}
</>
Expand Down
3 changes: 3 additions & 0 deletions web/src/polaris/namespace/operation/CreateDuck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default class CreateDuck extends FormDialog {
remove_user_ids: removeUserIds,
remove_group_ids: removeGroupIds,
service_export_to,
sync_to_global_registry: values.sync_to_global_registry,
},
]),
)
Expand All @@ -83,6 +84,7 @@ export default class CreateDuck extends FormDialog {
user_ids: userIds,
group_ids: groupIds,
service_export_to,
sync_to_global_registry: values.sync_to_global_registry,
},
]),
)
Expand Down Expand Up @@ -169,6 +171,7 @@ export interface Values {
groupIds: string[]
service_export_to?: string[]
visibilityMode?: string
sync_to_global_registry: boolean
}
class CreateForm extends Form {
Values: Values
Expand Down
22 changes: 11 additions & 11 deletions web/src/polaris/service/operation/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,6 @@ const CreateForm = purify(function CreateForm(props: DuckCmpProps<Duck>) {
</Button>
{showAdvance && (
<>
{options.authOpen && (
<FormItem label={'授权'}>
<ResourcePrincipalAuth
userDuck={userSelect}
userGroupDuck={userGroupSelect}
duck={duck}
store={store}
dispatch={dispatch}
/>
</FormItem>
)}
<FormItem
label={'可见性'}
tips={'当前服务允许可见的命名空间列表,当与命名空间的服务可见性冲突时,优先使用该选项配置'}
Expand Down Expand Up @@ -148,6 +137,17 @@ const CreateForm = purify(function CreateForm(props: DuckCmpProps<Duck>) {
></SelectMultiple>
)}
</FormItem>
{options.authOpen && (
<FormItem label={'授权'}>
<ResourcePrincipalAuth
userDuck={userSelect}
userGroupDuck={userGroupSelect}
duck={duck}
store={store}
dispatch={dispatch}
/>
</FormItem>
)}
</>
)}
</>
Expand Down
1 change: 1 addition & 0 deletions web/src/polaris/service/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface Namespace {
total_health_instance_count?: number
total_instance_count?: number
service_export_to?: string[]
sync_to_global_registry: boolean
}

export const READ_ONLY_NAMESPACE = BuildConfig.readonlyNamespace

0 comments on commit 829e06f

Please sign in to comment.