Skip to content

Commit

Permalink
Add Rollback button for user to quickly rollback change
Browse files Browse the repository at this point in the history
We currently only support rollback when issue is in the closed state and the issue type is schema update.

We will create a rollback issue in the reverse order of the original issue for the schema updated tasks having the rollback statement
  • Loading branch information
tianzhou committed Aug 30, 2021
1 parent 2ebd43b commit b124888
Show file tree
Hide file tree
Showing 4 changed files with 270 additions and 60 deletions.
16 changes: 15 additions & 1 deletion frontend/src/components/IssueStatusTransitionButtonGroup.vue
Expand Up @@ -85,6 +85,11 @@
{{ transition.buttonName }}
</button>
</template>
<template v-if="allowRollback">
<button type="button" class="btn-primary" @click.prevent="doRollback">
Rollback
</button>
</template>
</div>
</template>
</template>
Expand Down Expand Up @@ -170,12 +175,16 @@ export type IssueContext = {
export default {
name: "IssueStatusTransitionButtonGroup",
emits: ["create", "change-issue-status", "change-task-status"],
emits: ["create", "rollback", "change-issue-status", "change-task-status"],
props: {
create: {
required: true,
type: Boolean,
},
allowRollback: {
required: true,
type: Boolean,
},
issue: {
required: true,
type: Object as PropType<Issue | IssueCreate>,
Expand Down Expand Up @@ -424,6 +433,10 @@ export default {
emit("create");
};
const doRollback = () => {
emit("rollback");
};
return {
updateStatusModalState,
applicableTaskStatusTransitionList,
Expand All @@ -435,6 +448,7 @@ export default {
doIssueStatusTransition,
allowCreate,
doCreate,
doRollback,
};
},
};
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/plugins/issue/DatabaseSchemaUpdateTemplate.ts
Expand Up @@ -10,7 +10,7 @@ const template: IssueTemplate = {
const stageList: StageCreate[] = [];
for (let i = 0; i < ctx.databaseList.length; i++) {
stageList.push({
name: `[${ctx.databaseList[i].instance.environment.name}] ${ctx.databaseList[i].name}`,
name: `[${ctx.environmentList[i].name}] ${ctx.databaseList[i].name}`,
environmentId: ctx.environmentList[i].id,
taskList: [
{
Expand All @@ -22,8 +22,10 @@ const template: IssueTemplate = {
type: "bb.task.database.schema.update",
instanceId: ctx.databaseList[i].instance.id,
databaseId: ctx.databaseList[i].id,
statement: "",
rollbackStatement: "",
statement: ctx.statementList ? ctx.statementList[i] : "",
rollbackStatement: ctx.rollbackStatementList
? ctx.rollbackStatementList[i]
: "",
},
],
});
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/plugins/types.ts
@@ -1,5 +1,5 @@
import { Store } from "vuex";
import { Environment, Principal, IssueCreate, Issue, Database } from "../types";
import { Database, Environment, Issue, IssueCreate, Principal } from "../types";

// Issue
// It has to be string type because the id for stage field contain multiple parts.
Expand Down Expand Up @@ -86,6 +86,8 @@ export type TemplateContext = {
databaseList: Database[];
environmentList: Environment[];
currentUser: Principal;
statementList?: string[];
rollbackStatementList?: string[];
};

export type IssueTemplate = {
Expand Down

0 comments on commit b124888

Please sign in to comment.