Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Allow select stage via Sidebar and Flow

天舟f686f5a7a77c
diff --git a/frontend/src/components/StageSelect.vue b/frontend/src/components/StageSelect.vue
new file mode 100644
index 0000000000..6bad60e556
--- /dev/null
+++ b/frontend/src/components/StageSelect.vue
@@ -0,0 +1,64 @@
+<template>
+ <select
+ class="btn-select w-full disabled:cursor-not-allowed"
+ @change="
+ (e) => {
+ $emit('select-stage-id', e.target.value);
+ }
+ "
+ >
+ <template v-for="(stage, index) in pipeline.stageList" :key="index">
+ <option :value="stage.id" :selected="stage.id == state.selectedId">
+ {{ isActiveStage(stage.id) ? stage.name + " (active)" : stage.name }}
+ </option>
+ </template>
+ </select>
+</template>
+
+<script lang="ts">
+import { PropType, reactive, watch } from "vue";
+import { UNKNOWN_ID, Pipeline, StageId } from "../types";
+import { activeStage } from "../utils";
+
+interface LocalState {
+ selectedId: string;
+}
+
+export default {
+ name: "StageSelect",
+ emits: ["select-stage-id"],
+ components: {},
+ props: {
+ pipeline: {
+ required: true,
+ type: Object as PropType<Pipeline>,
+ },
+ selectedId: {
+ default: UNKNOWN_ID,
+ type: String,
+ },
+ },
+ setup(props, { emit }) {
+ const state = reactive<LocalState>({
+ selectedId: props.selectedId,
+ });
+
+ watch(
+ () => props.selectedId,
+ (cur, _) => {
+ state.selectedId = cur;
+ }
+ );
+
+ const isActiveStage = (stageId: StageId): boolean => {
+ const stage = activeStage(props.pipeline);
+ return stage.id == stageId;
+ };
+
+ return {
+ state,
+ isActiveStage,
+ };
+ },
+};
+</script>
diff --git a/frontend/src/utils/slug.ts b/frontend/src/utils/slug.ts
index e86f17bc69..8b9c0dae4c 100644
--- a/frontend/src/utils/slug.ts
+++ b/frontend/src/utils/slug.ts
@@ -13,6 +13,11 @@ export function idFromSlug(slug: string) {
return parts[parts.length - 1];
}
+export function indexFromSlug(slug: string): number {
+ const parts = slug.split("-");
+ return parseInt(parts[parts.length - 1]) - 1;
+}
+
export function issueSlug(issueName: string, issueId: IssueId) {
return [slug(issueName), issueId].join("-");
}
@@ -34,6 +39,10 @@ export function instanceSlug(instance: Instance): string {
].join("-");
}
+export function stageSlug(stageName: string, stageIndex: number): string {
+ return [slug(stageName), stageIndex + 1].join("-");
+}
+
export function databaseSlug(database: Database): string {
return [slug(database.name), database.id].join("-");
}
diff --git a/frontend/src/views/IssueDetail.vue b/frontend/src/views/IssueDetail.vue
index 221822534e..860d3b8279 100644
--- a/frontend/src/views/IssueDetail.vue
+++ b/frontend/src/views/IssueDetail.vue
@@ -41,7 +41,11 @@
currentPipelineType == 'SINGLE_STAGE'
"
>
- <PipelineSimpleFlow :pipeline="state.issue.pipeline" />
+ <PipelineSimpleFlow
+ :pipeline="state.issue.pipeline"
+ :selectedStage="selectedStage"
+ @select-stage-id="selectStageId"
+ />
</template>
</template>
@@ -78,11 +82,13 @@
<IssueSidebar
:issue="state.issue"
:new="state.new"
+ :selectedStage="selectedStage"
:inputFieldList="issueTemplate.inputFieldList"
:allowEdit="allowEditSidebar"
@update-assignee-id="updateAssigneeId"
@update-subscriber-list="updateSubscriberIdList"
@update-custom-field="updateCustomField"
+ @select-stage-id="selectStageId"
/>
</div>
<div class="lg:hidden border-t border-block-border" />
@@ -141,6 +147,9 @@ import {
isDemo,
pipelineType,
PipelineType,
+ indexFromSlug,
+ activeStage,
+ stageSlug,
} from "../utils";
import IssueHighlightPanel from "../views/IssueHighlightPanel.vue";
import IssueOutputPanel from "../views/IssueOutputPanel.vue";
@@ -160,6 +169,8 @@ import {
UNKNOWN_ID,
ProjectId,
Environment,
+ Stage,
+ StageId,
} from "../types";
import {
defaulTemplate,
@@ -483,6 +494,31 @@ export default {
console.log(currentPipelineType.value);
+ const selectedStage = computed(
+ (): Stage => {
+ const stageSlug = router.currentRoute.value.query.stage as string;
+ if (stageSlug) {
+ const index = indexFromSlug(stageSlug);
+ return (state.issue as Issue).pipeline.stageList[index];
+ }
+ return activeStage((state.issue as Issue).pipeline);
+ }
+ );
+
+ const selectStageId = (stageId: StageId) => {
+ const stageList = (state.issue as Issue).pipeline.stageList;
+ const index = stageList.findIndex((item) => {
+ return item.id == stageId;
+ });
+ router.replace({
+ name: "workspace.issue.detail",
+ query: {
+ ...router.currentRoute.value.query,
+ stage: stageSlug(stageList[index].name, index),
+ },
+ });
+ };
+
const allowEditSidebar = computed(() => {
// For now, we only allow assignee to update the field when the issue
// is 'OPEN'. This reduces flexibility as creator must ask assignee to
@@ -558,6 +594,8 @@ export default {
currentPipelineType,
currentUser,
issueTemplate,
+ selectedStage,
+ selectStageId,
allowEditSidebar,
allowEditOutput,
allowEditNameAndDescription,
diff --git a/frontend/src/views/IssueSidebar.vue b/frontend/src/views/IssueSidebar.vue
index 6386b803e7..bcb4820a94 100644
--- a/frontend/src/views/IssueSidebar.vue
+++ b/frontend/src/views/IssueSidebar.vue
@@ -66,17 +66,27 @@
<div
class="mt-6 border-t border-block-border pt-6 grid gap-y-6 gap-x-6 grid-cols-3"
>
- <template v-if="database.id != EMPTY_ID">
+ <template v-if="showStageSelect">
<h2 class="textlabel flex items-center col-span-1 col-start-1">
- Database
+ Stage
</h2>
- <router-link
- :to="`/db/${databaseSlug(database)}`"
- class="col-span-2 text-sm font-medium text-main hover:underline"
- >
- {{ database.name }}
- </router-link>
+ <div class="col-span-2">
+ <StageSelect
+ :pipeline="issue.pipeline"
+ :selectedId="selectedStage.id"
+ @select-stage-id="(stageId) => $emit('select-stage-id', stageId)"
+ />
+ </div>
</template>
+ <h2 class="textlabel flex items-center col-span-1 col-start-1">
+ Database
+ </h2>
+ <router-link
+ :to="`/db/${databaseSlug(database)}`"
+ class="col-span-2 text-sm font-medium text-main hover:underline"
+ >
+ {{ database.id == EMPTY_ID ? "N/A" : database.name }}
+ </router-link>
<h2 class="textlabel flex items-center col-span-1 col-start-1">
Environment
@@ -87,7 +97,10 @@
>
{{ environmentName(environment) }}
</router-link>
-
+ </div>
+ <div
+ class="mt-6 border-t border-block-border pt-6 grid gap-y-6 gap-x-6 grid-cols-3"
+ >
<h2 class="textlabel flex items-center col-span-1 col-start-1">
Project
</h2>
@@ -189,6 +202,7 @@ import DatabaseSelect from "../components/DatabaseSelect.vue";
import EnvironmentSelect from "../components/EnvironmentSelect.vue";
import ProjectSelect from "../components/ProjectSelect.vue";
import PrincipalSelect from "../components/PrincipalSelect.vue";
+import StageSelect from "../components/StageSelect.vue";
import IssueStatusIcon from "../components/IssueStatusIcon.vue";
import { InputField } from "../plugins";
import {
@@ -199,8 +213,10 @@ import {
Issue,
IssueNew,
EMPTY_ID,
+ Stage,
} from "../types";
-import { activeDatabase, activeEnvironment, isDBAOrOwner } from "../utils";
+import { allTaskList, isDBAOrOwner } from "../utils";
+import { useRouter } from "vue-router";
interface LocalState {}
@@ -210,6 +226,7 @@ export default {
"update-assignee-id",
"update-subscriber-list",
"update-custom-field",
+ "select-stage-id",
],
props: {
issue: {
@@ -220,6 +237,10 @@ export default {
required: true,
type: Boolean,
},
+ selectedStage: {
+ required: true,
+ type: Object as PropType<Stage>,
+ },
inputFieldList: {
required: true,
type: Object as PropType<InputField[]>,
@@ -234,10 +255,13 @@ export default {
ProjectSelect,
EnvironmentSelect,
PrincipalSelect,
+ StageSelect,
IssueStatusIcon,
},
setup(props, { emit }) {
const store = useStore();
+ const router = useRouter();
+
const state = reactive<LocalState>({});
const currentUser = computed(() => store.getters["auth/currentUser"]());
@@ -253,7 +277,20 @@ export default {
.taskList[0].databaseId;
return store.getters["database/databaseById"](databaseId);
}
- return activeDatabase((props.issue as Issue).pipeline);
+ const stage = props.selectedStage;
+ return stage.taskList[0].database;
+ }
+ );
+
+ const environment = computed(
+ (): Environment => {
+ if (props.new) {
+ const environmentId = (props.issue as IssueNew).pipeline?.stageList[0]
+ .environmentId;
+ return store.getters["environment/environmentById"](environmentId);
+ }
+ const stage = props.selectedStage;
+ return stage.environment;
}
);
@@ -268,16 +305,11 @@ export default {
}
);
- const environment = computed(
- (): Environment => {
- if (props.new) {
- const environmentId = (props.issue as IssueNew).pipeline?.stageList[0]
- .environmentId;
- return store.getters["environment/environmentById"](environmentId);
- }
- return activeEnvironment((props.issue as Issue).pipeline);
- }
- );
+ const showStageSelect = computed((): boolean => {
+ return (
+ !props.new && allTaskList((props.issue as Issue).pipeline).length > 1
+ );
+ });
const isCurrentUserSubscribed = computed((): boolean => {
for (const principal of (props.issue as Issue).subscriberList) {
@@ -353,6 +385,7 @@ export default {
environment,
database,
project,
+ showStageSelect,
isCurrentUserSubscribed,
subscriberList,
allowEditAssignee,
diff --git a/frontend/src/views/PipelineSimpleFlow.vue b/frontend/src/views/PipelineSimpleFlow.vue
index 8f8cb8ec31..f6b36a707b 100644
--- a/frontend/src/views/PipelineSimpleFlow.vue
+++ b/frontend/src/views/PipelineSimpleFlow.vue
@@ -77,19 +77,19 @@
</template>
</div>
<div
- class="hidden lg:ml-4 lg:flex lg:flex-col"
+ class="hidden cursor-pointer hover:underline lg:ml-4 lg:flex lg:flex-col"
:class="flowItemTextClass(item)"
+ @click.prevent="clickItem(item)"
>
<span class="text-xs">{{ item.stageName }}</span>
<span class="text-sm">{{ item.taskName }}</span>
</div>
<div
- class="ml-4 grid grid-cols-2 lg:hidden"
+ class="ml-4 group cursor-pointer grid grid-cols-2 lg:hidden"
:class="flowItemTextClass(item)"
+ @click.prevent="clickItem(item)"
>
- <span class="col-span-1 flex items-center text-sm w-32">{{
- item.stageName
- }}</span>
+ <span class="col-span-1 text-sm w-32">{{ item.stageName }}</span>
<span class="col-span-1 text-sm">{{ item.taskName }}</span>
</div>
</span>
@@ -122,10 +122,12 @@
<script lang="ts">
import { computed, PropType } from "vue";
-import { Pipeline, TaskStatus, TaskId } from "../types";
+import { useRouter } from "vue-router";
+import { Pipeline, TaskStatus, TaskId, Stage } from "../types";
import { activeTask } from "../utils";
interface FlowItem {
+ stageId: string;
stageName: string;
taskId: TaskId;
taskName: string;
@@ -134,19 +136,26 @@ interface FlowItem {
export default {
name: "PipelineSimpleFlow",
- emits: [],
+ emits: ["select-stage-id"],
props: {
pipeline: {
required: true,
type: Object as PropType<Pipeline>,
},
+ selectedStage: {
+ required: true,
+ type: Object as PropType<Stage>,
+ },
},
components: {},
- setup(props, {}) {
+ setup(props, { emit }) {
+ const router = useRouter();
+
const itemList = computed<FlowItem[]>(() => {
return props.pipeline.stageList.map((stage) => {
const task = stage.taskList[0];
return {
+ stageId: stage.id,
stageName: stage.name,
taskId: task.id,
taskName: task.name,
@@ -176,8 +185,11 @@ export default {
const flowItemTextClass = (item: FlowItem) => {
let textClass =
activeTask(props.pipeline).id === item.taskId
- ? "font-semibold "
+ ? "font-bold "
: "font-normal ";
+ if (item.stageId == props.selectedStage.id) {
+ textClass += "underline ";
+ }
switch (item.taskStatus) {
case "SKIPPED":
return textClass + "text-control";
@@ -195,11 +207,16 @@ export default {
}
};
+ const clickItem = (item: FlowItem) => {
+ emit("select-stage-id", item.stageId);
+ };
+
return {
itemList,
activeTask,
flowItemIconClass,
flowItemTextClass,
+ clickItem,
};
},
};