Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): show issue approval status for PENDING access grants (#19391)
rebeliced43ea5ea437f
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex b09915918e..21c8f439dc 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -52,6 +52,7 @@"latest": "Latest","error": "Error","canceled": "Canceled",+ "rejected": "Rejected","approve": "Approve","done": "Done","create": "Create",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex f4cd0c3a7b..c26ed8aa0e 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -52,6 +52,7 @@"latest": "Último","error": "Error","canceled": "Cancelado",+ "rejected": "Rechazado","approve": "Aprobar","done": "Hecho","create": "Crear",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex cf4070310f..ab2b59f17b 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -52,6 +52,7 @@"latest": "最新の","error": "間違い","canceled": "キャンセル",+ "rejected": "却下","approve": "承認する","done": "仕上げる","create": "作成する",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 6fc12a25d5..470b5cbd3c 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -52,6 +52,7 @@"latest": "Mới nhất","error": "Lỗi","canceled": "Đã hủy",+ "rejected": "Đã từ chối","approve": "Phê duyệt","done": "Hoàn tất","create": "Tạo",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex cf5dddb661..26907b8738 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -52,6 +52,7 @@"latest": "最新","error": "错误","canceled": "已取消",+ "rejected": "已拒绝","approve": "批准","done": "完成","create": "创建",diff --git a/frontend/src/utils/accessGrant.ts b/frontend/src/utils/accessGrant.tsindex 47b204217b..8da198ba1c 100644--- a/frontend/src/utils/accessGrant.ts+++ b/frontend/src/utils/accessGrant.ts@@ -4,12 +4,19 @@ import {type AccessGrant,AccessGrant_Status,} from "@/types/proto-es/v1/access_grant_service_pb";+import type { Issue } from "@/types/proto-es/v1/issue_service_pb";+import {+ Issue_ApprovalStatus,+ IssueStatus,+} from "@/types/proto-es/v1/issue_service_pb";export type AccessGrantDisplayStatus =| "ACTIVE"| "PENDING"| "EXPIRED"| "REVOKED"+ | "REJECTED"+ | "CANCELED"| "UNKNOWN";export const getAccessGrantExpireTimeMs = (@@ -50,7 +57,8 @@ export const getAccessGrantExpirationText = (};export const getAccessGrantDisplayStatus = (- grant: AccessGrant+ grant: AccessGrant,+ issue?: Issue): AccessGrantDisplayStatus => {const expireMs = getAccessGrantExpireTimeMs(grant);if (@@ -62,6 +70,14 @@ export const getAccessGrantDisplayStatus = (}switch (grant.status) {case AccessGrant_Status.PENDING:+ if (issue) {+ if (issue.approvalStatus === Issue_ApprovalStatus.REJECTED) {+ return "REJECTED";+ }+ if (issue.status === IssueStatus.CANCELED) {+ return "CANCELED";+ }+ }return "PENDING";case AccessGrant_Status.ACTIVE:return "ACTIVE";@@ -81,7 +97,10 @@ export const getAccessGrantStatusTagType = (case "PENDING":return "warning";case "REVOKED":+ case "REJECTED":return "error";+ case "CANCELED":+ return "default";default:return "default";}diff --git a/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessGrantItem.vue b/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessGrantItem.vueindex 1deef5cc61..c5c768f4aa 100644--- a/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessGrantItem.vue+++ b/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessGrantItem.vue@@ -21,7 +21,7 @@<template #trigger><pclass="max-w-full text-xs wrap-break-word whitespace-pre-wrap font-mono line-clamp-2"- :class="{ 'line-through text-gray-400': isExpired || isRevoked }"+ :class="{ 'line-through text-gray-400': isExpired || isRevoked || isRejectedOrCanceled }">{{ grant.query }}</p>@@ -74,6 +74,7 @@ import {type AccessGrant,AccessGrant_Status,} from "@/types/proto-es/v1/access_grant_service_pb";+import type { Issue } from "@/types/proto-es/v1/issue_service_pb";import {getAccessGrantDisplayStatus,getAccessGrantExpirationText,@@ -84,6 +85,7 @@ import {const props = defineProps<{grant: AccessGrant;highlight?: boolean;+ issue?: Issue;}>();defineEmits<{@@ -107,14 +109,35 @@ const isExpired = computed(() => {return expireTimeMs.value < Date.now();});-const displayStatus = computed(() => getAccessGrantDisplayStatus(props.grant));+const displayStatus = computed(() =>+ getAccessGrantDisplayStatus(props.grant, props.issue)+);const statusTagType = computed(() =>getAccessGrantStatusTagType(displayStatus.value));+const isRejectedOrCanceled = computed(+ () => displayStatus.value === "REJECTED" || displayStatus.value === "CANCELED"+);+const statusLabel = computed(() => {- return displayStatus.value;+ switch (displayStatus.value) {+ case "ACTIVE":+ return t("common.active");+ case "PENDING":+ return t("common.pending");+ case "EXPIRED":+ return t("sql-editor.expired");+ case "REVOKED":+ return t("common.revoked");+ case "REJECTED":+ return t("common.rejected");+ case "CANCELED":+ return t("common.canceled");+ default:+ return displayStatus.value;+ }});const expirationInfo = computed(() =>diff --git a/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessPane.vue b/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessPane.vueindex 4cd004664c..361bbb4c6d 100644--- a/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessPane.vue+++ b/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessPane.vue@@ -45,6 +45,7 @@:key="grant.name":grant="grant":highlight="grant.name === highlightAccessGrantName"+ :issue="issueByGrantName.get(grant.name)"@run="handleRun"/><div@@ -102,6 +103,7 @@ import {useAccessGrantStore,useConnectionOfCurrentSQLEditorTab,useDatabaseV1Store,+ useIssueV1Store,useProjectV1Store,useSQLEditorStore,useSQLEditorTabStore,@@ -110,6 +112,7 @@ import {type AccessGrant,AccessGrant_Status,} from "@/types/proto-es/v1/access_grant_service_pb";+import type { Issue } from "@/types/proto-es/v1/issue_service_pb";import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";import {extractDatabaseResourceName,@@ -132,6 +135,7 @@ const editorStore = useSQLEditorStore();const tabStore = useSQLEditorTabStore();const databaseStore = useDatabaseV1Store();const accessGrantStore = useAccessGrantStore();+const issueStore = useIssueV1Store();const { instance: currentInstance } = useConnectionOfCurrentSQLEditorTab();const { execute } = useExecuteSQL();const { highlightAccessGrantName } = useSQLEditorContext();@@ -140,6 +144,8 @@ const showDrawer = ref(false);const loading = ref(false);const accessGrantList = ref<AccessGrant[]>([]);const nextPageToken = ref("");+// Maps access grant name → Issue for PENDING grants with an associated issue.+const issueByGrantName = ref<Map<string, Issue>>(new Map());const containerRef = ref<HTMLDivElement>();const { width: containerWidth } = useElementSize(containerRef);const useSmallLayout = computed(@@ -263,6 +269,27 @@ const filter = computed((): AccessFilter => {return f;});+const fetchIssuesForPendingGrants = async (grants: AccessGrant[]) => {+ const pendingWithIssue = grants.filter(+ (g) => g.status === AccessGrant_Status.PENDING && g.issue+ );+ const results = await Promise.all(+ pendingWithIssue.map(async (g) => {+ try {+ const issue = await issueStore.fetchIssueByName(g.issue, true);+ return { grantName: g.name, issue };+ } catch {+ return undefined;+ }+ })+ );+ for (const r of results) {+ if (r) {+ issueByGrantName.value.set(r.grantName, r.issue);+ }+ }+};+const fetchAccessGrants = async (resetList = true) => {const project = editorStore.project;if (!project) return;@@ -277,10 +304,12 @@ const fetchAccessGrants = async (resetList = true) => {});if (resetList) {accessGrantList.value = response.accessGrants;+ issueByGrantName.value = new Map();} else {accessGrantList.value.push(...response.accessGrants);}nextPageToken.value = response.nextPageToken;+ await fetchIssuesForPendingGrants(response.accessGrants);} finally {loading.value = false;}