Skip to content

Commit

Permalink
feat(console): workload 设置更新策略和更新调度策略白屏化 (#2270)
Browse files Browse the repository at this point in the history
* feat(console): 添加设置更新策略到workload

* feat(console): workload更新组件优化

* feat(console): 添加节点调度的代码

* feat(console): 节点调度接口调试完成

* feat(console): 添加必要的interface

* fix(console): 修复冲突
  • Loading branch information
jo-hnny committed Apr 28, 2023
1 parent 2496209 commit 145e2f2
Show file tree
Hide file tree
Showing 33 changed files with 3,111 additions and 132 deletions.
11 changes: 8 additions & 3 deletions web/console/config/resource/k8sConfig/cronjobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
import { t } from '@tencent/tea-app/lib/i18n';
import { DetailField, DetailInfo } from '../../../src/modules/common/models';
import {
defaulNotExistedValue,
commonActionField,
commonDetailInfo,
dataFormatConfig,
defaulNotExistedValue,
generateResourceInfo
} from '../common';
import { DetailField, DetailInfo } from '../../../src/modules/common/models';
import { t, Trans } from '@tencent/tea-app/lib/i18n';

const displayField = Object.assign(
{},
Expand Down Expand Up @@ -74,6 +74,11 @@ const displayField = Object.assign(
name: t('删除'),
actionType: 'delete',
isInMoreOp: false
},
{
name: t('更新调度策略'),
actionType: 'modifyNodeAffinity',
isInMoreOp: true
}
]
}
Expand Down
20 changes: 15 additions & 5 deletions web/console/config/resource/k8sConfig/daemonset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
import { t } from '@tencent/tea-app/lib/i18n';
import { DetailField, DetailInfo } from '../../../src/modules/common/models';
import { t, Trans } from '@tencent/tea-app/lib/i18n';

import {
commonDisplayField,
defaulNotExistedValue,
commonActionField,
commonDetailInfo,
commonDisplayField,
dataFormatConfig,
workloadCommonTabList,
generateResourceInfo
defaulNotExistedValue,
generateResourceInfo,
workloadCommonTabList
} from '../common';

/** displayField,列表展示的细节 */
Expand Down Expand Up @@ -58,6 +58,16 @@ const displayField = Object.assign({}, commonDisplayField, {
name: t('删除'),
actionType: 'delete',
isInMoreOp: false
},
{
name: t('设置更新策略'),
actionType: 'modifyStrategy',
isInMoreOp: true
},
{
name: t('更新调度策略'),
actionType: 'modifyNodeAffinity',
isInMoreOp: true
}
]
}
Expand Down
86 changes: 48 additions & 38 deletions web/console/config/resource/k8sConfig/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
import { DetailField, DisplayField, DetailInfo } from '../../../src/modules/common/models';
import { t } from '@tencent/tea-app/lib/i18n';
import { DetailField, DetailInfo, DisplayField } from '../../../src/modules/common/models';
import { cloneDeep } from '../../../src/modules/common/utils';
import {
commonDisplayField,
defaulNotExistedValue,
workloadCommonTabList,
commonActionField,
commonDetailInfo,
commonDisplayField,
dataFormatConfig,
defaulNotExistedValue,
generateResourceInfo,
workloadCommonTabList
} from '../common';
import { cloneDeep } from '../../../src/modules/common/utils';
import { t, Trans } from '@tencent/tea-app/lib/i18n';

/** resource table 当中展示的数据
* commonDisplayField 使用公共的展示
Expand All @@ -38,7 +38,7 @@ const userDefinedDisplayField: DisplayField = {
dataFormat: dataFormatConfig['replicas'],
width: '20%',
headTitle: t('运行/期望Pod数量'),
noExsitedValue: '0',
noExsitedValue: '0'
},
operator: {
dataField: [''],
Expand All @@ -48,27 +48,37 @@ const userDefinedDisplayField: DisplayField = {
tips: '',
operatorList: [
{
name: t('更新实例数量页'),
name: t('更新Pod数量'),
actionType: 'modifyPod',
isInMoreOp: false,
isInMoreOp: false
},
{
name: t('更新镜像'),
actionType: 'modifyRegistry',
isInMoreOp: false,
isInMoreOp: false
},
{
name: t('设置更新策略'),
actionType: 'modifyStrategy',
isInMoreOp: true
},
{
name: t('更新调度策略'),
actionType: 'modifyNodeAffinity',
isInMoreOp: true
},
{
name: t('编辑YAML'),
actionType: 'modify',
isInMoreOp: true,
isInMoreOp: true
},
{
name: t('删除'),
actionType: 'delete',
isInMoreOp: true,
},
],
},
isInMoreOp: true
}
]
}
};

const displayField = Object.assign({}, commonDisplayField, userDefinedDisplayField);
Expand All @@ -85,35 +95,35 @@ const detailBasicInfo: DetailInfo = {
dataField: ['name'],
dataFormat: dataFormatConfig['text'],
label: t('名称'),
noExsitedValue: defaulNotExistedValue,
noExsitedValue: defaulNotExistedValue
},
namespace: {
dataField: ['namespace'],
dataFormat: dataFormatConfig['text'],
label: 'Namespace',
noExsitedValue: defaulNotExistedValue,
noExsitedValue: defaulNotExistedValue
},
description: {
dataField: ['annotations.description'],
dataFormat: dataFormatConfig['text'],
label: t('描述'),
noExsitedValue: defaulNotExistedValue,
noExsitedValue: defaulNotExistedValue
},
createdTime: {
dataField: ['creationTimestamp'],
dataFormat: dataFormatConfig['time'],
label: t('创建时间'),
tips: '',
noExsitedValue: defaulNotExistedValue,
noExsitedValue: defaulNotExistedValue
},
label: {
dataField: ['labels'],
dataFormat: dataFormatConfig['labels'],
label: 'Labels',
tips: '',
noExsitedValue: defaulNotExistedValue,
},
},
noExsitedValue: defaulNotExistedValue
}
}
},
spec: {
dataField: ['spec'],
Expand All @@ -123,28 +133,28 @@ const detailBasicInfo: DetailInfo = {
dataFormat: dataFormatConfig['labels'],
label: 'Selector',
tips: '',
noExsitedValue: defaulNotExistedValue,
noExsitedValue: defaulNotExistedValue
},
updateStrategy: {
dataField: ['strategy.type'],
dataFormat: dataFormatConfig['text'],
label: t('更新策略'),
tips: '',
noExsitedValue: defaulNotExistedValue,
noExsitedValue: defaulNotExistedValue
},
replicas: {
dataField: ['replicas'],
dataFormat: dataFormatConfig['text'],
label: t('副本数'),
noExsitedValue: '0',
noExsitedValue: '0'
},
networkType: {
dataField: ['template', 'metadata', 'annotations', 'k8s.v1.cni.cncf.io/networks'],
dataFormat: dataFormatConfig['text'],
label: t('网络模式'),
noExsitedValue: '-',
},
},
noExsitedValue: '-'
}
}
},
status: {
dataField: ['status'],
Expand All @@ -153,22 +163,22 @@ const detailBasicInfo: DetailInfo = {
dataField: ['readyReplicas'],
dataFormat: dataFormatConfig['text'],
label: t('运行副本数'),
noExsitedValue: '0',
},
},
},
},
noExsitedValue: '0'
}
}
}
}
};

let tabList = cloneDeep(workloadCommonTabList);
const tabList = cloneDeep(workloadCommonTabList);
tabList.splice(1, 0, {
id: 'history',
label: t('修订历史'),
label: t('修订历史')
});
/** 详情页面的相关配置 */
const detailField: DetailField = {
tabList,
detailInfo: Object.assign({}, commonDetailInfo(), detailBasicInfo),
detailInfo: Object.assign({}, commonDetailInfo(), detailBasicInfo)
};

/** deployment的配置 */
Expand All @@ -177,11 +187,11 @@ export const deployment = (k8sVersion: string) => {
k8sVersion,
resourceName: 'deployment',
requestType: {
list: 'deployments',
list: 'deployments'
},
isRelevantToNamespace: true,
displayField,
actionField,
detailField,
detailField
});
};
22 changes: 16 additions & 6 deletions web/console/config/resource/k8sConfig/statefulset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
import { t } from '@tencent/tea-app/lib/i18n';
import { DetailField, DetailInfo } from '../../../src/modules/common/models';
import {
commonDisplayField,
defaulNotExistedValue,
commonActionField,
dataFormatConfig,
commonDetailInfo,
workloadCommonTabList,
generateResourceInfo
commonDisplayField,
dataFormatConfig,
defaulNotExistedValue,
generateResourceInfo,
workloadCommonTabList
} from '../common';
import { t, Trans } from '@tencent/tea-app/lib/i18n';

const displayField = Object.assign({}, commonDisplayField, {
runningReplicas: {
Expand Down Expand Up @@ -56,6 +56,16 @@ const displayField = Object.assign({}, commonDisplayField, {
name: t('删除'),
actionType: 'delete',
isInMoreOp: false
},
{
name: t('设置更新策略'),
actionType: 'modifyStrategy',
isInMoreOp: true
},
{
name: t('更新调度策略'),
actionType: 'modifyNodeAffinity',
isInMoreOp: true
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions web/console/helpers/Validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
import { Validation } from 'src/modules/common';
import { ControllerFieldState, UseFormStateReturn } from 'react-hook-form';
import { Validation } from 'src/modules/common';

export interface Rule {
/**标签名 */
Expand Down Expand Up @@ -159,10 +159,10 @@ export function getReactHookFormStatusWithMessage({
status?: 'error' | 'success';
message?: string;
} {
console.log('getReactHookFormStatus:', fieldState, formState);
if (!fieldState.isTouched && !fieldState.isDirty && !formState.isSubmitted) {
return {};
}

return fieldState.invalid
? {
status: 'error',
Expand Down
34 changes: 18 additions & 16 deletions web/console/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,30 @@
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
export { RouteState, Router } from './Router';
export { Validate, getReactHookFormStatusWithMessage, isValidateSuccess } from './Validator';
export * from './appUtil';
export { getCookie } from './cookieUtil';
export * from './csrf';
export * from './isInIframe';
export { dateFormatter } from './dateFormatter';
export { dateFormat } from './dateUtil';
export { downloadCrt, downloadKubeconfig, getKubectlConfig } from './downloadCrt';
export { ResetStoreAction, generateResetableReducer } from './reduxStore';
export { isValidateSuccess, Validate, getReactHookFormStatusWithMessage } from './Validator';
export { downloadCsv } from './downloadCsv';
export * from './format';
export { getScrollBarSize } from './getScrollBarSize';
export * from './path';
export {
ConsoleModuleMapProps,
Method,
operationResult,
reduceNetworkRequest,
reduceNetworkWorkflow,
operationResult,
Method,
requestMethodForAction,
ConsoleModuleMapProps,
setConsoleAPIAddress
} from './reduceNetwork';
export { dateFormatter } from './dateFormatter';
export { downloadCsv } from './downloadCsv';
export { Router, RouteState } from './Router';
export { ResetStoreAction, generateResetableReducer } from './reduxStore';
export { assureRegion } from './regionLint';
export { getScrollBarSize } from './getScrollBarSize';
export { dateFormat } from './dateUtil';
export * from './appUtil';
export { getCookie } from './cookieUtil';
export { reduceK8sQueryString, reduceK8sRestfulPath, reduceNs, parseQueryString, cutNsStartClusterId } from './urlUtil';
export * from './request';
export * from './format';
export * from './csrf';
export * from './isInIframe';
export { satisfyClusterVersion } from './satisfyClusterVersion';
export { cutNsStartClusterId, parseQueryString, reduceK8sQueryString, reduceK8sRestfulPath, reduceNs } from './urlUtil';
4 changes: 4 additions & 0 deletions web/console/helpers/path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function getParamByUrl(key: string) {
const searchParams = new URL(window.location.href)?.searchParams;
return searchParams?.get(key);
}
Loading

0 comments on commit 145e2f2

Please sign in to comment.