Skip to content

Commit

Permalink
modify git build model layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzm0809 committed Nov 6, 2023
1 parent 3822628 commit ec2bd42
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 63 deletions.
2 changes: 2 additions & 0 deletions dinky-web/src/locales/en-US/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default {
'button.recovery': 'Recovery',
'button.cancel': 'Cancel',
'button.finish': 'Finish',
'button.retry': 'Retry',
'button.rebuild': 'Re Build',
'button.back': 'Back',
'button.save': 'Save',
'button.delete': 'Delete',
Expand Down
2 changes: 2 additions & 0 deletions dinky-web/src/locales/zh-CN/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export default {
'button.confirm': '确定',
'button.cancel': '取消',
'button.finish': '完成',
'button.retry': '重试',
'button.rebuild': '重新构建',
'button.back': '返回',
'button.save': '保存',
'button.delete': '删除',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { DataSources } from '@/types/RegCenter/data';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

Expand All @@ -29,23 +29,27 @@ import { API_CONSTANTS } from '@/services/endpoints';
import { GitProject } from '@/types/RegCenter/data.d';
import { InitGitBuildStepsState } from '@/types/RegCenter/init.d';
import { GitBuildStepsState } from '@/types/RegCenter/state.d';
import { Modal } from 'antd';
import { l } from '@/utils/intl';
import { Button, Modal } from 'antd';
import React, { useEffect, useState } from 'react';

/**
* props
*/
type BuildStepsProps = {
onCancel: (flag?: boolean) => void;
onOk: (flag?: boolean) => void;
onReTry?: () => void;
onRebuild: () => void;
title: string;
showLog?: boolean;
values: Partial<GitProject>;
};

export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
/**
* extract props
*/
const { onCancel: handleModalVisible, title, values } = props;
const { onOk: handleModalVisible, onReTry, showLog = false, onRebuild, title, values } = props;
// todo: refactor this
const [buildStepState, setBuildStepState] = useState<GitBuildStepsState>(InitGitBuildStepsState);

Expand Down Expand Up @@ -88,7 +92,7 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
// type // 1是总状态 2是log 3是部分状态
// status // 0是失败 1是进行中 2 完成
let result = JSON.parse(e.data);
const { currentStep, type, data, status, history } = result;
const { currentStep, type, data, status } = result;
lastStep = currentStep;

if (type === 0) {
Expand Down Expand Up @@ -171,18 +175,45 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
handleModalVisible();
};

// todo: 重试需要实现在不关闭弹窗的情况下,重新构建, 目前是关闭弹窗,重新打开,重新构建
const handleReTry = () => {
onReTry?.();
};

const footerButtons = [
<Button
key={'retry'}
type={'primary'}
danger
hidden={!onReTry}
disabled={onReTry && Number(steps[currentStep]?.status) !== 2}
onClick={() => handleReTry()}
>
{l('button.retry')}
</Button>,
<Button
key={'rebuild'}
type={'dashed'}
loading={currentStep !== steps.length && percent !== 99}
onClick={() => onRebuild()}
>
{l('button.rebuild')}
</Button>,
<Button
key={'finish'}
type={showLog ? 'default' : 'primary'}
loading={currentStep !== steps.length && percent !== 99}
onClick={() => handleCancel()}
>
{showLog ? l('button.close') : l('button.finish')}
</Button>
];

/**
* render
*/
return (
<Modal
title={title}
width={'85%'}
open={true}
maskClosable={false}
onCancel={() => handleCancel()}
okButtonProps={{ style: { display: 'none' } }}
>
<Modal title={title} width={'85%'} open={true} maskClosable={false} footer={footerButtons}>
<AutoSteps
steps={steps}
percent={percent}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

Expand Down Expand Up @@ -352,6 +352,15 @@ const ProjectProTable: React.FC = () => {
return <Empty image={Empty.PRESENTED_IMAGE_DEFAULT} />;
};

/**
* re try build
* @param value
*/
const handleReTryBuild = async (value: Partial<GitProject>) => {
handleCancel();
await handleBuild(value);
};

/**
* render
*/
Expand Down Expand Up @@ -401,7 +410,9 @@ const ProjectProTable: React.FC = () => {
{gitProjectStatus.buildOpen && (
<BuildSteps
title={l('rc.gp.build')}
onCancel={handleCancel}
onOk={handleCancel}
onRebuild={() => handleReTryBuild(gitProjectStatus.value)}
onReTry={() => handleReTryBuild(gitProjectStatus.value)}
values={gitProjectStatus.value}
/>
)}
Expand All @@ -410,7 +421,9 @@ const ProjectProTable: React.FC = () => {
{gitProjectStatus.logOpen && (
<BuildSteps
title={l('rc.gp.log')}
onCancel={handleCancel}
onOk={handleCancel}
showLog={gitProjectStatus.logOpen}
onRebuild={() => handleReTryBuild(gitProjectStatus.value)}
values={gitProjectStatus.value}
/>
)}
Expand Down
28 changes: 15 additions & 13 deletions dinky-web/src/pages/RegCenter/GitProject/data.d.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export type BuildStepsState = {
key: number;
title: string;
status: string;
status: string; // 0-notStart(未开始) 1-process(进行中/构建中) 2-failed(构建失败) 3-success(构建成功)
description: string;
disabled: boolean;
onClick: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@

import { EditBtn } from '@/components/CallBackButton/EditBtn';
import { PopconfirmDeleteBtn } from '@/components/CallBackButton/PopconfirmDeleteBtn';
import { BackIcon } from '@/components/Icons/CustomIcons';
import UDFRegisterModal from '@/pages/RegCenter/UDF/components/UDFRegister/UDFRegisterModal';
import { API_CONSTANTS } from '@/services/endpoints';
import { UDFRegisterInfo, UDFRegisterInfoParent } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import { useRequest } from '@@/plugin-request';
import { SaveTwoTone } from '@ant-design/icons';
import { ProColumns } from '@ant-design/pro-components';
import ProTable, { ActionType } from '@ant-design/pro-table';
import React, { Key, useEffect, useRef, useState } from 'react';
Expand Down Expand Up @@ -182,6 +184,8 @@ const UDFRegister: React.FC<UDFRegisterProps> = (props) => {
editable={{
deleteText: false,
type: 'single',
saveText: <SaveTwoTone title={l('button.save')} />,
cancelText: <BackIcon title={l('button.back')} />,
editableKeys: udfRegisterState.editableKeys,
onChange: editableKeysChange,
onSave: async (_, row) => handleOnSave(row),
Expand Down

0 comments on commit ec2bd42

Please sign in to comment.