Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add enum 'update' in commit api action field #153

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,19 @@ const PipelineEditor = (props: IYmlEditorProps) => {
const commitData = (commitContent: string, values: any) => {
const { path } = tree;
const { branch, message: commitMsg } = values;
const data = {

commit({
branch,
message: commitMsg || `Update ${fileName}`,
actions: [
{
content: commitContent,
path,
action: 'add',
action: 'update',
pathType: 'blob',
},
],
};

commit(data).then(() => {
}).then(() => {
onCancel();
message.success(i18n.t('application:modify file successfully'));
getRepoBlob();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,19 @@ const PipelineConfigDetail = (props: IProps) => {
const onUpdateYml = (ymlStr: string) => {
const fileName = caseDetail.name;
const { branch, path } = getBranchPath(caseDetail);
const data = {

return commit({
branch,
message: `Update ${fileName}`,
actions: [
{
content: ymlStr,
path,
action: 'add',
action: 'update',
pathType: 'blob',
},
],
};

return commit(data).then(() => {
}).then(() => {
getTreeNodeDetailNew({ id: nodeId, ...scopeParams });
if (recordRef.current && recordRef.current.reload) {
recordRef.current.reload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const AddPipelineYml = () => {
if (error) {
return;
}
const data = {
commit({
...values,
actions: [
{
Expand All @@ -146,8 +146,7 @@ const AddPipelineYml = () => {
pathType: 'blob',
},
],
};
commit(data).then((res: any) => {
}).then((res: any) => {
if (res.success) {
cancelEdit();
message.success(i18n.t('application:create file successfully'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,18 @@ export const AuditTemplateManager = () => {
});

const handleSubmit = (content: string) => {
const data = {
commit({
actions: [
{
action: 'add',
action: 'update',
content,
path: 'audit/template.json',
pathType: 'blob',
},
],
branch,
message: 'Update template.json',
};
commit(data).then((res) => {
}).then((res) => {
if (res.success) {
message.success(i18n.t('application:update file successfully'));
getRepoBlob();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,21 @@ const RepoEditor = ({ autoHeight, maxLines, ops, isDiceOrPipelineFile, name, blo
}
}

form.validateFields((error: Error, values: Pick<REPOSITORY.Commit, 'message'| 'branch'>) => {
form.validateFields((error: Error, values: Pick<REPOSITORY.Commit, 'message' | 'branch'>) => {
if (error) {
return;
}
const data = {
commit({
...values,
actions: [
{
action: 'add',
action: isAddMode ? 'add' : 'update',
content: state.value,
path,
pathType: 'blob',
},
],
};
commit(data).then((res) => {
}).then((res) => {
if (res.success) {
changeMode({ editFile: false, addFile: false });
if (isAddMode) {
Expand Down Expand Up @@ -131,14 +130,14 @@ const RepoEditor = ({ autoHeight, maxLines, ops, isDiceOrPipelineFile, name, blo
name: 'branch',
type: 'select',
initialValue: branch || 'master',
options: branches.map((a:string) => ({ name: a, value: a })),
options: branches.map((a: string) => ({ name: a, value: a })),
itemProps: {
placeholder: i18n.t('application:submit branch'),
disabled: true,
},
},
{
getComp: ({ form }: {form: any}) => (
getComp: ({ form }: { form: any }) => (
<div>
<Button type="primary" onClick={() => handleSubmit(form)}>
{i18n.t('application:save')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const RepoFileContainerComp = (props: IProps) => {
}, [isDiceOrPipelineFile, getRepoBlobLoading, parsePipelineYmlStructureLoading, pipelineYmlStructure, updater]);

const handleDelete = (values: Pick<REPOSITORY.Commit, 'message'| 'branch'>) => {
const data = {
commit({
...values,
actions: [
{
Expand All @@ -83,8 +83,7 @@ const RepoFileContainerComp = (props: IProps) => {
pathType: 'blob',
},
],
};
commit(data).then((res) => {
}).then((res) => {
toggleModal(false);
if (res.success) {
message.success(i18n.t('application:delete file successfully'));
Expand Down Expand Up @@ -193,19 +192,18 @@ const RepoFileContainerComp = (props: IProps) => {
const { path } = tree;
const { branch } = getInfoFromRefName(tree.refName);

const data = {
commit({
branch,
message: `Update ${path}`,
actions: [
{
action: 'add',
action: 'update',
content: ymlContent,
path,
pathType: 'blob',
},
],
};
commit(data).then((res) => {
}).then((res) => {
if (res.success) {
changeMode({ editFile: false, addFile: false });
message.success(i18n.t('application:modify file successfully'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class RepoMRForm extends React.PureComponent<IProps, IState> {
const { templateConfig, getTemplateConfig } = this.props;
const { tplContent } = this.state;
const { branch, path } = templateConfig;
const data = {
this.props.commit({
message: `Add merge request template: ${values.name}`,
branch,
actions: [
Expand All @@ -407,8 +407,7 @@ class RepoMRForm extends React.PureComponent<IProps, IState> {
pathType: 'blob',
},
],
};
this.props.commit(data).then((res: any) => {
}).then((res: any) => {
if (res.success) {
message.success(i18n.t('template was created successfully'));
this.toggleTplModel(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ const PureRepoNavOperation = () => {
return fieldsList;
};

const handleAdd = ({ dirName, ...values }: {dirName: string}) => {
const handleAdd = ({ dirName, ...values }: { dirName: string, message: string, branch: string }) => {
const path = `${tree.path ? `${tree.path}/` : tree.path}${dirName}`;
const data = {
commit({
...values,
actions: [
{
Expand All @@ -83,8 +83,7 @@ const PureRepoNavOperation = () => {
pathType: 'tree',
},
],
};
commit(data).then((res) => {
}).then((res) => {
toggleModal(false);
if (res.success) {
getRepoTree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ const YmlEditor = (props: IProps) => {

const handleDelete = (values: any) => {
const { path } = tree;
const data = {
commit({
...values,
actions: [
{
Expand All @@ -346,8 +346,7 @@ const YmlEditor = (props: IProps) => {
pathType: 'blob',
},
],
};
commit(data).then((res: any) => {
}).then((res: any) => {
toggleModal(false);
if (res.success) {
message.success(i18n.t('application:delete file successfully'));
Expand Down Expand Up @@ -663,21 +662,20 @@ const YmlEditor = (props: IProps) => {
const commitData = (commitContent: string, values: any) => {
const { path } = tree;
const { branch, message: commitMsg } = values;
const data = {
updater.openDrawer(false);

commit({
branch,
message: commitMsg || `Update ${fileName}`,
actions: [
{
content: commitContent,
path,
action: 'add',
action: 'update',
pathType: 'blob',
},
],
};
updater.openDrawer(false);

commit(data).then(() => {
}).then(() => {
changeMode({
editFile: false,
addFile: false,
Expand Down
2 changes: 1 addition & 1 deletion shell/app/modules/application/types/repo.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ declare namespace REPOSITORY {
}

interface CommitAction {
action: string;
action: 'add' | 'update' | 'delete';
content?: string;
path: string,
pathType: string,
Expand Down