Skip to content

Commit

Permalink
Revert "feat: 适配全局注册中心"
Browse files Browse the repository at this point in the history
This reverts commit 67ba183.
  • Loading branch information
tingfuyeh committed Nov 8, 2024
1 parent 67ba183 commit bf71fbf
Show file tree
Hide file tree
Showing 21 changed files with 90 additions and 405 deletions.
17 changes: 3 additions & 14 deletions web/src/polaris/administration/breaker/faultDetect/getColumns.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import * as React from 'react'
import FaultDetectDuck from './PageDuck'
import { Text, Copy, Bubble, Icon } from 'tea-component'
import { Text, Copy } from 'tea-component'
import { Column } from '@src/polaris/common/ducks/GridPage'
import Action from '@src/polaris/common/duckComponents/grid/Action'
import { DuckCmpProps } from 'saga-duck'
import router from '@src/polaris/common/util/router'
import { FaultDetectRule } from './types'
import { disableDeleteTip } from '@src/polaris/service/getColumns'
import { checkGlobalRegistry } from '../getColumns'

export default (props: DuckCmpProps<FaultDetectDuck>): Column<FaultDetectRule>[] => {
const {
Expand All @@ -27,14 +25,7 @@ export default (props: DuckCmpProps<FaultDetectDuck>): Column<FaultDetectRule>[]
<Copy text={x.id} />
</Text>
<br />
<Text>
{x.name}
{checkGlobalRegistry(x) && (
<Bubble content={disableDeleteTip}>
<Icon type='convertip--blue' />
</Bubble>
)}
</Text>
<Text>{x.name}</Text>
</>
)
},
Expand Down Expand Up @@ -88,16 +79,14 @@ export default (props: DuckCmpProps<FaultDetectDuck>): Column<FaultDetectRule>[]
key: 'action',
header: '操作',
render: x => {
const hasGlobalRegistry = checkGlobalRegistry(x)
return (
<React.Fragment>
<Action
disabled={!x.editable || hasGlobalRegistry}
disabled={!x.editable}
text={'编辑'}
fn={() => {
router.navigate(`/faultDetect-create?id=${x.id}`)
}}
tip={hasGlobalRegistry ? disableDeleteTip : '编辑'}
/>
<Action
disabled={x.deleteable === false}
Expand Down
26 changes: 4 additions & 22 deletions web/src/polaris/administration/breaker/getColumns.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import * as React from 'react'
import CircuitBreakerDuck from './PageDuck'
import { Text, Copy, Bubble, Icon } from 'tea-component'
import { Text, Copy } from 'tea-component'
import { Column } from '@src/polaris/common/ducks/GridPage'
import Action from '@src/polaris/common/duckComponents/grid/Action'
import { checkRuleType, CircuitBreakerRule } from './types'
import { DuckCmpProps } from 'saga-duck'
import router from '@src/polaris/common/util/router'
import { LimitMethodTypeMap } from '../accessLimiting/types'
import { disableDeleteTip } from '@src/polaris/service/getColumns'

export const checkGlobalRegistry = x => {
const hasSyncGlobal = Object.entries(x.metadata).find(
([key, value]) => key === 'MetadataKeySyncFromLocalRegistry' && value === 'internal-sync-from-local-registry',
)
return !!hasSyncGlobal
}

export default (props: DuckCmpProps<CircuitBreakerDuck>): Column<CircuitBreakerRule>[] => {
const {
Expand All @@ -34,14 +26,7 @@ export default (props: DuckCmpProps<CircuitBreakerDuck>): Column<CircuitBreakerR
<Copy text={x.id} />
</Text>
<br />
<Text>
{x.name}
{checkGlobalRegistry(x) && (
<Bubble content={disableDeleteTip}>
<Icon type='convertip--blue' />
</Bubble>
)}
</Text>
<Text>{x.name}</Text>
</>
)
},
Expand Down Expand Up @@ -108,25 +93,22 @@ export default (props: DuckCmpProps<CircuitBreakerDuck>): Column<CircuitBreakerR
key: 'action',
header: '操作',
render: x => {
const hasGlobalRegistry = checkGlobalRegistry(x)
return (
<React.Fragment>
<Action
disabled={!x.editable || hasGlobalRegistry}
disabled={!x.editable}
text={x.enable ? '禁用' : '启用'}
fn={() => {
dispatch(creators.toggle(x))
}}
tip={hasGlobalRegistry ? disableDeleteTip : ''}
/>
<Action
disabled={!x.editable || hasGlobalRegistry}
disabled={!x.editable}
text={'编辑'}
fn={() => {
const type = checkRuleType(x?.level)
router.navigate(`/circuitBreaker-create?id=${x.id}&type=${type}`)
}}
tip={hasGlobalRegistry ? disableDeleteTip : ''}
/>
<Action
disabled={x.deleteable === false}
Expand Down
1 change: 0 additions & 1 deletion web/src/polaris/administration/breaker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export interface CircuitBreakerRule {
etime?: string
editable: boolean
deleteable: boolean
metadata?: Record<string, string>
}
export interface ErrorCondition {
inputType: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import * as React from 'react'
import AccessLimitingDuck from './PageDuck'
import { Text, Copy, Bubble, Icon } from 'tea-component'
import { Text, Copy } from 'tea-component'
import { Column } from '@src/polaris/common/ducks/GridPage'
import Action from '@src/polaris/common/duckComponents/grid/Action'
import { Dispatch } from 'redux'
import { CustomRoute } from './model'
import { SwitchStatusAction } from '../../accessLimiting/types'
import { Link } from 'react-router-dom'
import { disableDeleteTip } from '@src/polaris/service/getColumns'
import { checkGlobalRegistry } from '../../breaker/getColumns'

export default (
{ creators, selector }: AccessLimitingDuck,
Expand All @@ -29,14 +27,7 @@ export default (
<Copy text={x.id} />
</Text>
<br />
<Text>
{x.name}
{checkGlobalRegistry(x) && (
<Bubble content={disableDeleteTip}>
<Icon type='convertip--blue' />
</Bubble>
)}
</Text>
<Text>{x.name}</Text>
</>
),
},
Expand Down Expand Up @@ -102,13 +93,11 @@ export default (
key: 'action',
header: '操作',
render: x => {
const hasGlobalRegistry = checkGlobalRegistry(x)
const actions: {
id: string
text: string
fn: (dispatch?: Dispatch<any>, e?) => void
disabled: boolean
tip?: string
}[] = [
{
id: 'switchStatus',
Expand All @@ -117,17 +106,15 @@ export default (
const swtichStatusAction = x.enable ? SwitchStatusAction.disable : SwitchStatusAction.start
dispatch(creators.switchStatus(x.id, x.name, swtichStatusAction))
},
disabled: !x.editable || hasGlobalRegistry,
tip: hasGlobalRegistry ? disableDeleteTip : '',
disabled: !x.editable,
},
{
id: 'modify',
text: '编辑',
fn: dispatch => {
dispatch(creators.modify(x))
},
disabled: !x.editable || hasGlobalRegistry,
tip: hasGlobalRegistry ? disableDeleteTip : '',
disabled: !x.editable,
},
{
id: 'remove',
Expand All @@ -141,7 +128,7 @@ export default (
return (
<React.Fragment>
{actions.map(action => (
<Action disabled={action.disabled} key={action.id} text={action.text} fn={action.fn} tip={action.tip} />
<Action disabled={action.disabled} key={action.id} text={action.text} fn={action.fn} />
))}
</React.Fragment>
)
Expand Down
4 changes: 1 addition & 3 deletions web/src/polaris/common/util/checkFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export const checkFeatureKey = (feature: Feature[], key: string) => {
export async function checkFeatureValid(featureKey) {
const feature = await cacheCheckFeature()
if (feature.length === 0) return true
const check = feature.find(item => item.name === featureKey)
if (!check) return true
return check?.display === FeatureDisplayType.visible
return feature.find(item => item.name === featureKey)?.display === FeatureDisplayType.visible
}
export function useCheckFeatureValid(features: string[] = []) {
const [result, setResult] = React.useState([] as Feature[])
Expand Down
34 changes: 0 additions & 34 deletions web/src/polaris/common/util/serverConfig.ts

This file was deleted.

15 changes: 1 addition & 14 deletions web/src/polaris/namespace/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Justify, Table, Button, SearchBox, Card } from 'tea-component'
import GridPageGrid from '../common/duckComponents/GridPageGrid'
import GridPagePagination from '../common/duckComponents/GridPagePagination'
import BasicLayout from '../common/components/BaseLayout'
import { useServerConfig } from '../common/util/serverConfig'

insertCSS(
'service',
Expand All @@ -32,8 +31,6 @@ export default function ServicePage(props: DuckCmpProps<NamespaceDuck>) {
const { selectors } = duck
const columns = getColumns(props)
const handlers = getHandlers(props)
const multiRegConfig = useServerConfig('multiregistries')
const multiRegConfigEnabled = multiRegConfig.open
return (
<BasicLayout title={'命名空间'} store={store} selectors={duck.selectors} header={<></>}>
<Table.ActionPanel>
Expand All @@ -58,17 +55,7 @@ export default function ServicePage(props: DuckCmpProps<NamespaceDuck>) {
/>
</Table.ActionPanel>
<Card>
<GridPageGrid
duck={duck}
dispatch={dispatch}
store={store}
columns={columns.filter(item => {
if (item.key === 'sync_to_global_registry') {
return multiRegConfigEnabled
}
return true
})}
/>
<GridPageGrid duck={duck} dispatch={dispatch} store={store} columns={columns} />
<GridPagePagination duck={duck} dispatch={dispatch} store={store} />
</Card>
</BasicLayout>
Expand Down
32 changes: 9 additions & 23 deletions web/src/polaris/namespace/getColumns.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
import * as React from 'react'
import { DuckCmpProps } from 'saga-duck'
import NamespacePageDuck, { NamespaceItem } from './PageDuck'
import { Bubble, Icon, Text } from 'tea-component'
import { Bubble, Text } from 'tea-component'
import { Column } from '../common/ducks/GridPage'
import Action from '../common/duckComponents/grid/Action'
import { CheckVisibilityMode, VisibilityModeMap } from '../service/operation/CreateDuck'
import { disableDeleteTip } from '../service/getColumns'

export default ({ duck: { creators } }: DuckCmpProps<NamespacePageDuck>): Column<NamespaceItem>[] => [
{
key: 'name',
header: '名称',
render: x => (
<Text>
{x.name}
{x.sync_to_global_registry && (
<Bubble content={disableDeleteTip}>
<Icon type='convertip--blue' />
</Bubble>
)}
</Text>
),
},
{
key: 'sync_to_global_registry',
header: '同步全局注册中心',
render: x => <Text>{x.sync_to_global_registry ? '开启' : '关闭' || '-'}</Text>,
render: x => <Text>{x.name}</Text>,
},
{
key: 'service_export_to',
Expand Down Expand Up @@ -56,7 +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 Expand Up @@ -92,11 +82,7 @@ export default ({ duck: { creators } }: DuckCmpProps<NamespacePageDuck>): Column
render: x => {
return (
<React.Fragment>
<Action
fn={dispatch => dispatch(creators.edit(x))}
disabled={!x.editable || x.sync_to_global_registry}
tip={x.sync_to_global_registry ? disableDeleteTip : '编辑'}
>
<Action fn={dispatch => dispatch(creators.edit(x))} disabled={!x.editable} tip={'编辑'}>
{'编辑'}
</Action>
<Action fn={dispatch => dispatch(creators.remove(x))} disabled={x.deleteable === false} tip={'删除'}>
Expand Down
Loading

0 comments on commit bf71fbf

Please sign in to comment.