Skip to content

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

chore: ux and code optimize for gitops (#19538)

ecmadao284e613a0e4c
diff --git a/frontend/src/components/User/Settings/CreateWorkloadIdentityDrawer.vue b/frontend/src/components/User/Settings/CreateWorkloadIdentityDrawer.vue
index 59aed898e1..2aa86319e6 100644
--- a/frontend/src/components/User/Settings/CreateWorkloadIdentityDrawer.vue
+++ b/frontend/src/components/User/Settings/CreateWorkloadIdentityDrawer.vue
@@ -358,6 +358,10 @@ import {
WorkloadIdentityConfig_ProviderType,
WorkloadIdentityConfigSchema,
} from "@/types/proto-es/v1/user_service_pb";
+import {
+ getWorkloadIdentityProviderText,
+ parseWorkloadIdentitySubjectPattern,
+} from "@/utils";
interface WifState {
emailPrefix: string;
@@ -436,64 +440,6 @@ const isEditMode = computed(
props.workloadIdentity.name !== unknownUser().name
);
-// Parse subject pattern and extract owner/repo/branch/refType
-const parseSubjectPattern = (pattern: string) => {
- const { providerType } = state.wif;
-
- if (providerType === WorkloadIdentityConfig_ProviderType.GITHUB) {
- const match = pattern.match(/^repo:([^/]+)\/(.*)$/);
- if (match) {
- const owner = match[1];
- const rest = match[2];
- if (rest === "*") {
- return { owner, repo: "", branch: "" };
- }
- const repoMatch = rest.match(/^([^:]+):(.*)$/);
- if (repoMatch) {
- const repo = repoMatch[1];
- const refPart = repoMatch[2];
- if (refPart === "*") {
- return { owner, repo, branch: "" };
- }
- const branchMatch = refPart.match(/^ref:refs\/heads\/(.+)$/);
- if (branchMatch) {
- return { owner, repo, branch: branchMatch[1] };
- }
- }
- }
- }
-
- if (providerType === WorkloadIdentityConfig_ProviderType.GITLAB) {
- const match = pattern.match(/^project_path:([^/]+)\/(.*)$/);
- if (match) {
- const owner = match[1];
- const rest = match[2];
- if (rest === "*") {
- return { owner, repo: "", branch: "", refType: "all" as const };
- }
- const projectMatch = rest.match(/^([^:]+):(.*)$/);
- if (projectMatch) {
- const repo = projectMatch[1];
- const refPart = projectMatch[2];
- if (refPart === "*") {
- return { owner, repo, branch: "", refType: "all" as const };
- }
- const refTypeMatch = refPart.match(/^ref_type:(branch|tag):ref:(.+)$/);
- if (refTypeMatch) {
- return {
- owner,
- repo,
- branch: refTypeMatch[2],
- refType: refTypeMatch[1] as "branch" | "tag",
- };
- }
- }
- }
- }
-
- return null;
-};
-
watch(
() => props.workloadIdentity,
(wi) => {
@@ -510,7 +456,9 @@ watch(
state.wif.audience = config.allowedAudiences[0] || "";
state.wif.subjectPattern = config.subjectPattern;
- const parsed = parseSubjectPattern(config.subjectPattern);
+ const parsed = parseWorkloadIdentitySubjectPattern(
+ state.workloadIdentity
+ );
if (parsed) {
state.wif.owner = parsed.owner;
state.wif.repo = parsed.repo;
@@ -526,16 +474,15 @@ watch(
}
);
-const platformOptions = [
- {
- label: "GitHub Actions",
- value: WorkloadIdentityConfig_ProviderType.GITHUB,
- },
- {
- label: "GitLab CI",
- value: WorkloadIdentityConfig_ProviderType.GITLAB,
- },
-];
+const platformOptions = computed(() => {
+ return [
+ WorkloadIdentityConfig_ProviderType.GITHUB,
+ WorkloadIdentityConfig_ProviderType.GITLAB,
+ ].map((provider) => ({
+ label: getWorkloadIdentityProviderText(provider),
+ value: provider,
+ }));
+});
const platformPresets: Partial<
Record<
@@ -635,9 +582,11 @@ watch(
// Watch for subject pattern changes and update fields (reverse binding)
watch(
() => state.wif.subjectPattern,
- (newPattern) => {
+ () => {
if (isUpdatingFromFields) return;
- const parsed = parseSubjectPattern(newPattern);
+ const parsed = parseWorkloadIdentitySubjectPattern({
+ workloadIdentityConfig: state.wif,
+ });
if (parsed) {
isUpdatingFromPattern = true;
state.wif.owner = parsed.owner;
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index f2cf6c5ab2..09a50e1469 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2869,8 +2869,9 @@
"workflow": {
"title": "Workflow file generation",
"description": "Copy the workflow files into your repository to automate SQL review and database rollouts.",
- "file-hint": "Save as {filePath} in your repository",
- "self-hosted-runner": "Self-hosted runner"
+ "file-hint": "Save as {filePath} in your repository {repository}",
+ "self-hosted-runner": "Self-hosted runner",
+ "provider-not-match": "The selected workload identity only works for {provider}."
},
"test-setup": {
"title": "Test your first GitOps migration",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 43673dc8dd..adc609bf6b 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2870,7 +2870,8 @@
"title": "Generación de archivo de flujo de trabajo",
"description": "Copie los archivos de flujo de trabajo en su repositorio para automatizar la revisión de SQL y los despliegues de base de datos.",
"file-hint": "Guardar como {filePath} en su repositorio",
- "self-hosted-runner": "Runner self-hosted"
+ "self-hosted-runner": "Runner self-hosted",
+ "provider-not-match": "La workload identity seleccionada solo funciona para {provider}."
},
"test-setup": {
"title": "Pruebe su primera migración GitOps",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index d9ff37a3a8..371735b601 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2870,7 +2870,8 @@
"title": "ワークフローファイル生成",
"description": "ワークフローファイルをリポジトリにコピーして、SQL レビューとデータベースロールアウトを自動化します。",
"file-hint": "リポジトリ内に {filePath} として保存",
- "self-hosted-runner": "セルフホスト runner"
+ "self-hosted-runner": "セルフホスト runner",
+ "provider-not-match": "選択された ワークロード アイデンティティ は {provider} 専用です。"
},
"test-setup": {
"title": "最初の GitOps マイグレーションをテスト",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index db6e96683b..b08eea16b5 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -2870,7 +2870,8 @@
"title": "Tạo tệp workflow",
"description": "Sao chép các tệp workflow vào kho lưu trữ của bạn để tự động hóa SQL review và triển khai cơ sở dữ liệu.",
"file-hint": "Lưu dưới dạng {filePath} trong kho lưu trữ của bạn",
- "self-hosted-runner": "Runner tự lưu trữ"
+ "self-hosted-runner": "Runner tự lưu trữ",
+ "provider-not-match": "Workload identity đã chọn chỉ hoạt động cho {provider}."
},
"test-setup": {
"title": "Thử nghiệm migration GitOps đầu tiên",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index cc133337cf..719762b205 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2870,7 +2870,8 @@
"title": "工作流文件生成",
"description": "将工作流文件复制到您的代码仓库中,以自动化 SQL 审查和数据库变更发布。",
"file-hint": "保存为仓库中的 {filePath}",
- "self-hosted-runner": "自托管 runner"
+ "self-hosted-runner": "自托管 runner",
+ "provider-not-match": "所选的 工作负载标识 (Workload Identity) 仅适用于 {provider}。"
},
"test-setup": {
"title": "测试您的首次 GitOps 迁移",
diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts
index 17d4a5e4c9..831a78a014 100644
--- a/frontend/src/utils/index.ts
+++ b/frontend/src/utils/index.ts
@@ -20,6 +20,7 @@ export * from "./TinyTimer";
export * from "./sheet";
export * from "./naive-ui";
export * from "./useDashboardSidebar";
+export * from "./workloadIdentity";
export * from "./v1";
export * from "./iam";
diff --git a/frontend/src/utils/workloadIdentity.ts b/frontend/src/utils/workloadIdentity.ts
new file mode 100644
index 0000000000..4499b88c06
--- /dev/null
+++ b/frontend/src/utils/workloadIdentity.ts
@@ -0,0 +1,70 @@
+import { WorkloadIdentityConfig_ProviderType } from "@/types/proto-es/v1/user_service_pb";
+
+// Parse subject pattern and extract owner/repo/branch/refType
+export const parseWorkloadIdentitySubjectPattern = (wi: {
+ workloadIdentityConfig?: {
+ subjectPattern: string;
+ providerType: WorkloadIdentityConfig_ProviderType;
+ };
+}) => {
+ if (!wi.workloadIdentityConfig) {
+ return;
+ }
+
+ const pattern = wi.workloadIdentityConfig.subjectPattern;
+ if (!pattern) {
+ return;
+ }
+
+ const providerType = wi.workloadIdentityConfig.providerType;
+ switch (providerType) {
+ case WorkloadIdentityConfig_ProviderType.GITHUB: {
+ const match = /^repo:([^/]+)\/(.*)$/.exec(pattern);
+ if (!match) return;
+ const owner = match[1];
+ const rest = match[2];
+ if (rest === "*") return { owner, repo: "", branch: "" };
+ const repoMatch = /^([^:]+):(.*)$/.exec(rest);
+ if (!repoMatch) return;
+ const repo = repoMatch[1];
+ const refPart = repoMatch[2];
+ if (refPart === "*") return { owner, repo, branch: "" };
+ const branchMatch = /^ref:refs\/heads\/(.+)$/.exec(refPart);
+ return { owner, repo, branch: branchMatch?.[1] ?? "" };
+ }
+ case WorkloadIdentityConfig_ProviderType.GITLAB: {
+ const match = /^project_path:([^/]+)\/(.*)$/.exec(pattern);
+ if (!match) return;
+ const owner = match[1];
+ const rest = match[2];
+ if (rest === "*") return { owner, repo: "", branch: "" };
+ const projectMatch = /^([^:]+):(.*)$/.exec(rest);
+ if (!projectMatch) return;
+ const repo = projectMatch[1];
+ const refPart = projectMatch[2];
+ if (refPart === "*") return { owner, repo, branch: "" };
+ const refTypeMatch = /^ref_type:(branch|tag):ref:(.+)$/.exec(refPart);
+ return {
+ owner,
+ repo,
+ branch: refTypeMatch?.[2] ?? "",
+ refType: refTypeMatch?.[1] as "branch" | "tag",
+ };
+ }
+ default:
+ return;
+ }
+};
+
+export const getWorkloadIdentityProviderText = (
+ providerType: WorkloadIdentityConfig_ProviderType
+) => {
+ switch (providerType) {
+ case WorkloadIdentityConfig_ProviderType.GITHUB:
+ return "GitHub Actions";
+ case WorkloadIdentityConfig_ProviderType.GITLAB:
+ return "GitLab CI";
+ default:
+ return "";
+ }
+};
diff --git a/frontend/src/views/project/ProjectGitOpsDashboard.vue b/frontend/src/views/project/ProjectGitOpsDashboard.vue
index 951824a6a0..303f1d9567 100644
--- a/frontend/src/views/project/ProjectGitOpsDashboard.vue
+++ b/frontend/src/views/project/ProjectGitOpsDashboard.vue
@@ -1,11 +1,11 @@
<template>
- <div class="w-full px-4 flex flex-col gap-y-6 py-4">
+ <div class="w-full px-4 flex flex-col gap-y-1 py-4">
<!-- Section 1: What is GitOps -->
- <div class="border border-gray-200 rounded-lg p-6 flex flex-col gap-y-2">
- <h2 class="text-lg font-medium">
- {{ $t("gitops.overview.title") }}
- </h2>
- <div>
+ <div class="border border-gray-200 rounded p-6 flex flex-col gap-y-3">
+ <div class="flex flex-col gap-y-1">
+ <h2 class="text-lg font-medium">
+ {{ $t("gitops.overview.title") }}
+ </h2>
<p class="textinfolabel">
{{ $t("gitops.overview.description") }}
</p>
@@ -30,9 +30,14 @@
</div>
</div>
+ <span
+ class="mx-auto w-0.5 h-8 bg-block-border"
+ aria-hidden="true"
+ ></span>
+
<!-- Section 2: Checks before we start -->
- <div class="border border-gray-200 rounded-lg p-6 flex flex-col gap-y-1">
- <h2 class="text-lg font-medium mb-2">
+ <div class="border border-gray-200 rounded p-6 flex flex-col gap-y-3">
+ <h2 class="text-lg font-medium">
{{ $t("gitops.checklist.title") }}
</h2>
@@ -47,7 +52,7 @@
class="w-5 h-5 text-warning shrink-0"
/>
- <div class="flex flex-col gap-y-1">
+ <div class="flex flex-col flex-1 gap-y-1">
<span class="text-sm font-medium">
{{ $t("gitops.checklist.external-url") }}
</span>
@@ -80,7 +85,7 @@
$t('gitops.workload-identity.select-placeholder')
"
clearable
- class="max-w-md"
+ class="max-w-lg"
/>
<PermissionGuardWrapper
v-slot="slotProps"
@@ -119,7 +124,7 @@
<span class="text-sm font-medium">{{
$t("gitops.checklist.target-databases")
}}</span>
- <div class="max-w-md">
+ <div class="max-w-lg">
<DatabaseSelect
v-model:value="selectedDatabaseNames"
:project-name="projectName"
@@ -139,129 +144,164 @@
</div>
</div>
+ <span
+ class="mx-auto w-0.5 h-8 bg-block-border"
+ aria-hidden="true"
+ ></span>
+
<!-- Section 3: Workflow file generation -->
- <div class="border border-gray-200 rounded-lg p-6 flex flex-col gap-y-3">
- <h2 class="text-lg font-medium">
- {{ $t("gitops.workflow.title") }}
- </h2>
- <p class="text-sm text-control-light">
- {{ $t("gitops.workflow.description") }}
- </p>
+ <div class="border border-gray-200 rounded p-6 flex flex-col gap-y-3">
+ <div class="flex flex-col gap-y-1">
+ <h2 class="text-lg font-medium">
+ {{ $t("gitops.workflow.title") }}
+ </h2>
+ <p class="text-sm text-control-light">
+ {{ $t("gitops.workflow.description") }}
+ </p>
+ </div>
<NTabs v-model:value="activeTab" type="line" animated>
- <NTabPane name="github-actions" tab="GitHub Actions">
+ <NTabPane :name="WorkloadIdentityConfig_ProviderType.GITHUB" tab="GitHub Actions">
+ <BBAttention v-if="selectedConfig && activeTab !== selectedConfig?.providerType" :type="'error'">
+ {{ $t("gitops.workflow.provider-not-match", { provider: getWorkloadIdentityProviderText(selectedConfig.providerType) }) }}
+ </BBAttention>
<!-- Runner type toggle -->
- <div class="flex items-center gap-x-2 mt-3">
+ <div class="flex items-center gap-x-2 my-3">
<span class="text-sm">
{{ $t("gitops.workflow.self-hosted-runner") }}
</span>
<NSwitch v-model:value="useSelfhostRunner" />
</div>
<!-- sql-review.yml -->
- <div class="flex flex-col gap-y-2 mt-3">
- <div class="flex items-center gap-x-2">
- <button
- class="flex items-center gap-x-1 text-sm text-control-light hover:text-control cursor-pointer"
- @click="showSqlReviewYaml = !showSqlReviewYaml"
- >
- <ChevronRightIcon
- v-if="!showSqlReviewYaml"
- class="w-4 h-4"
- />
- <ChevronDownIcon v-else class="w-4 h-4" />
- {{
- $t("gitops.workflow.file-hint", {
- filePath: ".github/workflows/sql-review.yml",
- })
- }}
- </button>
- <CopyButton :content="githubSqlReviewYaml" />
+ <div class="flex flex-col gap-y-2">
+ <div>
+ <NButton quaternary size="small" @click="showSqlReviewYaml = !showSqlReviewYaml">
+ <template #icon>
+ <ChevronRightIcon
+ v-if="!showSqlReviewYaml"
+ class="w-4 h-4"
+ />
+ <ChevronDownIcon v-else class="w-4 h-4" />
+ </template>
+ <i18n-t keypath="gitops.workflow.file-hint">
+ <template #filePath>
+ <span class="font-bold mx-1">
+ .github/workflows/sql-review.yml
+ </span>
+ </template>
+ <template #repository>
+ <span class="font-bold mx-1">
+ {{ parsedSubject?.repo }}
+ </span>
+ </template>
+ </i18n-t>
+ </NButton>
+ </div>
+ <div v-show="showSqlReviewYaml" class="relative rounded-xs p-4 bg-gray-50">
+ <div class="absolute top-2 right-2 p-2">
+ <CopyButton size="medium" :content="githubSqlReviewYaml" />
+ </div>
+ <NConfigProvider :hljs="hljs">
+ <NCode language="yaml" :code="githubSqlReviewYaml" />
+ </NConfigProvider>
</div>
- <NInput
- v-show="showSqlReviewYaml"
- :value="githubSqlReviewYaml"
- type="textarea"
- readonly
- :autosize="{ minRows: 10, maxRows: 30 }"
- class="font-mono text-sm"
- />
</div>
<!-- release.yml -->
<div class="flex flex-col gap-y-2 mt-4">
- <div class="flex items-center gap-x-2">
- <button
- class="flex items-center gap-x-1 text-sm text-control-light hover:text-control cursor-pointer"
- @click="showReleaseYaml = !showReleaseYaml"
- >
- <ChevronRightIcon
- v-if="!showReleaseYaml"
- class="w-4 h-4"
- />
- <ChevronDownIcon v-else class="w-4 h-4" />
- {{
- $t("gitops.workflow.file-hint", {
- filePath: ".github/workflows/release.yml",
- })
- }}
- </button>
- <CopyButton :content="githubReleaseYaml" />
+ <div>
+ <NButton quaternary size="small" @click="showReleaseYaml = !showReleaseYaml">
+ <template #icon>
+ <ChevronRightIcon
+ v-if="!showReleaseYaml"
+ class="w-4 h-4"
+ />
+ <ChevronDownIcon v-else class="w-4 h-4" />
+ </template>
+ <i18n-t keypath="gitops.workflow.file-hint">
+ <template #filePath>
+ <span class="font-bold mx-1">
+ .github/workflows/release.yml
+ </span>
+ </template>
+ <template #repository>
+ <span class="font-bold mx-1">
+ {{ parsedSubject?.repo }}
+ </span>
+ </template>
+ </i18n-t>
+ </NButton>
+ </div>
+ <div v-show="showReleaseYaml" class="relative rounded-xs p-4 bg-gray-50">
+ <div class="absolute top-2 right-2 p-2">
+ <CopyButton size="medium" :content="githubReleaseYaml" />
+ </div>
+ <NConfigProvider :hljs="hljs">
+ <NCode language="yaml" :code="githubReleaseYaml" />
+ </NConfigProvider>
</div>
- <NInput
- v-show="showReleaseYaml"
- :value="githubReleaseYaml"
- type="textarea"
- readonly
- :autosize="{ minRows: 10, maxRows: 30 }"
- class="font-mono text-sm"
- />
</div>
</NTabPane>
- <NTabPane name="gitlab-ci" tab="GitLab CI">
- <div class="flex flex-col gap-y-2 mt-3">
- <div class="flex items-center gap-x-2">
- <button
- class="flex items-center gap-x-1 text-sm text-control-light hover:text-control cursor-pointer"
- @click="showGitlabCiYaml = !showGitlabCiYaml"
- >
- <ChevronRightIcon
- v-if="!showGitlabCiYaml"
- class="w-4 h-4"
- />
- <ChevronDownIcon v-else class="w-4 h-4" />
- {{
- $t("gitops.workflow.file-hint", {
- filePath: ".gitlab-ci.yml",
- })
- }}
- </button>
- <CopyButton :content="gitlabCiYaml" />
+ <NTabPane :name="WorkloadIdentityConfig_ProviderType.GITLAB" tab="GitLab CI">
+ <div class="flex flex-col gap-y-2">
+ <BBAttention v-if="selectedConfig && activeTab !== selectedConfig?.providerType" :type="'error'">
+ {{ $t("gitops.workflow.provider-not-match", { provider: getWorkloadIdentityProviderText(selectedConfig.providerType) }) }}
+ </BBAttention>
+ <div>
+ <NButton quaternary size="small" @click="showGitlabCiYaml = !showGitlabCiYaml">
+ <template #icon>
+ <ChevronRightIcon
+ v-if="!showGitlabCiYaml"
+ class="w-4 h-4"
+ />
+ <ChevronDownIcon v-else class="w-4 h-4" />
+ </template>
+ <i18n-t keypath="gitops.workflow.file-hint">
+ <template #filePath>
+ <span class="font-bold mx-1">
+ .gitlab-ci.yml
+ </span>
+ </template>
+ <template #repository>
+ <span class="font-bold mx-1">
+ {{ parsedSubject?.repo }}
+ </span>
+ </template>
+ </i18n-t>
+ </NButton>
+ </div>
+ <div v-show="showGitlabCiYaml" class="relative rounded-xs p-4 bg-gray-50">
+ <div class="absolute top-2 right-2 p-2">
+ <CopyButton size="medium" :content="gitlabCiYaml" />
+ </div>
+ <NConfigProvider :hljs="hljs">
+ <NCode language="yaml" :code="gitlabCiYaml" />
+ </NConfigProvider>
</div>
- <NInput
- v-show="showGitlabCiYaml"
- :value="gitlabCiYaml"
- type="textarea"
- readonly
- :autosize="{ minRows: 10, maxRows: 30 }"
- class="font-mono text-sm"
- />
</div>
</NTabPane>
</NTabs>
</div>
+ <span
+ class="mx-auto w-0.5 h-8 bg-block-border"
+ aria-hidden="true"
+ ></span>
+
<!-- Section 4: Test your first GitOps migration -->
- <div class="border border-gray-200 rounded-lg p-6 flex flex-col gap-y-4">
- <h2 class="text-lg font-medium">
- {{ $t("gitops.test-setup.title") }}
- </h2>
- <p class="text-sm text-control-light">
- {{ $t("gitops.test-setup.description") }}
- </p>
+ <div class="border border-gray-200 rounded p-6 flex flex-col gap-y-3">
+ <div class="flex flex-col gap-y-1">
+ <h2 class="text-lg font-medium">
+ {{ $t("gitops.test-setup.title") }}
+ </h2>
+ <p class="text-sm text-control-light">
+ {{ $t("gitops.test-setup.description") }}
+ </p>
+ </div>
<!-- Sample migration file -->
<div class="flex flex-col gap-y-2">
<div class="flex items-center gap-x-2">
- <span class="text-sm text-control-light">{{ sampleFilePath }}</span>
+ <span class="text-sm text-control-light font-bold">{{ sampleFilePath }}</span>
<CopyButton :content="sampleSql" />
</div>
<NInput
@@ -327,15 +367,25 @@
</template>
<script lang="ts" setup>
+import hljs from "highlight.js/lib/core";
import {
CheckIcon,
ChevronDownIcon,
ChevronRightIcon,
XCircleIcon,
} from "lucide-vue-next";
-import { NButton, NInput, NSwitch, NTabPane, NTabs } from "naive-ui";
+import {
+ NButton,
+ NCode,
+ NConfigProvider,
+ NInput,
+ NSwitch,
+ NTabPane,
+ NTabs,
+} from "naive-ui";
import { computed, ref, watch } from "vue";
import gitopsWorkflowImage from "@/assets/gitops-workflow.svg";
+import { BBAttention } from "@/bbkit";
import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";
import CreateWorkloadIdentityDrawer from "@/components/User/Settings/CreateWorkloadIdentityDrawer.vue";
import {
@@ -354,6 +404,10 @@ import {
import { projectNamePrefix } from "@/store/modules/v1/common";
import type { User } from "@/types/proto-es/v1/user_service_pb";
import { WorkloadIdentityConfig_ProviderType } from "@/types/proto-es/v1/user_service_pb";
+import {
+ getWorkloadIdentityProviderText,
+ parseWorkloadIdentitySubjectPattern,
+} from "@/utils";
const props = defineProps<{
projectId: string;
@@ -368,11 +422,13 @@ const { project } = useProjectByName(projectName);
const showCreateDrawer = ref(false);
const selectedIdentityName = ref<string | undefined>(undefined);
const selectedDatabaseNames = ref<string[]>([]);
-const activeTab = ref("github-actions");
+const activeTab = ref<WorkloadIdentityConfig_ProviderType>(
+ WorkloadIdentityConfig_ProviderType.GITHUB
+);
const useSelfhostRunner = ref(false);
-const showSqlReviewYaml = ref(false);
-const showReleaseYaml = ref(false);
-const showGitlabCiYaml = ref(false);
+const showSqlReviewYaml = ref(true);
+const showReleaseYaml = ref(true);
+const showGitlabCiYaml = ref(true);
const selectedIdentity = computed(() => {
if (!selectedIdentityName.value) return undefined;
@@ -383,44 +439,19 @@ const selectedConfig = computed(
() => selectedIdentity.value?.workloadIdentityConfig
);
-// Parse subject pattern to extract owner/repo/branch.
-const parsedSubject = computed(() => {
- const pattern = selectedConfig.value?.subjectPattern;
- if (!pattern) return undefined;
-
- const providerType = selectedConfig.value?.providerType;
-
- if (providerType === WorkloadIdentityConfig_ProviderType.GITHUB) {
- const match = pattern.match(/^repo:([^/]+)\/(.*)$/);
- if (!match) return undefined;
- const owner = match[1];
- const rest = match[2];
- if (rest === "*") return { owner, repo: "", branch: "" };
- const repoMatch = rest.match(/^([^:]+):(.*)$/);
- if (!repoMatch) return undefined;
- const repo = repoMatch[1];
- const refPart = repoMatch[2];
- if (refPart === "*") return { owner, repo, branch: "" };
- const branchMatch = refPart.match(/^ref:refs\/heads\/(.+)$/);
- return { owner, repo, branch: branchMatch?.[1] ?? "" };
+watch(
+ () => selectedConfig.value,
+ (config) => {
+ activeTab.value =
+ config?.providerType ?? WorkloadIdentityConfig_ProviderType.GITHUB;
}
+);
- if (providerType === WorkloadIdentityConfig_ProviderType.GITLAB) {
- const match = pattern.match(/^project_path:([^/]+)\/(.*)$/);
- if (!match) return undefined;
- const owner = match[1];
- const rest = match[2];
- if (rest === "*") return { owner, repo: "", branch: "" };
- const projectMatch = rest.match(/^([^:]+):(.*)$/);
- if (!projectMatch) return undefined;
- const repo = projectMatch[1];
- const refPart = projectMatch[2];
- if (refPart === "*") return { owner, repo, branch: "" };
- const refTypeMatch = refPart.match(/^ref_type:(?:branch|tag):ref:(.+)$/);
- return { owner, repo, branch: refTypeMatch?.[1] ?? "" };
+const parsedSubject = computed(() => {
+ if (!selectedIdentity.value) {
+ return;
}
-
- return undefined;
+ return parseWorkloadIdentitySubjectPattern(selectedIdentity.value);
});
// Build a clickable repository URL from the identity.
@@ -443,16 +474,6 @@ const repoUrl = computed(() => {
// Branch from the identity, fallback to "main".
const branch = computed(() => parsedSubject.value?.branch || "main");
-// Auto-switch tab when identity changes.
-watch(selectedConfig, (config) => {
- if (!config) return;
- if (config.providerType === WorkloadIdentityConfig_ProviderType.GITLAB) {
- activeTab.value = "gitlab-ci";
- } else {
- activeTab.value = "github-actions";
- }
-});
-
const bytebaseUrl = computed(() => {
const url = actuatorStore.serverInfo?.externalUrl ?? "";
return url.replace(/\/$/, "");